Skip to main content

Zirium

Zirium 0.0.10 is an experimental release. The API may change without a migration path.

Zirium is a Rust library for reading, inspecting, transforming, and writing textual MLIR. It also provides typed Python bindings. The parser keeps the original bytes, including comments, whitespace, malformed syntax, and invalid UTF-8. A separate semantic layer provides a compact representation for verification and editing.

The project is useful when a tool needs to understand MLIR without linking LLVM, and when source fidelity matters alongside semantic processing.

Zirium currently targets the textual syntax of MLIR 22.1. It has a deliberately narrow dialect surface and is not a replacement for all of MLIR's parser or ODS infrastructure.

The current release is intended for experimentation, tooling prototypes, and evaluation of the lossless syntax/semantic split. It does not promise broad dialect coverage, bytecode support, ODS/TableGen loading, or a stable API.

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

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

What it provides

  • A byte-oriented lexer and lossless concrete syntax tree (CST).
  • Recovery from malformed input with ranged diagnostics and useful outer structure.
  • Stable machine-readable categories on semantic diagnostics.
  • Standard module handling and caller-provided func-like and call-like operation shapes.
  • Structural recovery of unknown custom operations, including nested regions, SSA declarations and uses, and trailing attribute dictionaries.
  • Strict and best-effort lowering into a separate semantic document.
  • Operations, regions, blocks, SSA values, types, attributes, locations, symbols, and dominance queries.
  • Python inspection of exact type and attribute spellings, scalar attributes, and stable value identity.
  • Form-independent operation roles for symbol names, signatures, and callees.
  • Deterministic generic MLIR output and structural round-trip comparison.
  • Buffered semantic edits that commit atomically.
  • Conservative source-preserving output for documents lowered with hybrid retention.
  • Rust and Python APIs over the same core implementation.
  • Explicit limits for file size, token count, nesting, and large payloads.

A small 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="")

Parsing and lowering are separate on purpose. A File owns the original bytes, tokens, CST, and syntax diagnostics. A Document owns resolved semantic data. This keeps malformed-source tooling from depending on a partly valid semantic model, while transformation code does not have to operate on syntax nodes.

Getting started

Zirium requires Rust 1.88 or newer. The Python package supports conventional CPython 3.11 through 3.14. Release artifacts are currently proven only for Linux x86_64 and macOS arm64 by CI; other platforms require a local source build with maturin and are not part of the platform promise. Wheels remain specific to each supported CPython version rather than using the stable ABI.

The getting-started guide covers:

  • building and testing the Rust workspace;
  • installing the Python extension into a virtual environment;
  • parsing, lowering, verifying, and writing MLIR;
  • choosing a retention profile and output mode.

For the shortest check from a fresh checkout:

cargo test --workspace

Install a published Python wheel with:

python -m pip install zirium

If a wheel is not available yet, build the extension locally using the getting-started guide.

Output modes

Zirium has three output paths, each with a different contract:

Output Source object Contract
Original Parsed file Reproduces the input bytes exactly.
Canonical Semantic document Emits deterministic generic MLIR from semantic storage.
Preserving Hybrid semantic document Copies unchanged source and regenerates edited operations or blocks.

Canonical output intentionally does not preserve comments, whitespace, aliases, or SSA spelling. Use original output when no semantic edit is needed, and hybrid retention when edits should leave unrelated source text alone.

Dialect support

Generic quoted operations are handled without a dialect registry. Unknown dialect types and attributes keep their balanced bodies as opaque values.

Registered custom syntax is currently a proving surface rather than broad MLIR dialect coverage. The built-in proving registry covers a fixed subset of Builtin, Func, Arith, and CF operations. A declarative registry can select from that same fixed set. The named stablehlo preset adds an initial custom-syntax subset for binary elementwise operations and stablehlo.return; it is not complete StableHLO support. Zirium does not load LLVM dialect definitions, interpret arbitrary ODS/TableGen files, or run Python callbacks while parsing.

The custom-format guide explains operation shapes, registry ownership, and the differences between Rust, Python, and the binary.

See compatibility and local wheel checks for the exact toolchain and CPython matrix. The corpus notes explain how syntax compatibility is tied to llvmorg-22.1.0.

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
fuzz/                   Lexer and parser fuzz targets

The architecture notes include the syntax representation baseline and processing benchmarks.

Development checks

The complete local quality gate, including the supported Rust and Python versions, is documented in the compatibility guide. The CI workflow runs those same commands.

Python development details are documented in the getting-started guide. The release guide records the registry setup, package checks, and publication order.

License

Zirium's original code is available under the MIT or Apache 2.0 license. Some MLIR-derived or adapted test material retains the provenance and licensing information recorded in the corpus manifest.

Release notes are recorded in the changelog.

Metadata

