Skip to content

[FlyDSL] Fix HSTU reference import fallback - #5394

Merged
gyohuangxin merged 6 commits into
mainfrom
fix-hstu-reference-import-fallback
Sep 10, 2026
Merged

gyohuangxin merged 6 commits into
mainfrom
fix-hstu-reference-import-fallback

Conversation

@gyohuangxin

Copy link
Copy Markdown
Member

Summary

  • Handle both missing triton_tests and missing op_tests when loading the HSTU torch reference helper.
  • Add the repository root to sys.path only in the fallback path before importing op_tests.triton_tests.utils.hstu_attention_ref.

Motivation

Standard AITER tests execute files directly with python3 op_tests/test_*.py. In that mode op_tests/ is on sys.path, but the repo root may not be. After #5382 changed op_tests/triton_tests/__init__.py to use absolute op_tests... imports, op_tests/test_flydsl_hstu_attention.py can fail while importing its triton-side reference helper with:

ModuleNotFoundError: No module named 'op_tests'

Testing

  • python3 -m py_compile op_tests/test_flydsl_hstu_attention.py
  • git diff --check

Note: local ruff is not installed in this environment, so I could not run the ruff check locally.

@gyohuangxin
gyohuangxin requested review from a team and a lite review from Copilot September 10, 2026 05:59
@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; main branch always runs both MI35X and MI300X
multigpu 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 5394 --add-label <label>

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 opt this PR out.

@github-actions github-actions Bot changed the title Fix HSTU reference import fallback [FlyDSL] Fix HSTU reference import fallback Sep 10, 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.

🟡 Changes recommended

The new fallback gate checks only exact ModuleNotFoundError.name values and can still fail to trigger when the missing module is reported as a dotted path (e.g., triton_tests.utils) in some environments.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR updates the FlyDSL HSTU attention test helper import logic to be resilient to different sys.path layouts when tests are executed directly (e.g., python3 op_tests/test_*.py), restoring the ability to load the torch reference implementation after absolute-import changes in op_tests/triton_tests.

Changes:

  • Extend the fallback trigger to handle both missing triton_tests and missing op_tests during the initial import attempt.
  • In the fallback path, prepend the repository root to sys.path before importing op_tests.triton_tests.utils.hstu_attention_ref.
File summaries
File Description
op_tests/test_flydsl_hstu_attention.py Makes torch-reference import robust by adding a fallback that adjusts sys.path and imports via op_tests.*.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread op_tests/test_flydsl_hstu_attention.py Resolved
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Copilot AI review requested due to automatic review settings September 10, 2026 06:52

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 change is narrowly scoped to test import fallback handling and appears correct and consistent with the stated motivation.

Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 10, 2026 07: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.

🟢 Approval recommended

The change is small, targeted, and correctly addresses the reported ModuleNotFoundError scenario without affecting the normal import path.

Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 10, 2026 07: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

The change is narrowly scoped to import fallback behavior in a test file and appears to correctly handle the reported sys.path/absolute-import failure mode without impacting the normal success path.

Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 10, 2026 08:43

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 change is narrowly scoped to import fallback logic, aligns with the stated motivation, and has low risk of affecting runtime behavior outside the intended test execution mode.

Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 10, 2026 13:06

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 change is narrowly scoped to test import fallback logic and appears to address the reported sys.path/absolute-import failure mode without impacting runtime code paths.

Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread op_tests/test_flydsl_hstu_attention.py Resolved
@gyohuangxin
gyohuangxin merged commit 2173f43 into main Sep 10, 2026
57 checks passed
@gyohuangxin
gyohuangxin deleted the fix-hstu-reference-import-fallback branch September 10, 2026 16:57
damien-lejeune pushed a commit that referenced this pull request Sep 14, 2026
damien-lejeune pushed a commit that referenced this pull request Sep 21, 2026
* temporarily add the HSTU forward kernel

* Add test scaffolding + start of backward kernel, dV only

* Implement dK and dS in the backward HSTU kernel

* Add dQ kernel as standalone + update tests

* Add masking variants + update tests

* Adding docs

* Update docs + first benchmark results

* Adding tiling and tunable config + update tests

* Add tuning

* Implement autograd integration

* Refactor: layout algebra cleanup + code deduplication

* Optimization: decouple tunning for dV/dK and dQ, update tuning file and tests

* Split fused dV and dK kernels

* Update docs

