Skip to content

[CI] [Test] Check that an A16W16 AOT replay cache serves a RUN_ONLY runtime - #6712

Open
yuychang wants to merge 20 commits into
ROCm:mainfrom
yuychang:fix/flydsl-bf16-aot-cache-signature
Open

yuychang wants to merge 20 commits into
ROCm:mainfrom
yuychang:fix/flydsl-bf16-aot-cache-signature

Conversation

@yuychang

@yuychang yuychang commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Motivation

Changes

  • tests/test_flydsl_aot_replay.py: new test_a16w16_aot_cache_serves_a_run_only_process.
    • Step 1: python -m aiter.aot.flydsl.gemm --csv <one ks7 row> into an empty cache (M=2, N=256, K=7168, split-K 7).
    • Step 2: a FLYDSL_RUNTIME_RUN_ONLY=1 process runs aiter.tuned_gemm.gemm_a16w16 on that shape.
    • The child asserts gemm_a16w16 dispatched to FlyDSL, so a missed row cannot pass on a fallback kernel.
    • Inputs are seeded values in {-1, 0, 1}: nonzero reference, 256 distinct columns, exact in bf16, exact compare.
    • A child probes device 0, so the pytest process starts no HIP runtime.
      • It reads _device_arch_and_cu, which gemm_a16w16 uses on gfx950, and requires get_gfx_runtime() to agree.
    • The children do not inherit COMPILE_ONLY, CU_NUM, AITER_AOT_REPLAY, FLYDSL_GPU_ARCH or ARCH.
      • Nor AITER_AOT_IMPORT or AITER_TRITON_ONLY, which make import aiter.tuned_gemm fail in the run-only child.
      • The FlyDSL cache stays enabled.
    • The test skips unless device 0 is gfx950; only the AOT child sets GPU_ARCHS.
      • The probe imports aiter inside its try, so an unreadable arch skips the test.
    • All children share one 240 s budget and run in their own process groups.
  • .github/scripts/split_tests.sh: lists the test next to tests/test_flydsl_aot_cache.py and tests/test_flydsl_aot_launch.py, so CI shards run it.
  • Scope: one tuned row on the plain split-K policy; the ht, bs, skinny, TDM and bpreshuffle paths are not covered.

Performance (if applicable)

  • No kernel or runtime change; nothing measured in this PR.
    • The original bug's first-call cost came from another author's run whose script is not available here.
    • It is not quoted.

Testing

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

Documentation

  • Docstrings updated

  • User guide updated

  • Performance guide updated

  • No documentation change is needed, with the reason stated below

  • Test-only change.

Dependencies

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

Breaking Changes

None.

PR Self-Review

Reviewed revision

df9ed677f1dcf957175661ea5060176f59ff1914

