mirror of
https://github.com/deepseek-ai/DeepGEMM.git
synced 2026-11-05 00:47:26 +00:00
[GH-ISSUE #365] [BUG] Non-deterministic numerical problem of k_grouped_fp8_gemm_nt_contiguous #174
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
deepseek-ai/DeepGEMM#174
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @FFGGSSJJ on GitHub (Jun 23, 2026).
Original GitHub issue: https://github.com/deepseek-ai/DeepGEMM/issues/365
I encountered a numerical problem when using
k_grouped_fp8_gemm_nt_contiguousfor wgrad computation in FP8 training. Specifically:athat belongs to this expert are all zerosthe computed result for that expert will be wrong non-deterministically. And what interesting is that if I use different scale factor value for the all-zero channel during per-channel cast, the error might disappear.
I can reproduce the error using the following minimal unit test on my GH200 machine and deep_gemm version '2.6.1':
with outputs:
@hiSandog commented on GitHub (Jun 25, 2026):
The repro is nicely narrowed down. For triage, the interesting boundary seems to be the combination of exactly 128 tokens for one expert and an all-zero column in
a; that would make a very good regression case because it exercises the grouped kernel path without relying on a large model. It may also be worth noting whether changing only the scale for the zero column alters the failing lane/column consistently, since that could help distinguish stale shared-memory data from a scale/dequantization edge case.@Functionhx commented on GitHub (Jul 9, 2026):
I traced the root cause to a PTX-level race condition in sm90_fp8_gemm_1d1d.cuh. Have a PR ready if you'd like to take a look.
@LiRunGuo commented on GitHub (Sep 22, 2026):
I checked this on an H200 (SM90, 132 SMs, driver 580.159.03, CUDA 13.0, PyTorch 2.11.0+cu130). It reproduces on 2.6.1, and it no longer reproduces after #343 (
1f6f3f3), including on currentmain.I used the script from this issue with two changes: 2000 iterations per
sf_valinstead of 10000, and an extra check that each call's output is bitwise equal to the first call's output. A call counts as bad if it fails either check.sf_val= 1, 1e-4, 1e-8, 1e-3054e2261(2.6.1, before #343)54e2261+ only thesm90_fp8_gemm_1d1d.cuhchange from #343main(78b6900)On 2.6.1 the output differs between calls in almost every call. With
sf_val=1, the first call already blows up (output norm 8.1e3 vs 1.3e-3 for the reference). The C++ extension is identical between54e2261and1f6f3f3, so the only difference between the first two rows is the tensormap drain added in #343.So this looks fixed on
mainby #343. #375 adds a further drain on top of #343; I did not test it, but for this repro #343 alone is enough. I only tested on H200, not GH200, so if it still reproduces for you on a recentmain, the commit and GPU would help.