AGENT SKILL

relax-compile

Guides TVM Relax IR construction/import, optimization pipelines, tvm.compile, executable export/load, and custom codegen boundaries.

License 许可
Apache-2.0
最近更新
2026-09-03
Stars
★ 351
Forks
27

01 前言 Front Matter

name
relax-compile
license
Apache 2.0
metadata
{ "disco-role": "operating" }
description
Guides TVM Relax IR construction/import, optimization pipelines, tvm.compile, executable export/load, and custom codegen boundaries.
disable-model-invocation
true

02 资源文件 4

03 SKILL.md 正文

Relax Compile Workflows

Use this sub-skill when a task involves high-level TVM Relax IR, model import, optimization pipelines, tvm.compile, VM execution, or deployable executable artifacts.

Route

  1. Confirm TVM imports and has the target backend required by the task. If not, first use ../install-build/SKILL.md.
  2. Decide how the IRModule is created: Relax NN frontend, TVMScript Relax, PyTorch/ONNX frontend import, or an existing IRModule.
  3. Apply the smallest needed pipeline or pass sequence. relax.get_pipeline("zero") is a safe baseline for tutorial-style CPU workflows; larger model and dlight flows need backend-specific checks.
  4. Compile through tvm.compile(mod, target, relax_pipeline=..., tir_pipeline=...).
  5. Run the executable locally with relax.VirtualMachine or export/load it for a deployment workflow.
  6. Use references/troubleshooting.md when the failure is about target mismatch, optional frontend dependencies, export/load, or pass/codegen boundaries.

Common decisions

  • Tiny local CPU compile: create or adapt a small Relax IRModule and target llvm. Run scripts/relax_compile_smoke.py before diagnosing a larger model.
  • PyTorch or ONNX import: require the matching frontend dependency and a small example input. Keep model downloads, weights, and external datasets out of the first debugging loop.
  • Custom optimization: keep Relax graph passes and TIR/S-TIR scheduling passes separate. Route schedule/meta-schedule decisions to ../s-tir-tuning/SKILL.md.
  • Remote execution: compile/export locally, then use ../rpc-deployment/SKILL.md for upload/load/run and tracker/server details.

API anchor

The verified top-level compile entry point is:

tvm.compile(
    mod,
    target=None,
    *,
    relax_pipeline="default",
    tir_pipeline="default",
)

It accepts a Relax/TIR IRModule or TIRx PrimFunc and returns a runtime Executable. The pipeline arguments accept a named pipeline, pass object, or callable depending on the workflow.

Boundaries

  • Build/import failures are not Relax failures; route to install-build.
  • TIRx PrimFunc authoring and tile primitive lowering use tirx-kernels.
  • S-TIR schedule primitives and meta-schedule tuning use s-tir-tuning.
  • RPC trackers, servers, proxies, and remote-device triage use rpc-deployment.

04 同仓库更多 Skills

VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-triton-opt

Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-solve

END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-skill

PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-pattern-fusion

Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-orchestrate

Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-feedback

Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).

★ 351