cuda: batch ragged attention across independent streams#365
Conversation
|
Reviewed the CPU-safety and it's clean β every glm.c change is behind The one thing holding the merge: it's an attention batching kernel β correctness-sensitive β and I have no GPU here, so I can't run With a green test from hardware, this merges. It stacks naturally with #298's CUDA work, so coordinating the two is worth it. |
|
Ran it on real silicon β RTX 5080 / sm_120 (the #306 box), CUDA 12.8, nvcc built against the PR head (786f98d):
That's a second sm_120 confirmation alongside the author's 5090. Stacks cleanly with #298's CUDA work (I've been running the g64 container on this same box). Happy to run the full |
|
running the tests now. |
|
Merged. @mohamedmastouri2000-boop's run is what unblocked it: |
|
Ran the gate you asked for on real silicon β RTX 5070 Ti (sm_120), CUDA 12.8, Windows, 1. The shipped test passes (false green)But it runs at toy dimensions β K=3, T=3, H=2, S=3. At that geometry the bug below doesn't trigger, so 2. Token-identity A/B on a short prompt failsDrove
3. Root cause: non-deterministic corruption at production scaleWrote a kernel-level A/B (ragged-CUDA vs batch-CUDA, both on GPU, same tensors β no model/routing/quant confound) at real MLA dims β K=512, Q=192, R=64, V=256, H=64: A cold ragged S=4 call vs the per-sequence batch reference, 5 consecutive identical runs (same inputs, same tensors, fresh process each time): It's intermittent: ~1 in 5 identical runs diverges, by ~0.01β0.025 relative rms. That signature β non-deterministic, not reproducible every run, no crash β points to a race / uninitialized-device-memory read in the ragged path's use of the shared This is exactly the "subtly-wrong-but-not-crashing" case you flagged β except worse, because it's not even reliably reproducible, so it'll flake in CI and silently degrade output in production. Suggestion
Happy to post the repro test ( |
|
Follow-up with the repro tests pushed to a branch on my fork, so anyone with GPU hardware can build/run them directly:
The repro is intermittent (~1 in 5 runs), so run |
Summary
Validation
make -C c glm CUDA=0tests/test_ragged_attention:ragged_relative_rms=0Measured result
On the 6x RTX 5090 full-residency GLM-5.2 setup at B=256, the decode forward changed from 26.131 s to 14.344 s (1.82x), while the attention phase changed from 15.143 s to 3.303 s (4.58x). Disk reads remained zero.