pytorch - ✅(Solved) Fix [CuteDSL] Missing operation: index_expr [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
pytorch/pytorch#181182Fetched 2026-04-23 07:22:04
View on GitHub
Comments
1
Participants
2
Timeline
55
Reactions
0
Author
Participants
Timeline (top)
mentioned ×24subscribed ×24labeled ×5commented ×1

Error Message

InductorError: LoweringException: RuntimeError: CuteDSL template failed: ================================================================================ UNSUPPORTED CUTEDSL OPERATION: 'index_expr'

Fix Action

Fixed

PR fix notes

PR #181207: Fix kindexpr error with flex

Description (problem / solution / changelog)

Stack from ghstack (oldest at bottom):

  • #181216
  • -> #181207

fixes : #181182 cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo @Chillee @yanboliang @BoyuanFeng @liangel-02 @howardzhang-cv

Changed files

  • test/inductor/test_cutedsl_template.py (modified, +42/-0)
  • torch/_inductor/codegen/cutedsl/cutedsl_kernel.py (modified, +3/-1)
  • torch/_inductor/codegen/cutedsl/cutedsl_op_overrides.py (modified, +14/-0)

Code Example

InductorError: LoweringException: RuntimeError: CuteDSL template failed: ================================================================================
UNSUPPORTED CUTEDSL OPERATION: 'index_expr'

---

target: flex_attention
  args[0]: TensorBox(
    View(
      StorageBox(
        ComputedBuffer(name='buf199', layout=FixedLayout('cuda:0', torch.bfloat16, size=[128, 4, 342, 1, 128], stride=[175104, 43776, 128, 128, 1]), data=Pointwise(
          'cuda',
          torch.bfloat16,
          def inner_fn(index):
              i0, i1, i2, _, i4 = index
              tmp0 = ops.load(buf190, i4 + 128 * i1 + 512 * i0 + 65536 * i2)
              tmp1 = ops.load(arg112_1, i4 + 128 * i1)
              tmp2 = ops.to_dtype(tmp1, torch.bfloat16, src_dtype=torch.float32)
              tmp3 = tmp0 + tmp2
              return tmp3
          ,
          ranges=[128, 4, 342, 1, 128],
          origin_node=clone_7,
          origins=OrderedSet([clone_7, permute_26, view_47, add_8, view...,
RAW_BUFFERClick to expand / collapse

🐛 Describe the bug

Operation: index_expr Args: (ModularIndexing(tmp1, 1, 2), torch.int64) Kwargs: {}

hit unsupported cutedsl operation 'index_expr' issue when using flex attention with flash attention 4 backend:

InductorError: LoweringException: RuntimeError: CuteDSL template failed: ================================================================================
UNSUPPORTED CUTEDSL OPERATION: 'index_expr'
target: flex_attention
  args[0]: TensorBox(
    View(
      StorageBox(
        ComputedBuffer(name='buf199', layout=FixedLayout('cuda:0', torch.bfloat16, size=[128, 4, 342, 1, 128], stride=[175104, 43776, 128, 128, 1]), data=Pointwise(
          'cuda',
          torch.bfloat16,
          def inner_fn(index):
              i0, i1, i2, _, i4 = index
              tmp0 = ops.load(buf190, i4 + 128 * i1 + 512 * i0 + 65536 * i2)
              tmp1 = ops.load(arg112_1, i4 + 128 * i1)
              tmp2 = ops.to_dtype(tmp1, torch.bfloat16, src_dtype=torch.float32)
              tmp3 = tmp0 + tmp2
              return tmp3
          ,
          ranges=[128, 4, 342, 1, 128],
          origin_node=clone_7,
          origins=OrderedSet([clone_7, permute_26, view_47, add_8, view...,

Versions

torch 2.11, flash attention4

cc @chauhang @penguinwu @voznesenskym @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @aakhundov @coconutruben @jataylo @Chillee @drisspg @yanboliang @BoyuanFeng @liangel-02 @howardzhang-cv

extent analysis

TL;DR

The issue is likely due to an unsupported index_expr operation in the CuteDSL template when using flex attention with flash attention 4 backend, and a workaround may involve modifying the indexing operation or updating the backend.

Guidance

  • Verify that the index_expr operation is supported in the current version of the flash attention backend, and consider updating to a version that supports this operation if available.
  • Check the documentation for the flex_attention target to see if there are any specific requirements or limitations for indexing operations.
  • Consider modifying the indexing operation to use a supported method, such as using a different indexing function or reordering the indices.
  • Review the stacktrace to identify the specific line of code that is causing the error and investigate possible workarounds for that particular operation.

Example

No code snippet is provided as the issue does not contain enough information to suggest a specific code change.

Notes

The issue may be specific to the combination of flex_attention and flash attention 4 backend, and the solution may depend on the specific requirements of the project.

Recommendation

Apply workaround: The issue is likely due to an unsupported operation, and a workaround may be necessary to resolve the issue. Updating to a fixed version may not be possible, and modifying the indexing operation may be the most feasible solution.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

pytorch - ✅(Solved) Fix [CuteDSL] Missing operation: index_expr [1 pull requests, 1 comments, 2 participants]