Repository navigation
test(kernels): add the missing AWQ Marlin determinism regression (#4683) - #4726
Merged
Merged
Conversation
#4683 reports that AwqMarlinLinear occasionally returns a different output for an identical input (sometimes one 64x64 tile off by ~0.25) while GPTQ MarlinLinear stays bitwise stable, so the PPL of one AWQ checkpoint varies across processes. No test covered it: test_awq_machete_marlin compares two back-to-back calls against the Torch oracle with a tolerance, which both hides a single bad tile and never repeats a launch. The new test repeats the launch. Every case runs several hundred forwards back to back with no host synchronisation between them - the reporter's window, where the rate was 1 mismatch in 600 to 3000 launches - and accumulates the mismatch flag and magnitude on the device so one bad launch anywhere in the loop fails the case, not just the last one. Repeated launches must be bitwise identical because they are the same kernel on the same input; the Torch AWQ comparison stays a tolerance check because it is a different quantizer, not a determinism oracle. Coverage: the Llama-3.2-1B AWQ shapes (K=2048/8192, N=512/2048/8192) at M=512 and M=2048 in fp16 and bf16; alternating batch shapes on one module, which pins that a launch does not inherit the previous launch's split-K slicing through the module's reused lock workspace; a fresh module's first result; the Torch oracle; and per-module lock-workspace ownership (the #4665 aliasing failure mode). Verified on sm_121 (GB10): 13 passed; the neighbouring narrow-projection oracle suite also passes (137 passed together). The test skips without CUDA or when the Marlin extension is unavailable. Not reproduced on sm_121 while writing this: 1,600 launches on the default launch config, 10,800 with the sm_89-only narrow_fp32_awq config forced on, 2,000 with alternating batch shapes and 200 two-stream rounds were all bitwise stable. The lock workspace was also instrumented: locks_off never exceeded gridDim - 1, so the max(sms, 128) sizing is exactly sufficient and there is no off-by-one.
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.
Refs #4683 — does not close it: the intermittent non-determinism was not reproducible on the only hardware available here (GB10, sm_121), so this lands the missing regression, not a speculative kernel change.
Why
#4683 reports
AwqMarlinLinearoccasionally returning a different result for an identical input (sometimes one 64x64 tile off by ~0.25) while GPTQMarlinLinearstays bitwise stable, so the PPL of one AWQ checkpoint varies across processes. No test covered it:test_awq_machete_marlincompares two back-to-back calls against the Torch oracle with a tolerance, which hides a single bad tile and never repeats a launch.What
tests/kernels/test_awq_marlin_determinism_4683.py(13 tests) repeats the launch: several hundred forwards back to back with no host sync between them (the reporter's 1-in-600–3000 window), accumulating the mismatch flag and magnitude on the device, so one bad launch anywhere in the loop fails. Repeated launches must be bitwise identical; the Torch AWQ comparison stays a tolerance check because it is a different quantizer, not a determinism oracle.Coverage: Llama-3.2-1B AWQ shapes (K=2048/8192, N=512/2048/8192) at M=512/2048 in fp16 and bf16; alternating batch shapes on one module (pins that a launch does not inherit the previous launch's split-K slicing through the reused lock workspace); fresh-module first result; Torch oracle; per-module lock-workspace ownership (the #4665 aliasing class).
Evidence
test_marlin_fp32_schedule.py→ 137 passed. Skips cleanly without CUDA/Marlin.True/max|Δ| 0.031against a deliberately different module,Falsefor identical output.narrow_fp32_awqconfig forced on, 2,000 alternating batch shapes, 400 two-stream rounds — all bitwise stable.blocks_per_smis always 1,locks_offnever exceededgridDim - 1, and a guard-slice experiment saw no write pastsms - 1;max(sms, 128)is sufficient.Residual
The reporter's hardware is sm_89 (RTX 4090), where
narrow_fp32_awqis active; this test should fail there if the bug is live. All validation here is sm_121. CI'sawq_cpu.ymldoes not collecttests/kernels, so the test runs where a GPU is present, like the other Marlin kernel tests.