Skip to content

[Feat] Allow dangling producer in wasp pipeline planning (#1263)#1647

Merged
LeiWang1999 merged 3 commits intotile-ai:mainfrom
kurisu6912:fix-1263
Jan 9, 2026
Merged

[Feat] Allow dangling producer in wasp pipeline planning (#1263)#1647
LeiWang1999 merged 3 commits intotile-ai:mainfrom
kurisu6912:fix-1263

Conversation

@kurisu6912
Copy link
Collaborator

@kurisu6912 kurisu6912 commented Jan 9, 2026

This pr fix #1263 by allowing dangling producer, i.e. whose produced data is not consumed by other statment.

Summary by CodeRabbit

  • Bug Fixes

    • Safer handling in the transformation pipeline: when a required pattern is missing the system now emits the transformed statement and logs a warning instead of failing, avoiding insertion of an unnecessary synchronization.
  • Tests

    • Added an end-to-end test exercising a pipelined kernel scenario to guard against regressions for this case.

✏️ Tip: You can customize this high-level summary in your review settings.

@github-actions
Copy link

github-actions bot commented Jan 9, 2026

👋 Hi! Thank you for contributing to the TileLang project.

Please remember to run pre-commit run --all-files in the root directory of the project to ensure your changes are properly linted and formatted. This will help ensure your contribution passes the format check.

We appreciate you taking this step! Our team will review your contribution, and we look forward to your awesome work! 🚀

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 9, 2026

📝 Walkthrough

Walkthrough

The producer emission path was modified to emit transformed producer statements when the corresponding release pattern is empty: the statement is appended, a warning is logged, and an early continue skips mbarrier insertion instead of asserting.

Changes

Cohort / File(s) Summary
Producer Release Pattern Handling
src/transform/warp_specialized_rewriter.cc
When map.release[i] is empty, append the transformed producer statement, log a warning, and continue early to bypass inserting an mbarrier (removed the previous assertion-like requirement).
Test: pipeline no-consumer case
testing/python/issue/test_tilelang_issue_1263.py
Added test_issue_1263_pipeline_no_consumer() to reproduce a pipelined loop case with shared buffers and a producer-only scenario (exercise regression related to T.Pipelined variable usage).

Sequence Diagram(s)

(Skipped — changes are localized and do not introduce a new multi-component control flow requiring a sequence diagram.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰
A producer leapt where releases were thin,
I nudged the emitter to let it pass in,
A warning I left where the barrier hid,
No assert to stop it — the pipeline slid,
Hoppity-hop — tests now begin.

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly identifies the main change: allowing dangling producers in wasp pipeline planning, directly addressing issue #1263.
Linked Issues check ✅ Passed The code changes meet the primary objectives from issue #1263 by handling producers with no corresponding release patterns, preventing false 'not passed in as API arguments' errors for pipelined kernels.
Out of Scope Changes check ✅ Passed All changes are directly related to the stated objective: modifications to the warp_specialized_rewriter.cc handle dangling producers, and the new test file validates the fix for issue #1263 with a pipelined kernel.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2baca64 and aa91188.

📒 Files selected for processing (1)
  • testing/python/issue/test_tilelang_issue_1263.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • testing/python/issue/test_tilelang_issue_1263.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Test for Python 3.12 with Metal (on macos-latest)
  • GitHub Check: Test for Python 3.12 with Nightly-ROCm-7.1 (on self-hosted-amd)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
testing/python/issue/test_tilelang_issue_1263.py (2)

4-7: Consider adding a docstring to explain the regression test.

The test function lacks documentation explaining what regression it validates. Adding a brief docstring would help maintainers understand the test's purpose and the specific scenario from issue #1263 (compilation failure with pipelined loops containing dangling producers).

📝 Suggested docstring
 def test_issue_1263_pipeline_no_consumer():
+    """Regression test for issue #1263.
+    
+    Validates that pipelined loops compile successfully when they contain
+    'dangling producers' (operations whose outputs are not consumed by
+    subsequent statements). Previously failed with error: "variables X are
+    used, but are not passed in as API arguments".
+    """
     @tilelang.jit()
     def test_kernel(M, N):

18-22: Core test logic correctly validates the dangling producer scenario.

The pipelined loop implements the exact regression scenario from issue #1263:

  • Two-level indirection (ids[i]ids2[id]) creates the "longer chain" that triggered the bug
  • Buffer A is written but never consumed
  • Buffer B is cleared but never used

Both are intentional "dangling producers" that validate the fix. Consider adding a brief inline comment explaining this is the expected behavior being tested.

💭 Optional clarifying comment
             for i in T.Pipelined(4, num_stages=1):
                 id = ids[i]
                 id2 = ids2[id]
+                # A and B are dangling producers (outputs not consumed) - validates fix for #1263
                 T.copy(KV[id2, :], A)
                 T.clear(B)
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 96f2983 and 2baca64.

📒 Files selected for processing (1)
  • testing/python/issue/test_tilelang_issue_1263.py
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2026-01-06T05:20:45.325Z
Learnt from: silentCoder-dev
Repo: tile-ai/tilelang PR: 1606
File: testing/python/transform/test_tilelang_transform_hoist_broadcast_values.py:30-30
Timestamp: 2026-01-06T05:20:45.325Z
Learning: In `testing/python/transform/test_tilelang_transform_hoist_broadcast_values.py`, the test validates that the `hoist_broadcast_values` transformation pass correctly identifies and hoists broadcast operations by checking for patterns in the generated kernel source code. The specific literal values used (e.g., 430) are not important for the test's purpose, as it does not validate numerical precision or actual stored tensor values.

Applied to files:

  • testing/python/issue/test_tilelang_issue_1263.py
📚 Learning: 2025-11-14T07:56:11.098Z
Learnt from: lucifer1004
Repo: tile-ai/tilelang PR: 1256
File: testing/python/jit/test_tilelang_jit_gemm_nvrtc.py:55-115
Timestamp: 2025-11-14T07:56:11.098Z
Learning: In `testing/python/jit/test_tilelang_jit_gemm_nvrtc.py`, the global function `tilelang_callback_cuda_postproc` registered via `tvm.register_global_func(..., override=True)` is intentionally not restored after the test completes, as the persistent behavior is expected.

Applied to files:

  • testing/python/issue/test_tilelang_issue_1263.py
📚 Learning: 2025-12-18T04:50:00.512Z
Learnt from: silentCoder-dev
Repo: tile-ai/tilelang PR: 1464
File: testing/python/language/test_tilelang_language_rand.py:14-14
Timestamp: 2025-12-18T04:50:00.512Z
Learning: In `testing/python/language/test_tilelang_language_rand.py`, the TileLang kernel uses `blk_M = M` (single block) and calls `rng_rand()` four times per element to align results with the Triton implementation, which uses `blk_M = 128` (multiple blocks) and calls the RNG once per element. These differences compensate for internal RNG behavior differences between TileLang and Triton.

Applied to files:

  • testing/python/issue/test_tilelang_issue_1263.py
🧬 Code graph analysis (1)
testing/python/issue/test_tilelang_issue_1263.py (5)
tilelang/language/proxy.py (1)
  • Tensor (233-233)
tilelang/language/kernel.py (1)
  • threads (215-219)
tilelang/language/allocate.py (1)
  • alloc_shared (39-54)
tilelang/language/loop.py (1)
  • Pipelined (97-134)
tilelang/language/fill_op.py (1)
  • clear (39-62)
🔇 Additional comments (4)
testing/python/issue/test_tilelang_issue_1263.py (4)

1-2: LGTM!

Standard imports for tilelang testing are correctly structured.


8-16: LGTM!

The function signature and tensor shapes are well-aligned:

  • The ids2 parameter creates the multi-level indirection that triggered the original regression
  • Kernel lanes (4) matches both the tensor sizes and loop iteration count
  • Shared buffer allocations are appropriate for the test scenario

24-25: LGTM!

The test correctly validates compilation success by invoking the kernel. The absence of explicit assertions is appropriate here—the test passes if compilation completes without raising the "variables X are used, but are not passed in as API arguments" error from the original issue.


28-29: LGTM!

Standard test main guard using tilelang's test runner.

@LeiWang1999 LeiWang1999 merged commit 326be4d into tile-ai:main Jan 9, 2026
4 of 6 checks passed
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.

[BUG] Another regression: "variables X are used, but are not passed in as API arguments" error in T.Pipelined

2 participants