Skip to content

[HIP] [JIT] [Bugfix] Round mHC outputs to nearest even on gfx942 - #8653

Merged
junhaha666 merged 1 commit into
ROCm:mainfrom
Arist12:yz/gfx942-mhc-bf16-rne
Dec 1, 2026
Merged

junhaha666 merged 1 commit into
ROCm:mainfrom
Arist12:yz/gfx942-mhc-bf16-rne

Conversation

@Arist12

@Arist12 Arist12 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Build module_mhc and module_fused_ar_mhc with -DOPUS_FP32_to_BF16_DEFAULT=5, so their FP32 -> BF16 conversions round to nearest even on gfx942 instead of truncating. test_mhc_post gains a check that catches truncation, and test_mhc_seam.py checks the gfx942 ASM seam (which keeps truncating) against the truncation of mhc_post's value instead of bit-exactness with mhc_post.

Motivation

On gfx942, every BF16 value the mHC kernels write is rounded toward zero. mhc_kernels.cu and mhc_post_pre_gram.cu convert with opus::cast, and on architectures without a hardware BF16 convert that cast uses OPUS_FP32_to_BF16_DEFAULT, which defaults to 2, truncation (csrc/include/opus/opus.hpp). The mega_mhc modules already pass =5; the two modules that build mhc_kernels.cu do not.

Truncation stays inside test_mhc.py's tolerance, but it is a bias, not noise: mhc_post shrinks the residual streams by 0.3-0.4 % per call. DeepSeek-V4.1 runs mhc_post twice per layer (80 calls per forward), the shrink compounds, and on MI300X the model's teacher-forced NLL sits 0.1-0.3 nat above the same checkpoint on MI355X. With this change the two match.

The same bias was fixed for RMSNorm in #6300 and for the custom all-reduce in #6640, with the same flag and env override.

Which MI300X DeepSeek-V4.1 path this reaches

