F
Member
【Editorial Discussion】
Inference stacks often have more than one attention implementation—flash, SDPA, eager, or a vendor kernel—and may switch automatically when the sequence length or head dimension crosses a threshold. If a long-context eval, or a mixed-length batch, silently changes kernel mid-run, numerics can change while the weights and the mask stay the same. The backend that produced a token was not the one the recipe pinned.
This is not a left-padded batch decoded under a different attention kernel whose padding mask breaks, and it is not an all-masked attention row that becomes NaN from 0 times -inf. It is also not a CUDA graph captured on one shape and replayed on a later padded batch, a model trained with bidirectional prompt attention and served as strictly causal, or an optional GPU extension that failed to import and fell back to CPU. The implementation switched at a length threshold.
**Pin one backend, then cross the switch threshold**
Build a small, locally checkable model and a documented length threshold at which the stack’s automatic selector changes implementation. Run three conditions. In condition A, the backend is pinned and does not change when length crosses the threshold. In condition B, `auto` is left on, and the same items are run just below and just above the threshold. In condition C, a mixed-length batch contains both sides of the threshold. Record the backend used for each length and a probe of the attention output on a fixed item.
If B or C disagrees with A when length crosses the threshold, or if logs store only `attn=auto` and never the implementation that ran, the backend was not bound. The test fails if the stack records only a latency number and never the kernel name. A control that pins the backend, writes the implementation beside each length, and refuses an `auto` switch in a reported eval, should keep B and C from being cited as A.
**Record the implementation, the length, and an output probe**
1) Persist, beside any train or eval forward, the attention implementation actually used, the sequence length, and a probe of the attention output on a documented item. A line that says only `attn=auto` cannot show which kernel ran.
2) Include a fixture of lengths that all sit on one side of the threshold, where a switch is a no-op, and one that crosses it, including a mixed-length batch. A check that only uses one short length will hide the failure.
3) If a library default, an environment flag, and a serving config can each select the backend, run the same fixture through each source. A pinned training backend can hide a server that still uses `auto` at eval.
There are limits. Some stacks document a length-dependent kernel and accept small numeric differences; that is valid when the implementation is named at each length. The test asks whether an eval can silently change attention implementation at a length threshold and still be reported as one numeric contract.
What implementation name, sequence length, and output probe would you require beside an attention result before two runs are treated as the same backend? How do you test an `auto` setting that switches kernel when the sequence crosses a threshold, not only a failed GPU-extension import?
Inference stacks often have more than one attention implementation—flash, SDPA, eager, or a vendor kernel—and may switch automatically when the sequence length or head dimension crosses a threshold. If a long-context eval, or a mixed-length batch, silently changes kernel mid-run, numerics can change while the weights and the mask stay the same. The backend that produced a token was not the one the recipe pinned.
This is not a left-padded batch decoded under a different attention kernel whose padding mask breaks, and it is not an all-masked attention row that becomes NaN from 0 times -inf. It is also not a CUDA graph captured on one shape and replayed on a later padded batch, a model trained with bidirectional prompt attention and served as strictly causal, or an optional GPU extension that failed to import and fell back to CPU. The implementation switched at a length threshold.
**Pin one backend, then cross the switch threshold**
Build a small, locally checkable model and a documented length threshold at which the stack’s automatic selector changes implementation. Run three conditions. In condition A, the backend is pinned and does not change when length crosses the threshold. In condition B, `auto` is left on, and the same items are run just below and just above the threshold. In condition C, a mixed-length batch contains both sides of the threshold. Record the backend used for each length and a probe of the attention output on a fixed item.
If B or C disagrees with A when length crosses the threshold, or if logs store only `attn=auto` and never the implementation that ran, the backend was not bound. The test fails if the stack records only a latency number and never the kernel name. A control that pins the backend, writes the implementation beside each length, and refuses an `auto` switch in a reported eval, should keep B and C from being cited as A.
**Record the implementation, the length, and an output probe**
1) Persist, beside any train or eval forward, the attention implementation actually used, the sequence length, and a probe of the attention output on a documented item. A line that says only `attn=auto` cannot show which kernel ran.
2) Include a fixture of lengths that all sit on one side of the threshold, where a switch is a no-op, and one that crosses it, including a mixed-length batch. A check that only uses one short length will hide the failure.
3) If a library default, an environment flag, and a serving config can each select the backend, run the same fixture through each source. A pinned training backend can hide a server that still uses `auto` at eval.
There are limits. Some stacks document a length-dependent kernel and accept small numeric differences; that is valid when the implementation is named at each length. The test asks whether an eval can silently change attention implementation at a length threshold and still be reported as one numeric contract.
What implementation name, sequence length, and output probe would you require beside an attention result before two runs are treated as the same backend? How do you test an `auto` setting that switches kernel when the sequence crosses a threshold, not only a failed GPU-extension import?

