Skip to content

[HIP] [JIT] [Build] Export ctypes entry points on Windows and add a JIT op smoke test - #6273

Merged
gyohuangxin merged 6 commits into
ROCm:mainfrom
0xDELUXA:windows-jit-op-tests
Oct 10, 2026
Merged

gyohuangxin merged 6 commits into
ROCm:mainfrom
0xDELUXA:windows-jit-op-tests

Conversation

@0xDELUXA

@0xDELUXA 0xDELUXA commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Follow-up to #2699, from the Windows CI discussion there. Ops built with ffi_type="ctypes" could not load on Windows, no committed test covered the Windows JIT path, and a rocm[devel] pip install whose toolchain was not unpacked yet produced a misleading fallback warning. Running the wider op test set on Windows turned up two more Windows bugs, fixed here as well.

Technical Details

The ctypes entry points are marked __attribute__((visibility("default"))), which does not export anything from a PE DLL, so the module built and then failed with function 'rms_norm_opus' not found. AITER_C_ITFS, the two OPUS_EXPORT macros and getPaddedM now use __declspec(dllexport) on Windows. Linux is unchanged.

op_tests/windows/test_jit_ops_smoke.py checks rms_norm, rmsnorm2d_fwd, silu_and_mul, topk_softmax and rotary_embedding_fwd against a torch reference, each in its own subprocess with a timeout, so a failed build, hang or GPU fault is reported against that op.

Merged tuned config paths were joined with : but split with os.pathsep, so on Windows any op with tuned files under configs/model_configs/ tried to open one long path. hipbsolgemm included <sys/file.h> and linked with -lhipblaslt, but the ROCm SDK on Windows ships only libhipblaslt.dll.a; it now uses a LockFileEx-based flock there, and -l<name> falls back to lib<name>.dll.a when no <name>.lib exists.

rocm[devel] from pip ships its toolchain as an archive that stays packed until rocm-sdk init runs; the warning now points there instead of at HIP_PATH. requirements.txt gets the same sys_platform != 'win32' marker on flydsl that pyproject.toml already has.

Test Plan

Windows 11, RX 9060 XT (gfx1200), Python 3.12/3.13, torch 2.14.0+rocm10.1.0 and 2.16.0a0+rocm10.2.0 with the matching rocm[devel], no HIP_PATH. The smoke test from a clean JIT cache, plus test_hipblaslt_lifecycle.py, test_batched_gemm_a8w8.py and concurrent hipBLASLt online tuning writing one CSV.

Test Result

All five smoke ops pass. test_hipblaslt_lifecycle passes; three concurrent tuning processes wrote 9 well-formed rows under one header. test_batched_gemm_a8w8 now reaches the kernel, which is XDL-only and unsupported on RDNA.

Submission Checklist

@0xDELUXA
0xDELUXA requested a review from a team October 8, 2026 14:07
@github-actions github-actions Bot changed the title [HIP] [JIT] Export ctypes entry points on Windows and add a JIT op smoke test [HIP] Export ctypes entry points on Windows and add a JIT op smoke test Oct 8, 2026
@github-actions github-actions Bot added the HIP label Oct 8, 2026
@github-actions

github-actions Bot commented Oct 8, 2026

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: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: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
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 6273 --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.

@0xDELUXA 0xDELUXA mentioned this pull request Oct 8, 2026
1 task done
@zufayu
zufayu requested review from yzhou103 and zufayu October 9, 2026 01:55
@zufayu
zufayu requested review from gyohuangxin and removed request for yzhou103 October 9, 2026 02:48
@zufayu

zufayu commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Thanks for turning this around so quickly, and for answering both asks in one PR. The ROCm 10.1 + Python 3.13 result is exactly what we needed — that combination was the single biggest unknown in our CI plan, and it's now settled.

Reviewed the whole diff. The export fix is right and the test reads well. A few notes, none blocking.

The export bug is real and your diagnosis is the correct one. PE exports nothing without __declspec(dllexport), so every ffi_type="ctypes" op was unreachable on Windows regardless of whether it built. Worth noting for anyone reading later: the aiter_hip_common.h hunk alone covers 14 AITER_C_ITFS symbols across 8 files, so this is three macro sites and one bare site, not a per-op fix.

Six bare __attribute__((visibility("default"))) uses remain, in csrc/include/mha_fwd.h (×3), csrc/include/mha_bwd.h (×1) and csrc/ck_tile_gemm_moe_2stages/include/moe_cktile2stages.h (×2). All flash-attention and CK-tile MoE, so out of scope here and correctly left alone. We'll want them before either of those lands on Windows, and at that point it's probably worth a single AITER_EXPORT macro rather than a fifth copy of the #ifdef.

On the test. The things I was most worried about, you've handled:

  • Real torch references rather than self-comparison.
  • Subprocess isolation, so a GPU fault in one op is attributed to that op.
  • topk_softmax sorting both sides before comparing, since the kernel promises no order within the top-k.
  • Both is_neox paths and both need_renorm paths exercised.
  • The dtype choices steering to specific dispatch paths, with comments saying which — that's the part that makes this a JIT smoke test rather than a numerics test.