* Add group aware load balancing optimization

* Add tuned shape for B=120

* Add hstu backward tuned shaped on uniform seqlen regime

* Fuse dV/dK with the dQ kernel for improved performance + update tuning

* Remove stale tuning file

* Fix semi_local_fig lower bound window, for the dV/dK part

* Enable the use of single barrier for the dV, dK and dQ sub-parts, instead of two (for dV/DK and dQ), bringing minor performance gain

* Add FlyDSL HSTU attention fwd kernel

* Adding barriers tunable file + tunable interface

* Update docs

* Remove dev docs

* Remove dq split kernel

* Cleanup ArithValue, _to_raw, etc

* Use view and refactor copy-atom

* refactor s_waitcnt to use llvm.InlineAsmOp

* Apply black on the hstu backward kernel

* Add unit tests in the right format

* Read dq kernel + cleanup

* Use @fx.struct SharedStorage instead of SmemPtr LDS operations, removed fx.Index

* Remove the two barrier feature as it brought too little benefits; also cleaned up tests, tuner and tuned file

* Remove temporary copy of the HSTU forward kernel

* Remove dead code + comments

* further comment cleanup

* Fix ruff issues

* Run Ruff & Black

* Rerun Black & Ruff after merge

* Fix str2bool issue

* Use ShareAllocation + view()

* Fix format + Index/Int32

* Add test scaffolding + start of backward kernel, dV only

* Implement dK and dS in the backward HSTU kernel

* Add dQ kernel as standalone + update tests

* Add masking variants + update tests

* Adding docs

* Update docs + first benchmark results

* Adding tiling and tunable config + update tests

* Add tuning

* Implement autograd integration

* Refactor: layout algebra cleanup + code deduplication

* Optimization: decouple tunning for dV/dK and dQ, update tuning file and tests

* Split fused dV and dK kernels

* Update docs

* Add group aware load balancing optimization

* Add tuned shape for B=120

* Add hstu backward tuned shaped on uniform seqlen regime

* Fuse dV/dK with the dQ kernel for improved performance + update tuning

* Remove stale tuning file

* Fix semi_local_fig lower bound window, for the dV/dK part

* Enable the use of single barrier for the dV, dK and dQ sub-parts, instead of two (for dV/DK and dQ), bringing minor performance gain

* Adding barriers tunable file + tunable interface

* Update docs

* Remove dev docs

* Remove dq split kernel

* Cleanup ArithValue, _to_raw, etc

* Use view and refactor copy-atom

* refactor s_waitcnt to use llvm.InlineAsmOp

* Apply black on the hstu backward kernel

* Add unit tests in the right format

* Read dq kernel + cleanup

* Use @fx.struct SharedStorage instead of SmemPtr LDS operations, removed fx.Index

* Remove the two barrier feature as it brought too little benefits; also cleaned up tests, tuner and tuned file

* Remove dead code + comments

* further comment cleanup

* Fix ruff issues

* Fix issues uncovered after rebasing

* Fix api usage: remove mma ssa, hand-rolled s_waitcnt, buffer_ops from aiter and shrui deprecation

* Use addressable_lds_bytes_for_gfx in place of SMEM_CAPACITY_MAP

* Address K_COL_GUARD issues, cleanup tests, add a missing barrier + retune

* Relax the (batch*num_heads) % 8 backward constraint; guard non-causal autograd

* Cleanup: improve usage of FlyDSL stable API

* Remove usaged of buffer_ops and use the ptrtoint API

* Improve FlyDSL stable API usage

* Add the possibility to skip validation in the test

* Guard dQ padded K columns; validate untuned tiles per arch

* Update HSTU backward tuning file

* Turn sort_by_length ON by default

* move backward csv file to aiter standard location

* Expose HSTU backward kernel at package level

* Extra common functions for fwd and bwd HSTU kernels

* Move test + delete legacy files

* Add helper functions on common code

* Cleanup: guard on devices + fix license

* Parameterize MFMA size based on architecture

* Remove redundant compiler flags

* Turn sort_by_length ON by default also on the public interface

* Fix test's top-level import, mirroring PR #5394

* Moving HSTU kernels in their own folder

* Removing redundant file

* Add missing __init__.py

* Remove lru cache for the batch

* Add gfx950 tuned shapes

---------

Co-authored-by: Damien Lejeune <[email protected]>
Co-authored-by: Robin Elbers <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants