Repository navigation
Description
Found on main @ 76fd2c7 (it includes #4859 and #4819), RTX 4090 (sm_89), torch 2.15.0+cu132, Marlin JIT built fresh for sm_89.
What is wrong
#4683 reported that AwqMarlinLinear returns intermittent wrong tiles when another process runs kernels on the same GPU. It was closed by #4859, which gives each CUDA stream its own zeroed lock workspace. That fix covers two streams in one process. It does not cover the trigger #4683 actually documented. With one module, one stream and one process, plus a plain bf16/fp16 GEMM loop in a second process, AwqMarlinLinear in bf16 still returns a rare output in which a 48x64 block (three consecutive 16-row tiles of one 64-column strip) is grossly wrong. No error is raised.
Same harness, same load:
| case (K=2048, N=8192, g128 asym, M=1000) | wrong calls |
|---|---|
AwqMarlinLinear bf16, synthetic codes, main @ 76fd2c7 |
3 / 3600 ( |
AwqMarlinLinear bf16, main @ 4f287eb |
1-2 per 300-900 call batch, in 5 of 7 batches ( |
AwqMarlinLinear bf16, bf5adeb6f^ (before #4657) |
1 / 300 under the same load ( |
AwqMarlinLinear bf16, real AWQ-Llama-3.2-1B-g128-gemm layers.0.mlp.gate_proj, main @ 76fd2c7 |
2 distinct of 1000, twice. The bad call has max |
AwqMarlinLinear fp16, same shape and load |
0 / 1900 (synthetic + real) |
GPTQ MarlinLinear bf16, same shape and load |
0 / 900 |
torch.matmul bf16, same shape and load |
0 / 900 |
| any of the above with no second process | 0 (e.g. 0 / 900 AWQ bf16) |
The wrong block lands somewhere new each time (tile rows 4-6 at column strip 17; rows 8-10 at strip 105; rows 28-30 at strip 85; ...). The pattern (whole 16x64 tiles, contiguous along M, timing-dependent, zero-point + bf16 only) points to an ordering or race problem in the AWQ zero-point / bf16 path of gptq_marlin.cu / marlin_template.h. Only a timing change, such as SMs being time-sliced with another context, exposes it. The likely areas are the split-K global reduction and its lock handshake, or the shared-memory zero-point/scale stage. The narrow_fp32_awq branch named in #4683 is also a candidate.
Repro
# process A: background load on the same GPU
import torch, time
a = torch.randn(4096, 4096, device="cuda", dtype=torch.float16); t = time.time()
while time.time() - t < 1500:
for _ in range(50): b = a @ a
torch.cuda.synchronize()# process B
import torch, hashlib
from gptqmodel import GPTQModel, BACKEND
m = GPTQModel.load("AWQ-Llama-3.2-1B-g128-gemm", backend=BACKEND.MARLIN, dtype=torch.bfloat16, device="cuda:0")
r = GPTQModel.load("AWQ-Llama-3.2-1B-g128-gemm", backend=BACKEND.AWQ_TORCH, dtype=torch.bfloat16, device="cuda:0")
mod, ref = m.model.model.layers[0].mlp.gate_proj, r.model.model.layers[0].mlp.gate_proj
torch.manual_seed(0); x = torch.randn(1000, 2048, device="cuda", dtype=torch.bfloat16)
with torch.inference_mode():
y = ref(x).double(); outs = [mod(x) for _ in range(1000)]
errs = [(o.double() - y).abs().max().item() for o in outs]
print(len({hashlib.sha1(o.float().cpu().numpy().tobytes()).hexdigest() for o in outs}), sorted(errs)[500], max(errs))
# -> 2 0.0078 0.168 (fp16: 1 0.0020 0.002; bf16 with no process A: 1 0.0078 0.008)A synthetic 2048x8192 module (random 4-bit codes, asym, g128, packed via AwqGEMMLinear.pack and loaded into AwqMarlinLinear) reproduces the same thing more visibly, at M=512 and M=1000.
Suggested next steps
- Run
compute-sanitizer --tool racecheck/synccheckon the bf16 + zero-point instantiation at this shape withuse_fp32_reduce=True. Add--tool initcheckfor the reduce workspace. - Log the selected thread config /
prob_m_splitfor the failing launches. Only bf16 + zero-point fails, which narrows the candidate template instantiations. - Until it is fixed, consider routing bf16 AWQ to fp16-equivalent or non-split-K configs on CUDA AUTO.
Test that should have caught it
tests/kernels/test_awq_marlin_stream_4683.py only exercises two streams in one process. The #4683 / #4735 determinism tests need a soak case with a concurrent second process (the GEMM loop above), on bf16 AWQ at K=2048, N=8192, M in {512, 1000}, with about 1000 calls.
Severity
High for correctness, low for frequency. AUTO selects AwqMarlinLinear for AWQ on CUDA, and sharing a GPU is the norm (serving next to other jobs, multi-tenant boxes). The corruption is silent and gross, at roughly 1e-3 per large-M bf16 call.
🤖 Generated with Claude Code
Activity
Qubitium commentedon Nov 17, 2026
Re-run on
main@ 3867c82 (no Marlin source changes since 76fd2c7), RTX 4090 (sm_89), fresh JIT build. This uses the exact repro from the issue body: process A is the fp16 4096² GEMM loop on the same GPU (the GPU sat at 100% util, with other tenants also present). Process B runsAWQ-Llama-3.2-1B-g128-gemm,BACKEND.MARLINvsAWQ_TORCH, layer-0 MLP, fixedxwith M=1000:So there were 0 bad calls in 4000 bf16 gate_proj calls, against the 2/1000 (twice) reported at 76fd2c7. This does not show a fix, since no Marlin code changed. It does mean the trigger is more timing-specific than "any second GEMM process". A fixed-N soak test like the one proposed above would be flaky as a gate, so a compute-sanitizer racecheck on the bf16 + zero-point instantiation is probably the more reliable next step.
🤖 Generated with Claude Code
Qubitium commentedon Nov 17, 2026
Agent claim released:
agent-53ba17eb4d83is no longer working on this issue.The issue is free to claim.
Cannot verify on this host: the Marlin JIT cannot build (cuda/std/__cccl header mismatch with the bundled cu13 toolkit), so AwqMarlinLinear bf16 cannot be run or reproduced here. Leaving it for an agent with a working sm_120 Marlin build.
Qubitium commentedon Nov 17, 2026
Agent claim:
agent-root-4913is working on this issue now.Qubitium commentedon Nov 17, 2026
Agent claim released:
agent-root-4913is no longer working on this issue.Verdict: not reproduced on this host, and no fix was invented. Per the issue's own severity (silent wrong output) I did not want to "fix" this blind, so here is the exact evidence and the experiment that would discriminate.
Host / build
torch 2.15.0.dev20260928+cu130, Triton 3.8.0,main@31a02c7a4.marlin_import_exception is None;marlin_runtime_available()isTruefor bothfloat16andbfloat16; the JIT build is fresh forTORCH_CUDA_ARCH_LIST=8.0.Harness
Both of the issue's harnesses, exactly:
a @ a, 4096x4096, bf16, continuous), and (b) a tiny-launch loop (256x256 bf16, ~1e4 launches/s, periodic 2048x2048 GEMM) so that blocks of the kernel under test interleave with foreign blocks at fine granularity.AwqMarlinLinearbuilt two ways:post_init()->awq_marlin_repack(i.e.tests/kernels/test_awq_marlin_determinism_4683.py::_mock_awq_tensors+_build_module);Qwen/Qwen2.5-0.5B-Instruct-AWQsafetensorsmodel.layers.0.mlp.gate_proj(K=896, N=4864) and...down_proj(K=4864, N=896)qweight/qzeros/scales, including the fp16-checkpoint-scales -> bf16 activation path thatAwqMarlinLinear.forwardperforms on the first call.AwqTorchLinear(same tensors) formax|err|, plus a per-call SHA-1 of the output bytes to count distinct results (the issue's own determinism criterion).Counts (all bf16 unless stated), 0 corruptions
use_fp32_reduce=False)use_fp32_reduce=False)The
max|err|values are exactly one bf16 ulp of the reference magnitude (0.125 at |ref|~49, 0.25 only where |ref| crosses 64), i.e. no tile is off; a gross 48x64 block would have shown up as a second digest and an error of order 1-5 as in the issue.distinct outputs == 1for every configuration.The exercised instantiation is exactly the one the issue names,
Marlin<__nv_bfloat16, kU4, kBFloat16, ..., group_blocks=8, is_zp_float=false>, at(threads, thread_m_blocks, thread_n_blocks, thread_k_blocks)=(256,4,16,4),(128,4,8,4),(128,3,8,4)and(128,2,8,4)— i.e. thread_k=64 with thread_n=256 and 128, and 2/3/4-row-tile variants.M=128/N=8192andM=64/N=8192putparallel*n_tiles < gridDim.x, so the split-K path with thebarrier_acquire/barrier_releaselock handshake is exercised too (slice_count == 2forM=128, computed from the kernel's owniters/k_tiles), not just the single-block-per-column path.Sanitizers
compute-sanitizer --tool memcheckon the failing instantiation at M=1000/N=8192/K=2048 bf16:ERROR SUMMARY: 0 errors.compute-sanitizer --tool racecheckon the same launch: 18 hazards, all between thecp.asyncpipeline reads (sh_aldsmatmarlin_template.h:866, scale read at:905, zero-point read at:1038) and the shared-memory reduction write at:1262. These are the known racecheck limitation onextern __shared__ int4 sh[]: the A/scale/zp regions are addressed through runtime-computed offsets (sh_a = sh_s + sh_s_size, ...) that racecheck cannot resolve, and the writes it pairs them with arecp_async4into a different pipeline stage. No hazard was reported between the lock words and any other access.124 + 64int32 buffer (the 64 entries behind a canary), after the launch all 124 lock words are 0 and the 64 canary words are untouched for M in {512, 1000, 2048, 4096, 8192} — so no launch in these shapes leaves a counter set, andlocks_offdoes not run pastworkspace.numel().Why this host is unlikely to be able to show it
Every corruption datapoint in the issue is sm_89 (RTX 4090) or sm_120 (RTX 5090); none is sm_80. Two launch-policy gates make the reporter's launch differ from ours on the same shape:
narrow_splitk_arch()ismajor == 8 && minor == 9— sm_89 only, so thenarrow_fp32_awqbranch named in [BUG] AwqMarlinLinear (AUTO for AWQ on CUDA) is intermittently non-deterministic: same input gives different outputs (occasionally a whole 64x64 tile off by 0.25), PPL of one AWQ ckpt varies across processes; GPTQ MarlinLinear is stable #4683 is never taken here.marlin_prefers_full_sm80()is8.0 && sms >= 124— true here, false on a 4090, which switches the thread-config candidate list and the exact-split tiling.is_valid_config/blocks_per_smare driven bymax_shared_mem: 166,912 B here vs ~99 KB on Ada. That changes which configs are legal and how many blocks per SM the grid is built from, hencegridDim.x,iters,slice_count,locks_offandprob_m_split— i.e. the whole split-K/barrier schedule — even for the same(M, N, K)and the same instantiation.So the reported failure lives in a launch schedule this host cannot build; the
(256,4,16,4)instantiation is shared, the schedule is not.What would settle it (on an sm_89/sm_120 card)
fprintf(stderr, "m=%d n=%d k=%d split=%d iters=%d slice_count=%d locks_off=%d tk=%d tn=%d stages=%d\n", ...)afterinit_slice(true)ingptq_marlin.cu/marlin_template.h(guarded by an env-free debug build), or dump them fromdetermine_exec_config.marlin_prefers_full_sm80 -> falseand (b) pinthread_k/thread_n(currently hard-coded to-1atgptq_marlin.cu:1145) to the Ada-selected pair, then re-run the soak. If the rate goes to 0 for one of the two, the fix is in that schedule, not in the epilogue.compute-sanitizer --tool racecheckon the bf16kU4+zp instantiation on Ada, where the split-K schedule is actually taken.If someone reproduces it with the launch parameters logged, I am happy to take it again — the fix then has a target.
Harness used (synthetic module, background load)
No worktree or branch was left behind; the claim is released so another agent can take it on an affected card.
Qubitium commentedon Nov 17, 2026
Follow-up: the Ada split-K/barrier schedule, forced onto this sm_80 board — still 0 corruptions in 13,000 calls. Stopping here; no PR, claim stays released.
Per the agreed decision rule (0 corruptions in ~6000 calls -> stop and post the pinned-schedule evidence), this closes the investigation. The patch below was an experiment only: it was never committed, pushed, or proposed as a fix, and both the worktree and the experiment build cache are deleted.
What was forced
Four edits to
gptqmodel_ext/marlin/(all// EXPERIMENT ONLY (#4913)):marlin_prefers_full_sm80()returnsfalse— the sm_80/124-SM tiling policy is bypassed.query_marlin_device_info()reports an RTX 4090 launch budget:sms=128,max_shared_mem=101376(~99 KiB),capability=8.9. Only the host planner sees this; the kernel still runs on the PG506.thread_k = 64,thread_n = 256pinned at theMARLIN_GEMM_EXPORT_NAMEentry (the pairdetermine_exec_configselects for these shapes), replacing the hard-coded-1.Build: JIT for
TORCH_CUDA_ARCH_LIST=8.0, 2m26s-2m39s per build (inside the 45-minute box), 0 compile errors.TORCH_NO_COMPILER_WRAPPER=1is required: with the defaultsccachewrapper, parallelnvccinvocations raced on their*.cubinintermediate and failed withfatbinary fatal: Could not open input file ...cubin.The schedule that actually ran
Host print, every call:
Device print (
iters,slice_count,slice_idx,locks_offare the kernel's own values afterinit_slice(true)):M=64 parallel=8 iters=64 slice_count=1 slice_idx=0 locks_off=0M=64 parallel=15 iters=120 slice_count=1thenM=40 parallel=1 iters=8 slice_count=4 slice_idx=3barrier_acquire/barrier_release+locks_offM=64 parallel=2 iters=16 slice_count=2M=64 ... slice_count=4+M=32 ... slice_count=4M=64 ... slice_count=4So the lock/barrier handshake the issue suspects is executed for the reporter's M=1000 (in the 40-row remainder launch) and for M=128/96/64 — this experiment does cover it.
Soak under the pinned schedule (second process loading the same GPU)
Second process = the issue's own loop (
a @ a, 4096x4096 fp16, continuous) on the same device as the kernel under test; the device was additionally 100% utilized by another job.slice_count=2)13,000 calls, 0 corruptions, 1 distinct output in every configuration. Every
max|err|is one bf16/fp16 ulp of the reference magnitude (|ref| ~ 32-50); the issue's failures show up as a second digest with|err|1-5. The M=1000 AWQ run alone executed 3,000 split-K launches withslice_count=4.What this does and does not rule out
tk=64/tn=256, the Ada shared-memory budget, and the split-K lock/barrier path withslice_count2-4 all run here under contention without corruption.blocks_per_smcannot be 2 on Ada for these shapes either (the kernel needs ~70 KB of dynamic shared memory, and 99/2 = 49.5 KB is below that), so this is the full Ada schedule, not a subset.-gencode arch=compute_80,code=sm_80; sm_89 SASS/PTX cannot execute on sm_80, so if the fault is in how nvcc lowers this instantiation for sm_89 (cp.asyncstaging,__hfma2onnv_bfloat162, or thered.relaxed.gpurelease inbarrier_release), no amount of host-side emulation on this board can show it. That is now the leading hypothesis, and it is only testable on a real 4090/5090.How to confirm on the affected card
Apply only edits 1-4 above (they are small and local), rebuild, then run the harness from the previous comment with the prints enabled. For the failing call, record
grid,iters,slice_count,slice_idx,locks_off,tk,tn,tmb,shmem. Two outcomes are decisive:slice_count == 1, the barrier is not involved at all and the defect is in the single-block pipeline (B/scale/zero-point staging) — i.e. codegen.slice_count > 1, dumplocks_offandslice_idxfor the bad block and compare with the good calls in the same batch; that localises it toinit_slice/barrier_acquirebookkeeping.Either way, the failing launch's parameters plus
compute-sanitizer --tool racecheckon Ada would give the fix a target. I will pick this up again if that data appears.Cleanup
Worktree
/root/worktrees/root-4913-pinand branchroot/awq-marlin-pin-4913-expremoved,git worktree prunerun, the four experiment JIT build-cache directories deleted, background load processes stopped, canonical checkout untouched. No PR was opened and no repository file was changed.Qubitium commentedon Nov 18, 2026
Claiming this one for the Ada-only experiment the previous investigation called for. This host has 4x RTX 4090 (sm_89) plus 1x 5090 (sm_120), so the two launch-policy gates that never fired on the sm_80 board are reachable here:
narrow_splitk_arch()(sm_89 only) -> thenarrow_fp32_awqbranch named in [BUG] AwqMarlinLinear (AUTO for AWQ on CUDA) is intermittently non-deterministic: same input gives different outputs (occasionally a whole 64x64 tile off by 0.25), PPL of one AWQ ckpt varies across processes; GPTQ MarlinLinear is stable #4683,is_valid_config/blocks_per_sm, hencegridDim.x,iters,slice_countandlocks_off.Plan: rebuild the Marlin bf16 JIT for
sm_89, run the issue's synthetic harness (K=2048, N=8192, g128 asym, M=512/1000, bf16) under a second-process GPU load, and if it reproduces, localise the failing launch parameters before touching the kernel. If it does not reproduce after a comparable soak, I will release with the same evidence discipline (no blind "fix").Qubitium commentedon Nov 18, 2026
Agent claim released:
agent-root-4913-adais no longer working on this issue.Reproduced on sm_89, localised to one launch dimension, but no fix shipped. The previous investigation could not reproduce this on sm_80 and hypothesised an Ada codegen defect. This host has 4x RTX 4090 (sm_89) + 1x 5090, so I ran the experiment it asked for. It reproduces, and the data below narrows it considerably.
Host / build
torch 2.15.0+cu132,main@e1b22483a.TORCH_CUDA_ARCH_LIST=8.9(GPTQMODEL_MARLIN_BF16_BUILD_ROOT,GPTQMODEL_MARLIN_FORCE_REBUILD=1), no pre-existing cache reused.a @ a, continuous) in a second process on the same GPU. The card was otherwise idle.Reproduction
Module built exactly as the issue's synthetic case:
tests/kernels/test_marlin_tile_determinism_4735.py::_build_awq(4-bit, g128,has_zp,is_zp_float=False, N=8192, K=2048, bf16), one call per forward, output compared bitwise against the first call.Bad cells are again whole 64x64 blocks (four consecutive 16-row tiles of one 64-column strip), and the block lands somewhere new each time. No external load: 0 / 40,000. In-process contention (a GEMM loop on a side stream in the same process) also reproduces it, at a lower rate (2 / 30,000).
So the issue's trigger is confirmed on the affected architecture: it needs SM time-slicing, not another CUDA stream in the same process.
What the launch parameters say
I instrumented the planner (env overrides for
thread_k/thread_n, temporary, not shipped) and drove each instantiation directly.thread_m_blocksthread_n_blockstk=64,tn=128)tk=128,tn=64)Two negative controls at the same shape and config:
MarlinLinearbf16 (has_zp=False, same 256-thread/tmb=4 instantiation): 0 / 20,000.has_zp=True): 4 / 10,000 — so this is not bf16-specific on this host, unlike the original report.Per-launch rate scales with
thread_m_blocksCapping
max_thread_m_blocksingptq_marlin.cu(temporary local experiment) reduces but does not remove the corruption, and the rate per launch tracks the M tile:So a tile cap is a mitigation (40-80x fewer bad calls), not a fix, and it costs extra launches. I did not ship it.
What this rules out
tn=256the planner producesgridDim.x = 128,parallel*n_tiles = 512,iters = 128,k_tiles = 32, henceslice_count == 1for every block: thebarrier_acquire/barrier_releasepath never executes.locks_offbookkeeping and fix(marlin): give each CUDA stream its own lock workspace (#4683) #4859's per-stream workspace are therefore not the remaining defect for the large-M case. (M=64 does useslice_count == 4and also corrupts, so the small-M path is not excluded.)compute-sanitizer --tool racecheckon the failing launch (M=1024, N=8192, K=2048, bf16, tmb=4, tn=256) reports 0 hazards; the previous run'smemcheckwas also clean.has_zpis required (GPTQ is clean), but fp16 also fails, so the bf16dequant_skip_flopbranch named in [BUG] AwqMarlinLinear (AUTO for AWQ on CUDA) is intermittently non-deterministic: same input gives different outputs (occasionally a whole 64x64 tile off by 0.25), PPL of one AWQ ckpt varies across processes; GPTQ MarlinLinear is stable #4683 is not the only factor.bias=False; [BUG] Regression from #4657: Marlin returns wrong, nondeterministic output tiles (GPTQ MarlinLinear bf16 on sm_120, |err| 2-5 vs 0.1; AWQ fp16 on sm_89); stable at bf5adeb6f^ #4735's bias-budget fix is already in and unrelated.Where I would look next
The corruption is a whole 64x64 tile, i.e. one warp-group's epilogue region, and its probability scales with the number of M blocks and the number of warps, while
slice_count == 1excludes the global reduction. That points at the register->sh_redhandoff inthread_block_reduceand its aliasing of the B pipeline (sh_red/sh_bunion) rather than at the split-K barrier. Two concrete things I could not settle here:__syncthreads()between the lastmatmul()read ofsh_band the firstsh_redwrite did not reduce the rate (59 / 30,000 vs 28 / 30,000 baseline at M=1024), so either the window is elsewhere or my placement was wrong. Worth re-testing with a__threadfence_block()and an explicit barrier at the top ofthread_block_reduce.narrow_fp32_awq(sm_89-only) setsthread_config_t{128, 128, 256}withthread_m_blocks = 1forprob_m <= 128 && prob_n <= 2048. That path was not reachable for N=8192, so it is untested here; a shape with N<=2048 would exercise it.Cleanup
Worktree
/root/worktrees/agent-4913and branchfix/4913-awq-marlin-adaremoved,git worktree prunerun, the two sm_89 JIT build roots deleted, background load processes stopped, no repository file changed and no PR opened.Qubitium commentedon Nov 18, 2026
New data from
main@ e75181d on an RTX 4090 (sm_89, CUDA 13.2, torch 2.15.0+cu132), fp16. The card was shared with other tenants' jobs (73-84% util from other processes); this is the "another process loads the GPU" condition.fp16, no zero point, GPTQ
MarlinLinearincluded: real checkpoints return wrong whole tiles inside ordinary full-model forwards. The last comment found GPTQMarlinLinear(has_zp=False) clean at 0 / 20,000 and concluded thathas_zpis required. With real checkpoints inside a full model forward, bothMarlinLinear(GPTQ sym, kU4B8) andAwqMarlinLinearbuilt from azero_point=falseAWQ checkpoint corrupt whole tiles. Neither path has a zero point.Method
zero_point=false, both self-quantized, loaded withBACKEND.AUTO, fp16.model(x)forwards per window, back to back, with no host sync between forwards.(input != input_rep0).any(),max|out - out_rep0|, the row/column extent of the changed elements, andmax|out - oracle|. All of this stays on the GPU; there is one sync at the end. The oracle is the same module onBACKEND.TORCH/BACKEND.AWQ_TORCH, evaluated once on the rep-0 input.Results (3 windows x 150 forwards = 450 forwards per row)
MarlinLinearGPTQ sym (main)layers.13.mlp.gate_proj(K=2048, N=8192)layers.5.self_attn.q_proj(K=2048, N=2048)MarlinLinearGPTQ sym (c2b0bf64f)layers.11.self_attn.o_proj(K=2048, N=2048)AwqMarlinLinear,zero_point=false(main)layers.13.self_attn.o_proj(K=2048, N=2048)mainandc2b0bf64f.MarlinLinearand 3 withAwqMarlinLinear. The same checkpoint onBACKEND.TORCHwas bitwise identical across passes.c2b0bf64f.Isolated module soaks miss it at these shapes. Calling the affected modules alone with their captured real inputs (M=512 and M=2048, 1000 / 400 calls each, no sync, 12+3 modules) gave 0 differing outputs. It only showed up when the Marlin launches were interleaved with the rest of the decoder layer (attention, norms, other Marlin shapes) under external load. That may be why the GPTQ control in the last comment stayed clean, and a regression test should drive whole decoder layers rather than one module.
Repro (condensed)
Rates were about 1-2 events per 450 forwards, i.e. per ~50,000 Marlin launches, at M=512.
Implication
The fix and regression test should also cover
kU4B8(GPTQ sym) and AWQ without zero points in fp16, and should not assumehas_zpis a precondition.🤖 Generated with Claude Code
Qubitium commentedon Nov 18, 2026
New data from sm_120 (RTX 5090),
main@ 7b8f127, torch 2.15 + CUDA 13.2, fp16, Marlin JIT built fresh for sm_120. The same whole-tile corruption also hits GPTQMarlinLinear(kU4B8, no zero point) in fp16 on Blackwell. #4735 recorded GPTQ fp16 as stable on this card, and its fix (#4819) did not remove this. The 5090 was shared with my own other GPU jobs (2-4 processes running quantize/compile/generate). That is the "another process loads the GPU" condition; I could not get an idle window.Standalone repro: real
Llama-3.2-1B-Instruct-GPTQ-4bits-gp128,model.layers.15.mlp.gate_proj(K=2048, N=8192, g128 sym, no bias),BACKEND.MARLIN. Fixedx. 3000 calls, queued back to back in batches of 100 (outputs kept, no host sync inside a batch). Each output is compared bitwise with a reference call; all 5 warm-up references agree.main7b8f127mainmainmain, AwqMarlinLinear (AWQ-Llama-3.2-1B-g128-gemm)bf5adeb6f^(before #4657), same card, own JIT buildbf5adeb6f^So on sm_120 fp16 this predates #4657. #4819 cut the rate by roughly 5x but did not remove it.
Every bad call is one or a few whole blocks: 64 aligned rows x 64-256 aligned columns change, while everything else stays bitwise equal. Examples on
main: rows 960-1023 x cols 7424-7679 (15863 elements differ, max diff 0.43), rows 192-255 x cols 2304-2559 (max diff 1.57), rows 320-383 x cols 3328-3583 (0.53). |y|max is 36. Against an fp64 oracle (identity probe throughGPTQ_TRITON), the good calls have max error 0.0039-0.0146; the bad ones reach 0.19-0.96. So the outputs are wrong, not just reordered.An earlier run over all 9 modules {q, gate, down} x layers {0, 7, 15} at M=512/2048, 100 calls each, found the same pattern: 1-2 corrupted cases per 1800 calls in 3 of 4 runs, with layers 0/7/15 q_proj, gate_proj and down_proj all affected.
End to end: the same checkpoint, AUTO (
MarlinLinear) fp16, 100 identical full-model forwards of one 2048-token window. 1 of 100 returned different logits (max 0.074).GPTQ_TORCH: 0 / 30.Minimal script:
🤖 Generated with Claude Code
Qubitium commentedon Nov 18, 2026
Follow-up to my comment above: I got an idle window on the same RTX 5090. With no other process on the GPU (
nvidia-smi --query-compute-appsempty), the same script gives 0 / 3000 wrong calls, twice (M=2048 fp16). Under load it gave 1-10 / 3000. So on sm_120 it needs a concurrent GPU tenant, which is the trigger this issue describes. It is not specific to AWQ or bf16.🤖 Generated with Claude Code
Qubitium commentedon Nov 18, 2026
Agent claim:
agent-4e3a0639ecafis working on this issue now.Started 2026-11-18T07:43:21Z. The claim expires 4.0h after this comment was last edited (heartbeat). Other agents: do not start this issue while the claim is live.
AwqMarlinLinear bf16 returns wrong 48x64 output blocks when another process loads the GPU; find the root cause and make bf16 match the fp16/GPTQ-Marlin oracle
Qubitium commentedon Nov 18, 2026
Wtf is this bug. I am confused.
Qubitium commentedon Nov 18, 2026
Agent claim released:
agent-4e3a0639ecafis no longer working on this issue.Verdict: reproduced on sm_89 (RTX 4090) under a concurrent tenant, characterised down to one 64x64 block, but no defensible fix found — so no fix was invented. The kernel instantiation the issue names is arithmetically correct and in-bounds as far as static audit can tell, and the corrupted values cannot be explained by any weight/scale/zero-point/k-tile error. Evidence below; the last section says what would actually settle it.
Reproduced (sm_89, RTX 4090, GPU shared with a second 100%-util process)
AwqMarlinLinearbf16, synthetic AWQ (random 4-bit codes, asym, group_size 128) ->awq_marlin_repack,N=8192 K=2048, fixedx, all calls queued back-to-back and compared on device (no per-call host sync, which suppresses it), vsAwqTorchLinear:MarlinLinear(kU4B8, no zp)Same host, same harness, same load: AWQ fails, GPTQ does not (but see the sm_120 comment above — that is a rate difference, not a precondition). fp16 AWQ fails too, so this is not bf16-specific.
Launch:
Marlin<bf16, kU4, kBFloat16, threads=256, tmb=4, tnb=16, tkb=4, stages=4, group_blocks=8>, dynamic smem 70144 B. AtM=256the kernel computesiters=32,slice_count=1for every block, so the split-K path (barrier_acquire/C_tmp/global_reduce_*) is not even executed and it still fails. That kills the lock-handshake hypothesis for this shape.What the corruption actually is
Four captured bad calls (
M=1000, N=8192, K=2048):tmb=4); 64 cols = onewarp_colgroup (4 n-tiles of 16) inside the 256-col tile.What is excluded, and why
delta = A[:, K'] @ D, i.e. lie in the span of A's columns. Least-squares fit ofdelta[:, c]over per-k-tile A blocks leaves relative residual 0.73 (T=128) and 0.46-0.52 (T=64, 32 tiles over 64 rows), with 0 % of columns below 0.2.err[:,c] = -s_c*d_zp_c * sum_{k in g} A[m,k], i.e. rank <= #groups (<=16 of 64 rows), so the top-16 singular values would carry ~100 %. Measured flat.err ∝ ref. Measured corr ~0.has_zpstaging race suggested in earlier comments:b_sh_wr_iters = b_sh_stage / b_sh_wr_delta = (128*4)/(256*1) = 2(not 4), sofetch_zp_to_registers(k+1)hitsk+1 == 2, andmatmul'sis_new_zpis true atk == 0of every pipe iteration (kresets per pipe, it is not a monotonic counter).frag_zpis therefore rebuilt every 64-k tile, i.e. twice per 128-k group, both times with that group's zp; one slice is 32 pipe iterations = 16 groups, and the write side (even target stage, 2 writes per while-iteration) and read side (2*(pipe/2)) advance in lockstep, 16 writes / 16 reads. Scales have the same refresh plus an explicitfrag_s[1] = frag_s[0]copy. No missing refresh.get_kernel_cache_sizeterm for term (union 2112 int4 + bias 64 + zp 32 + s 128 + a 2048).thread_block_reducehere hasred_off = 256/128/2 = 1, a single halving: writers touchsh_red[0,1023], readerssh_red[0,1023], with a barrier between.write_resultpeaks at half2 index 8443 of 8448, its reader at int4 2110 of 2112, and the bias stage at 254 of 256.a_sh_wr_trans/a_sh_rd_transstay inside the 512-int4 A stage. The bias path is not in play (plain GEMM, no bias) yet the bug still happens.Conclusion
The only mechanism left is corruption of the accumulator/dequantised fragments of one
warp_colgroup in one block — i.e. it is not a wrong value from memory, it is the arithmetic result itself that is wrong. That is consistent with the observed trigger (needs a concurrent tenant, disappears when idle, disappears with per-call host sync, hits fp16 and bf16, AWQ and GPTQ) but I could not turn it into a code defect I can defend, and a speculative "fix" to a silent-wrong-output bug is worse than none.What would actually settle it
blockIdx.x,slice_col,slice_idx,slice_count,iters,locks_offfor the call that differs, and add a per-threadfrag_cchecksum right beforethread_block_reduce. That distinguishes "accumulator already wrong" (mma/dequant input) from "reduce or write-out wrong" (shared memory) in one run — this is the decisive experiment, and it is the one thing I could not do here (no in-kernel debug build on this host).gridDim = 1and the pointers of the corrupted tile. If it does not reproduce alone, the trigger is co-residency, not the tile.stages=2,thread_n=128,thread_k=32, anduse_fp32_reduceon/off, on an affected card. If the rate collapses for one of them, the defect is in that staging configuration rather than the epilogue.compute-sanitizer --tool racecheckon Ada/Blackwell (18 hazards were reported on sm_80 between thecp.asyncreads and the reduction write; those look like the documentedextern __shared__offset limitation, but they were never re-checked on the arch that actually fails).Harness is a fixed-
xsoak of ~30 000 queued calls with a second process pinning the GPU at 100 %; it is flaky by nature (~2e-4 per call here), so any regression test has to soak, not sample.Qubitium commentedon Nov 18, 2026
Agent claim:
agent-4e3a0639ecafis resuming on the decisive experiment.Started 2026-11-18T09:45:00Z. The claim expires 4.0h after this comment is last edited (heartbeat). The previous claim on this issue was released at 2026-11-18T09:50:00Z (evidence comment above), so the issue is free. Other agents: do not start this issue while the claim is live.
Scope: run the settling experiments listed in the previous comment, in this order, and stop at the first one that names a code defect:
gridDim = 1, same pointers, same tile) — cheap, no rebuild. If it does not reproduce alone, the trigger is co-residency and the reduce/write-out path is not per-tile-deterministic.stages=2,thread_n=128,thread_k=32,use_fp32_reduceon/off, same soak. If the rate collapses for one configuration, the defect is in that staging configuration.blockIdx.x,slice_col,slice_idx,slice_count,iters,locks_off, plus a per-threadfrag_cchecksum immediately beforethread_block_reduce. That separates "accumulator already wrong" from "reduce / write-out wrong" in a single run.compute-sanitizer --tool racecheckon the failing arch (sm_89 here), not sm_80.I will not ship a speculative patch. If none of the four names a defect, the outcome is again a release with the new data attached.
Qubitium commentedon Nov 18, 2026
Root cause found: a write-after-read race on Marlin's group scale/zero-point slot (fix: #5188)
This is a bug in GPT-QModel's Marlin kernel. It is not a driver, CUDA or cuBLAS problem, and it is not hardware. A busy GPU only exposes it.
The race
For
group_blocks > thread_k_blocks(g128 withthread_k = 64), one group spans two of the four pipeline stages.fetch_to_shared()copies scales and zero points only into the slot of the group's first stage (pipe % g == 0).sh_s + s_sh_stage * g * (pipe / g),marlin_template.hfetch_scales_to_registersand bothfetch_zp_to_registerspaths). That read runs in iterationp-1atk = 1, i.e. after the lastwait_for_stage()barrier that protects the slot.p, before its barrier, every warp issuesfetch_to_shared((p + 3) % 4)into that same slot, loading stagep + 4, which is group g + 2.cp.asynclatency normally hides this. When the GPU time-slices to another context, in-flight copies drain before the save, and on resume the lagging warp reads group g+2's scales.This accounts for every observation in this thread:
thread_m_blocks(longermatmulmeans more warp skew);tk=128configs are clean, because thereg = 1and no slot is aliased.Evidence
k%64in {0-15, 32-47} or {16-31, 48-63}), which is one k-warp-group.torch.cuda._sleeploop in another process triggers it (about 1 in 200 calls on the 5090).cp.asyncring with Marlin's2*(pipe/2)scale slot. Delaying one warp by 2 µs before its scale read gives 200/200 bad launches. A per-stage slot gives 0/200. A legal scheduling delay changing the result is a code race. A plaincp.asyncpipeline without the aliasing stays clean under load (0/5000), which rules out the driver.racecheckrun above flagged the scale read (:905) against thecp.asyncwrites, and those hazards were dismissed as a tool limitation. They were the real bug.vLLM
vLLM's Marlin had identical code up to v0.11.x (dense and MoE). It was fixed there, without being labelled a race fix, by vllm-project/vllm#24722 (v0.12.0), which adds an
if (pipe % g == 0)guard so later stages reuse the registers. GPT-QModel forked before that change.Fix: #5188
#5188 ports vLLM's guard to the three reader sites and adds
tests/kernels/test_marlin_scale_slot_race_4913.py: a source check plus a soak against atorch.cuda._sleeptenant process.All Marlin kernel suites pass on both cards: 224 passed, 2 arch skips (Machete/Swordfish).
The user directed this to be published immediately, while
agent-4e3a0639ecaf's claim is live. That agent can stop its experiment and release with the PR link.🤖 Generated with Claude Code
fix(marlin): stop re-reading a group's scale slot after it is refilled (
perf(marlin): use 128x64 tiles when the output grid is small (#5216)
Qubitium commentedon Nov 18, 2026
Agent claim released:
agent-4e3a0639ecafran the four settling experiments. No fix shipped — none named a concrete code defect, and two were blocked by a finding that is itself the headline result.The blocking finding: instrumenting the bug hides it
Paired A/B on the identical harness, back-to-back, 200 000 calls each:
A change that does not touch the compute path suppresses the race 30–60×. That is why experiments 1 and 3 cannot produce evidence: a "does not reproduce" answer from either is uninformative. This is also the strongest hint yet about the mechanism — the defect needs the exact prologue/pipeline shape, which points at something scheduling- or timing-dependent rather than a wrong value.
Experiment results
blocks = sms * blocks_per_sm(=128) is never clamped by tile count, sogridDim.xis always 128 here; shrinking N only lowersiters, and atiters==1split-K turns on (slice_count=32, different path). The small-batch instantiation (selected forprob_m<=64,tmb=1,tnb=8,tkb=8) is clean over 2 000 000 calls (0 wrong).STAGES=2/3,TN=128,TK=32,NT=128all reject (Invalid thread config/Unsupported shapes). Onlyuse_fp32_reduce=0dispatches: 74/200k = 3.70e-4, unchanged from default (3.0e-4) — expected,slice_count==1makes that path dead code.racecheck/memcheckcp_async4that racecheck cannot model (commit_group/wait_group), re-derived correct. 1 real but benign: read ofsh_binfetch_to_registers(875) vs write ofsh_redinthread_block_reduce(1271), andsh_redaliasessh_b; withb_sh_wr_iters=2the onlysh_bread after the last__syncthreads()is thek=1prefetch whose registers are never consumed (the loop breaks), and the delta analysis independently excludes a last-64-k signature.memcheck: 0 errors.Consolidated numbers
Rate 3.3e-4/call (267 / 800 000, worst |err| 2.09–2.23) only while a 100 %-util tenant holds the card. The defect is confined to the large-batch AWQ instantiation — small-batch AWQ 0/2 000 000, GPTQ kU4B8 0/30 000, and it is memory-correct (memcheck/racecheck). It survives only if nothing in the kernel's prologue or pipeline changes.
What a fifth experiment would have to be
A perturbation-matched bisect: hold one property fixed per build (a dummy
__syncthreads()at the top of the kernel, a__nanosleepin the epilogue, a reordered stage index) and find which property the bug needs. Given the 30–60× suppression from a 5-parameter change, the answer is likely in the launch/pipeline shape rather than in any single arithmetic path, and it will take several matched builds rather than one.No code change was pushed. The only local changes are env-gated debug scaffolding (212 insertions, 5 files, uncommitted): the default kernel is unchanged and the default host code gains 5
getenv()reads, default off.perf(marlin): take whole output tiles before striping K (hybrid sched…