Skip to content

Conversation

@LeiWang1999
Copy link
Member

@LeiWang1999 LeiWang1999 commented Oct 21, 2025

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

Now we can support target = "cuda -arch=sm_80" to compile a sm80 kernel on any machines.

Summary by CodeRabbit

  • Documentation

    • Added a comprehensive "Targets" guide (usage, examples, advanced options, troubleshooting) and linked it in the Getting Started index.
  • New Features

    • Added a runtime API to list and describe supported compilation targets.
    • Improved target validation with clearer, more helpful error messages.
  • Refactor

    • Centralized target resolution to simplify behavior and make validation more consistent.
  • Chores

    • Cleaned up a codespell configuration entry.

  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
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 21, 2025

Walkthrough

Adds 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

Cohort / File(s) Summary
Documentation
docs/get_started/targets.md, docs/index.md
New guide explaining target names, option syntax, hardware/arch tags, programmatic creation (helpers), troubleshooting; added to docs toctree.
Target utilities (API & logic)
tilelang/utils/target.py
Replaced/expanded previous mapping with SUPPORTED_TARGETS (Dict[str,str]); added describe_supported_targets(); refactored determine_target() to accept TVM Target instances, validate strings by constructing a Target, and raise clearer errors listing supported targets.
Kernel target handling
tilelang/jit/kernel.py
Removed import of AVALIABLE_TARGETS; simplified logic to call determine_target(target, return_object=True) and use the returned TVM Target object directly.
Build config
pyproject.toml
Removed builtin = "clear,rare,en-GB_to_en-US" from [tool.codespell].

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hopped through targets, one by one,

SUPPORTED_TARGETS now shines like sun,
Docs to guide each arch and flag,
determine_target clears the lag,
Hooray — build paths neatly done!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "[Target] Enhance target selection helpers and documentation" accurately captures the main objectives of this pull request. The changeset introduces three key enhancements: new documentation in docs/get_started/targets.md, enhanced helper functions (SUPPORTED_TARGETS constant and describe_supported_targets() function) in tilelang/utils/target.py, and improved target validation logic in determine_target. The title is concise, specific, and clearly conveys that the changes focus on improving target selection capabilities and their documentation, which aligns well with the actual implementation details across all modified files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3636719 and d90a4e1.

📒 Files selected for processing (1)
  • pyproject.toml (0 hunks)
💤 Files with no reviewable changes (1)
  • pyproject.toml
⏰ 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)
  • GitHub Check: Test for Python 3.12 with Metal (on macos-latest)
  • GitHub Check: Build wheels for Python 3.8 on ubuntu-latest with CUDA-12.1
  • GitHub Check: Build wheels for Python 3.8 on macos-latest with Metal
  • GitHub Check: Build wheels for Python 3.8 on ubuntu-24.04-arm with CUDA-12.8

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.

@github-actions
Copy link

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

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

100-116: Enhanced target validation logic is solid.

The refactored validation correctly:

  • Accepts Target instances 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

📥 Commits

Reviewing files that changed from the base of the PR and between 1d4b718 and 3636719.

📒 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 Target when the input is already a Target instance.

tilelang/jit/kernel.py (2)

14-14: LGTM! Simplified import reflects centralized target handling.

Delegating to determine_target removes the need to import and validate against AVALIABLE_TARGETS locally.


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_TARGETS constant 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 -arch flags 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_target and direct TVM Target usage. The recommendation to prefer strings over Target instances 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.

@LeiWang1999 LeiWang1999 merged commit 42c267e into tile-ai:main Oct 21, 2025
12 of 14 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