Release files for zirium 0.0.10

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

Source distribution (sdist)

Source distribution for zirium 0.0.10
File Size Uploaded Provenance
zirium-0.0.10.tar.gz 225.6 kB With provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for zirium 0.0.10
File
zirium-0.0.10-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.0.10-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details
zirium-0.0.10-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.0.10-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
zirium-0.0.10-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.0.10-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
zirium-0.0.10-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.0.10-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details

Total release size: 8.7 MB

Release files / zirium-0.0.10.tar.gz

Download URL zirium-0.0.10.tar.gz
Size 225.6 kB
Tags Source
SHA-256 checksum
How to use checksums
735d762588d8bfa6e2b8396ec205f121ea07534ebe81c3c9b4e7fe0dc02fee41
BLAKE2b-256 checksum
How to use checksums
d244e9865015a0f64642e90347635b35d01336646e03032fd98631d9881de5c1
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 Sep 9, 2026.

Transparency log

Release files / zirium-0.0.10-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL zirium-0.0.10-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.1 MB
Tags CPython 3.14 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
d89933db2ecf21afa8a45c0b20037521da489d7b975023a0b5b2aa7725261a2a
BLAKE2b-256 checksum
How to use checksums
d519f338b012862fdd9621f0d5bcd81d5b250cc10fd2c2bb135ee8f94e82acb6
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 Sep 9, 2026.

Transparency log

Release files / zirium-0.0.10-cp314-cp314-macosx_11_0_arm64.whl

Download URL zirium-0.0.10-cp314-cp314-macosx_11_0_arm64.whl
Size 1.0 MB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9569fd9a70eb3b77db3ba0b7230201bd8507de784368356d1861df144ff27335
BLAKE2b-256 checksum
How to use checksums
a46743e91a0b1962d3c1fee544db2a5f8f481916d746e057d9afcf4c1860c46f
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 Sep 9, 2026.

Transparency log

Release files / zirium-0.0.10-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL zirium-0.0.10-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.1 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
c215d6de1e381b4133b629818f6393890a34f32525415dec7db9d90cf616a020
BLAKE2b-256 checksum
How to use checksums
4fef7efc4265359c5727e7518499e023adc5842fd60a477ad893a87198ce8c75
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 Sep 9, 2026.

Transparency log

Release files / zirium-0.0.10-cp313-cp313-macosx_11_0_arm64.whl

Download URL zirium-0.0.10-cp313-cp313-macosx_11_0_arm64.whl
Size 1.0 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ea623b2e186ac7dcf29b08ea6186321a2cafe804a749afee55e89db9a86e8ed6
BLAKE2b-256 checksum
How to use checksums
04499d0c1473160f8f191216c7e7a8588c95f9cca64e28ee33f9945e1e64808c
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 Sep 9, 2026.

Transparency log

Release files / zirium-0.0.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL zirium-0.0.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.1 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
07ed53c3abc5290c427c3d299613b6f5b1f896926e46822d19ba5cf2519a2f91
BLAKE2b-256 checksum
How to use checksums
12e22610491f0bd7c2c3427bccdb138d907794e1da1cbc3beefe6bedcbe02951
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 Sep 9, 2026.

Transparency log

Release files / zirium-0.0.10-cp312-cp312-macosx_11_0_arm64.whl

Download URL zirium-0.0.10-cp312-cp312-macosx_11_0_arm64.whl
Size 1.0 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
fa4cdc8d78d28ec0ed5ca648a5f1c4b6d32927206d3e054226bee1b03ddade3f
BLAKE2b-256 checksum
How to use checksums
205b1f1a8481312d670d9bce4e798891237014729449b444c1df36a25d2eeb5c
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 Sep 9, 2026.

Transparency log

Release files / zirium-0.0.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL zirium-0.0.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.1 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
2ec4a9423a353a2dc22a70ce18af934254020f8ed694f69f060b845958ea7b36
BLAKE2b-256 checksum
How to use checksums
c2384770c90627cbef025380606bf9219a4adc112d37079838f75a2ae2db146a
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 Sep 9, 2026.

Transparency log

Release files / zirium-0.0.10-cp311-cp311-macosx_11_0_arm64.whl

Download URL zirium-0.0.10-cp311-cp311-macosx_11_0_arm64.whl
Size 1.0 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
fc2add113ffc9a90245a6347ac042cddc9ce57384d9de7f0611b47c34321ecff
BLAKE2b-256 checksum
How to use checksums
7d209b9d5c733ddf88e05d4e9d7ef7a88233b713e7c484093ec5a7fb4e645d5f
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 Sep 9, 2026.

Transparency log

Security for zirium 0.0.10

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.

Select from 9 files

Attestation for zirium-0.0.10.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 Sep 9, 2026.

Transparency log

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.

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