Skip to content

[OPUS] [JIT] Fall back to regular COs when A0 strict is unsupported by the HIP runtime - #7185

Merged
zufayu merged 3 commits into
mainfrom
demonsan/opus-a0-strict-fallback
Nov 3, 2026
Merged

zufayu merged 3 commits into
mainfrom
demonsan/opus-a0-strict-fallback

Conversation

@demonsan

@demonsan demonsan commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Problem

On gfx1250 A0 nodes, HIP runtimes older than ROCm 10.1.0 reject the
gfx1250-strict (0xeb) code objects. The loader correctly selected
gen_co/gfx1250-a0/, but registration failed, breaking OPUS BF16 GEMM and
downstream models. Reproduced on g21-10 (4x gfx1250, ASIC Revision 0, 256 CU)
with the same runtime as the failing ATOM CI job (HIP 7.16.26315):

HIP runtime regular 0x49 A0 strict 0xeb
7.16.26315 registers/launches invalid device function (fatbin), hipErrorNoBinaryForGpu (module API)
7.16.26385 registers/launches registers/launches

HSA_DISABLE_GFX12_STRICT=0/1/unset makes no difference. The failing CI job used
aiter b5078fc49, which already contained gfx1250-a0/ and ASIC-based routing,
so this is a runtime floor, not a missing image or kid mismatch.

Change

On ASIC Revision 0 the loader now:

  1. selects the strict image as before;
  2. preflights it with hipModuleLoadData (no dependence on AITER_CHECK throw mode);
  3. if the runtime rejects an existing strict image, falls back once per
    process to the same symbol's regular gfx1250 image, with one warning;
  4. otherwise keeps strict (on HIP >= 7.16.26385 nothing changes).

Missing files and wrong ELF profiles are still hard errors and never silently
select another profile. A0 CI should still be upgraded to ROCm 10.1.0 release
for the A0-tuned kernels; the fallback only restores compatibility.

Validation

Regular 0x49 correctness on A0 was established before enabling the fallback:

  • g21-10 A0 + HIP 7.16.26315, direct module API: compute / wl / wlr kernels,
    tiny and ragged M/N/K, batch 2, padded source rows - all matched the CPU
    golden, max_err=0.
  • End-to-end with this loader on A0 + HIP 7.16.26315:
    [opus] A0 gfx1250-strict CO not loadable ... falling back to regular
    then FALLBACK_E2E_PASS max_err=0.
  • Same end-to-end test on HIP 7.16.26385: no warning, max_err=0
    (strict remains preferred).
  • op_tests/cpp/test_opus_co_profile.cpp (C++17) and
    op_tests/cpp/test_opus_co_cache.cpp (mock HIP, old/new runtime scenarios)
    pass; test_opus_co_profile.py (6 tests) and test_opus_co_builder.py
    (13 tests) pass; Ruff/Black clean.

The native A0 test binary needed -std=c++20 under the old image's clang 23
because its libstdc++ rejects the defaulted std::pair copy constructor for the
non-copyable module type in C++17; runtime code is unchanged by that.

Files

  • csrc/opus_gemm/include/gfx1250/opus_co_launch_gfx1250.cuh: preflight + fallback
  • csrc/opus_gemm/include/gfx1250/opus_co_profile_gfx1250.h: regular-fallback path selection
  • op_tests/cpp/test_opus_co_{cache,profile}.cpp: regression coverage
  • csrc/opus_gemm/gen_co/{README,HYBRID_VALIDATION}.md: runtime matrix and fallback policy

Follow-up: gfx1250-strict at the OPUS BF16 GEMM CO call

