Repository navigation
fix(mha): select sink kernel when only sink_ptr is provided - #4976
Conversation
mha_batch_prefill_func aborts with "no matching kernel found" for any caller that supplies a learned per-head sink logit via sink_ptr without also setting sink_size (e.g. gpt-oss on SGLang's AITER backend): RuntimeError: invalid argument for batch_prefill: no matching kernel found. page_size=1, num_pages=6, dtype=bf16. The message blames KV-cache size and GPU generation; neither is the cause. Two bugs combine: 1. cmdGenFunc_mha_batch_prefill's trailing parameters were ordered sink_ptr, gen, kv_last_page_lens, block_table, seqlen_k, while _mha_batch_prefill invokes the op all-positionally as kv_last_page_lens, block_table, seqlen_k, sink_ptr, gen. compile_ops forwards that same tuple to the generator, so it read kv_last_page_lens as sink_ptr and never saw a sink. 2. has_effective_sink tested sink_size > 0 only, while the C++ side (csrc/cpp_itfs/mha_fwd_batch_prefill.cu:52) uses has_sink = args.sink_size > 0 || args.sink_ptr != nullptr.
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
PR title tags: |
There was a problem hiding this comment.
Pull request overview
Fixes mha_batch_prefill_func dispatch failures (“no matching kernel found”) when callers provide a learned per-head sink logit via sink_ptr without also setting sink_size, by aligning generator argument ordering and improving sink-kernel selection.
Changes:
- Reordered trailing parameters in
cmdGenFunc_mha_batch_prefillto match the positional calling convention used by the compiled op path. - Updated sink detection so
sink_ptrparticipates in sink-kernel selection (in addition tosink_size).
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| # Sink only applies when there is a causal/window mask; full attention | ||
| # (window_size_left==-1 and window_size_right==-1) ignores sink_size. | ||
| has_effective_sink = sink_size > 0 and ( | ||
| has_effective_sink = (sink_size > 0 or sink_ptr is not None) and ( | ||
| causal or not (window_size_left == -1 and window_size_right == -1) | ||
| ) |
mha_batch_prefill_func aborts with "no matching kernel found" for any caller that supplies a learned per-head sink logit via sink_ptr without also setting sink_size (e.g. gpt-oss on SGLang's AITER backend):
RuntimeError: invalid argument for batch_prefill: no matching kernel
found. page_size=1, num_pages=6, dtype=bf16.
The message blames KV-cache size and GPU generation; neither is the cause. Two bugs combine:
cmdGenFunc_mha_batch_prefill's trailing parameters were ordered sink_ptr, gen, kv_last_page_lens, block_table, seqlen_k, while _mha_batch_prefill invokes the op all-positionally as kv_last_page_lens, block_table, seqlen_k, sink_ptr, gen. compile_ops forwards that same tuple to the generator, so it read kv_last_page_lens as sink_ptr and never saw a sink.
has_effective_sink tested sink_size > 0 only, while the C++ side (csrc/cpp_itfs/mha_fwd_batch_prefill.cu:52) uses has_sink = args.sink_size > 0 || args.sink_ptr != nullptr.
Motivation
Technical Details
Test Plan
Test Result
Submission Checklist