- 
                Notifications
    You must be signed in to change notification settings 
- Fork 292
[Target] Enhance target selection helpers and documentation #1085
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Commit Message: - add SUPPORTED_TARGETS metadata and expose describe_supported_targets() - relax target validation to accept option suffixes and upgrade error messages - document target usage and compute capability mapping in docs/get_started/targets.md - note preference for string targets when caching and link the new guide in docs/index.md
| WalkthroughAdds documentation for configuring build targets and centralizes target validation/normalization into a new/expanded utility mapping; kernel code now delegates target resolution to that utility. Also removes a codespell setting. Changes
 Sequence Diagram(s)sequenceDiagram
  autonumber
  participant Kernel as Kernel (jit/kernel.py)
  participant Utils as target utils (tilelang/utils/target.py)
  participant TVM as TVM Target
  Kernel->>Utils: determine_target(target_input, return_object=true)
  alt input is TVM Target
    Utils-->>Kernel: return same TVM Target
  else input is string or options
    Utils->>TVM: TVM Target(string + options)  -- attempt construct
    TVM-->>Utils: TVM Target object / error
    Utils-->>Kernel: TVM Target object
  end
  note right of Kernel: Kernel uses the returned TVM Target directly
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
 Poem
 Pre-merge checks and finishing touches✅ Passed checks (3 passed)
 ✨ Finishing touches🧪 Generate unit tests (beta)
 📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
 💤 Files with no reviewable changes (1)
 ⏰ 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). (4)
 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. Comment  | 
| 👋 Hi! Thank you for contributing to the TileLang project. Please remember to run  We appreciate you taking this step! Our team will review your contribution, and we look forward to your awesome work! 🚀 | 
There was a problem hiding this 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 (1)
tilelang/utils/target.py (1)
100-116: Enhanced target validation logic is solid.The refactored validation correctly:
- Accepts
Targetinstances directly without re-parsing- Validates strings by attempting to construct a
Target(catches invalid options)- Provides helpful error messages listing all supported targets with examples
The static analyzer flags the long exception messages at lines 105, 110-113, and 116 (TRY003). While the messages are helpful, you could optionally extract them to a module-level constant or helper function if you want to satisfy the linter:
def _build_unsupported_target_error(target: str) -> str: examples = ", ".join(f"`{name}`" for name in SUPPORTED_TARGETS) return ( f"Target {target} is not supported. Supported targets include: {examples}. " "Pass additional options after the base name, e.g. `cuda -arch=sm_80`." )Then use:
raise AssertionError(_build_unsupported_target_error(target)) from err
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
- docs/get_started/targets.md(1 hunks)
- docs/index.md(1 hunks)
- tilelang/jit/kernel.py(2 hunks)
- tilelang/utils/target.py(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
tilelang/utils/target.py (1)
tilelang/language/ast/ir.py (1)
target(1682-1713)
tilelang/jit/kernel.py (1)
tilelang/utils/target.py (1)
determine_target(61-122)
🪛 LanguageTool
docs/get_started/targets.md
[style] ~102-~102: Consider using the synonym “brief” (= concise, using a few words, not lasting long) to strengthen your wording.
Context: ...upported targets in code  Looking for a quick reminder of the built-in base names and...
(QUICK_BRIEF)
🪛 Ruff (0.14.1)
tilelang/utils/target.py
105-105: Avoid specifying long messages outside the exception class
(TRY003)
110-113: Avoid specifying long messages outside the exception class
(TRY003)
116-116: Avoid specifying long messages outside the exception class
(TRY003)
⏰ 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). (1)
- GitHub Check: Quick Lint
🔇 Additional comments (10)
tilelang/utils/target.py (3)
9-17: LGTM! Clear and well-documented target metadata.The public constant provides useful descriptions for all supported targets, including guidance on options like
cuda -arch=sm_80.
20-24: LGTM! Clean helper for runtime target discovery.Returning a copy prevents external modification of the constant, which is good defensive programming.
118-122: LGTM! Efficient return_object handling.The optimization at lines 119-120 correctly avoids re-constructing a
Targetwhen the input is already aTargetinstance.tilelang/jit/kernel.py (2)
14-14: LGTM! Simplified import reflects centralized target handling.Delegating to
determine_targetremoves the need to import and validate againstAVALIABLE_TARGETSlocally.
93-94: LGTM! Cleaner target resolution.The refactored code correctly delegates target validation and object construction to
determine_target, which now handles all the validation logic including Target instances, string normalization, and error messages.docs/index.md (1)
17-17: LGTM! Documentation structure updated correctly.The new targets page is appropriately placed in the "GET STARTED" section alongside Installation and overview.
docs/get_started/targets.md (4)
1-22: LGTM! Clear introduction to targets.The overview effectively explains what targets are and provides a helpful reference table that aligns with the
SUPPORTED_TARGETSconstant in the code.
23-72: LGTM! Comprehensive target usage examples.The examples clearly demonstrate target string syntax, and the compute capability mapping table is a valuable reference. The note about when
-archflags matter (autotuning) vs when they're optional (general use) is particularly helpful.
73-99: LGTM! Practical guidance on programmatic target creation.The examples demonstrate both
determine_targetand direct TVMTargetusage. The recommendation to prefer strings overTargetinstances for caching (lines 96-98) is valuable operational advice that aligns with the PR objectives.
100-120: LGTM! Helpful discovery and troubleshooting guidance.The
describe_supported_targets()example provides a practical way to list targets at runtime, and the troubleshooting tips address common issues users might encounter.
Commit Message:
Now we can support target = "cuda -arch=sm_80" to compile a sm80 kernel on any machines.
Summary by CodeRabbit
Documentation
New Features
Refactor
Chores