ROCr reports gfx1250-strict on A0 by default while rocm_agent_enumerator
still reports gfx1250 (#14668 blocked). Arch detection is left untouched:
every layer keeps the real runtime id. Only the OPUS BF16 GEMM CO call ignores
the distinction:

  • the CO loader (select_image, select_regular_fallback) accepts both
    ids, still picks the profile from the ASIC Revision, and still falls back to
    the regular image on old runtimes;
  • A16W16 launch planning resolves CO kids only through the base gfx1250
    family when the real id is gfx1250-strict; non-CO OPUS kids and every
    other kernel keep the real id.

Shared aiter/jit/**, registry keys, GPU_ARCHS build targets, tuned-CSV
lookup and codegen are unchanged; keep GPU_ARCHS=gfx1250 for JIT builds
during the transition. New op_tests/test_gfx1250_strict_alias.py asserts the
real arch value is preserved and only CO kid planning aliases it; C++ CO
profile cases cover both ids plus the strict-id regular fallback (pytest: 24
passed; CO_PROFILE_CPP17_TESTS_PASS).

A0 profile directory name

The A0 images are built with --offload-arch=gfx1250-strict, so the profile is
now named gen_co/gfx1250-strict/ instead of the misleading
gfx1250-a0/. This renames the tracked profile directory (221 COs +
build_info.json), the build_co.py default output, CO loader selection,
docs and tests. The loader still reads a legacy gfx1250-a0/ directory when
gfx1250-strict/ is absent, so existing checkouts keep working.

Validation: pytest CO builder/profile suites pass; C++
test_opus_co_profile and test_opus_co_cache pass (including the legacy
directory case); A0 hardware CO launch re-run on g21-10 with the renamed
directory passes on both HIP 7.16.26315 (regular fallback) and 7.16.26385
(strict images).

HIP runtimes before 7.16.26385 reject gfx1250-strict code objects, which broke A0 nodes on older ROCm (e.g. ATOM CI 7.16.26315: invalid device function). On ASIC Revision 0, preflight the strict image with hipModuleLoadData and fall back to the same symbol regular gfx1250 image when the runtime rejects it, warning once per process. Missing files and wrong ELF profiles remain hard errors, and strict stays preferred on HIP >= 7.16.26385. Validate compute/wl/wlr regular COs on A0 hardware against a CPU golden and add profile/cache regression tests.
@demonsan
demonsan requested a review from a team October 30, 2026 01:31
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

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

Extended tests (opt-in via labels):

Label Tests
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 gfx1201 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 7185 --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.

@github-actions github-actions Bot added the OPUS label Oct 30, 2026
@aiter-bot

aiter-bot commented Oct 30, 2026 •

Copy link
Copy Markdown

NOT READY FOR HUMAN REVIEW

PR Self-Review

Revision 6b5ef5dbd5db · mode shadow

Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision.

Questions to answer in the PR description

  1. What behavior does this PR change, and why is the existing behavior insufficient?
  2. What did you validate, and what remains unverified? Include commands, hardware/configuration and results.
  3. Which architecture, dtype and shape boundaries select the changed kernel path, and what invariant prevents unsupported inputs from reaching it?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

Edit the PR Self-Review section in the PR description. Include the current revision SHA; this comment refreshes automatically.

Missing or invalid answers

  • FAIL — missing ### Reviewed revision in the PR description
  • FAIL — missing ### Behavior and intent in the PR description
  • FAIL — missing ### Validation and unverified scope in the PR description
  • FAIL — missing ### PR-specific question in the PR description
  • FAIL — missing ### Changed op tests in the PR description
  • FAIL — Reviewed revision must contain at least the first 7 characters of the current head SHA
  • FAIL — Behavior and intent has no substantive answer
  • FAIL — Validation and unverified scope has no substantive answer
  • FAIL — PR-specific question has no substantive answer
  • FAIL — changed op test not explained in Changed op tests: op_tests/cpp/test_opus_co_auto_runtime.cpp
  • FAIL — changed op test not explained in Changed op tests: op_tests/cpp/test_opus_co_cache.cpp
  • FAIL — changed op test not explained in Changed op tests: op_tests/cpp/test_opus_co_profile.cpp
  • FAIL — changed op test not explained in Changed op tests: op_tests/test_gfx1250_strict_alias.py
  • FAIL — changed op test not explained in Changed op tests: op_tests/test_opus_co_builder.py
  • FAIL — changed op test not explained in Changed op tests: op_tests/test_opus_co_integration.py
  • FAIL — changed op test not explained in Changed op tests: op_tests/test_opus_co_profile.py
  • FAIL — Changed op tests must explain why each changed op test is necessary and non-redundant

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

@demonsan
demonsan requested a review from zufayu October 30, 2026 02:19
@zufayu

zufayu commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

The fallback approach and the A0 validation look good to me. One non-blocking concern: hip_module_accepts() currently treats every hipModuleLoadData failure as an unsupported strict CO. This could mask errors such as hipErrorInvalidImage, OOM, or context/runtime failures and report them as an old-runtime compatibility issue.

Could we restrict fallback to the observed compatibility error (hipErrorNoBinaryForGpu, plus any other status confirmed on the affected runtime) and propagate other errors normally? This would preserve the intended fallback without hiding unrelated failures.

zufayu
zufayu previously approved these changes Oct 30, 2026
@zufayu

zufayu commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Thanks for adding the old-runtime compatibility path and for validating the regular COs on A0. I think this needs two adjustments before landing alongside the gfx1250-strict rollout:

  1. Accept the exact runtime identity. Once ROCr lands the switch, A0 will report gcnArchName == "gfx1250-strict". select_image() currently accepts only "gfx1250", so the loader will fail before reaching the strict-CO path. Please preserve the exact arch and handle these cases explicitly:

    • gfx1250, revision 0: legacy ROCr reporting for A0
    • gfx1250-strict, revision 0: final A0 identity
    • gfx1250, revision > 0: B0
    • inconsistent combinations such as gfx1250-strict, revision > 0: hard error
  2. Limit regular-CO fallback to the legacy identity. Falling back to the validated gfx1250 CO is reasonable for an old runtime that still reports A0 as gfx1250 and rejects mach 0xeb. However, if ROCr already reports gfx1250-strict, failure to load the strict image should remain a hard error. Falling back there would hide a runtime/package/compiler regression and recreate an A0/B0 translation layer inside AITER.

I would therefore gate fallback approximately as:

const bool legacy_a0 = arch == "gfx1250" && asic_revision == 0;
const bool strict_a0 = arch == "gfx1250-strict" && asic_revision == 0;

Only legacy_a0 may try the regular image. strict_a0 must use the strict image.

Also, hip_module_accepts() currently treats every non-success status as evidence that strict is unsupported. Please allow fallback only for the capability error observed in validation (hipErrorNoBinaryForGpu from hipModuleLoadData); OOM, corrupt-image, and other HIP errors should be reported rather than silently switching profiles.

Tests should cover both runtime identities, inconsistent arch/revision pairs, exact-strict load failure without fallback, and a non-capability HIP error. This also needs to be coordinated with #6767 so both PRs use the same canonical strict artifact-directory convention (gfx1250-strict versus the transitional gfx1250-a0).

@zufayu

zufayu commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

@demonsan any update

ROCr reports the strict ISA id on A0 by default while rocm_agent_enumerator still reports gfx1250 during the transition. Keep arch detection untouched (real id everywhere): only the OPUS BF16 GEMM CO call ignores the distinction. The CO loader accepts both ids for image selection and old-runtime regular fallback, and A16W16 launch planning resolves CO kids through the base gfx1250 family while non-CO kids keep the real id. Shared JIT probes, registry keys, GPU_ARCHS build targets and codegen are untouched.
@demonsan
demonsan force-pushed the demonsan/opus-a0-strict-fallback branch from 44bfd2c to 2f723b3 Compare November 2, 2026 08:15
@github-actions github-actions Bot changed the title [OPUS] Fall back to regular COs when A0 strict is unsupported by the HIP runtime [OPUS] [JIT] Fall back to regular COs when A0 strict is unsupported by the HIP runtime Nov 2, 2026
@github-actions github-actions Bot added the JIT label Nov 2, 2026
The A0 images are compiled with --offload-arch=gfx1250-strict, so the profile directory, build_co default output and build metadata should use that name instead of the misleading gfx1250-a0. Rename gen_co/gfx1250-a0/ to gen_co/gfx1250-strict/, set target_profile=strict, update the CO loader, docs and tests. The loader still reads a legacy gfx1250-a0/ directory when gfx1250-strict/ is absent.
@demonsan
demonsan force-pushed the demonsan/opus-a0-strict-fallback branch from 46c6f32 to 6b5ef5d Compare November 2, 2026 08:39
@zufayu

zufayu commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Given the immediate need to unblock OPUS/ATOM testing on A0 with the older ROCm runtime, I am OK with landing this as a transitional compatibility fix once the required CI is green. The regular 0x49 CO path has been validated on old-runtime A0, and this restores functionality without waiting for the complete stack rollout.

Before merge, I strongly recommend one small safety constraint: only fall back when hipModuleLoadData returns the compatibility error observed in validation (hipErrorNoBinaryForGpu). Other failures such as OOM, invalid/corrupt image, or context/runtime errors should remain hard errors rather than being reported as an unsupported strict target.

Please track a follow-up PR to make the final routing follow the exact ISA identity reported by ROCr:

  • gfx1250-strict -> strict 0xeb CO
  • gfx1250 -> regular 0x49 CO

That follow-up should remove the preflight/fallback layer once the reported-ID path is in place. The broader directory/packaging cleanup should not block this immediate old-ROCm A0 test recovery.

@zufayu zufayu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved as a transitional compatibility fix to unblock old-ROCm A0 OPUS/ATOM testing. Please track the reported-ISA routing cleanup and removal of the preflight/fallback layer in a follow-up PR.

@zufayu
zufayu merged commit ad7e3e6 into main Nov 3, 2026
@zufayu
zufayu deleted the demonsan/opus-a0-strict-fallback branch November 3, 2026 05:01
zufayu added a commit that referenced this pull request Nov 6, 2026
…failure (#7505)

#7185 added hip_module_accepts() as a capability probe: on an A0 node it
tries hipModuleLoadData() on the gfx1250-strict (0xeb) code object and,
when the HIP runtime is older than ROCm 10.1 and rejects it, falls back to
the regular gfx1250 CO. The fallback works, but the failed probe leaves
HIP's sticky last-error set to hipErrorNoBinaryForGpu and never clears it.
A successful HIP call does not reset that record, so the stale error is
inherited by the next unrelated HIP call (e.g. torch.empty during serving
init) and aborts the process there, far from its real cause.

Clear the recorded error with hipGetLastError() in the probe's failure
branch so a failed capability probe leaves no error state behind.

Validated on a real MI450 A0 node (torch HIP 7.16.26315, old runtime):
without this line the DeepSeek-V4-Flash server dies at startup with
hipErrorNoBinaryForGpu surfacing in torch.empty (matches the extended-test
CI crash); with it the server starts, the expected "falling back to regular
gfx1250 CO" warning prints once, and no HIP load error occurs.

Note: this fixes only the startup crash. A separate, independent in-serving
GPU memory access fault on A0 (unrelated to this sticky error) is tracked
elsewhere and is out of scope for this PR.

Co-authored-by: zufayu <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
shantipriya-amd pushed a commit to shantipriya-amd/aiter that referenced this pull request Nov 18, 2026
…y the HIP runtime (ROCm#7185)

* [OPUS] Fall back to regular COs when A0 strict is unsupported

HIP runtimes before 7.16.26385 reject gfx1250-strict code objects, which broke A0 nodes on older ROCm (e.g. ATOM CI 7.16.26315: invalid device function). On ASIC Revision 0, preflight the strict image with hipModuleLoadData and fall back to the same symbol regular gfx1250 image when the runtime rejects it, warning once per process. Missing files and wrong ELF profiles remain hard errors, and strict stays preferred on HIP >= 7.16.26385. Validate compute/wl/wlr regular COs on A0 hardware against a CPU golden and add profile/cache regression tests.

* [OPUS] Treat gfx1250-strict as gfx1250 at the CO call

ROCr reports the strict ISA id on A0 by default while rocm_agent_enumerator still reports gfx1250 during the transition. Keep arch detection untouched (real id everywhere): only the OPUS BF16 GEMM CO call ignores the distinction. The CO loader accepts both ids for image selection and old-runtime regular fallback, and A16W16 launch planning resolves CO kids through the base gfx1250 family while non-CO kids keep the real id. Shared JIT probes, registry keys, GPU_ARCHS build targets and codegen are untouched.

* [OPUS] Name the A0 strict CO profile gfx1250-strict

The A0 images are compiled with --offload-arch=gfx1250-strict, so the profile directory, build_co default output and build metadata should use that name instead of the misleading gfx1250-a0. Rename gen_co/gfx1250-a0/ to gen_co/gfx1250-strict/, set target_profile=strict, update the CO loader, docs and tests. The loader still reads a legacy gfx1250-a0/ directory when gfx1250-strict/ is absent.
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.

4 participants