Skip to main content

Zirium

Zirium 0.0.6 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.

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.

The CLI examples show how to query and edit small MLIR files with the zirium command.

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. Zirium does not load LLVM dialect definitions, interpret arbitrary ODS/TableGen files, or run Python callbacks while parsing.

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.6

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.6
File Size Uploaded Provenance
zirium-0.0.6.tar.gz 205.9 kB With provenance Details

Built distributions (wheels)

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

Total release size: 7.9 MB

Release files / zirium-0.0.6.tar.gz

Download URL zirium-0.0.6.tar.gz
Size 205.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d37d6d3a6d41e2ad13739563da22bf16c074e18779db139756e538692c9d1e87
BLAKE2b-256 checksum
How to use checksums
77dc4c73319fd89a5c029cfed04efc16ca5f0548f635e2f4fd9a038ee960d592
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 8, 2026.

Transparency log

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

Download URL zirium-0.0.6-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.0 MB
Tags CPython 3.14 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
8a223eda06990f9dd4677dc7157620f3c4620d40d0a21584c04ebd2cb6d32552
BLAKE2b-256 checksum
How to use checksums
8e6f3991c72bffe399ed06a9186847a80221aa79bd2eaf39899e9a9caaf70355
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 8, 2026.

Transparency log

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

Download URL zirium-0.0.6-cp314-cp314-macosx_11_0_arm64.whl
Size 908.1 kB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
56711bf1f21da8177a61fc25a79d9f4866a17887b0d981f0f0bc0a23c1dc0360
BLAKE2b-256 checksum
How to use checksums
11a72519074e1d05cbd20dcf029f20a01994437d743c3f1e8601b3ee175117b9
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 8, 2026.

Transparency log

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

Download URL zirium-0.0.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.0 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
1edcbde073b5d04cf3314278932198b066d9f677ce70ae17500491605f8e6ba2
BLAKE2b-256 checksum
How to use checksums
d16872afdbbeadb476e6cd3d39766a243c7730baf122a750641c502adb08101b
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 8, 2026.

Transparency log

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

Download URL zirium-0.0.6-cp313-cp313-macosx_11_0_arm64.whl
Size 908.7 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
52cd505d1c1635b147f143c37294396b09344033f342e5bb33a1d497c2caf2a7
BLAKE2b-256 checksum
How to use checksums
4c435f5f956338d67611d17948fdfbcdc7c67f766b239c802d7b5104d3bba7f9
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 8, 2026.

Transparency log

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

Download URL zirium-0.0.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.0 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
3e2c997eda8242972b4b641d3b9053b82e72aba63fc51a9ba0fc6e6a1a5c6e6c
BLAKE2b-256 checksum
How to use checksums
d88483e98a89868e5faeee7c6ae30c6774fd7ba618a43744515cfe53a32c7cf1
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 8, 2026.

Transparency log

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

Download URL zirium-0.0.6-cp312-cp312-macosx_11_0_arm64.whl
Size 908.5 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
6d336bdddcb7392b8f1ced0ced2ae6b1ce93e576367fc9ecbbdd714b341ddfc0
BLAKE2b-256 checksum
How to use checksums
5412e9efc709432017aabc2b376356a88ac6863f812e48e3c4d197cb44a8693f
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 8, 2026.

Transparency log

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

Download URL zirium-0.0.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.0 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
8db883eb6f28d98c93045b12f03fe15177a2327f1eec9099dd5bcc9b24c0a481
BLAKE2b-256 checksum
How to use checksums
e94a4f075f7c262daca7e38973f0a789da0b4266177ecd1e037bd0739b8e9f38
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 8, 2026.

Transparency log

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

Download URL zirium-0.0.6-cp311-cp311-macosx_11_0_arm64.whl
Size 912.0 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
14141f7f879a8c948f181c51772c73bd9d6c5e3c5a7a7deb0c83c1f553168ae0
BLAKE2b-256 checksum
How to use checksums
a745265435bde6ad1e4c1fbcb9ab6209753a514b5261f64b506a9df05c639f03
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 8, 2026.

Transparency log

Security for zirium 0.0.6

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.6.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 8, 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