The NLL numbers above were measured on the SGLang path, which is module_mhc on gfx942. The prebuilt gfx942 ASM seam is a different path and this PR does not change it:

  • SGLang main (gfx942, MI300X): module_mhc. deepseek_v4_mhc.post() falls through to aiter.ops.mhc.mhc_post on HIP (python/sglang/srt/models/deepseek_v4_mhc.py:698-729), and the fused attn/MoE boundary calls aiter.ops.mhc.mhc_fused_post_pre (deepseek_v4_fused_mhc.py:300-328). Both are module_mhc kernels. SGLang's mega_mhc path requires _is_gfx95_supported and is off by default, so gfx942 never takes it (deepseek_v4_mhc.py:789-800, environ.py:2173). The service logs of the two cx57-4 rows (cards 0-3 and 4-7) show module_mhc imported and no module_mhc_seam_asm/mega_mhc reference.
  • vLLM main (gfx942): not the seam. rocm_aiter_ops.is_mega_mhc_available() is CDNA4-only (vllm/_aiter_ops.py:2974-2983 on origin/main 78f20a5a3, vllm/platforms/rocm.py:374-383), so the gfx942 DSV4.1 path does not take mega_mhc (vllm/models/deepseek_v41/amd/model.py:334-339).
  • ATOM (gfx942): the seam, still truncating (follow-up [ASM] [gfx942] Rebuild mhc_seam residual_out with RNE (the ATOM DeepSeek-V4.1 path) #8738). atom/model_ops/deepseek_v41/mhc_pre_delayed.py:54-60,214-218 uses mega_mhc for a seam with a post whenever mhc_fused_post_pre_delayed_asm_supported(H=5120, hc=4) holds and ATOM_DSV41_MHC_BACKEND != "triton" (the default is auto; its unit test expects auto -> mega). That runs _mega_mhc_asm (aiter/ops/mega_mhc.py:561-569), whose residual_out still truncates. ATOM is therefore the one serving stack on MI300X where the residual-bias fix does not reach the model. Follow-up: rebuild the hsa/gfx942/mhc_seam code objects with RNE for residual_out and restore the bit-exact seam test; until then ATOM can run with ATOM_DSV41_MHC_BACKEND=triton. I will file/track that separately; it is not part of this PR.

Changes

  • aiter/jit/optCompilerConfig.json: module_mhc (mhc_kernels.cu, mhc_post_pre_gram.cu) and module_fused_ar_mhc get -DOPUS_FP32_to_BF16_DEFAULT={OPUS_FP32_to_BF16_DEFAULT, default 5}, exactly as the mega_mhc modules.
  • op_tests/test_mhc.py: mhc_post_ref_fp32 is split out of mhc_post_ref; test_mhc_post asserts that the signed rounding error relative to the FP32 result is at most 5e-4 and reports it as round_bias. Truncation gives about -2.8e-3; round to nearest gives 0 with a spread of 5e-5 at the smallest case (m=1, hidden=512).
  • op_tests/test_mhc_seam.py: the gfx942 ASM seam (hsa/gfx942/mhc_seam, prebuilt) keeps its truncating residual_out, which the test asserted bit-exact against mhc_post. It now checks that every element is the truncation of mhc_post's value (equal, or one BF16 ulp smaller in magnitude, same sign), and checks layer_input and the gates against the seam's own residual_out, which is what the kernels compute them from. Its docstrings and asm_mhc_seam.cu's header say so. Making the seam round too needs its kernels rebuilt, which this PR does not do.
  • Also changed by the flag (same bias, now RNE): mhc_pre's outputs, mhc_post_pre's next residual and BF16 GEMM operands in mhc_kernels.cu / mhc_post_pre_gram.cu, and the all-reduce stores built into module_fused_ar_mhc (consistent with module_custom_all_reduce since [JIT] Round custom all-reduce BF16 stores to nearest even #6640). Comments in mhc_kernels.cu that said these stores truncate are updated.
  • gfx950, gfx12 and gfx1250 convert in hardware with round to nearest even and ignore the mode, so only gfx942 and older change.

Performance (if applicable)

Measured on an idle MI300X (gfx942, BDF 0000:0c:00.0 / renderD128, row cx57-4:32300 taken out of service and restored), hidden 5120, hc 4. The PR-base mhc_kernels.cu (024bf6b8...) was compiled twice with -DOPUS_FP32_to_BF16_DEFAULT=2 (base) and =5 (head); the rest of the flags, compiler and source are identical. PR head differs from base only in comments in that file (git diff ab0223ec4..d9861a4a5 -- csrc/kernels/mhc_kernels.cu).

  • Warm = CUDA-graph replay of 20-40 back-to-back raw launches, median of 9 replays. This is kernel time; it excludes Python/dispatch overhead and launch gaps.
  • Cold = one raw launch after a 1 GiB L2 flush, median of 21.
  • A/A = the same module timed twice; the max observed A/A difference is 3.2 % for mhc_post and 7.8 % for mhc_post_reduce (one outlier; typical <2 %). Two independent runs (rebuild, and prebuilt .so re-run) agree within 2.1 percentage points except mhc_post_reduce at m=8192 (+11.1 % vs +15.7 %); both show the same direction.
  • Output rounding bias at m=512: base -2.81e-3, head -4.8e-6, confirming the flag actually took effect.
kernel m base us head us delta A/A max
mhc_post 1 2.07 2.13 +3.0 % 0.8 %
mhc_post 64 2.93 3.15 +7.3 % 0.2 %
mhc_post 512 12.05 13.57 +12.7 % 2.0 %
mhc_post 2048 50.38 53.69 +6.6 % 3.2 %
mhc_post 8192 208.05 211.05 +1.4 % 0.1 %
mhc_post_reduce 1 2.21 2.33 +5.4 % 0.2 %
mhc_post_reduce 64 2.89 3.15 +8.7 % 0.2 %
mhc_post_reduce 512 10.21 12.09 +18.5 % 2.0 %
mhc_post_reduce 2048 42.70 49.37 +15.6 % 7.8 %
mhc_post_reduce 8192 157.10 181.79 +15.7 % 2.8 %

Cold single-launch deltas at m = 1 / 64 / 512 / 2048 / 8192 (includes launch and L2-miss time, so the relative cost is compressed): mhc_post -1.3 / -1.5 / +7.2 / +1.2 / +0.5 %; mhc_post_reduce -1.1 / -2.1 / +7.3 / +10.0 / +8.0 %.

RNE is not free: the fast software RNE adds three integer ops per element, and the kernel is not fully bandwidth-bound at decode/mid-size m. At m=2048 this is +3.3 us per mhc_post; at 80 posts per forward that is an upper bound of +0.27 ms per forward, and end-to-end impact was not measured here. The previous head-only 50.3 us number was taken beside a loaded server and is replaced by this table.

Testing

  • Unit tests added or updated
  • Performance benchmarks run
  • Tested on MI250X
  • Tested on MI300X

All on MI300X (gfx942):

check before after
test_mhc.py (whole file, default sweep) new check fails: bias -2.81e-3 (m=1, hidden 4096) passes; bias 3.1e-6 / -7.5e-6 / -2.9e-6 at m = 1 / 64 / 2048, hidden 5120
test_mhc_seam.py (whole file) 0 failures 0 failures
multigpu_tests/test_fused_ar_mhc_post_only.py -t 2 passes passes (fused and split paths agree)
RNE instruction pair (v_bfe_u32 + v_add3_u32) per mhc_post_kernel instantiation, main's mhc_kernels.cu built for gfx942 with module_mhc's flags (28 instantiations) 48 (only the reduce epilogue's explicit RNE) 352
mhc_post on one DeepSeek-V4.1 layer's real residual (T = 2000): scale of output vs FP32 result 0.9961 1.0002 (= BF16 round-to-nearest of the FP32 result)
DeepSeek-V4.1-Flash, TP4/EP4, teacher-forced NLL: 2,000 / 1,205 / 14,207 tokens [MI355X, same checkpoint] 3.65-3.69 / 3.37-3.42 / 1.60 3.36-3.37 / 3.17-3.18 / 1.48-1.49 [3.36 / 3.18 / 1.49]

CI note: the default PR CI runs on gfx950 only (.github/workflows/aiter-test.yaml:22), where this change is a no-op, and op_tests/test_mhc_seam.py:826 skips off gfx942. Without labels this fix and its new check merge with no CI exercise. A maintainer should add ci:mi300x (and ci:multi-gpu for module_fused_ar_mhc) before merge. The multi-GPU test is author-verified at TP2 only; TP4/8 remain unverified.

Documentation

  • Docstrings updated
  • User guide updated
  • Performance guide updated
  • No documentation change is needed, with the reason stated below

A compile flag and a test check; no API or behavior change beyond the rounding mode.

Dependencies

  • No new third-party dependencies added
  • New dependencies are listed and justified below

Breaking Changes

None for a default build. OPUS_FP32_to_BF16_DEFAULT=2 requests the old truncation, but it only takes effect on a fresh module build: the JIT .so cache is keyed by module name only (aiter/jit/core.py:2015, :1319; build target :1488), so a warm cache reuses the RNE .so and the override silently does nothing. Before switching, remove module_mhc.so / module_fused_ar_mhc.so and their build/ directories, or set AITER_REBUILD=1 for the next import. Verified on gfx942: env=5 fresh build bias -4.8e-6; env=2 on the same cache bias -4.8e-6 with the same .so mtime; env=2 after clearing the cache bias -2.8e-3.

PR Self-Review

Reviewed revision

d9861a4

Behavior and intent

On gfx942 the mHC modules' BF16 outputs change from truncation to round-to-nearest-even; nothing changes on architectures with a hardware BF16 convert. Truncation is a systematic shrink of the residual streams that compounds across layers.

Validation and unverified scope

Validated as in Testing. All op tests ran on MI300X on aiter 8c964fa from a ROCm SGLang image (same opus default, module flags and mHC test files as main, with this PR's flag and test changes applied), because main's import aiter in that image needs a newer Triton (gl.amd.cdna5); main's own mhc_kernels.cu was checked at the ISA level. The perf table above is a separate build of the PR-base kernel source with the two flag values on an idle MI300X card. Remains unverified: a run of main's package on gfx942 (CI covers it), MI250X, module_fused_ar_mhc at TP 4/8, the gfx942 ASM seam with rounding (out of scope; ATOM affected), end-to-end serving impact of the RNE cost, and the other JIT modules that compile opus without the flag (not audited).

PR-specific question

Which architecture, dtype and shape boundaries select the changed path: only the BF16 conversions compiled into module_mhc and module_fused_ar_mhc on architectures without a hardware BF16 convert (gfx942 and older), because opus uses OPUS_FP32_to_BF16_DEFAULT only there; gfx950, gfx12 and gfx1250 take the hardware conversion and ignore the mode (csrc/include/opus/opus.hpp, fp32_to_bf16). FP16 outputs are unaffected. No shape boundary changes: every shape these modules run takes the same conversion. The invariant is the compile flag itself (the same one #6300 and #6640 use), with the env override OPUS_FP32_to_BF16_DEFAULT for a build that wants the old truncation; because the JIT cache is keyed by module name only, the override requires clearing the module .so/build dir (or AITER_REBUILD=1) first. The new test check is skipped for such a build; it cannot tell a fresh truncating build from a stale RNE one when the env asks for truncation. The prebuilt gfx942 ASM seam is not rebuilt and keeps truncating; its test now states that contract.

Changed op tests

op_tests/test_mhc.py: test_mhc_post now asserts the sign of the rounding error (BF16, non-truncating builds). The existing tolerance check cannot see truncation, so this is the only check that would catch the bug fixed here.
op_tests/test_mhc_seam.py: the seam's residual_out contract changes from "bit-exact with mhc_post" to "the truncation of mhc_post's value", because mhc_post now rounds and the prebuilt seam kernels do not; without this the gfx942 seam test would fail.

module_mhc and module_fused_ar_mhc build csrc/kernels/mhc_kernels.cu without
-DOPUS_FP32_to_BF16_DEFAULT, so every FP32 -> BF16 conversion in those kernels
(mhc_post's stores, mhc_pre's outputs, mhc_post_pre's next residual, BF16 GEMM
operands) takes opus.hpp's default, mode 2: truncate. gfx950, gfx1250 and gfx12
convert in hardware with round-to-nearest-even and ignore the flag, so only
gfx942 and older are affected. The mega_mhc modules already pass the flag (5,
software RNE); this gives the two modules that build mhc_kernels.cu the same one,
as ROCm#6300 did for RMSNorm and ROCm#6640 for the custom all-reduce.

Truncation stays inside test_mhc.py's tolerance, but it rounds every output
toward zero, so mhc_post shrinks the residual streams by 0.3-0.4% per call.
DeepSeek-V4.1 runs mhc_post twice per layer (80 calls per forward; SGLang calls
aiter's mhc_post on ROCm), and the shrink compounds: on MI300X its
teacher-forced NLL sat 0.1-0.3 nat above the same checkpoint on MI355X.

Tests:
- test_mhc.py: test_mhc_post also checks the signed rounding error against the
  FP32 result, which the tolerance check cannot see (truncation: -2.8e-3; round
  to nearest: 0 with a spread of 5e-5 at m=1, hidden=512). BF16 only, skipped
  for a build that asks for truncation (OPUS_FP32_to_BF16_DEFAULT 1 or 2), and
  guarded against all-zero inputs.
- test_mhc_seam.py: the gfx942 ASM seam (hsa/gfx942/mhc_seam) keeps its
  truncating residual_out, which was asserted bit-exact against mhc_post. It is
  now checked as the truncation of mhc_post's value (equal, or one BF16 ulp
  smaller in magnitude), and layer_input and the gates against the seam's own
  residual_out, which is what the kernels compute from. Comments and the op's
  docstring say so.

Measured on MI300X (gfx942), aiter 8c964fa from a ROCm SGLang image (same
opus default, module flags and mHC tests as main) with this change's flags and
tests:
- test_mhc.py: before, the new check fails (bias -2.81e-3 at m=1, hidden 4096);
  after, the whole file passes (bias 3.1e-6 / -7.5e-6 / -2.9e-6 at m = 1 / 64 /
  2048, hidden 5120).
- test_mhc_seam.py: 0 failures before and after.
- multigpu_tests/test_fused_ar_mhc_post_only.py -t 2: passes before and after
  (fused and split paths agree).
- Main's mhc_kernels.cu compiled for gfx942 with module_mhc's flags: the RNE
  pair (v_bfe_u32 + v_add3_u32) per mhc_post_kernel instantiation goes from 48
  to 352.
- DeepSeek-V4.1-Flash, TP4/EP4, teacher-forced NLL (MI355X on the same
  checkpoint in brackets): 2,000 tokens 3.65-3.69 -> 3.36-3.37 [3.36];
  1,205 tokens 3.37-3.42 -> 3.17-3.18 [3.18]; 14,207 tokens 1.60 -> 1.48-1.49
  [1.49].

Co-authored-by: Jin Pan <[email protected]>
Co-authored-by: Jinwei Yao <[email protected]>
@Arist12
Arist12 requested a review from a team November 25, 2026 06:25
@github-actions github-actions Bot changed the title [JIT] [Bugfix] Round mHC outputs to nearest even on gfx942 [HIP] [JIT] [Bugfix] Round mHC outputs to nearest even on gfx942 Nov 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter standard tests on MI35X
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:mi300x Run Aiter standard tests on MI300X in PRs; main branch always runs them
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the Radeon R9700 ROCm runner
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 8653 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

Reviews:
A reviewer is usually assigned within one working day after the PR is ready for review (see Code Review Process). If nobody has responded for about a week, mention the area contact listed in CONTACTS.md. Want to help review? See REVIEWERS.md.

@aiter-bot

aiter-bot commented Nov 25, 2026 •

Copy link
Copy Markdown

READY FOR HUMAN REVIEW

PR Self-Review

Revision d9861a4a5efc · mode shadow

Author self-review accepted. Readiness report:

Author answers

  • PASS — current-SHA answers are present and structurally specific
Show the author's self-review answers

Behavior and intent

On gfx942 the mHC modules' BF16 outputs change from truncation to round-to-nearest-even; nothing changes on architectures with a hardware BF16 convert. Truncation is a systematic shrink of the residual streams that compounds across layers.

Validation and unverified scope

Validated as in Testing. All op tests ran on MI300X on aiter 8c964fa61 from a ROCm SGLang image (same opus default, module flags and mHC test files as main, with this PR's flag and test changes applied), because main's `import aiter` in that image needs a newer Triton (`gl.amd.cdna5`); main's own `mhc_kernels.cu` was checked at the ISA level. The perf table above is a separate build of the PR-base kernel source with the two flag values on an idle MI300X card. Remains unverified: a run of main's package on gfx942 (CI covers it), MI250X, `module_fused_ar_mhc` at TP 4/8, the gfx942 ASM seam with rounding (out of scope; ATOM affected), end-to-end serving impact of the RNE cost, and the other JIT modules that compile opus without the flag (not audited).

PR-specific question

Which architecture, dtype and shape boundaries select the changed path: only the BF16 conversions compiled into `module_mhc` and `module_fused_ar_mhc` on architectures without a hardware BF16 convert (gfx942 and older), because opus uses `OPUS_FP32_to_BF16_DEFAULT` only there; gfx950, gfx12 and gfx1250 take the hardware conversion and ignore the mode (`csrc/include/opus/opus.hpp`, `fp32_to_bf16`). FP16 outputs are unaffected. No shape boundary changes: every shape these modules run takes the same conversion. The invariant is the compile flag itself (the same one #6300 and #6640 use), with the env override `OPUS_FP32_to_BF16_DEFAULT` for a build that wants the old truncation; because the JIT cache is keyed by module name only, the override requires clearing the module `.so`/build dir (or `AITER_REBUILD=1`) first. The new test check is skipped for such a build; it cannot tell a fresh truncating build from a stale RNE one when the env asks for truncation. The prebuilt gfx942 ASM seam is not rebuilt and keeps truncating; its test now states that contract.

Changed op tests

`op_tests/test_mhc.py`: `test_mhc_post` now asserts the sign of the rounding error (BF16, non-truncating builds). The existing tolerance check cannot see truncation, so this is the only check that would catch the bug fixed here.
`op_tests/test_mhc_seam.py`: the seam's `residual_out` contract changes from "bit-exact with `mhc_post`" to "the truncation of `mhc_post`'s value", because `mhc_post` now rounds and the prebuilt seam kernels do not; without this the gfx942 seam test would fail.

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply
  • ADVISORY — Copilot did not review the current head SHA

Code and op-test hygiene

  • PASS — no committed artifact or conflict marker detected

Required CI

  • PASS — Black: passed
  • PASS — Ruff: passed
  • PASS — Repository dependency: passed
  • PASS — Aiter Test Gate: passed

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

@junhaha666

Copy link
Copy Markdown
Contributor

@aiter-bot review

@aiter-bot

Copy link
Copy Markdown

aiter-bot — queued behind 3 review(s); expect to start in about 52 min. The box reviews one PR at a time.

@aiter-bot aiter-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ROCm/aiter PR #8653 — [HIP] [JIT] [Bugfix] Round mHC outputs to nearest even on gfx942

Review (advisory): ⚠️ NEEDS WORK
Validation (deterministic): NOT RUN — REVIEW_AUTO_VALIDATE=0 and no GPU access in this review session (/dev/kfd permission denied); triage found 2 candidate targets (op_tests/test_mhc.py, op_tests/test_mhc_seam.py) and picked none — environment gap, not a PR defect
Perf (advisory): NOT RUN — no GPU access in this session; the PR's own number is head-only (50.3 us, m=2048 hidden 5120, beside a loaded server) and cannot show a regression
Size: 101 lines / 6 files
Design (advisory): fix the rounding mode at the compile-flag level for the two CUDA mHC modules while leaving the prebuilt gfx942 ASM seam truncating, accepting a documented ≤1-ulp fused-vs-unfused residual_out divergence until the seam kernels are rebuilt
Human: recommend Andreas Karatzas review whether the mega_mhc gfx942 H=5120 bf16 route through the truncating ASM seam (aiter/ops/mega_mhc.py:562 → _mega_mhc_asm) keeps PR #8653's residual-bias fix off the DeepSeek-V4.1 serving path on MI300X, and when the seam kernels get the same rounding

⚠️ [verified] aiter/ops/mega_mhc.py:562 routes the gfx942, hidden 5120, bf16, has_post case — DeepSeek-V4.1's shape on MI300X — through _mega_mhc_asm and the prebuilt ASM seam, whose residual_out still truncates after this PR (op_tests/test_mhc_seam.py's rewritten contract states the divergence), so the residual-stream bias the motivation says compounds to 0.1–0.3 nat NLL persists on that fused path. Author must state which path a DSV4.1 deployment takes on MI300X (seam vs module_mhc) and confirm the measured NLL fix reaches it, or schedule the seam rebuild.

⚠️ [verified] .github/workflows/aiter-test.yaml:22 builds default PR CI with GPU_ARCH_LIST='gfx950' only, where this change is a no-op (hardware bf16 convert), op_tests/test_mhc_seam.py:826 skips off gfx942, and the new bias assert passes trivially — so without labels the fix and its new check merge with zero CI exercise, and module_fused_ar_mhc is author-verified at TP2 only (TP4/8 unverified). Reviewer should ask a maintainer to add the ci:mi300x and ci:multi-gpu labels the PR body requests before merge.

if get_gfx() != "gfx942":

⚠️ [verified] No base-vs-head timing of mhc_post exists — the PR's only number is head-only (50.3 us, m=2048 hidden 5120, beside a loaded server) and its own ISA count shows RNE instruction pairs rising 48 → 352 per mhc_post_kernel instantiation, so a latency cost on gfx942 is plausible but unmeasured. Author must run mhc_post base vs head on an idle gfx942 (op_tests/test_mhc.py already times it) and report the delta.

📝 [verified] The JIT .so cache is keyed by module filename only (aiter/jit/core.py:2015), so the OPUS_FP32_to_BF16_DEFAULT value aiter/jit/optCompilerConfig.json evaluates is in no cache key and the PR body's revert path ("=2 restores the old truncation") silently reuses the cached RNE .so on a warm cache — the same exposure #6300/#6640 shipped. Reviewer should ask the author to state the cache-clear requirement next to the env override.

@Arist12

Arist12 commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Updated the body with the requested data. No code change: the only code-level issue was the body's revert claim.

Perf (base vs head, MI300X gfx942, idle card 0c:00.0, H=5120, hc=4, PR-base kernel, kernel-only CUDA-graph timing, A/A <=3.2 %): mhc_post base -> head at m = 1 / 64 / 512 / 2048 / 8192: 2.07 -> 2.13 us (+3.0 %), 2.93 -> 3.15 (+7.3 %), 12.05 -> 13.57 (+12.7 %), 50.38 -> 53.69 (+6.6 %), 208.05 -> 211.05 (+1.4 %). mhc_post_reduce: +5.4 / +8.7 / +18.5 / +15.6 / +15.7 %. A second independent run reproduces these within 2.1 pp (except mhc_post_reduce m=8192, +11.1 % vs +15.7 %). Cold single-launch deltas are smaller (launch/L2 dominated). RNE is not free; end-to-end impact was not measured (80 posts/forward -> +0.27 ms/forward upper bound at m=2048).

Path: SGLang main on gfx942 calls aiter.ops.mhc.mhc_post and mhc_fused_post_pre -> module_mhc; its mega_mhc path requires gfx95 and is off by default, and the two cx57-4 service logs show module_mhc imports with zero mhc_seam/mega_mhc references. vLLM main gates is_mega_mhc_available() to CDNA4. ATOM gfx942 is the one that takes mega_mhc -> _mega_mhc_asm for seams with a post (ATOM_DSV41_MHC_BACKEND=auto), so the seam staying truncating affects ATOM, not SGLang/vLLM. Seam-rebuild follow-up: #8738; ATOM_DSV41_MHC_BACKEND=triton is the interim mitigation.

Cache: confirmed aiter/jit/core.py:2015/:1319/:1488 key the .so by module name only. Empirically, a flag=5 build then flag=2 on the same cache reuses the same .so (bias -4.8e-6, same mtime); clearing it and rebuilding flag=2 gives -2.8e-3. The body now states the cache-clear requirement (or AITER_REBUILD=1) next to the override.

@Arist12

Arist12 commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@junhaha666 @zufayu — the three author items from the aiter-bot review of
d9861a4a are handled in the comment above and in the description:

  1. Which DSV4.1 path on MI300X — SGLang on gfx942 goes through
    module_mhc; the truncating ASM seam is reached only by ATOM's
    mega_mhc path (ATOM_DSV41_MHC_BACKEND=auto). Seam rebuild tracked in
    [ASM] [gfx942] Rebuild mhc_seam residual_out with RNE (the ATOM DeepSeek-V4.1 path) #8738; ATOM_DSV41_MHC_BACKEND=triton is the interim mitigation.
  2. Perf — mhc_post base -> head on gfx942 is now in the description
    (+3.0 / +7.3 / +12.7 / +6.6 / +1.4 % at m = 1 / 64 / 512 / 2048 / 8192 with
    A/A <= 3.2 %), plus mhc_post_reduce.
  3. Cache-clear note — the description now states that the .so is keyed by
    module name only (aiter/jit/core.py:2015), so a flag change needs
    AITER_REBUILD=1 or a cleared cache.

Remaining reviewer side, per the same review: the default PR CI builds gfx950
only, where this change is a no-op, so it needs ci:mi300x (and ci:multi-gpu
for module_fused_ar_mhc, author-verified at TP2 only). Could a maintainer add
those two labels? CI on d9861a4a is otherwise green (35 checks passed, 25 skipped,
0 failed).

@junhaha666
junhaha666 merged commit acadfad into ROCm:main Dec 1, 2026
62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants