Skip to content

fix: migrate TVM API from tir to s_tir/tirx for apache-tvm 0.25#1

Open
WilliamOdinson wants to merge 1 commit into
mlsyscourse:mainfrom
WilliamOdinson:fix/tvm-0.25-api-migration
Open

fix: migrate TVM API from tir to s_tir/tirx for apache-tvm 0.25#1
WilliamOdinson wants to merge 1 commit into
mlsyscourse:mainfrom
WilliamOdinson:fix/tvm-0.25-api-migration

Conversation

@WilliamOdinson

Copy link
Copy Markdown

Summary

apache-tvm 0.25 renamed/reorganized the TensorIR scheduling API. This PR migrates all assignment2 code to the new API so the assignment works with the current TVM release.

The schedule in schedule_example.ipynb was verified on Google Colab with a T4 GPU.

Note

My Colab install command is:

python -m pip install --pre -U -f https://mlc.ai/wheels mlc-llm-nightly-cu128 mlc-ai-nightly-cu128

API changes

Old (tvm <0.25) New (apache-tvm 0.25)
from tvm import tir from tvm import s_tir
from tvm.script import tir as T from tvm.script import tirx as T
from tvm.tir.schedule import BlockRV from tvm.s_tir.schedule import SBlockRV
from tvm import meta_schedule as ms from tvm.s_tir import meta_schedule as ms
from tvm.meta_schedule.space_generator import ScheduleFn from tvm.s_tir.meta_schedule.space_generator import ScheduleFn
tir.Schedule(...) s_tir.Schedule(...)
@T.prim_func @T.prim_func(s_tir=True)
T.alloc_buffer(...) T.sblock_alloc_buffer(...)
T.block("name") T.sblock("name")
sch.get_block("name") sch.get_sblock("name")
T.thread_binding(N, "blockIdx.x") T.thread_binding(N, thread="blockIdx.x")
tvm.nd.array(...) tvm.runtime.tensor(...)
tvm.nd.empty(...) tvm.runtime.empty(...)
tvm.cuda() tvm.runtime.cuda() (or from tvm.runtime import cuda)
tvm.testing.assert_allclose(...) np.testing.assert_allclose(...)
f.imported_modules[0].get_source() f.imports[0].inspect_source()

Known limitation

reference.py is not included in this PR. As a student I don't have the correct solution to regenerate it against the new API; this file should be updated by course staff.

@WilliamOdinson WilliamOdinson marked this pull request as ready for review July 10, 2026 03:00
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