- 
                Notifications
    
You must be signed in to change notification settings  - Fork 294
 
[bug] fix type object is not subscriptable in py38 #959
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
[bug] fix type object is not subscriptable in py38 #959
Conversation
| 
           👋 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! 🚀  | 
    
          
WalkthroughUpdated 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
 Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
 Pre-merge checks and finishing touches❌ Failed checks (1 warning)
 ✅ Passed checks (2 passed)
 ✨ Finishing touches
 🧪 Generate unit tests (beta)
 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   | 
    
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: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 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
Listto the typing imports is the correct fix for Python 3.8 compatibility, where PEP 585 built-in generics are not yet available.
| params: List[KernelParam], | ||
| result_idx: List[int], | 
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.
🧩 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.
| 
           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.  | 
    
| 
           Adding  At the framework level, we may need a   | 
    
| 
           @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.  | 
    
Py3.9+ support
list[KernelParam].Summary by CodeRabbit