Skip to content

[CuTeDSL] Support dynamic shapes in right_inverse - #3582

Open
kzos wants to merge 2 commits into
NVIDIA:mainfrom
kzos:codex/issue-3471-dynamic-right-inverse
Open

kzos wants to merge 2 commits into
NVIDIA:mainfrom
kzos:codex/issue-3471-dynamic-right-inverse

Conversation

@kzos

@kzos kzos commented Sep 4, 2026 •

Copy link
Copy Markdown

Summary

  • allow right_inverse to accept dynamic shapes when every stride is a fully static integer
  • retain only the maximal inverse prefix whose stride continuity is statically provable, and carry dynamic shape values through CuTe expansion and base lowering
  • preserve the existing static-shape behavior, including dynamic strides and supported scaled-basis forms
  • add verifier, expansion, full-pipeline, and cutegen regression coverage for continuous, truncated, and zero-stride cases

For (16, N):(1, 16), this returns the functionally equivalent uncoalesced (16, N):(1, 16) layout demonstrated by PyCuTe in the issue discussion. Producing the canonical 16*N:1 representation depends on dynamic coalescing, which is tracked separately in #3469. Consequently, callers that require a coalesced rank-1 inverse, including the blackwell_helpers.py TMA-shape path, still depend on #3469.

Testing

  • cmake --build build-cutlass-compiler --target check-cute -j 8 (236/236 passed)
  • cmake --build build-cutlass-compiler --target check-cutegen-unittests -j 8 (220/220 passed across 25 test binaries)
  • focused post-review MLIR suite (5/5 passed)
  • ctest --test-dir build-cutlass-compiler -R 'cg_right_inverse_test' --output-on-failure (1/1 passed)
  • git diff --check

The compiler and tests were built CPU-only against the LLVM revision pinned by cutlass_compiler/LLVM_COMMIT.

Contribution disclosure

AI assistance was used for repository research, implementation, independent review, and running the checks above.

Fixes #3471

Sync the dialect reference with the dynamic-shape contract and cover the
runtime prefix-product and scalar-order lowering paths. Also fix a dangling
comment in the neighboring left-inverse test.

Test Plan:

```bash
build-cutlass-compiler/llvm-project/bin/llvm-lit -v build-cutlass-compiler/cute_ir/test/Conversion/CuteToBase/pipeline_full.mlir build-cutlass-compiler/cute_ir/test/Conversion/CuteExpandOps/LayoutAlgebra/left_inverse.mlir build-cutlass-compiler/cute_ir/test/Conversion/CuteExpandOps/LayoutAlgebra/right_inverse.mlir build-cutlass-compiler/cute_ir/test/Dialect/Cute/LayoutAlgebra/right_inverse.mlir build-cutlass-compiler/cute_ir/test/Dialect/Cute/LayoutAlgebra/right_inverse_errors.mlir
ctest --test-dir build-cutlass-compiler -R 'cg_right_inverse_test' --output-on-failure
git diff --check
```
@kzos

kzos commented Sep 24, 2026

Copy link
Copy Markdown
Author

Hi @ccecka, following up on the fix for #3471. Would you be able to review the dynamic-shape/static-integer-stride right_inverse support, or point me to the right compiler reviewer? The PR records 236 passing CuTe IR tests and 220 passing cutegen tests. It deliberately returns the equivalent uncoalesced inverse; canonical dynamic coalescing remains separate under #3469. Thanks!

@kzos

kzos commented Oct 5, 2026

Copy link
Copy Markdown
Author

Hi @ccecka, following up on the September 24 review request: is the dynamic-shape/static-stride right_inverse approach in this PR suitable, or should I route it to another compiler reviewer? The scope keeps the equivalent inverse uncoalesced; canonical dynamic coalescing remains separate under #3469. Happy to address scope or test feedback. Thanks!

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

This PR has been labeled inactive-30d due to no recent activity in the past 30 days. Please close this PR if it is no longer required. Otherwise, please respond with a comment indicating any updates. This PR will be labeled inactive-90d if there is no activity in the next 60 days.

@kzos

kzos commented Nov 4, 2026

Copy link
Copy Markdown
Author

This PR is still needed and awaiting review. @ccecka, could you review it or point me to the right compiler reviewer? Happy to address feedback.

@ccecka

ccecka commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

I'm not the right reviewer for this. Perhaps @kerrmudgeon knows who should review this?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] [CuTeDSL] cute.right_inverse refuses layouts with dynamic sizes

2 participants