Skip to content

[Refactor] Move dtypes.py from eager to language and add bits/bytes properties#1646

Merged
LeiWang1999 merged 1 commit intotile-ai:mainfrom
LeiWang1999:refactor/move-dtypes-to-language
Jan 9, 2026
Merged

[Refactor] Move dtypes.py from eager to language and add bits/bytes properties#1646
LeiWang1999 merged 1 commit intotile-ai:mainfrom
LeiWang1999:refactor/move-dtypes-to-language

Conversation

@LeiWang1999
Copy link
Member

@LeiWang1999 LeiWang1999 commented Jan 9, 2026

Summary

  • Move dtypes.py from tilelang/language/eager/ to tilelang/language/ since dtype definitions are general-purpose, not eager-specific
  • Add bytes property to dtype as a convenient alias for itemsize
  • Create tilelang/dtypes.py for direct import via from tilelang.dtypes import ...

Changes

File Change
language/dtypes.py Moved from language/eager/dtypes.py, added bytes property and type hints
tilelang/dtypes.py New re-export module for convenient access
language/eager/*.py Updated imports from . to ..
language/allocate.py Updated imports
jit/adapter/tvm_ffi.py Updated imports
tilelang/__init__.py Updated imports

Test plan

  • Verified from tilelang.dtypes import float32, int8, dtype works
  • Verified dtype.bits and dtype.bytes properties work correctly

Summary by CodeRabbit

  • New Features

    • Added bits and bytes properties to dtype objects for convenient access to type size information.
    • Introduced a new accessible module for importing data type utilities directly.
  • Refactor

    • Reorganized internal data type imports for improved code structure and accessibility.

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

…roperties

- Move `tilelang/language/eager/dtypes.py` to `tilelang/language/dtypes.py`
  since dtype definitions are general-purpose, not eager-specific
- Add `bytes` property to dtype (alias for `itemsize`) for convenience
- Add type hints for `bits` and `bytes` properties in TYPE_CHECKING block
- Create `tilelang/dtypes.py` for direct import via `from tilelang.dtypes import ...`
- Update all import paths accordingly

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@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 changes reorganize the dtypes module structure by redirecting imports from tilelang.language.eager.dtypes to tilelang.language.dtypes across multiple files. Additionally, new bits and bytes properties are added to the dtype interface, and a new convenience re-export module is introduced at tilelang/dtypes.py.

Changes

Cohort / File(s) Summary
dtypes Module Import Restructuring
testing/python/language/test_tilelang_language_frontend_v2.py, tilelang/__init__.py, tilelang/jit/adapter/tvm_ffi.py, tilelang/language/eager/__init__.py, tilelang/language/eager/ast.py, tilelang/language/eager/builder.py
Updated import paths to source dtypes from tilelang.language.dtypes instead of tilelang.language.eager.dtypes. Affects public export in main __init__.py and internal references across eager module.
dtype Interface Enhancements
tilelang/language/dtypes.py
Added bits: int and bytes: int type annotations to dtype class under TYPE_CHECKING. Implemented __dtype_bytes__() function and exposed public bytes property via dtype.bytes = property(__dtype_bytes__).
New Convenience Re-export Layer
tilelang/dtypes.py
New module created to re-export all public members from tilelang.language.dtypes, including explicit re-exports of dtype, AnyDType, and get_tvm_dtype.
Import Refactoring
tilelang/language/allocate.py
Replaced eager-specific relative imports with generalized package-level imports: from .eager import dtypesfrom . import dtypes and from .eager.dtypes import dtypefrom .dtypes import dtype.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Imports march in a line so neat,
From eager to language they retreat,
New properties shine: bits and bytes,
A cleaner structure now in sight!
dtypes dance in their proper place.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: moving dtypes from eager to language and adding bits/bytes properties.

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

✨ Finishing touches
  • 📝 Generate docstrings

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)
tilelang/dtypes.py (1)

1-3: New re-export module looks good, with minor cleanup opportunity.

The new tilelang/dtypes.py module successfully provides a convenient top-level import path for dtype definitions. Line 3's explicit imports are redundant since line 2 already imports everything via wildcard, but they serve as useful documentation for the primary public symbols.

The static analysis hints suggest the noqa directives may be unnecessary if F401 (unused imports) is not enabled in your linter configuration. Consider removing them or verifying your linter settings.

♻️ Optional cleanup of noqa directives

If F401 is not enabled in your linter, the noqa directives can be removed:

 # Re-export from language.dtypes for convenient access via `from tilelang.dtypes import ...`
-from tilelang.language.dtypes import *  # noqa: F401, F403
-from tilelang.language.dtypes import dtype, AnyDType, get_tvm_dtype  # noqa: F401
+from tilelang.language.dtypes import *  # noqa: F403
+from tilelang.language.dtypes import dtype, AnyDType, get_tvm_dtype

Alternatively, if the explicit imports on line 3 are purely for documentation and your team prefers cleaner code, you could remove line 3 entirely since the wildcard already imports these symbols.

tilelang/__init__.py (1)

163-163: Import path update looks correct.

The change from from .language.eager import dtypes to from .language import dtypes correctly reflects the module reorganization.

The static analysis tool suggests the noqa: F401 directive may be unnecessary. If dtypes is properly re-exported (e.g., via __all__ or other means), the directive can be removed as cleanup.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6e43953 and e1a8e50.

📒 Files selected for processing (9)
  • testing/python/language/test_tilelang_language_frontend_v2.py
  • tilelang/__init__.py
  • tilelang/dtypes.py
  • tilelang/jit/adapter/tvm_ffi.py
  • tilelang/language/allocate.py
  • tilelang/language/dtypes.py
  • tilelang/language/eager/__init__.py
  • tilelang/language/eager/ast.py
  • tilelang/language/eager/builder.py
🧰 Additional context used
🧬 Code graph analysis (2)
tilelang/jit/adapter/tvm_ffi.py (1)
tilelang/language/dtypes.py (1)
  • dtype (14-19)
tilelang/dtypes.py (1)
tilelang/language/dtypes.py (2)
  • dtype (14-19)
  • get_tvm_dtype (236-239)
🪛 Ruff (0.14.10)
tilelang/__init__.py

163-163: Unused noqa directive (non-enabled: F401)

Remove unused noqa directive

(RUF100)

tilelang/language/eager/__init__.py

2-2: from ..dtypes import * used; unable to detect undefined names

(F403)

tilelang/dtypes.py

2-2: Unused noqa directive (non-enabled: F401)

Remove unused noqa directive

(RUF100)


3-3: Unused noqa directive (non-enabled: F401)

Remove unused noqa directive

(RUF100)

⏰ 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)
🔇 Additional comments (8)
tilelang/jit/adapter/tvm_ffi.py (1)

22-22: LGTM! Import path correctly updated.

The import path change from tilelang.language.eager.dtypes to tilelang.language.dtypes aligns with the PR's objective to move dtype definitions to a more general-purpose location.

tilelang/language/eager/ast.py (1)

18-18: LGTM! Relative import correctly updated.

The change from . import dtypes to .. import dtypes correctly adjusts the relative import to reference the parent package, reflecting the move of dtypes from tilelang.language.eager to tilelang.language.

testing/python/language/test_tilelang_language_frontend_v2.py (1)

43-43: LGTM! Test import updated correctly.

The import path for _all_dtypes has been correctly updated to reflect the new location of the dtypes module.

tilelang/language/eager/builder.py (1)

30-30: LGTM! Relative import correctly adjusted.

The change from . import dtypes as dt to .. import dtypes as dt properly updates the relative import to reference the parent package, consistent with the dtypes module relocation.

tilelang/language/dtypes.py (2)

225-233: Implementation of bytes property looks correct.

The bytes property is properly implemented as an alias for itemsize, which is a standard attribute on data types. The implementation follows Python property conventions correctly.


15-18: No changes needed — tvm.DataType has a native bits property.

The bits property is provided by tvm.DataType and is widely used throughout the codebase (e.g., DataType(dtype).bits in tests and production code). Only bytes required a custom implementation via __dtype_bytes__() since it wasn't available on the underlying tvm.DataType. The type hints at lines 15-18 are accurate and complete.

tilelang/language/allocate.py (1)

31-32: Import path updates are correct.

The changes from from .eager import dtypes to from . import dtypes and from from .eager.dtypes import dtype to from .dtypes import dtype correctly reflect the reorganization of the dtypes module from the eager subpackage to the language package level.

tilelang/language/eager/__init__.py (1)

2-2: Re-export path updated correctly.

The change from from .dtypes import * to from ..dtypes import * properly redirects the re-export to the new centralized dtypes module location in the parent language package, maintaining backward compatibility for code importing from tilelang.language.eager.

Note: The F403 static analysis warning about wildcard imports is expected and acceptable in re-export modules like this one.

@LeiWang1999 LeiWang1999 merged commit 01d651a into tile-ai:main Jan 9, 2026
7 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.

1 participant