Skip to main content

IntentDSL

Write an operator algorithm once. Compile it for different execution models.

English · 简体中文

Documentation Site · First Route · Handbook · Architecture · Scoreboard · V1 Archive

IntentDSL is a Python kernel language and an MLIR compiler built on CompilerInfra for GPU, CPU, and accelerator programs. Authors describe tensor computations, logical domains, accesses, state, and explicit multi-kernel composition with @I.kernel and @I.program. Compiler passes form the physical program and lower it through five native exits: Triton, cuTile, Mojo, Weft, and BANG C.

IntentDSL is a component of the Dongshan Community's TianChen AI Software Stack. This repository provides the language frontend, MLIR compiler, runtime bindings, examples, and bilingual handbook (online and offline in doc/). Development is maintained on GitHub, with a Gitee mirror.

IntentDSL paper overview: algorithm reuse and compiler workflow

Original paper overview (PDF). Target labels reflect the paper prototype; current native exits are Triton, cuTile, Mojo, Weft, and BANG C.

  • Programmable algorithms: compose reductions, contractions, indexed access, ordered recurrences, and multi-stage @I.program workflows without branching on hardware backends.
  • Reusable optimization: shared semantic analyses in KIR and execution-family passes in Block, CPU, and DSA organize ownership, reuse, and storage; downstream compilers perform final layout and instruction lowering.
  • Ordinary Python calls: compile once with I.jit, pass PyTorch tensors or native buffers, reuse warm calls across shapes within artifact guards, and inspect IR, receipts, and decisions.

Quick Start & Showcase Examples

Prebuilt manylinux_2_28_x86_64 wheels are upcoming on PyPI—bundling all five exits' compilation units (libintentdsl.so with static MLIR) so deployment environments need no LLVM/MLIR SDK ([cuda] pulls torch and triton, [cutile] pulls cuda-tile, [cpu] pulls weft-core and triton-weft; MLU uses the same wheel with host Neuware/torch_mlu, and Mojo is probed by intentdsl doctor). Until the PyPI release goes live, build from source on Linux (Python ≥3.10, CMake ≥3.22, Ninja, C++17, LLVM/MLIR 20.1.8; see First Route and Handbook).

# Upcoming on PyPI (switch to direct pip install once published):
# python -m pip install "intentdsl[cuda,cpu]"
python -m pip install torch triton
intentdsl setup --backend triton
intentdsl doctor --backend triton
python examples/demo/rmsnorm_demo.py
python examples/first_kernel.py
python examples/formulas.py
  • examples/demo/rmsnorm_demo.py: compiles one RMSNorm kernel across available exits (Triton, Mojo, Weft), verifies FP64 accuracy, and benchmarks against PyTorch eager, F.rms_norm, and torch.compile (pass --show-triton --show-ir to inspect generated code and KIR IR).
  • examples/first_kernel.py: minimal starter @I.kernel compiling row-wise Softmax to Triton and verifying against PyTorch:
import torch
import intentdsl as I


@I.kernel
def softmax(x: I.In[I.f16, ("M", "N")], out: I.Out[I.f16, ("M", "N")]):
    for row in I.parallel(x.dim(0)):
        v = I.cast(x[row, :], I.f32)
        peak = I.reduce(v, axis=0, combine=I.max_num, init=I.neg_inf(I.f32))
        w = I.exp(v - peak)
        out[row, :] = I.cast(w / I.sum(w, axis=0, acc=I.f32), I.f16)


if __name__ == "__main__":
    x = torch.randn(64, 1024, dtype=torch.float16, device="cuda")
    y = I.jit(softmax, backend="triton").run(x)
    torch.testing.assert_close(y, torch.softmax(x.float(), dim=-1).half())
    print("softmax passed")
  • examples/formulas.py & examples/inspect_candidate.py: verifies nine core operators (ReLU, Softmax, RMSNorm, LayerNorm, Transpose, Prefix Sum, Embedding, GEMM, Q6_K GEMV) and demonstrates candidate derivation via compilerinfra-dev. Over 30 complete @I.kernel and @I.program operators cover attention, FlashAttention backward, paged decode / MLA, ALiBi, state-space scans, normalizations, quantized contractions, sparse access, and mutable updates.

