Repository navigation
Profiles: the inspected head kernels issue HGMMA (wgmma), and all 14 accumulate BF16 as the Hopper model says (k = 16, F = 25, truncation) - #186
Conversation
tensor_instructions.py reads, from the head GEMM's Nsight Compute reports, the tensor operations on the HGMMA and HMMA paths and the executed SASS, and searches cuBLAS's libraries for the nvjet kernels with cuobjdump. wgmma_precision.py probes how the tensor cores accumulate BF16 products into FP32 with crafted inputs whose exact sums are known: the fractional bits kept after alignment, the truncation direction of dropped bits, the block size, whether the accumulator joins the aligned sum, and the rounding to FP32. It runs through Triton's tl.dot (wgmma on sm_90, checked in the PTX and SASS) and through the head's own torch.matmul at one row count per head kernel. run_all.sh gains a wgmma step; analyze_all.sh runs tensor_instructions.py.
mypy could not type the result rows; they are now list[dict[str, Any]]. The cuBLAS check adds M = 40, 80 and 160, so it covers all 14 head kernels named in evidence/certified_head/README.md.
head_tensor_instructions.json (tensor_instructions.py at f850e97): in the head GEMM's ncu reports at M = 1 and 32, every BF16-to-FP32 tensor operation is on the HGMMA path and the SASS has 64 and 48 HGMMA instructions and no HMMA; cuobjdump finds no nvjet function in libcublasLt.so.13 or libcublas.so.13. wgmma_precision.json (wgmma_precision.py at f850e97, a few seconds of GPU in a CPU-window hold, no timing): through Triton's wgmma and through the head's own torch.matmul at one row count for each of the 14 head kernels, the BF16 accumulation keeps 25 fractional bits below the largest addend, truncates dropped bits toward zero, adds blocks of 16 products together with the FP32 accumulator, and truncates the sum to FP32. That matches the paper's Hopper model (k = 16, F = 25, truncation) on the probed inputs. The evidence README describes the probe, the result each hypothesis would give and the scope; evidence/certified_head/README.md now says the Hopper model's published form was measured through HMMA and cites this evidence for the wgmma the stock kernels issue.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ea234a197b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| wgmma) "${LOCK[@]}" python experiments/profiling/wgmma_precision.py \ | ||
| --out evidence/profiles/wgmma_precision.json ;; |
There was a problem hiding this comment.
Include the WGMMA probe in the default run
When experiments/profiling/run_all.sh is invoked without step arguments—as advertised at the top of the script to reproduce every profile—main() replaces the arguments with a list that still ends at ncu. Consequently this newly added step is never run by the default reproducer, leaving evidence/profiles/wgmma_precision.json missing or stale unless the caller knows to request wgmma explicitly; add it to the default step list.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 362dc5d: the default step list now ends with wgmma.
Address Codex review on #186: without step arguments run_all.sh stopped at ncu, so the default reproduction never ran the new wgmma step.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 362dc5deb0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| beyond = [r for r in rows if r['test'] == 'align_neg' and r['param'] > f_pos] | ||
| neg = sorted({r['result'] for r in beyond}) | ||
| if neg == [0.0]: | ||
| neg_trunc = 'toward zero' | ||
| elif all(v == -(2.0**-f_pos) for v in neg): | ||
| neg_trunc = 'toward minus infinity' |
There was a problem hiding this comment.
Distinguish nearest-even before reporting truncation
When the alignment stage rounds dropped addends to nearest-even, these probes produce the same neg == [0.0]: at e = 26, 2^-e is exactly half of the retained 2^-25 quantum and rounds to zero, while every larger e is closer to zero. Thus this branch only rules out rounding toward minus infinity (and similar modes); it does not establish that aligned addends are truncated toward zero, despite that conclusion being used to claim the measured head matches the truncating Hopper model. Add a non-tie input such as 3 * 2^-27, or report the result as ambiguous.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 02b921b, with evidence regenerated in cabbab2. The probe adds dropped fractions of 0.25, 0.5, 0.625, 0.75 and 0.875 of the 2^-25 quantum, both signs. All vanish on Triton and on all 14 head kernels, so dropped bits are truncated toward zero; rounding to nearest would keep a quantum above 0.5. It also adds two non-tie FP32-rounding sums (0.75 step above a representable value), which rule out nearest with ties toward zero, and FP32-exact control rows showing the cuBLAS BF16 epilogue rounds to nearest even, which the cuBLAS rounding reading assumes. The README table lists each row and the result every hypothesis gives.
Address Codex review on #186: powers of two cannot separate truncation of the dropped bits from rounding to nearest, because 2^-26 is a tie at F = 25. The probe adds dropped fractions of 0.25 to 0.875 of the last kept quantum (both signs), two non-tie sums 0.75 of an FP32 step above a representable value for the Triton rounding test, and a quarter-step BF16-tie case on the cuBLAS path, so nearest with ties toward zero is told apart from truncation as well. Reviewer pre-review: the cuBLAS rows read the accumulator's rounding through the FP32-to-BF16 epilogue, which assumes that epilogue rounds to nearest even. Four control rows whose FP32 sums are exact classify the epilogue, and the accumulator's rounding is reported only when the epilogue is nearest-even.
wgmma_precision.json from 02b921b. The dropped fractions 0.25-0.875 of the 2^-25 quantum vanish for both signs, so dropped bits are truncated toward zero, not rounded to nearest. The Triton sums 0.75 of an FP32 step above a representable value truncate, which rules out round to nearest with ties toward zero. On the cuBLAS path the FP32-exact control rows show the BF16 epilogue rounds to nearest even, and under that epilogue the quarter-step rows show the sum is truncated to FP32. All 14 head kernels and Triton give the same answers. The README's test table states each new row and the result every hypothesis would give.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cabbab244c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| split-K allowance (1.19e-4). The stock head kernels issue the warpgroup `wgmma` | ||
| (SASS `HGMMA`) instead; on this GPU a probe with crafted inputs finds the same |
There was a problem hiding this comment.
Limit the WGMMA assertion to the inspected kernels
Only the M=1 and M=32 kernels have instruction counters and captured SASS; evidence/profiles/README.md explicitly states that the other kernels' SASS could not be read and only their numerical behavior was measured. Because the HMMA implementation is described as exhibiting the same accumulation behavior, those behavioral results cannot establish that the other 12 kernels issue HGMMA, so narrow this statement to the two inspected kernels or collect instruction evidence for the remainder.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 030355d: the README now claims wgmma (HGMMA) only for the two kernels whose SASS and counters were inspected (M = 1 and 32), and says the other 12 head kernels were measured numerically, behave the same way on the probed inputs, and had their instruction left unread.
| if [ "${#head_ncu[@]}" -gt 0 ]; then | ||
| run tensor_instructions.py --ncu "${head_ncu[@]}" \ | ||
| --search-libs "$libdir/libcublasLt.so.13" "$libdir/libcublas.so.13" \ | ||
| --out "$EV/head_tensor_instructions.json" > /dev/null |
There was a problem hiding this comment.
Require both head reports before regenerating evidence
In the inspected analyze_all.sh flow, an interrupted run_ncu.sh that leaves only one of head_gemm_m1.ncu-rep and head_gemm_m32.ncu-rep still makes this condition true. tensor_instructions.py accepts a single report, so the analysis exits successfully after overwriting head_tensor_instructions.json with incomplete evidence even though the README claims both row counts; validate the two exact inputs before regenerating the file.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 030355d: analyze_all.sh names both head reports explicitly and stops if only one exists. Both exist for the committed run. The step is skipped only when neither exists.
|
Verdict: REQUEST CHANGES at cabbab2 The probe and its evidence are sound. Two Codex comments on this head are valid and unanswered; the first narrows a claim. Blocking
Checked at cabbab2
Optional: |
…orts Address Codex review on #186. evidence/certified_head/README.md claimed that every head kernel issues wgmma, but only the M = 1 and 32 kernels' SASS and counters were read; the other 12 were measured numerically only. It now says so. analyze_all.sh regenerates head_tensor_instructions.json only when both head ncu reports exist and stops if only one does.
|
@codex review |
Reviewer suggestion on #186: the conservative model covers multi-term adders that keep at least FP32's 23 fraction bits; the measured F is 25.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a5517c5029
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| tri = summarize(rows) | ||
| tri['rounding_to_fp32'] = rounding_mode(rnd) | ||
| tri['round_acc_tie_odd_result_minus_1'] = rnd['round_acc_tie_odd'] - 1.0 | ||
| result['triton'] = {'k': args.k, 'instructions': info, 'summary': tri, 'rows': rows} |
There was a problem hiding this comment.
Preserve the Triton version in the evidence output
On every probe run, this assignment replaces the triton.__version__ string stored in result at line 330, so the generated evidence never records which Triton compiler produced the inspected PTX/SASS (the committed JSON confirms that triton contains only the probe results). Because compiler lowering is central to this measurement, retain the version under a distinct key such as triton_version or include it in the nested Triton result.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 5e3a1fc, with evidence regenerated in f6a9e75. A separate 'versions' key records PyTorch 2.13.0+cu130 (CUDA 13.0), Triton 3.7.1, Triton's ptxas (CUDA 12.8 build), cuBLASLt 130101 and its library, and driver 570.195.03. The Triton path also records its PTX version (8.7) and target (sm_90a). Every row and summary is identical to the previous run apart from these keys, checked in the CPU window. The README's scope paragraph names the versions.
|
Verdict: REQUEST CHANGES at a5517c5 Both items from my review at cabbab2 are fixed and answered:
Blocking
Everything else from my cabbab2 review stands: the instruction evidence, the probe design, the results for all 15 paths, the epilogue gating and the scope statement. |
Address Codex review on #186: result['triton'] held the Triton version and was then overwritten by the Triton path's results, so the evidence named no compiler for the inspected PTX and SASS. A 'versions' key now records PyTorch, its CUDA, Triton, Triton's ptxas, the cuBLASLt version and library, and the driver; the Triton path also records its PTX version and target.
wgmma_precision.json from 5e3a1fc. Every row and summary is identical to the 02b921b run (checked in the CPU window); the file now records PyTorch 2.13.0+cu130, Triton 3.7.1 with its bundled ptxas from CUDA 12.8, cuBLASLt 130101, driver 570.195.03, and the Triton kernel's PTX 8.7 for sm_90a. The README's scope paragraph names these versions.
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Verdict: APPROVE at f6a9e75 a5517c5..f6a9e75 fixes Codex 4162937315, which has a reply.
Everything from my reviews at cabbab2 and a5517c5 stands:
Codex found no major issues on f6a9e75. Host identity is clean, and the commits are Sam's. |
The wgmma evidence (#186, profile-wgmma) replaces the open-assumption wording, within the probes' scope. §2.2: Khattak and Mikaitis measured the warp-level mma path; the two stock head kernels we inspected (at M = 1 and 32) issue the warpgroup wgmma instead, and on crafted inputs all fourteen stock head kernels accumulate as the Hopper model assumes (16-product blocks, 25 fractional bits, truncation of the dropped bits and of the sum). It is a measurement on one GPU, and neither model is a vendor contract; the 1/58 sentence stays. Limitations: the probes find that accumulation, with more fractional bits than the conservative model needs, but used products with one exact operand and reached neither subnormals nor other GPUs, so neither model is established for all inputs. Appendix A: the Hopper-model item names the HMMA source of the published model and gives the probe result with its full scope (operands, GH200, driver 570.195.03, CUDA 13.0, PyTorch 2.13's cuBLAS; what was not probed); Table A.1's row and Table 1's row 3 cite the probes. Notes: the divergence figure's caption says the same in one clause. Both registers get an identical profile-wgmma entry (files and producers as in evidence/profiles/README.md).
The certified head's Hopper error model assumes that the stock head GEMM adds each block of 16 BF16 products and the FP32 accumulator in one aligned multi-term adder. The adder keeps F = 25 fractional bits below the largest addend's leading bit, truncates what it drops and truncates the sum to FP32. The paper attributes this model to Khattak and Mikaitis, who measured it through the warp-level
mma(SASSHMMA). This PR measures, on this GPU, which instruction the stock kernels issue and how that instruction accumulates.Based on main now that #173 has merged; its commits are f00f50e through cabbab2.
tensor_instructions.pyimportsmetric_rowsfrom #173'sncu_summary.py.Results (measured;
evidence/profiles/README.md, "Which tensor-core instruction the head uses, and how it accumulates")Instruction. In the ncu reports of the head GEMM at M = 1 (
nvjet_sm90_tst_512x8_64x3_2x1_v_bz_TNT) and M = 32 (..._384x32_...), all BF16-to-FP32 tensor operations are on the HGMMA (warpgroupwgmma) path and none on the HMMA path. The captured SASS has 64 and 48HGMMAinstructions (HGMMA.64x8x16.F32.BF16,HGMMA.64x32x16.F32.BF16) and noHMMA(head_tensor_instructions.json). The other head kernels cannot be read statically, becausecuobjdump -symbolslists nonvjet_sm90function inlibcublasLt.so.13orlibcublas.so.13.Accumulation.
wgmma_precision.pyuses crafted rows whose exact sums are known, so that one property of the adder decides each result. It runs through Tritontl.dot(fourwgmma.mma_asyncin the PTX,HGMMA.64x16x16.F32.BF16in the SASS) and through the head's owntorch.matmul(ones, W.T)at W = 248320 x 2560, at one row count per head kernel. The profiler confirmed all 14 kernels ofevidence/certified_head/README.md. Triton and all 14 kernels give the same answers:This matches the paper's Hopper model (k = 16, F = 25, truncation) and satisfies the conservative model. It is a measurement on crafted inputs of one GH200 (driver 570.195.03, CUDA 13.0, PyTorch 2.13's cuBLAS), not a vendor contract. The operands are powers of two and short sums of them, with one operand of each product equal to 1. Full-significand products, subnormals, K offsets beyond 128 and other GPUs or libraries were not probed. The README states this scope.
Changes
experiments/profiling/tensor_instructions.py(new; run byanalyze_all.sh) andwgmma_precision.py(new;run_all.sh wgmma, GPU for a few seconds, no timing).evidence/profiles/head_tensor_instructions.json(repo_commitf850e97) andwgmma_precision.json(every row and result, component versions,repo_commit5e3a1fc). Both were produced in exclusive CPU-window holds with main's approval for this probe.evidence/certified_head/README.md: thehopper-wgmmamodel's published form is now attributed to HMMA measurements, and this evidence is cited for thewgmmathe stock kernels issue.Validation
scripts/check_host_identity.shon the new evidence and both READMEs: no matches.Codex review
run_all.sh:84, include the wgmma probe in the default run: added (362dc5d).wgmma_precision.py:209, distinguish nearest-even before reporting truncation: non-tie dropped fractions, non-tie FP32-rounding sums and BF16-epilogue controls added (02b921b); evidence rerun (cabbab2). All results support truncation.evidence/certified_head/README.md:36, limit the wgmma assertion to the inspected kernels: done (030355d).analyze_all.sh:129, require both head reports: done (030355d).wgmma_precision.py:343, preserve the Triton version: a separateversionskey (PyTorch, CUDA, Triton, Triton's ptxas, cuBLASLt, driver) plus the Triton kernel's PTX version and target (5e3a1fc); evidence regenerated with identical rows (f6a9e75).