Skip to content

Conversation

@BBuf
Copy link
Contributor

@BBuf BBuf commented Oct 9, 2025

docker run --gpus all -v /home/bbuf:/home/bbuf -it --rm --ipc=host nvcr.io/nvidia/pytorch:
23.01-py3

python3 /home/bbuf/tilelang/examples/elementwise/test_example_elementwise.py
Traceback (most recent call last):
  File "/home/bbuf/tilelang/examples/elementwise/test_example_elementwise.py", line 1, in <module>
    import tilelang.testing
  File "/home/bbuf/tilelang/tilelang/__init__.py", line 82, in <module>
    from .jit import jit, JITKernel, compile  # noqa: F401
  File "/home/bbuf/tilelang/tilelang/jit/__init__.py", line 19, in <module>
    from tilelang.jit.adapter.utils import is_metal_target
  File "/home/bbuf/tilelang/tilelang/jit/adapter/__init__.py", line 6, in <module>
    from .torch import MetalKernelAdapter  # noqa: F401
  File "/home/bbuf/tilelang/tilelang/jit/adapter/torch/__init__.py", line 1, in <module>
    from .metal import MetalKernelAdapter
  File "/home/bbuf/tilelang/tilelang/jit/adapter/torch/metal.py", line 13, in <module>
    class MetalKernelAdapter(BaseKernelAdapter):
  File "/home/bbuf/tilelang/tilelang/jit/adapter/torch/metal.py", line 17, in MetalKernelAdapter
    params: list[KernelParam],
TypeError: 'type' object is not subscriptable
root@5cf8a7876e56:/home/bbuf/tilelang# python3
Python 3.8.10 (default, Nov 14 2022, 12:59:47) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

Py3.9+ support list[KernelParam] .

Summary by CodeRabbit

  • Chores
    • Standardized public type annotations to use consistent generic types.
    • No changes to runtime behavior or performance.
    • No user-facing impact; functionality remains unchanged.

@github-actions
Copy link

github-actions bot commented Oct 9, 2025

👋 Hi! Thank you for contributing to the TileLang project.

Please remember to run bash format.sh 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 Oct 9, 2025

Walkthrough

Updated type annotations in tilelang/jit/adapter/torch/metal.py: constructor parameters in MetalKernelAdapter now use typing.List for KernelParam and int arrays; corresponding typing import added. No runtime or control flow changes.

Changes

Cohort / File(s) Summary
Type hint updates
tilelang/jit/adapter/torch/metal.py
Switched annotations from built-in list[...] to typing.List[...] for parameters and indices; added List to imports. No logic changes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

I twitch my whiskers at types so neat,
Lists now wear caps—how dapper, how sweet!
No gears were turned, no logic spun,
Just annotations, crisp and done.
Hippity-hop, I stamp approval—
Small hops count in big code’s removal.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ 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 clearly describes fixing the "type object is not subscriptable" error encountered in Python 3.8. It concisely captures the main objective of the changeset without extraneous details. The use of "py38" is concise and widely understood while remaining specific about the target environment.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9a7cda4 and a35a4c0.

📒 Files selected for processing (1)
  • tilelang/jit/adapter/torch/metal.py (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tilelang/jit/adapter/torch/metal.py (2)
tilelang/jit/kernel.py (1)
  • params (466-467)
tilelang/engine/param.py (1)
  • KernelParam (12-103)
⏰ 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: build-test-metal
  • GitHub Check: format-check
🔇 Additional comments (1)
tilelang/jit/adapter/torch/metal.py (1)

2-2: LGTM! Import correctly adds Python 3.8 compatibility.

The addition of List to the typing imports is the correct fix for Python 3.8 compatibility, where PEP 585 built-in generics are not yet available.

Comment on lines +17 to +18
params: List[KernelParam],
result_idx: List[int],
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Fix correctly resolves Python 3.8 compatibility.

The type annotation changes from list[...] to List[...] directly address the Python 3.8 incompatibility issue. The changes are consistent with the existing codebase patterns shown in the relevant code snippets.

To ensure comprehensive Python 3.8 compatibility across the project, verify that no other files use PEP 585-style generics:


🏁 Script executed:

#!/bin/bash
# Description: Search for PEP 585 style generic annotations that are incompatible with Python 3.8

# Search for common PEP 585 patterns in type annotations
echo "=== Searching for PEP 585-style built-in generics ==="
rg -n --type py -P ':\s*(list|dict|set|tuple|frozenset)\[' --glob '!test*' --glob '!*_test.py'

echo ""
echo "=== Checking for 'from __future__ import annotations' ==="
rg -n --type py 'from __future__ import annotations'

Length of output: 454


🏁 Script executed:

#!/bin/bash
echo "=== Searching for PEP 585-style built-in generics in Python files ==="
rg -n ':\s*(list|dict|set|tuple|frozenset)\[' --glob '**/*.py' --glob '!**/test*' --glob '!**/*_test.py'

Length of output: 1084


One remaining PEP 585 generic in tilelang/layout/fragment.py
Line 35 uses shape: list[int], which will error at runtime on Python 3.8. Replace with List[int] (and import it from typing) or add from __future__ import annotations.

🤖 Prompt for AI Agents
tilelang/layout/fragment.py around line 35: the type annotation uses PEP 585
form "list[int]" which fails on Python 3.8; change the annotation to "List[int]"
and add "from typing import List" to the imports at the top, or alternatively
add "from __future__ import annotations" as the first line of the file to defer
evaluation of annotations; ensure only one of these fixes is applied
consistently and run tests to verify.

@LeiWang1999
Copy link
Member

LGTM. I would also like to discuss whether we have methods to avoid breaking issues for Python 3.8, particularly regarding PRs that may include syntax supported only in Python 3.9+.

But people who want to use py38 should know that py38 has been deprecated in October 2024. Would be better if you can upgrade into a newer version of python

Also cc @XuehaiPan @oraluben if you have any ideas.

@XuehaiPan
Copy link
Collaborator

Adding from __future__ import annotations to the top of the file would be sufficient. And that would not need code changes in the future.

At the framework level, we may need a py38 CI if we claim we officially support Python 3.8. But I think the benefit would be very marginal. We need to move forward, as the lowest Python version supported by PyTorch is now 3.10.

@LeiWang1999
Copy link
Member

@XuehaiPan, I agree. However, we should maintain support for Python 3.8 due to some reasons. We plan to deprecate Python 3.8 in the future once we integrate with TVM-FFI. In the meantime, I suggest introducing a simple CI that imports tilelang and runs a quick gemm test to verify python 3.8 syntax support. @yyttt6, cc'ing you when you have time.

@LeiWang1999 LeiWang1999 merged commit 6b2bb31 into tile-ai:main Oct 9, 2025
7 of 8 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.

3 participants