[PR #4274] [Engine] prevent SM60 VMAD input accumulator aliasing #4983

Open
opened 2026-11-07 16:31:47 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4274
Author: @Joe11221
Created: 10/27/2026
Status: 🔄 Open

Base: main ← Head: fix/sm60-vmad-accumulator-alias


📝 Commits (2)

  • 7185fcb [Engine] prevent SM60 VMAD input accumulator aliasing
  • 3fb95a8 [Docs] P100 alias note: the full engine build has now run with the fix

📊 Changes

3 files changed (+96 additions, -1 deletions)

View changed files

➕ docs/P100_DP4A_ALIAS.md (+43 -0)
📝 include/strata/kernels/dp4a.hpp (+3 -1)
➕ tools/sm60_dp4a_alias_check.cu (+50 -0)

📄 Description

Problem and result: on sm_60 the strata_dp4a fallback is four chained vmad instructions in one asm block, with the accumulator declared "+r". NVCC may therefore give the output the same register as a or b. The first vmad then overwrites that input before the remaining three read it, and the dot product is wrong. A probe that forces accumulator == A, accumulator == B, and both gave 61,324-62,997 mismatches per 65,536 inputs on a P100 before the change and none after. The accumulator is now "+&r" (early clobber), so it always gets its own register. Nothing else changes; SM61+ still uses native DP4A.

Related discussion: none. This is a focused fix. Related earlier work: #883 and #1279 (the VMAD fallback itself). #1279 mentions a "scoped accumulator" for this aliasing, but current main still has "+r".

Approach: an early-clobber constraint is the minimal way to tell the compiler the output is written before the inputs are last read. No call site changes. tools/sm60_dp4a_alias_check.cu is a self-contained regression check, and docs/P100_DP4A_ALIAS.md records how to run it.

Validation:
Passed: nvcc -O3 -arch=sm_60 -Iinclude tools/sm60_dp4a_alias_check.cu -o alias-check, run after the change on three P100s (sm_60 build, the changed path), an RTX 2080 Ti (sm_75 build) and an RTX 3060 (sm_86 build): 0 mismatches in 262,144 comparisons per card. The RTX cards use native DP4A, so they confirm the unchanged path still agrees with the oracle, not the fix. Before the change on one P100: 62997 / 62238 / 61325 / 61324 mismatches across the four arms.
Passed: SASS for the probe built for sm_60 has four VMAD per strata_dp4a and no IDP; built for sm_61 it keeps four native IDP.
Passed: full engine at c62d5e3a (engine 0.1.55) with only this fix, root Dockerfile, CUDA 12.9.1, CUDA_ARCHITECTURES=60;75;86, on a six-card layer split with three P100s (RTX 2080 Ti, RTX 3060, 3 x P100, RTX 3060). Two runs, Swift 1.5 IQ3_S, MTP, two slots: 16,512 and 16,325 output tokens, 0 failed requests, no engine, GPU or non-finite errors, reads up to 128K. Median decode over all prompts 53.7 and 53.9 tok/s. These runs did not include a no-fix baseline, so they are not a before/after speed result. Report and raw logs (b1, b2) come from #5045.
Passed: 14 more runs of my DFlash2 branch at cc75837c, which contains the same fix and adds other changes, on the same machine: no failed requests or engine errors, 12 of 12 sanity checks in the draft standard benchmark. 16 runs in all, 215,584 output tokens.
Failed: none observed.
Not run: the same full-engine runs without the fix, so I have not shown a model-level difference from it; SASS inspection of real engine kernels for the aliased pattern; current main; HIP and SYCL builds (the changed asm is under the CUDA sm_60 guard only).

Limits: the probe forces the aliasing. I have not shown that any real engine kernel currently compiles into the aliased pattern, so this is not claimed as an observed production corruption; it removes a compiler-dependent wrong-result path. The server logs of these runs also print a false-looking warning that the engine was built for sm_0, sm_5, sm_6, sm_7, sm_8; the build recipe names 60, 75 and 86, and no launch failure occurred. I did not investigate it. Outside the measurements, I run this fix as my everyday engine on these P100s.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/4274 **Author:** [@Joe11221](https://github.com/Joe11221) **Created:** 10/27/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/sm60-vmad-accumulator-alias` --- ### 📝 Commits (2) - [`7185fcb`](https://github.com/Niko1221/Strata/commit/7185fcb65ce53caef26f15b09972c86853a05fdc) [Engine] prevent SM60 VMAD input accumulator aliasing - [`3fb95a8`](https://github.com/Niko1221/Strata/commit/3fb95a884ebc2945d367e8241d155caf6a5d296c) [Docs] P100 alias note: the full engine build has now run with the fix ### 📊 Changes **3 files changed** (+96 additions, -1 deletions) <details> <summary>View changed files</summary> ➕ `docs/P100_DP4A_ALIAS.md` (+43 -0) 📝 `include/strata/kernels/dp4a.hpp` (+3 -1) ➕ `tools/sm60_dp4a_alias_check.cu` (+50 -0) </details> ### 📄 Description Problem and result: on sm_60 the `strata_dp4a` fallback is four chained `vmad` instructions in one asm block, with the accumulator declared `"+r"`. NVCC may therefore give the output the same register as `a` or `b`. The first `vmad` then overwrites that input before the remaining three read it, and the dot product is wrong. A probe that forces accumulator == A, accumulator == B, and both gave 61,324-62,997 mismatches per 65,536 inputs on a P100 before the change and none after. The accumulator is now `"+&r"` (early clobber), so it always gets its own register. Nothing else changes; SM61+ still uses native DP4A. Related discussion: none. This is a focused fix. Related earlier work: #883 and #1279 (the VMAD fallback itself). #1279 mentions a "scoped accumulator" for this aliasing, but current `main` still has `"+r"`. Approach: an early-clobber constraint is the minimal way to tell the compiler the output is written before the inputs are last read. No call site changes. `tools/sm60_dp4a_alias_check.cu` is a self-contained regression check, and `docs/P100_DP4A_ALIAS.md` records how to run it. Validation: Passed: `nvcc -O3 -arch=sm_60 -Iinclude tools/sm60_dp4a_alias_check.cu -o alias-check`, run after the change on three P100s (sm_60 build, the changed path), an RTX 2080 Ti (sm_75 build) and an RTX 3060 (sm_86 build): 0 mismatches in 262,144 comparisons per card. The RTX cards use native DP4A, so they confirm the unchanged path still agrees with the oracle, not the fix. Before the change on one P100: 62997 / 62238 / 61325 / 61324 mismatches across the four arms. Passed: SASS for the probe built for sm_60 has four `VMAD` per `strata_dp4a` and no `IDP`; built for sm_61 it keeps four native `IDP`. Passed: full engine at `c62d5e3a` (engine 0.1.55) with only this fix, root `Dockerfile`, CUDA 12.9.1, `CUDA_ARCHITECTURES=60;75;86`, on a six-card layer split with three P100s (RTX 2080 Ti, RTX 3060, 3 x P100, RTX 3060). Two runs, Swift 1.5 IQ3_S, MTP, two slots: 16,512 and 16,325 output tokens, 0 failed requests, no engine, GPU or non-finite errors, reads up to 128K. Median decode over all prompts 53.7 and 53.9 tok/s. These runs did not include a no-fix baseline, so they are not a before/after speed result. Report and raw logs ([`b1`, `b2`](https://github.com/Joe11221/Strata/tree/74ebc8b494ce38a5072dbf94abeea2e88f7845c7/bench/results/2026-11-02-community-6gpu-dflash2-main-0.1.55)) come from #5045. Passed: 14 more runs of my DFlash2 branch at `cc75837c`, which contains the same fix and adds other changes, on the same machine: no failed requests or engine errors, 12 of 12 sanity checks in the draft standard benchmark. 16 runs in all, 215,584 output tokens. Failed: none observed. Not run: the same full-engine runs without the fix, so I have not shown a model-level difference from it; SASS inspection of real engine kernels for the aliased pattern; current `main`; HIP and SYCL builds (the changed asm is under the CUDA sm_60 guard only). Limits: the probe forces the aliasing. I have not shown that any real engine kernel currently compiles into the aliased pattern, so this is not claimed as an observed production corruption; it removes a compiler-dependent wrong-result path. The server logs of these runs also print a false-looking warning that the engine was built for `sm_0, sm_5, sm_6, sm_7, sm_8`; the build recipe names 60, 75 and 86, and no launch failure occurred. I did not investigate it. Outside the measurements, I run this fix as my everyday engine on these P100s. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4983
No description provided.