Skip to content

[BugFix] Fix FP4 dequant symbolic exponent clamp#2656

Open
mygitljf wants to merge 1 commit into
tile-ai:mainfrom
mygitljf:fix/issue-2615-symbolic-min
Open

[BugFix] Fix FP4 dequant symbolic exponent clamp#2656
mygitljf wants to merge 1 commit into
tile-ai:mainfrom
mygitljf:fix/issue-2615-symbolic-min

Conversation

@mygitljf

@mygitljf mygitljf commented Jul 13, 2026

Copy link
Copy Markdown

Summary

Fix the trace-time crash in _tir_u8_to_f4_to_bf16 caused by applying Python's built-in min to symbolic PrimExpr operands.

Changes

  • Replace the eager Python min call with TileLang's lazy T.min.
  • Remove the misleading comment that described the upper clamp as a max operation.
  • Add trace regression coverage for:
    • Python integer scale=0.
    • A symbolic uint16 scale loaded from a buffer.
  • Verify that tracing produces exactly one Min<uint16> node.

Validation

  • Reproduced the original PrimExpr.__bool__ failure on:
    • TileLang v0.1.11.
    • TileLang v0.1.12.
    • Latest origin/main.
  • Verified the candidate fix produces TRACE_OK for both scale paths.
  • Verified the existing builds with ninja -j64.
  • Local experiments were not rerun after the final commit, as requested; remote CI is pending.

C++ style / lint notes

  • Python-only change; no C++ files were modified.
  • git diff --check passed.
  • C++ formatting and lint checks are not applicable.

Fixes #2615

Summary

  • Replaced Python’s eager min with TileLang’s lazy T.min in _tir_u8_to_f4_to_bf16, preventing symbolic PrimExpr.__bool__ trace-time crashes.
  • Added regression coverage for both literal and symbolic uint16 scales.
  • Tests verify tracing produces exactly one Min<uint16> node.

Validation

  • Existing builds passed.
  • git diff --check passed.

@github-actions

Copy link
Copy Markdown

👋 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

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2039ea25-fc49-40a0-96de-eb9f7787e95b

📥 Commits

Reviewing files that changed from the base of the PR and between 6ed02ae and 5844c62.

📒 Files selected for processing (2)
  • testing/python/issue/test_tilelang_issue_2615.py
  • tilelang/quantize/quantization.py

📝 Walkthrough

Walkthrough

The FP4-to-bfloat16 conversion now clamps symbolic exponents with T.min. A parametrized pytest regression test traces both scaling paths and verifies the resulting uint16 TIR Min node.

Changes

Symbolic exponent clamp

Layer / File(s) Summary
TIR clamp and regression coverage
tilelang/quantize/quantization.py, testing/python/issue/test_tilelang_issue_2615.py
The conversion helper replaces Python min with T.min, and the regression test validates the generated clamp for buffered and zero scaling inputs.

Estimated code review effort: 2 (Simple) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the fix to the FP4 dequant symbolic exponent clamp.
Linked Issues check ✅ Passed The code replaces Python min with T.min and adds regression tests for scalar and symbolic uint16 scales, matching #2615.
Out of Scope Changes check ✅ Passed The changes stay focused on the quantization fix and its regression test, with no unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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

Labels

None yet

Projects

None yet

1 participant