@@ -116,6 +116,24 @@ Configs are typically discovered automatically through autotuning, but can also
116116 - ``"block_ptr"``: Block pointer indexing
117117```
118118
119+ ### Memory and Caching
120+
121+ ``` {eval-rst}
122+ .. autoattribute:: Config.load_eviction_policies
123+
124+ Eviction policies for load operations issued from device loops. Provide one policy
125+ per ``hl.load`` site discovered in the kernel. Allowed values:
126+
127+ - ``""``: No eviction policy (omitted)
128+ - ``"first"``: Maps to Triton ``eviction_policy='evict_first'``
129+ - ``"last"``: Maps to Triton ``eviction_policy='evict_last'``
130+
131+ Notes:
132+
133+ - The number of entries must match the number of load sites considered tunable by the kernel.
134+ - An explicit ``eviction_policy=...`` argument passed to ``hl.load`` overrides this config.
135+ ```
136+
119137## Usage Examples
120138
121139### Manual Config Creation
@@ -142,6 +160,31 @@ def my_kernel(x: torch.Tensor) -> torch.Tensor:
142160 return result
143161```
144162
163+ ### Eviction Policy Example
164+
165+ ``` python
166+ import torch
167+ import helion
168+ import helion.language as hl
169+
170+ @helion.kernel (
171+ config = {
172+ " block_size" : 16 ,
173+ " load_eviction_policies" : [" " , " last" ], # second load uses evict_last
174+ }
175+ )
176+ def kernel_with_eviction (x : torch.Tensor, y : torch.Tensor) -> torch.Tensor:
177+ out = torch.empty_like(x)
178+ for tile in hl.tile(x.size(0 )):
179+ a = hl.load(x, [tile]) # No eviction policy
180+ b = hl.load(y, [tile]) # Will use evict_last from config
181+ out[tile] = a + b
182+ return out
183+
184+ # Explicit policy on hl.load overrides config:
185+ # hl.load(x, [tile], eviction_policy="evict_first")
186+ ```
187+
145188### Config Serialization
146189
147190``` python
0 commit comments