How the Compiler is Organized

Compiler passes consume typed semantics, def-use, coordinate relations, side effects, and target capabilities. Execution decisions are formed and verified in MLIR IR before each exit printer emits target code, allowing GPU, CPU, and DSA targets to share algorithm semantics while keeping distinct execution and storage models.

Paper figure: one logical computation realized as a GPU program, CPU task hierarchy, and DSA local-storage program

Original execution-model figure (PDF): each execution model assigns ownership and carries state across source regions; CPU implementation requirements shape local blocks, while DSA dependencies govern input-buffer reuse.

IntentDSL compilation tree from Python kernel through KIR, Block, CPU tasks, and DSA to five native exits

Compilation tree (PDF): KIR lowers to Block (feeding Triton, cuTile, and DSA → BANG C) and CPU tasks (feeding Mojo and Weft).

See the Product Architecture (local) and KIR Numerical Contracts (local) for node boundaries, exit contracts, and numerical permissions.

Performance Across Execution Models

Paper evaluation across GPU, CPU, and MLU

The following original paper figures compare complete operators against target-written implementations. Speedup is reference latency / generated latency (higher is better). Median operator latency includes preparation and required layout conversion, and excludes compilation, JIT, and tuning. See paper evaluation notes for measurement scope.

Paper GPU performance: generated Triton and cuTile against Triton references on RTX 5090D and H100

GPU (PDF): eight representative workloads and the geometric mean across all 44 common workloads on RTX 5090D (1.18× Triton, 1.20× cuTile) and H100 (1.27× Triton, 1.24× cuTile) against the paper's Triton references.

x86 CPU · 7 native comparisons MLU370 · 6 library comparisons
Paper x86 Mojo performance against five MAX-based and two independent Mojo implementations Paper MLU BANG C performance against CNNL, CNNL Extra, and TMO implementations
Original PDF Original PDF

CPU: seven generated x86 Mojo programs on eight physical cores within one NUMA node compared against five Modular/MAX and two independent Mojo references. MLU: six generated BANG C programs on MLU370 compared against CNNL, CNNL Extra, and TMO using CNCC/CNRT.

Current five-exit same-semantics scoreboard

Across RTX 5090 D, Xeon 8470Q, and MLU370, the same-semantics scoreboard (per-row CSV) evaluates 367 complete calls, of which 348 have a same-device reference under matching numerical semantics: 200 faster, 126 tied, and 22 slower (classified from the interquartile spread across three interleaved rounds; the remaining 19 rows on MLU370 have no same-semantics device reference because CNNL/torch_mlu lacks BF16, FP8, INT32-output, or device linear-algebra primitives). Each row's primary baseline is the fastest mature implementation available on the same device—including Inductor (torch.compile), library kernels, and eager execution—with every candidate required to pass the numerical criteria; see the scoreboard details.

Exit Device Faster Tied Slower Unpaired
Triton RTX 5090 D 26 39 7 0
cuTile RTX 5090 D 29 37 6 0
BANG C MLU370 39 15 6 19
Mojo Xeon 8470Q 55 16 1 0
Weft Xeon 8470Q 51 19 2 0

Representative complete-call timings from the scoreboard:

  • FlashAttention backward: on Xeon 8470Q (0–7 cores, fused SDPA contract), Mojo runs in 111.14 ms vs same-round fused SDPA 134.00 ms, and Weft runs in 107.70 ms vs 133.73 ms; on RTX 5090 D, Triton (612.35 µs) and cuTile (660.99 µs) both beat the Triton reference (765.54 / 765.31 µs); on MLU370, BANG C runs in 64.45 ms vs ATen 72.78 ms.
  • CPU ALiBi attention (Xeon 8470Q, 0–7 cores, SDPA contract): Mojo 31.88 ms vs ATen 60.21 ms; Weft 32.70 ms vs ATen 60.58 ms.
  • rms_norm_backward (4096×4096 BF16): RTX 5090 D Triton 102.40 µs and cuTile 103.97 µs tie Inductor (102.37 µs); Xeon (cores 0–7) Weft 3.73 ms and Mojo 4.37 ms both beat Inductor (8.47 ms).