And it measures no performance, which sidesteps a problem you may not have hit: the Windows torch wheels are built without Kineto, so run_perftest returns 0.00 us and any uplift ratio comes out nan. Several existing op tests will need handling for that; this one is immune by construction.

Two small suggestions:

  1. _run_isolated has no timeout. A hung JIT build would hold the job until the workflow-level timeout rather than failing the op. Given a cold build is ~6 minutes by your measurement, something generous like timeout=1800 would still fail fast relative to a stuck process.
  2. Since you found that requirements.txt can't be installed on Windows: pyproject.toml already carries flydsl==0.3.4.1; sys_platform != 'win32', but requirements.txt line 24 has the bare pin. Adding the same marker there would let CI use pip install -r requirements.txt instead of the hand-listed package set, which otherwise drifts. Happy for that to be a separate PR if you'd rather keep this one focused.

On chip_info.py:570 — you're right and I was wrong. I hadn't noticed that line 16 already imports cpp_extension the same way at module scope, and I'd missed that the csrc/*/gen_instances.py codegen scripts run with jit/utils on sys.path rather than as part of the package. That makes it a coordinated change across jit/utils and those scripts, not a one-line fix. Agreed it belongs in its own change, and I've dropped it from our list.

One coordination note. Xin hit the same export bug independently while building out the Windows CI job in #6242, and fixed three of the same four sites there. Yours is the superset and also carries the harness, so I'll ask him to drop the csrc/ changes from #6242 and depend on this.

Only full CI hasn't run here yet — it's a fork PR, so the workflows need a maintainer to kick them off. I'll do that, and assuming it's green this is good to merge.

One question, not blocking: your card is gfx1200 and the runners we're targeting are gfx1201. Same RDNA4 family and the same toolchain, so I don't expect a difference, but did anything in your run depend on the specific target beyond torch[device-gfx1200]?

@zufayu

zufayu commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

One more thing you may be better placed to settle than we are, if you have the time and the appetite.

We don't actually know which aiter ops work on RDNA4 — and that gap is not a Windows one. aiter exports 327 @compile_ops ops across 65 modules; 17 of those modules are explicitly gated to gfx942/gfx950 and 16 carry RDNA-aware code, which leaves most of the surface undeclared either way. On the Linux side there is no gfx1201 runner at all and the only RDNA machine in CI is a single gfx1100 running an optional Triton flash-attention job. So there is no baseline anywhere to compare Windows against, and right now the five ops in this PR are the only ones anybody has demonstrated on RDNA4.

Your machine is the cheapest place to turn that into a real list. Would you be willing to run these 21 and report what passes?

test_aiter_add.py                 test_layernorm2d.py            test_sample.py
test_aiter_addInp.py              test_layernorm2dFusedAddQuant.py  test_sampling.py
test_aiter_sigmoid.py             test_mla_reduce.py             test_topk_per_row_stable.py
test_batched_gemm_a8w8.py         test_moe_local_expert_ids.py   test_topk_plain.py
test_fused_qk_norm.py             test_opus_co_integration.py    test_topk_softmax.py
test_groupnorm.py                 test_pretune.py
test_hipblaslt_lifecycle.py       test_ps_metadata_sizing.py
                                  test_rmsnorm2d.py
                                  test_rope.py

That is everything under op_tests/ that mentions none of gfx942/gfx950/gfx90a, hand-written asm, fp4/fp8, flydsl, or multi-GPU — a crude filter, so expect some of them to be wrong on their face.

Two things worth knowing before you start. Nineteen of the twenty-one are argparse scripts rather than pytest files, and ten define test_* functions taking positional arguments, so pytest collects them and fails on missing fixtures; they need python op_tests/<name>.py the way Xin drove test_rmsnorm2d.py. And most of them go through aiter.test_common.perftest, so expect 0.00 us and nan uplift from the missing Kineto — that is noise, not a failure, unless it trips a divide.

A failure here is information, not a problem to fix. What we want out of it is the split between "this op has no RDNA4 implementation", which is expected and not a Windows issue, and "this op should work and doesn't", which is a real bug. Even a partial list — say the first handful you get through — would be more than exists today.

No obligation at all, and this is clearly separate from the PR, which stands on its own. If you'd rather not, we'll run it in CI once the job is up; it will just take longer and cost more runner time than it would on your desk.

Comment thread op_tests/windows/test_jit_ops_smoke.py Resolved
@zufayu
zufayu requested a review from gyohuangxin October 9, 2026 09:05
@zufayu

zufayu commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

@gyohuangxin over to you to review and merge this one.

Context in case it saves you time: the only red check is Flash Attention - Triton / MI35X, failing in the Run MHA bench (v2) step with a GPU coredump and exit 134. That is pre-existing — the same job failed on three of the last four main runs — and this PR cannot affect it, since all three csrc/ hunks are inside #ifdef _WIN32 and the aiter/__init__.py change is inside the sys.platform == "win32" branch. Everything else is green, including Aiter Test, Triton Test, OPUS Test, Windows Smoke Test and FA Triton on RDNA3.

