Skip to content

test(kernels): add the missing AWQ Marlin determinism regression (#4683) - #4726

Merged
Qubitium merged 1 commit into
mainfrom
fix/awq-marlin-determinism-4683
Nov 17, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/awq-marlin-determinism-4683

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

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 AwqMarlinLinear occasionally returning a different result 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 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

  • Green on sm_121: 13 passed; with test_marlin_fp32_schedule.py → 137 passed. Skips cleanly without CUDA/Marlin.
  • Not vacuous: the same accumulation reports True / max|Δ| 0.031 against a deliberately different module, False for identical output.
  • Not reproduced on sm_121 while writing this: 1,600 launches default config, 10,800 with the sm_89-only narrow_fp32_awq config forced on, 2,000 alternating batch shapes, 400 two-stream rounds — all bitwise stable.
  • The workspace/OOB hypothesis was tested and disproved: blocks_per_sm is always 1, locks_off never exceeded gridDim - 1, and a guard-slice experiment saw no write past sms - 1; max(sms, 128) is sufficient.

Residual

The reporter's hardware is sm_89 (RTX 4090), where narrow_fp32_awq is active; this test should fail there if the bug is live. All validation here is sm_121. CI's awq_cpu.yml does not collect tests/kernels, so the test runs where a GPU is present, like the other Marlin kernel tests.

#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant