Skip to content

Docs reference nonexistent tvm.script / tvm.tirx paths after standalone TIRx extraction #20928

Open

Description

@erhsh

Summary

After #20803 ([REFACTOR] Consume standalone TIRx as a pinned dependency) and
#20831 ([REFACTOR] Bump TIRx and migrate object and constraint APIs), the
in-tree Python layout no longer provides tvm.script.* or tvm.tirx.*.
However, 80+ references to these paths remain under docs/ and one bundled
README
, and the executable examples that teach them now fail with
ModuleNotFoundError.

The Python tutorials under docs/deep_dive/*/tutorials/*.py were already
migrated to the new spellings (e.g. docs/deep_dive/relax/tutorials/relax_creation.py),
so only the .rst documentation and one README still teach the removed paths.

What actually works on current main

Taken from test files (e.g. tests/python/driver/test_compile.py,
tests/python/disco/test_session.py) and the migrated tutorials:

from tvm.relax import script as R        # Relax dialect
from tvm.s_tir import script as Ts       # s_tir dialect
from tvm_tirx.script import ir as I      # shared IR namespace
from tvm_tirx.script import tirx as T    # TIRx kernel dialect

@tvm.script.ir_module becomes @I.ir_module or @tvm_tirx.script.ir_module
(both are used in tests). Kernel-side APIs live under the standalone package:

compiled = tvm_tirx.tirx.compile(kernel, target="cuda", pipeline="tirx")
from tvm_tirx.tirx.layout import S, TileLayout
from tvm_tirx.tirx import transform

Why the old paths are gone

  • python/tvm/ contains no script/ or tirx/ subpackage, and a repo-wide
    grep finds no sys.modules["tvm.script"] / "tvm.tirx" binding or
    import_module("tvm...") shim in either python/tvm/ or
    3rdparty/tvm-tirx/python/.
  • The TVMScript engine now lives in tvm_tirx.script (standalone repo).
    Parent dialects register into it at import time
    (tvm_tirx.script.register_dialect("relax", "tvm.relax.script", ...),
    ("s_tir", "tvm.s_tir.script"), ("tirx", "tvm_tirx.tirx.script")), so the
    old top-level tvm.script facade has no implementation anymore.
  • from tvm.script import ... therefore fails with
    ModuleNotFoundError: No module named 'tvm.script'.

Inventory (80+ references)

from tvm.script import ... — 40 lines:

  • docs/arch/tvmscript.rst (1 code block + 2 prose mentions)
  • docs/deep_dive/relax/abstraction.rst (1), dpl.rst (2), learning.rst (4)
  • docs/deep_dive/tensor_ir/abstraction.rst (2), index.rst (1 prose),
    learning.rst (2)
  • docs/tirx/overview.rst, native_basics.rst (2), programming/index.rst,
    api/tile.rst (prose), native_basics/cuda/first_kernel.rst,
    native_basics/cuda/profiling.rst
  • 19 files under docs/tirx/tile_ops/
  • python/tvm/relax/backend/contrib/example_npu/README.md (1)

@tvm.script.ir_module decorator — 3 lines:
docs/arch/relax_vm.rst:74, docs/deep_dive/tensor_ir/learning.rst:65,240.

Engine API references in docs/arch/tvmscript.rst — 6 lines:
tvm.script.parser, tvm.script.parse, tvm.script.from_source (x2),
tvm.script.parser.protocol_registry, tvm.script.register_dialect.

tvm.tirx.* — 32 lines:

  • docs/install/pypi.rst ("including modules such as tvm.tirx")
  • docs/tirx/install.rst (3, incl. the verify snippet
    python -c "import tvm, tvm.tirx; print(tvm.__version__)")
  • docs/tirx/arch/backends.rst, arch/lowering_pipeline.rst,
    api/tile_dispatch.rst (2), docs/tirx/layout.rst
  • docs/arch/index.rst (2: tvm.tirx.Var, tvm.tirx.Add)
  • docs/tirx/overview.rst ("tvm.script.tirx is the construction syntax for
    the tvm.tirx object")
  • tvm.tirx.compile(...) in 12 docs/tirx/tile_ops/*.rst files
  • from tvm.tirx.layout import ... in 7 docs/tirx/tile_ops/*.rst files

Plus docs/reference/api/python/index.rst:73 still has a
:caption: tvm.script toctree, although the autosummary pages it points to
(docs/reference/api/python/script/*.rst) already document tvm_tirx.script.

Repro for the inventory:

grep -rEn "tvm\.script|tvm\.tirx" docs python --include="*.rst" --include="*.md" --include="*.py"

Suggested resolution — direction A: update the docs

The migrated .py tutorials already establish the target spellings:

Stale spelling Working spelling on current main
from tvm.script import relax as R from tvm.relax import script as R
from tvm.script import s_tir as Ts from tvm.s_tir import script as Ts
from tvm.script import ir as I from tvm_tirx.script import ir as I
from tvm.script import tirx as T / Tx from tvm_tirx.script import tirx as T
@tvm.script.ir_module @I.ir_module / @tvm_tirx.script.ir_module
tvm.script.parse / from_source / register_dialect / parser same under tvm_tirx.script
tvm.tirx.compile(...) tvm_tirx.tirx.compile(...)
from tvm.tirx.layout import ... from tvm_tirx.tirx.layout import ...
from tvm.tirx import transform from tvm_tirx.tirx import transform
tvm.tirx.Var / tvm.tirx.Add tvm_tirx.tirx.Var / tvm_tirx.tirx.Add
import tvm, tvm.tirx (install.rst verify) import tvm, tvm_tirx.tirx

Possible direction B: restore a compatibility facade

Some evidence suggests these spellings may have been intended to keep working:

  • Comments in 3rdparty/tvm-tirx/python/tvm_tirx/__init__.py still speak the
    embedded naming ("# tvm.script — must be imported before any dialect
    package so that tvm.script.register_dialect is reachable ...",
    "# tvm.tirx — registers itself via tvm.script.register_dialect"), which
    reads as if tvm.script / tvm.tirx bindings are expected to exist.
  • docs/tirx/install.rst says "the TIRx compiler is the tvm.tirx module".
    That statement is true for the currently published 0.27 wheel (pre-extraction
    vendored layout) but false for wheels built from this tree, so the doc was
    not wrong when written — the layout changed under it.

If a tvm.script / tvm.tirx facade is planned, this issue can track it;
otherwise I will send a docs-only PR per direction A.

Notes for whoever does the sweep

  • TVMScript printer provenance headers (# from tvm.script import ...) are
    comments emitted inside printed output; they never execute and are fine to
    keep as-is. Do not bulk-rewrite round-trip output blocks (none were found
    under docs/; they do appear in test expectations, which are correct).
  • docs/tirx/api/cuda.rst and api/ptx.rst already use the standalone
    spelling (from tvm_tirx.script import tirx as Tx), so the tree currently
    mixes both spellings for the same thing.
  • The stale comments in tvm_tirx/__init__.py may be worth updating in the
    standalone repo as a follow-up.

Activity

  1. erhsh commented on Nov 7, 2026

    @erhsh
    ContributorAuthor

    While preparing #20929, a self-review found the stale-path problem is wider than the tvm.script / tvm.tirx classes originally inventoried here. The same extraction also moved:

    • tvm.ir.* -> tvm_tirx.ir.* (transform passes, PassContext, assert_structural_equal, Call/Range/Stmt, register_op_attr, ir.type) — e.g. docs/arch/pass_infra.rst (7 refs), docs/tirx/api/tile_dispatch.rst (5)
    • tvm.target.* -> tvm_tirx.target.* (Target, target.tag) — 14 refs incl. docs/arch/relax_vm.rst, docs/tirx/install.rst verify command, the CUDA tutorials
    • tvm.IRModule -> tvm_tirx.IRModule — 7 refs
    • tvm.backend.* / tvm.codegen -> tvm_tirx.backend / tvm_tirx.codegen — 10 refs
    • tvm.runtime.{tensor,Tensor,empty,Device,load_module} -> tvm_tirx.runtime.* — the parent tvm.runtime package now only exports BenchmarkResult/time_evaluator/vm/disco — ~40 refs across tile_ops, native_basics/cuda, tutorials
    • device constructors tvm.cuda()/cpu()/metal()/vulkan() -> tvm_tirx.* — 13 refs incl. the device-detection snippet in docs/install/from_source.rst

    All of the above are covered by the second commit of #20929 (same mechanical policy; canonical spellings verified against live test code, e.g. tests/python/driver/test_compile.py uses tvm_tirx.target.Target("llvm") and tvm_tirx.ir.assert_structural_equal).

    Intentionally not changed in #20929:

    1. The two historical "separate tvm.tir object model" mentions (docs/tirx/overview.rst:115, docs/tirx/arch/lowering_pipeline.rst:155) — they contrast TIRx with the legacy TVM object model; not live API references. Could optionally be reworded to name the legacy model explicitly.
    2. docs/arch/index.rst still contains prose that tours the old source tree layout ("The tvm/ir folder contains...", "tvm/node", "tvm/target" sections). Those modules/folders now live in the tvm-tirx submodule, so the whole "Source Tree Structure" narrative deserves a dedicated rewrite rather than mechanical replacement — leaving it as a tracked follow-up here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions