Skip to content

[repro] flash_attn_generic: concise causal-mask loop trips dynamic-if…#763

Draft
xudoyuan wants to merge 1 commit into
mainfrom
repro/dynamic-if-list-carry-fa-generic
Draft

[repro] flash_attn_generic: concise causal-mask loop trips dynamic-if…#763
xudoyuan wants to merge 1 commit into
mainfrom
repro/dynamic-if-list-carry-fa-generic

Conversation

@xudoyuan

Copy link
Copy Markdown
Collaborator

… list-carry

Collapses the 112-line hand-unrolled causal mask (s_raw_lo_0..15 / s_raw_hi_0..15) into a range_constexpr(16) loop. This is the intended concise form but it currently FAILS at compile time:

TypeError: state variable 's_raw_lo' is list, not an MLIR Value;
stateful dynamic if requires MLIR-backed values.

Suspected FlyDSL compile-time defect: tile_needs_mask is a runtime value, so if tile_needs_mask: lowers to a dynamic scf.if. The if-rewriter can carry a reassigned named scalar MLIR value out of the branch, but not a reassigned list local. The original 112-line unroll existed solely to work around this (carry 16+16 named scalars).

Committed intentionally as a minimal repro so the rewriter can be fixed to carry list-typed locals (flatten to per-element scf.if yields). Once fixed, this is the desired form. Does NOT build as-is.

Motivation

Technical Details

Test Plan

Test Result

Submission Checklist

… list-carry

Collapses the 112-line hand-unrolled causal mask (s_raw_lo_0..15 /
s_raw_hi_0..15) into a range_constexpr(16) loop. This is the intended
concise form but it currently FAILS at compile time:

  TypeError: state variable 's_raw_lo' is list, not an MLIR Value;
             stateful dynamic if requires MLIR-backed values.

Suspected FlyDSL compile-time defect: `tile_needs_mask` is a runtime
value, so `if tile_needs_mask:` lowers to a dynamic scf.if. The
if-rewriter can carry a reassigned *named scalar* MLIR value out of the
branch, but not a reassigned *list* local. The original 112-line unroll
existed solely to work around this (carry 16+16 named scalars).

Committed intentionally as a minimal repro so the rewriter can be fixed
to carry list-typed locals (flatten to per-element scf.if yields). Once
fixed, this is the desired form. Does NOT build as-is.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@xudoyuan xudoyuan marked this pull request as draft June 29, 2026 12:05
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.

1 participant