Skip to content

[BugFix] Reject unsupported fast-math input dtypes - #2804

Merged
LeiWang1999 merged 2 commits into
tile-ai:mainfrom
erhsh:agent/reject-invalid-fastmath-dtypes
Jul 30, 2026
Merged

[BugFix] Reject unsupported fast-math input dtypes#2804
LeiWang1999 merged 2 commits into
tile-ai:mainfrom
erhsh:agent/reject-invalid-fastmath-dtypes

Conversation

@erhsh

@erhsh erhsh commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • reject integer, boolean, and float8 inputs for the eight explicit fast-math intrinsics
  • report an actionable frontend TypeError instead of emitting identity operations or undefined CUDA symbols
  • add GPU-independent coverage across every affected intrinsic and dtype family

Root cause

The T.__exp, T.__log, and related wrappers forwarded every input dtype directly to CUDA code generation. CUDA fast-math lowering only has valid paths for standard floating-point type codes: small integers and float8 fell through to an empty function name and became silent identity operations, while 32/64-bit integers emitted undefined CUDA symbols.

The wrappers now use one shared validator matching TVM's floating-point type-code convention. Standard float and bfloat inputs retain their existing frontend behavior; unsupported types fail during intrinsic construction.

Fixes #2597.

Validation

  • .venv/bin/python -m pytest testing/python/language/test_tilelang_language_fastmath.py -q (88 passed)
  • .venv/bin/python -m pytest testing/python/math/test_math_fast_math.py testing/python/language/test_tilelang_language_dialect.py -q (18 passed, 34 skipped without a local GPU)
  • python3 -m pre_commit run --files tilelang/language/math_intrinsics.py testing/python/language/test_tilelang_language_fastmath.py
  • git diff --check

Summary

  • Added shared frontend dtype validation for all eight fast-math intrinsics (e.g., __exp, __log, __tan, __cos, __sin, __exp10, __log2, __log10) using TVM floating-point type-code conventions.
  • Rejects integer, boolean, and float8 input dtypes with actionable frontend TypeErrors (while preserving existing behavior for float/bfloat inputs).
  • Updated intrinsic implementations to use the shared validator instead of directly converting inputs.
  • Added parametrized GPU-independent tests covering both unsupported dtype rejection (error includes intrinsic name and dtype) and supported float/bfloat acceptance (frontend returns tvm.tirx.Call with matching dtype).

C++ style / lint notes

  • No C++/CI/lint-related files or documentation were changed; docs/developer_guide/cpp_style.md and the “C++ API Style Audit (warning only)” CI step are not impacted by this PR.
  • All changes are correctness-focused in the Python frontend and corresponding frontend tests (no warning-only style findings introduced or touched).

@coderabbitai

coderabbitai Bot commented Jul 29, 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 Plus

Run ID: 065e7ba8-846b-4fa7-8bdf-6ee49ef44cf1

📥 Commits

Reviewing files that changed from the base of the PR and between 092e4cf and ebc1f78.

📒 Files selected for processing (1)
  • testing/python/language/test_tilelang_language_fastmath.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • testing/python/language/test_tilelang_language_fastmath.py

📝 Walkthrough

Walkthrough

Fastmath intrinsics now validate frontend argument dtypes, accepting float and bfloat inputs while rejecting unsupported types. Parametrized tests cover rejection messages, returned call types, and dtype preservation.

Changes

Fastmath dtype validation

Layer / File(s) Summary
Frontend fastmath validation
tilelang/language/math_intrinsics.py
A shared validator restricts eight fastmath intrinsics to float and bfloat dtypes with intrinsic-specific TypeError messages.
Fastmath dtype tests
testing/python/language/test_tilelang_language_fastmath.py
Parametrized tests verify unsupported dtype rejection and floating-point tirx.Call dtype preservation.

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

Possibly related issues

  • tile-ai/tilelang issue 2565 — Covers overlapping fastmath intrinsic dtype validation and floating-point coverage concerns.
🚥 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 matches the main change: rejecting unsupported fast-math input dtypes.
Linked Issues check ✅ Passed The validator and tests cover all eight fast-math intrinsics and reject integer, bool, and float8 dtypes as required by #2597.
Out of Scope Changes check ✅ Passed The added acceptance tests and shared helper are directly related to the fast-math dtype-guard fix and stay within scope.
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.

@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! 🚀

@erhsh
erhsh marked this pull request as ready for review July 29, 2026 10:23

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@testing/python/language/test_tilelang_language_fastmath.py`:
- Around line 19-36: Update test_fastmath_rejects_unsupported_dtype to include
int64 and uint64 in the parameterized dtype matrix, and strengthen the
pytest.raises match so it asserts the error includes the offending dtype via the
expected “but got {dtype}” text.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: aa5e6786-0008-4677-9c75-dcf6c8440296

📥 Commits

Reviewing files that changed from the base of the PR and between e41fadb and 092e4cf.

📒 Files selected for processing (2)
  • testing/python/language/test_tilelang_language_fastmath.py
  • tilelang/language/math_intrinsics.py

Comment thread testing/python/language/test_tilelang_language_fastmath.py
LeiWang1999
LeiWang1999 previously approved these changes Jul 29, 2026

@LeiWang1999 LeiWang1999 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@LeiWang1999
LeiWang1999 merged commit 21e8c06 into tile-ai:main Jul 30, 2026
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

2 participants