Zirium is a Rust library and command-line tool for reading, inspecting, editing, and writing textual MLIR, with typed Python bindings. It works without linking LLVM. The parser preserves the original bytes, including comments, whitespace, malformed syntax, and invalid UTF-8. A separate semantic representation supports verification and structural edits.
Compare structural and SSA changes between two MLIR documents:
zirium --diff before.mlir after.mlir 'filter(dialect("arith")) | json'
See semantic diff for the comparison and query contract.
Version 0.7.0 is experimental. It targets MLIR 22.1 textual syntax and supports selected custom dialect forms. The API may change without a migration path; bytecode and ODS/TableGen loading are unsupported.
Homepage and guides · Rust API
Installation
Install the Python package with:
python -m pip install zirium==0.7.0
Published wheels cover CPython 3.11 through 3.14 on Linux x86_64 and macOS arm64. Wheels are specific to each CPython version. Other platforms require a local source build and are unsupported.
CLI binaries
CLI archives are produced by the release workflow for Linux x86_64 (static musl) and macOS arm64 (macOS 11 or newer). They require neither Rust nor Python.
Download the matching zirium-0.7.0-TARGET.tar.gz archive and its .sha256
file from the 0.7.0 release:
| Platform | Target |
|---|---|
| Linux x86_64, kernel 3.2 or newer | x86_64-unknown-linux-musl |
| macOS arm64, macOS 11 or newer | aarch64-apple-darwin |
In the download directory, select your target from the table:
target=aarch64-apple-darwin
archive=zirium-0.7.0-$target.tar.gz
shasum -a 256 -c "$archive.sha256"
tar -xzf "$archive"
mkdir -p "$HOME/.local/bin"
install -m 755 "${archive%.tar.gz}/zirium" "$HOME/.local/bin/zirium"
"$HOME/.local/bin/zirium" --version
Add $HOME/.local/bin to your PATH if it is not already there. On Linux,
sha256sum -c "$archive.sha256" can also verify the checksum.
The archive naming follows cargo-binstall conventions, so users with
cargo-binstall can install a
release that provides binaries with cargo binstall zirium --version '=0.7.0'.
CLI from source
Rust builds require Rust 1.88 or newer. Install the published CLI with:
cargo install zirium --version '=0.7.0' --locked
From a checkout of the matching release, use:
git clone --branch v0.7.0 --depth 1 https://github.com/zayenz/zirium.git
cd zirium
cargo install --path crates/zirium --locked
The Python wheel does not include the CLI. The getting-started guide covers Rust usage and building the Python extension locally.
For a Rust application, add the library dependency:
[dependencies]
zirium = "=0.7.0"
Command-line utility
The zirium binary queries and edits textual MLIR. Pass the query first,
followed by any input files. With no input files, it reads from standard input.
For example, this selects every arith.addi operation in input.mlir:
zirium 'filter(op("arith.addi"))' input.mlir
Use zirium --help for CLI options and --list-presets for dialect coverage.
Value-taking long options accept both --option VALUE and --option=VALUE.
Use -f - for a literal query file named -; it does not read query source
from stdin. An MLIR stdin operand (-) may be supplied only once.
For semantic queries on StableHLO, pass --preset stablehlo --strict to reject
unsupported custom forms rather than continuing with incomplete information.
To count each operation type within each function, save this as a query file
and run it with zirium --preset stablehlo -f counts.zirium model.mlir:
functions = filter(op("func.func"));
functions | map_by(attr("sym_name"), children | subtree | names | tally) | json
Add reachable | before names to include supported referenced bodies,
counting each reachable operation once.
Scalar expressions, collections and pure functions use Zirql. Zirium supplies MLIR operations, SSA traversal, dialect rules and edit safety. The local calculated-value guide explains the value syntax with runnable Zirium examples; the Zirql reference provides further detail on the shared language.
The query language reference lists every predicate and pipeline stage. The CLI examples show complete queries, dependency slices, and edits.
You can also run the binary from a source checkout with Cargo:
cargo run --quiet --bin zirium -- \
'filter(op("arith.addi"))' input.mlir
Python example
import zirium
source = """\
"builtin.module"() ({
%value = "example.make"() : () -> i32
"example.consume"(%value) : (i32) -> ()
}) : () -> ()
"""
parsed = zirium.parse_text(source)
assert parsed.original_bytes() == source.encode()
lowered = parsed.lower_strict("semantic")
if lowered.document is None:
for diagnostic in lowered.diagnostics:
print(diagnostic.range, diagnostic.message)
raise SystemExit(1)
document = lowered.document
document.validate_structure()
table = document.operation_table()
print([table.operation(index).name for index in range(table.count)])
print(document.canonical_bytes().decode(), end="")
A File owns the original bytes, tokens, concrete syntax tree (CST), and
diagnostics. A Document owns resolved semantic data. Use the file to inspect
malformed source; use the document for semantic queries and structural edits.
Structured queries
Rust and Python can build reusable queries without query source strings:
from zirium.query import ops, op
consumers = ops().filter(op("example.make")).users().unique()
selected = document.query(consumers)
counts = document.query(consumers.names().tally())
Rust uses the same builders: document.query(&consumers)?. Queries return native
operation handles, strings, counts, and maps. The structured query guide
covers predicates, nested queries, semantic projections, and evaluation limits.
Output modes
Zirium has four output paths, each with a different contract:
| Output | Source object | Contract |
|---|---|---|
| Original | Parsed file | Reproduces the input bytes exactly. |
| Formatted | Parsed file or semantic document | Normalizes layout while retaining source assembly, names, aliases, and comments where available. |
| Canonical | Semantic document | Emits deterministic generic MLIR from semantic storage. |
| Preserving | Hybrid semantic document | Copies unchanged source and regenerates edited operations or blocks. |
Use zirium 'format' input.mlir for source-aware formatting. Pass
format(assembly = "generic") to regenerate quoted generic operations before
applying the same layout. Canonical output also normalizes SSA names and does
not preserve comments or aliases. Use original output to reproduce the input,
or hybrid retention when edits should preserve unrelated source text.
For the exact structural-editing limits of Rust, Python, and the CLI, see the structural editing capability matrix.
Dialect support
Generic quoted operations are handled without a dialect registry. Unknown dialect types and attributes keep their balanced bodies as opaque values.
The baseline registry covers selected Builtin, Func, Arith, and CF operations. Bundled presets add custom forms from other dialects. Unsupported forms use best-effort recovery. Presets support structural queries, without full dialect verification or execution.
The custom-format guide explains registry configuration, operation shapes, and use from Rust, Python, and the CLI. The preset reference groups the available dialects and links to their exact registry definitions.
The corpus notes
describe how syntax compatibility is checked against llvmorg-22.1.0.
The cross-interface capability reference compares parsing, verification, queries, construction, mutation, output, callbacks, registries, and resource limits across Rust, Python, and the CLI.
Agent skills
The repository includes optional skills for agents working with Zirium:
- CLI: queries, reports, dependency slices, and complete-document edits.
- Python: typed API usage, diagnostics, retention, and transactions.
- Rust: library integration and document ownership.
- Custom formats: research a project's dialect and build a registry; explicitly invoked as
$zirium-custom-format.
Install each skill folder independently through your agent's skill mechanism. Skills are distributed in the repository, outside the Python wheel and Rust crate.
Repository layout
crates/zirium/ Core Rust library
crates/zirium-python/ PyO3 extension module
python/zirium/ Python package and type declarations
python/tests/ Python API tests
tests/corpus/ Versioned MLIR compatibility corpus
docs/ Usage, compatibility, and architecture notes
skills/ Agent guidance for CLI, libraries, and custom formats
fuzz/ Lexer and parser fuzz targets
The architecture notes describe the syntax representation and processing benchmarks.
Development
Run the Rust workspace tests from the repository root:
cargo test --workspace
The compatibility guide lists the full CI checks, supported toolchains, and wheel checks. The getting-started guide covers Python development, and the release guide describes packaging and publication.
License
Zirium's original code is available under the MIT or Apache 2.0 license. Some MLIR-derived or adapted test material carries the source attribution and license notices recorded in the corpus manifest.
Release history is recorded in the changelog.
Metadata
Release files for zirium 0.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| zirium-0.7.0.tar.gz | 555.9 kB | With provenance | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| zirium-0.7.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.14 | CPython 3.14 | Linux glibc 2.17+ x86-64 | Details |
| zirium-0.7.0-cp314-cp314-macosx_11_0_arm64.whl | CPython 3.14 | CPython 3.14 | macOS 11.0+ ARM64 | Details |
| zirium-0.7.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.13 | CPython 3.13 | Linux glibc 2.17+ x86-64 | Details |
| zirium-0.7.0-cp313-cp313-macosx_11_0_arm64.whl | CPython 3.13 | CPython 3.13 | macOS 11.0+ ARM64 | Details |
| zirium-0.7.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.12 | CPython 3.12 | Linux glibc 2.17+ x86-64 | Details |
| zirium-0.7.0-cp312-cp312-macosx_11_0_arm64.whl | CPython 3.12 | CPython 3.12 | macOS 11.0+ ARM64 | Details |
| zirium-0.7.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.11 | CPython 3.11 | Linux glibc 2.17+ x86-64 | Details |
| zirium-0.7.0-cp311-cp311-macosx_11_0_arm64.whl | CPython 3.11 | CPython 3.11 | macOS 11.0+ ARM64 | Details |
Total release size: 32.2 MB
Release files / zirium-0.7.0.tar.gz
| Download URL | zirium-0.7.0.tar.gz |
|---|---|
| Size | 555.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
61cc22e90c25ded17d4773b8d19b92665b011ba92eec4786a0db36d0fa8aee43
|
|
BLAKE2b-256 checksum How to use checksums |
834bbee729394255644a96a52d4ae391f3d782a5b7d420e1210b5c43f310dfd4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.
Transparency logRelease files / zirium-0.7.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | zirium-0.7.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 4.2 MB |
| Tags | CPython 3.14 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
6721a60aaf0d4b264f7bc806503d5f381d30543a061d965e5cdbdb5c79f16f0f
|
|
BLAKE2b-256 checksum How to use checksums |
90f8371dacbec414198fbfeb6084d203f3d1298166ed13cdcd3d4bd82add2ee6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.
Transparency logRelease files / zirium-0.7.0-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | zirium-0.7.0-cp314-cp314-macosx_11_0_arm64.whl |
|---|---|
| Size | 3.7 MB |
| Tags | CPython 3.14 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
928e76b198449c0b934f1a9d92c47ef262d6b85367b37f83853bb0314819c24c
|
|
BLAKE2b-256 checksum How to use checksums |
43db540d4f8fe359b2b80994995c9256ba64ae1172bf7f760fb800e93d10d759
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.
Transparency logRelease files / zirium-0.7.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | zirium-0.7.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 4.2 MB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
38e1670426c808de080bd296fced4e3e39c2cbb5e57552cc20ebd3e0f58ac1a6
|
|
BLAKE2b-256 checksum How to use checksums |
4b5975c7a5fa2885321bf42aa5b821314ee28fec8103bd680c38d1d607eb3fd4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.
Transparency logRelease files / zirium-0.7.0-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | zirium-0.7.0-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 3.7 MB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
16f3b7d68875adeeb363091770adbf10fbb824d237399d16a677790bea54eb49
|
|
BLAKE2b-256 checksum How to use checksums |
0de2dd45ec8c43108c2b97136c13b415e74ba501f1b8c485928578244276b5c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.
Transparency logRelease files / zirium-0.7.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | zirium-0.7.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 4.2 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
bab63992e36a5b7c1a8165ce173f80948ae6e4f06842fe9902d80c943bfdebf8
|
|
BLAKE2b-256 checksum How to use checksums |
674faf94c624cfed2732f1ba1d22d32af7d03c04bca0358ceb09cc476d36c3fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.
Transparency logRelease files / zirium-0.7.0-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | zirium-0.7.0-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 3.7 MB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
f922a37bd2d8c0675d1ef80f2d19e8bd0d8ea2928f0c0601c175d5cf5a95aa87
|
|
BLAKE2b-256 checksum How to use checksums |
a38bb7d4225014bde75a7eeefd660e9ff0a7cebbb9bada175ae355885f70a055
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.
Transparency logRelease files / zirium-0.7.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | zirium-0.7.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 4.2 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
194a95e4f9ab5698f6f74a0901fbadb646b051d9b0237043ae42cf54c88ff769
|
|
BLAKE2b-256 checksum How to use checksums |
09f36c4f910b121f08cf905fed16b6605f24d2a61f49548c77bda57b816ad419
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.
Transparency logRelease files / zirium-0.7.0-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | zirium-0.7.0-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 3.7 MB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
981b39d2aecbb601539be0a21eadee3c47d2dab46ffa14dfc571f2a2895f55f5
|
|
BLAKE2b-256 checksum How to use checksums |
6ed3d93a81fd63e60128e628b70c1f78b91964e30e7a8f90573b48ba32d0479c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.
Transparency logSecurity for zirium 0.7.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.
Full provenance
All 9 files in this release have been uploaded with provenance metadata.
Attestation for zirium-0.7.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.
Transparency logA 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.