Independent baselines, numerical verdicts, and raw CSVs are maintained in Intent-Bench.

Documentation, Agents & Contributing

  • Online Documentation (https://tianchen-ai.github.io/Intent/): English Handbook · 中文工具书 · First Route · Scoreboard
  • Agent & Developer Entry (5 min): build out-of-source (cmake -S . -B build/intent), then run compilerinfra-dev --workspace . layout, components, doctor, and bench-describe <workload> (or intentdsl layout / intentdsl doctor / intentdsl manual --lang en; see AGENTS.md and agent/skills/intentdsl-development.md).
  • Extending Examples & Benchmarks: place new @I.kernel / @I.program operators under examples/<domain>/ and minimal IR reproducers under test/<domain>/. In Intent-Bench, register workloads in src/intent_bench/workloads/<domain>.py, library providers in src/intent_bench/providers/<lib>.py, and licensed upstream baselines in src/intent_bench/references/<upstream>/, then run INTENT_ROOT="$PWD" intent-bench run <workload> ... in-place on the target machine.
  • Contributing & Issues: start with doc/architecture.en.md and doc/manual.en.md; enable .githooks/pre-push (git config core.hooksPath .githooks) before pushing, and report reproducible issues in GitHub Issues.

IntentDSL is licensed under Apache-2.0. Third-party components retain their own notices and licenses.

Metadata

Release files for intentdsl 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for intentdsl 2.1.0
File Size Uploaded Provenance Actions
intentdsl-2.1.0.tar.gz 3.3 MB Without provenance Details for intentdsl-2.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for intentdsl 2.1.0
File Interpreter ABI Platform Actions
intentdsl-2.1.0-py3-none-manylinux_2_38_riscv64.whl Python 3 none Linux glibc 2.38+ RISC-V 64 Details for intentdsl-2.1.0-py3-none-manylinux_2_38_riscv64.whl
intentdsl-2.1.0-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details for intentdsl-2.1.0-py3-none-manylinux_2_28_x86_64.whl

Total release size: 29.2 MB

Release files / intentdsl-2.1.0.tar.gz

Download URL intentdsl-2.1.0.tar.gz
Size 3.3 MB
Tags Source
SHA-256 checksum
How to use checksums
4bd05445dec204b4caf3bf87bedabc62ef708ebd5483655246cfe8c4c8dc8e29
BLAKE2b-256 checksum
How to use checksums
272db2b08544425fe16a6f8399787b24d391ea6ec0cb632b3effb98fced60703
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

Release files / intentdsl-2.1.0-py3-none-manylinux_2_38_riscv64.whl

Download URL intentdsl-2.1.0-py3-none-manylinux_2_38_riscv64.whl
Size 12.7 MB
Tags Linux glibc 2.38+ RISC-V 64 Python 3
SHA-256 checksum
How to use checksums
b8842104992a9460958cc18ce2d0c8e457cb7d0034fb4976dadd2c740cd5489a
BLAKE2b-256 checksum
How to use checksums
afd1fcd4c268702fcf136261f23e10ba83779e96b99f7c6a598eb1a77aeb6614
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

Release files / intentdsl-2.1.0-py3-none-manylinux_2_28_x86_64.whl

Download URL intentdsl-2.1.0-py3-none-manylinux_2_28_x86_64.whl
Size 13.1 MB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
753cb499adc76f4894ee26e7ca43227a1e2caf00f7945fe0925d142416be5eb7
BLAKE2b-256 checksum
How to use checksums
8b2f839e63e7bc7ce0a53fb4fbe438ca1a1da8a62f81c2a35eb41823f7edc35f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

Security for intentdsl 2.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page