fix(mha): don't compute FA3 scheduler metadata for non-FA3 backends#276
Closed
qywu wants to merge 1 commit into
Closed
fix(mha): don't compute FA3 scheduler metadata for non-FA3 backends#276qywu wants to merge 1 commit into
qywu wants to merge 1 commit into
Conversation
``_maybe_compute_scheduler_metadata``'s docstring promises ``None`` when
the active backend doesn't consume pre-computed scheduler metadata, but
the implementation unconditionally calls ``mha_decode_scheduler_metadata``
and returns its result. Downstream, ``forward_decode`` then passes the
non-None tensor to whichever kernel is selected — and triton / fa4 /
flashinfer reject the unknown ``scheduler_metadata`` kwarg:
TypeError: triton_mha_decode_with_kvcache() got an unexpected
keyword argument 'scheduler_metadata'
Guard the call so the docstring is the truth: skip the compute (and the
downstream kwarg) when ``kernel_solution`` is anything other than
``"fa3"`` or ``None`` (None == auto-select, which may land on FA3).
Found while running --attention-backend=triton end-to-end on H100;
reproduces with any non-FA3 selection on Hopper.
Signed-off-by: Qingyang Wu <willqywu@gmail.com>
This was referenced May 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MHAAttnBackend._maybe_compute_scheduler_metadata's docstring says it returnsNonewhen the active backend doesn't consume pre-computed scheduler metadata, but the implementation unconditionally callsmha_decode_scheduler_metadataand returns its result. Downstream inforward_decode, the non-None tensor gets passed to the selected kernel — and triton / fa4 / flashinfer reject the unknownscheduler_metadatakwarg:Guard the call so the docstring matches the behaviour: skip the compute (and therefore the downstream kwarg) when
kernel_solutionis anything other than"fa3"orNone(None == auto-select, may land on FA3).Repro
Test plan
--attention-backend=tritonend-to-end inference on Hopper (Qwen2-1.5B-Instruct) — confirmed locally; produces correct output.--attention-backend=fa3continues to consume the pre-computed metadata as before.--attention-backend=mha(auto) continues to compute it (auto-select may still land on FA3).--attention-backend=fa4/flashinferno longer trip the TypeError.Related
Encountered while verifying #272 / #273 / #274 / #275 end-to-end on H100.