Skip to content

[FLYDSL]: if dispatch dynamic tests refactor#346

Open
xudoyuan wants to merge 58 commits intomainfrom
yxd/if_dispatch_dynamic_tests_refactor
Open

[FLYDSL]: if dispatch dynamic tests refactor#346
xudoyuan wants to merge 58 commits intomainfrom
yxd/if_dispatch_dynamic_tests_refactor

Conversation

@xudoyuan
Copy link
Copy Markdown
Contributor

@xudoyuan xudoyuan commented Apr 3, 2026

Motivation

  1. Scope analysis.

  2. Dynamic judgment.

  3. Rectification of non-standard test cases.

  4. Correct construction of scf.if.

Technical Details

Test Plan

Test Result

Submission Checklist

@xudoyuan xudoyuan marked this pull request as ready for review April 8, 2026 16:47
@xudoyuan xudoyuan marked this pull request as draft April 8, 2026 16:47
@xudoyuan xudoyuan changed the title Yxd/if dispatch dynamic tests refactor [FLYDSL]: if dispatch dynamic tests refactor Apr 9, 2026
@xudoyuan xudoyuan marked this pull request as ready for review April 10, 2026 07:14
Comment thread python/flydsl/compiler/ast_rewriter.py
Comment thread python/flydsl/expr/numeric.py Outdated
Comment thread python/flydsl/compiler/ast_rewriter.py
Comment thread python/flydsl/expr/primitive.py Outdated
Comment thread examples/04-preshuffle_gemm.py Outdated
sjfeng1999
sjfeng1999 previously approved these changes Apr 16, 2026
xudoyuan and others added 8 commits April 20, 2026 14:36
The AST rewriter's control_flow_scope pop loses variables defined in
const_expr if blocks from the symbol scope. When a later bare if
(without const_expr) is encountered, the rewriter treats it as dynamic
and rewrites it into closures via scf_if_dispatch. Variables like val_s
defined earlier don't get passed as parameters, causing
UnboundLocalError at compile time.

Fix: wrap all bare if/elif conditions inside @flyc.kernel (kernel_gemm)
and @flyc.jit (launch_gemm) with const_expr(), since they are all
compile-time Python constants.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
…scheduler

use_mfma_k32 and _is_gfx950 are compile-time constants; leaving them as
bare if/elif causes the AST rewriter to treat them as dynamic branches,
which can lead to scope/type errors via scf_if_dispatch.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants