Repository navigation
[FlyDSL] Fix HSTU reference import fallback - #5394
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
PR title tags & labels: |
There was a problem hiding this comment.
🟡 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_testsand missingop_testsduring the initial import attempt. - In the fallback path, prepend the repository root to
sys.pathbefore importingop_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.
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
There was a problem hiding this comment.
🟢 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>
There was a problem hiding this comment.
🟢 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
There was a problem hiding this comment.
🟢 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
There was a problem hiding this comment.
🟢 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
There was a problem hiding this comment.
🟢 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
* 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]>
Summary
triton_testsand missingop_testswhen loading the HSTU torch reference helper.sys.pathonly in the fallback path before importingop_tests.triton_tests.utils.hstu_attention_ref.Motivation
Standard AITER tests execute files directly with
python3 op_tests/test_*.py. In that modeop_tests/is onsys.path, but the repo root may not be. After #5382 changedop_tests/triton_tests/__init__.pyto use absoluteop_tests...imports,op_tests/test_flydsl_hstu_attention.pycan fail while importing its triton-side reference helper with:Testing
python3 -m py_compile op_tests/test_flydsl_hstu_attention.pygit diff --checkNote: local
ruffis not installed in this environment, so I could not run the ruff check locally.