test(qwen4_exp): compare chunked prefill to one-shot at bf16 tolerance - #388
Draft
gdevenyi wants to merge 1 commit into
Draft
test(qwen4_exp): compare chunked prefill to one-shot at bf16 tolerance#388gdevenyi wants to merge 1 commit into
gdevenyi wants to merge 1 commit into
Conversation
`torch.equal` fails for all three cut points on torch 2.11.0+cu130 / flashinfer 0.6.18 / triton 3.6.0 (sm_89): cuBLAS picks a different kernel for M=5000 and M=5000-cut, so the indexer's q and k round differently, a few rows flip one block at the top-k margin, and the layer output differs by up to 2.6e-3 (a few bf16 ulps). Both paths are deterministic run to run. Use the tolerance of the neighbouring oracle tests. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0173pf9k9fSVtwbm3f898HDt
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.
What
test_chunked_prefill_matches_one_shotassertstorch.equalbetween the chunked and the one-shot prefill output of the QSA layer. On torch 2.11.0+cu130 / flashinfer 0.6.18 / triton 3.6.0 (RTX 6000 Ada, sm_89) all three cut points fail onmain(af71ba4), by a few bf16 ulps. This compares at the tolerance the neighbouring oracle tests in the same file already use (rtol=2e-2, atol=2e-2) and says why in the docstring.Why this is the test's contract and not a chunked-prefill bug
Measured on plain
mainwith the test's own fixture, seed and cut points:qkv_projover the same rows gives different bf16 results for M=5000 and M=904 (max diff 3.9e-3, one ulp at that magnitude); the indexer's q and k differ for every cut. cuBLAS picks its kernel per shape, which a chunked prefill cannot avoid.qkv_projmax diff, M=5000 vs M=rowsThe bf16 defaults of
assert_close(atol 1e-5) also fail, on elements near 1e-6, so the explicit tolerance is the one that matches the rest of the file.Testing
tests/models/qwen4_exp/test_qsa_backend.pyon the stack above: 9 passed (was 3 failed, 6 passed).🤖 Generated with Claude Code
https://claude.ai/code/session_0173pf9k9fSVtwbm3f898HDt