Two non-blocking suggestions are open with the author (a timeout on the test's subprocess call, and the missing sys_platform marker on flydsl in requirements.txt); neither needs to hold the merge, and the second is better as its own PR.

Once this lands you can drop the three csrc/ files from #6242 and leave it as pure CI.

@0xDELUXA
0xDELUXA force-pushed the windows-jit-op-tests branch from b95cb75 to d4ff6d8 Compare October 9, 2026 13:58
@0xDELUXA

0xDELUXA commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Updates:

  • _run_isolated now has a 1800s timeout; a hang is reported as a failure of that op.
  • The sys_platform marker on flydsl in requirements.txt is in this PR after all, since it is a one-line change in the same area. main's file fails to resolve on Windows, and with the marker it resolves, while Linux still gets flydsl==0.3.4.1.
  • On gfx1200 vs gfx1201: nothing depends on the specific target. The arch is detected at JIT time and passed as --offload-arch, and every kernel path the five ops use treats __gfx1200__ and __gfx1201__ the same.

I ran the 21 op tests. Two failures were aiter bugs on Windows, and those fixes are now in this PR: merged tuned-config paths were joined with : but split with os.pathsep, which broke any op with files under configs/model_configs/, and hipbsolgemm included <sys/file.h> and linked -lhipblaslt, while the ROCm SDK on Windows only ships libhipblaslt.dll.a.

Result Tests
Pass add, addInp, sigmoid, fused_qk_norm, groupnorm, mla_reduce, opus_co_integration, pretune, ps_metadata_sizing, rmsnorm2d, sample, topk_softmax, hipblaslt_lifecycle (with this PR), rope (686 checks passed, default sweep stopped early)
No RDNA4 implementation batched_gemm_a8w8 (XDL-only CK instance; reaches the kernel with this PR), sampling (csrc/cpp_itfs/utils.py arch allow-list has no gfx12)
RDNA bug, not Windows topk_plain: static_assert(size >= 2 * opus::get_warp_size()) in the bitonic sort fails to compile on wave32
CK on Windows layernorm2d, layernorm2dFusedAddQuant: std::memcpy in device code in amd_buffer_addressing_builtins.hpp, same at the pinned CK commit; fixed in rocm-libraries#13393, after which a CK submodule bump is needed
FlyDSL (Linux-only) moe_local_expert_ids, topk_per_row_stable

@0xDELUXA 0xDELUXA changed the title [HIP] Export ctypes entry points on Windows and add a JIT op smoke test [HIP] Windows: export ctypes entry points, fix hipbsolgemm and tuned config loading, add JIT op smoke test Oct 9, 2026
@github-actions github-actions Bot changed the title [HIP] Windows: export ctypes entry points, fix hipbsolgemm and tuned config loading, add JIT op smoke test [HIP] [JIT] [Build] Export ctypes entry points on Windows and add a JIT op smoke test Oct 9, 2026
@0xDELUXA

0xDELUXA commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

@gyohuangxin the test is now under op_tests/windows/, and the other review points are addressed in the comment above. Since your review, the PR also fixes two Windows bugs the wider op test run turned up (tuned config path merging and the hipbsolgemm build/link). Could you take another look when you have a moment?

@zufayu zufayu assigned gyohuangxin and unassigned yzhou103 Oct 10, 2026
@gyohuangxin
gyohuangxin merged commit ebc73de into ROCm:main Oct 10, 2026
zufayu added a commit that referenced this pull request Oct 12, 2026
The Windows ROCm torch wheels are built without Kineto. torch.profiler still
runs there, but records no device events, so get_trace_perf finds an empty
device frame and returns 0. Every op test that reports a duration prints
0.00 us, and the ones that divide to show an uplift print nan -- visible in
the Windows CI run of test_rmsnorm2d.py as

    [perf] torch avg: 0.00 us, ck avg: 0.00 us, uplift: nan%
    test_rmsnorm2d.py:93: RuntimeWarning: invalid value encountered in scalar divide

122 of the 166 files under op_tests/ go through perftest or run_perftest, so
this is most of the suite. The same gap was hit independently in ROCm/FlyDSL
PR #1239, whose author reports the pytest performance wrapper not completing
"because Torch Kineto's DataFrame field is unavailable".

perftest already has a use_cuda_event path that times with torch.cuda.Event
and never touches the profiler; five call sites pass it explicitly. Probe for
Kineto once and take that path automatically when it is missing, rather than
handing the caller a 0. Builds that ship Kineto -- every Linux ROCm wheel --
resolve to the profiler path exactly as before.

The Windows smoke suite added in #6273 measures no performance, so nothing
depends on this today. It matters as soon as any existing op test is pointed
at Windows, which is the next phase rather than this one.

Verified on MI308X, ROCm 7.2.4, torch 2.10.0, a 4096x4096 fp16 mm:

    profiler path      785.4 us    (unchanged)
    cuda.Event path    799.9 us
    forced fallback    798.1 us

The two timing methods agree to within 2%, so the fallback is not just
nonzero but comparable.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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