Behavior and intent

  • Guards the AOT -> run-only contract for A16W16: an AOT-built cache must serve inference without a compile.
  • The runtime and the AOT driver are unchanged against main.
  • Revision notes:
    • df9ed677f merges main bf5994891a: keeps both tests/test_flydsl_aot_launch.py ([FlyDSL] [CI] Launch FlyDSL AOT cache entries through _run_compiled #8451) and tests/test_flydsl_aot_replay.py in split_tests.sh.
    • c315b6bba registers tests/test_flydsl_aot_replay.py in split_tests.sh, moves the probe's aiter imports inside try, and clears AITER_AOT_IMPORT and AITER_TRITON_ONLY.
    • 8c790d5ad probes device 0 with _device_arch_and_cu (matching gemm_a16w16 on gfx950) and clears inherited CU_NUM, COMPILE_ONLY, AITER_AOT_REPLAY, FLYDSL_GPU_ARCH, and ARCH.
    • a9ec0d9fa and 0601e5384 assert FlyDSL dispatch (solMap["flydsl"]) and use seeded {-1, 0, 1} inputs so all 256 columns are distinct and exact in bf16.

Validation and unverified scope

  • MI355X (gfx950), ROCm 10.0.0, pytest -q tests/test_flydsl_aot_replay.py:
    • At head df9ed677f with flydsl==0.5.3: 22 passed, 2 skipped in 32.8 s (the skips report "torch already has out_dtype meta support").
    • At c315b6bba: 22 passed, 2 skipped in 23.9 s; -k run_only_process passes with CU_NUM=80 AITER_AOT_IMPORT=1 AITER_TRITON_ONLY=1 exported.
    • bash .github/scripts/split_tests.sh --shards 8 --dry-run lists tests/test_flydsl_aot_replay.py.
  • Seeded failure:
    • Running the RUN_ONLY subprocess against an empty cache fails with no usable AOT cache for gemm_a16w16_gfx950.
  • Unverified: MI300X / MI250X in CI (the test skips off gfx950); FlyDSL policies other than the plain split-K row.

PR-specific question

  • CI permissions and untrusted-input boundary: .github/scripts/split_tests.sh only appends the static repo-relative string "tests/test_flydsl_aot_replay.py" to the ALL_FILES shard list; it reads no PR title, body, branch name, or external input and changes no workflow trigger (pull_request, not pull_request_target) or token permissions.
  • Runtime boundary: drift between the AOT replay and the runtime launch of gemm_a16w16 changes the FlyDSL cache key and causes a FLYDSL_RUNTIME_RUN_ONLY=1 miss, which test_a16w16_aot_cache_serves_a_run_only_process catches across two fresh processes.

Changed op tests

None. No op_tests/ file changes (tests/test_flydsl_aot_replay.py is under tests/).

@yuychang
yuychang requested review from a team and a balanced review from Copilot October 20, 2026 09:14
@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 6712 --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 changed the title [Bugfix] Match FlyDSL A16W16 AOT semaphore dtype to runtime [FlyDSL] [Bugfix] Match FlyDSL A16W16 AOT semaphore dtype to runtime Oct 20, 2026

Copilot AI 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.

🟢 Approval recommended

The narrow dtype correction matches the runtime contract and has focused regression coverage, with no unresolved findings.

No open issues 🎉

What changed in this PR

Aligns the gfx950 FlyDSL A16W16 AOT semaphore dtype with runtime so inference can reuse compiled cache entries.

Changes:

  • Uses int64 for the AOT semaphore while retaining int32 signals.
  • Adds CPU regression coverage for BF16/FP16 with split-K values 1 and 7.
  • Preserves direct test invocation while adjusting import-path setup.
File Description
tests/​test_aot_drivers.py Adds buffer-dtype regression checks and adjusts path bootstrap.
aiter/​aot/​flydsl/​gemm.py Matches the AOT semaphore dtype to runtime.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 21, 2026 09:27

Copilot AI 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.

🟢 Approval recommended

The narrow dtype correction addresses cache compatibility, with focused regression coverage and no unresolved findings.

No open issues 🎉

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 21, 2026 09:30

Copilot AI 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.

🟢 Approval recommended

The narrow dtype correction matches the runtime contract, with focused regression coverage and no unresolved findings.

No open issues 🎉

Review effort: Balanced

@xytpai

xytpai commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Review comment

LGTM. SplitKProtocol.take_ticket() explicitly uses an fx.Int64 pointer and performs atomic_add with fx.Int64(1), while the signal buffer is accessed as fx.Int32. Changing the AOT semaphore to torch.int64 therefore matches both the runtime allocation and the kernel’s actual access width—not just the cache signature.

Non-blocking suggestion: the new test mocks run_cached, so it verifies dtype consistency rather than compilation or disk-cache reuse. Consider adding the documented separate-process AOT → FLYDSL_RUNTIME_RUN_ONLY=1 check as a GPU regression test, covering at least one split_k > 1 case.

Review result: APPROVE

Yes, this PR can be approved based on the source review of commit d9b8763e2ceb.

  • Correctness: The semaphore uses 64-bit atomic operations; only the signal uses 32-bit accesses.
  • Blocking findings: None identified.
  • Follow-up: Automated GPU cache-reuse coverage would be useful but is not required for approval.

Validation scope: I reviewed the source but did not independently reproduce the author’s GPU results. This review has not been submitted to GitHub.

Copilot AI balanced review requested due to automatic review settings October 26, 2026 06:13
@xytpai xytpai added the ci:atom label Oct 26, 2026
xytpai
xytpai previously approved these changes Oct 26, 2026

Copilot AI 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.

🟢 Approval recommended

The narrowly scoped dtype correction has targeted regression coverage and leaves runtime kernel execution unchanged.

No open issues 🎉

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 27, 2026 13:01

Copilot AI 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.

🟡 Changes recommended

The new tests prevent collection without FlyDSL and leave the CPU regression dependent on the host GPU architecture.

1 open issue
1 previously missed issue

In code that hasn't changed since last review

Medium severity Mock ROCm architecture to make regression host-independent

tests/​test_aot_drivers.py:49

The CPU regression still depends on the host architecture: _compile_hgemm_to_cache() validates parameters using gemm_kernel.get_rocm_arch(), not target_gfx. If that query returns gfx1250, the shared-memory capacity lookup fails and all four subcases raise ValueError before reaching the dtype assertions. Mock the query to return gfx950 alongside run_cached so this regression is independent of the host architecture.

Review effort: Balanced

Comment thread tests/test_aot_drivers.py Resolved
Copilot AI balanced review requested due to automatic review settings October 27, 2026 13:35

Copilot AI 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.

🟢 Approval recommended

No active review issues were identified for the added AOT replay cache regression test.

No open issues 🎉

Review effort: Balanced

- The comment said CI runs tests/ in a 10-minute step; aiter_test.sh runs each tests/ file under `timeout 60m`.
- State the real limit and why the 240 s budget still matters: a hung child fails with its output, not the file.
Copilot AI balanced review requested due to automatic review settings November 20, 2026 11:19

Copilot AI 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.

🟢 Approval recommended

No active review issues are reported for the test-only addition of gfx950 AOT cache-replay coverage.

No open issues 🎉

Review effort: Balanced

- The comment cited a 60m per-file limit from aiter_test.sh; CI sets AITER_TEST, so that arm never ran tests/ files
- The tests/ step it replaced (10 minutes, pytest -q tests) was removed from aiter-test.yaml by ROCm#8352
- State only what the budget does: a hung child fails this test with its output
…ettings and probe via chip_info

- Children no longer inherit COMPILE_ONLY, and FLYDSL_RUNTIME_ENABLE_CACHE is forced to 1
- The device probe reads the arch and CU count through get_gfx_runtime() and get_cu_num(), the pair tuned_gemm uses
- The probe prints nothing on a non-ROCm torch or when the helpers raise, so the test skips instead of failing
Copilot AI balanced review requested due to automatic review settings November 20, 2026 22:10

Copilot AI 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.

🟡 Changes recommended

The test fixture uses inherited CU_NUM rather than the runtime’s device-scoped CU count, which can produce an unselectable tuning row and a dispatch assertion failure unrelated to cache reuse.

1 open issue

Review effort: Balanced

Comment thread tests/test_flydsl_aot_replay.py Outdated
Comment on lines +248 to +250
from aiter.jit.utils.chip_info import get_cu_num, get_gfx_runtime
try:
print("device", get_gfx_runtime(), get_cu_num())

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed: the test now probes device 0 through the same device-scoped helper the runtime uses, _device_arch_and_cu(torch.device("cuda", 0)) (tests/test_flydsl_aot_replay.py:251), and clears the inherited CU_NUM for its child processes (:328). No further change.

…ks its row up

- Read device 0's arch and CU count through _device_arch_and_cu, which gemm_a16w16 uses on gfx950
- Skip unless get_gfx_runtime() agrees, as flydsl_hgemm requires, and catch AssertionError from mixed-CU hosts
- Clear CU_NUM, AITER_AOT_REPLAY, FLYDSL_GPU_ARCH and ARCH from the children's environment
- With CU_NUM=80 exported the old probe fails the test on a 256-CU gfx950; the new one passes
- Name the GPU test in the module docstring instead of calling it the last one
Copilot AI balanced review requested due to automatic review settings November 22, 2026 01:07

Copilot AI 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.

🟢 Approval recommended

No active review issues are reported for this test-only gfx950 AOT cache-reuse regression change.

1 open issue

Review effort: Balanced

…onment from failing it

- Register tests/test_flydsl_aot_replay.py in split_tests.sh next to test_flydsl_aot_cache.py, as HK12 asks
- Import aiter inside the probe's try block so an unreadable arch skips the test instead of failing it
- Clear AITER_AOT_IMPORT and AITER_TRITON_ONLY from the children; with AITER_AOT_IMPORT exported the old test failed
Copilot AI balanced review requested due to automatic review settings November 22, 2026 01:20
@github-actions github-actions Bot changed the title [Test] Check that an A16W16 AOT replay cache serves a RUN_ONLY runtime [CI] [Test] Check that an A16W16 AOT replay cache serves a RUN_ONLY runtime Nov 22, 2026
@github-actions github-actions Bot added the CI label Nov 22, 2026

Copilot AI 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.

🟢 Approval recommended

The supplied review evidence identifies no active issues with the AOT replay regression coverage and CI-sharding changes.

1 open issue

Review effort: Balanced

"$TEST_DIR/tuning_tests/test_tuner_infra.py" \
"tests/test_flydsl_aot_cache.py"
"tests/test_flydsl_aot_cache.py" \
"tests/test_flydsl_aot_replay.py"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not move these FlyDSL related tests directly to $TEST_DIR/flydsl_tests/ ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

They live under tests/ (alongside tests/test_flydsl_aot_cache.py from #8356 and tests/test_flydsl_aot_launch.py from #8451) for three reasons:

  1. Runner dispatch in .github/scripts/aiter_test.sh:109: tests/test_*.py is matched by glob and run via python3 -m pytest -q "$file". Files under op_tests/flydsl_tests/ default to python3 "$file" unless each path is also hardcoded in aiter_test.sh (test_flydsl_aot_replay.py has no __main__ and would exit 0 running 0 tests; test_flydsl_aot_cache.py / test_flydsl_aot_launch.py require --child in __main__ and would fail).
  2. Test contract (.github/instructions/aiter-ops-flydsl.instructions.md:14 / aiter-op-test): op_tests/flydsl_tests/** is scoped to @benchmark() + run_perftest + checkAllclose operator sweeps, whereas tests/test_flydsl_aot_{cache,launch,replay}.py are pytest unit/subprocess regression suites (mostly CPU dry_run checks).
  3. PR scope (HK2 / HK12): tests/test_flydsl_aot_replay.py already exists on main ([FlyDSL] [JIT] Build the GEMM, conv, chunk_gdn_h and FP8 FMHA AOT caches by replaying the runtime #6956/[FlyDSL] [AOT] Scan gfx1250 GEMM rows at representative M, not every M #7652/[FlyDSL] [AOT] Fix the Nightly's FlyDSL AOT replay on torch 2.9.1 (#7805 + #7561) #7892/[FlyDSL] AOT replay: pass out= so blockscale bpreshuffle jobs reach FlyDSL #8433) and docs/flydsl_aot_cache.md:102 references tests/test_flydsl_aot_cache.py; moving them here would pull unrelated files and op_tests/ into this PR.

If you'd like all three tests/test_flydsl_aot_{cache,launch,replay}.py consolidated into op_tests/flydsl_tests/ (with a matching op_tests/flydsl_tests/test_*.py pytest pattern in .github/scripts/aiter_test.sh and doc updates), I'm happy to send a dedicated follow-up PR—or do it here if you prefer.

- Keep both tests/test_flydsl_aot_launch.py (ROCm#8451) and tests/test_flydsl_aot_replay.py in split_tests.sh
Copilot AI balanced review requested due to automatic review settings November 23, 2026 08:20

Copilot AI 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.

🟢 Approval recommended

No active review issues were identified for the AOT replay regression coverage and its CI integration.

1 open issue

Review effort: Balanced

@zufayu

zufayu commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

@zhiding512 for AOT solution check

This branch has not been deployed

No deployments
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.

8 participants