Skip to main content

Zirium

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.

Version 0.0.13 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.

Installation

Install the Python package with:

python -m pip install zirium

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.

Rust builds require Rust 1.88 or newer. From a source checkout, install the CLI with:

cargo install --path crates/zirium

The Python wheel does not include the CLI. The getting-started guide covers Rust usage and building the Python extension locally.

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

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 syntax diagnostics. A Document owns resolved semantic data. Keeping them separate lets you inspect malformed source without requiring a valid semantic model, and edit semantic structure without manipulating syntax nodes.

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 normalizes formatting and 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.

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 a small set of Builtin, Func, Arith, and CF operations. Bundled presets expose selected custom forms from other dialects for structural queries. Unsupported forms use best-effort recovery; presets do not implement 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.

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

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 notes are recorded in the changelog.

Metadata

Release files for zirium 0.0.13

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.13
File Size Uploaded Provenance
zirium-0.0.13.tar.gz 307.6 kB With provenance Details

Built distributions (wheels)

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

Total release size: 9.5 MB

Release files / zirium-0.0.13.tar.gz

Download URL zirium-0.0.13.tar.gz
Size 307.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7d2ea177256571f2abcdb54a4bc5951f443d90de2de86f012503f14ac0bfdb84
BLAKE2b-256 checksum
How to use checksums
6617235482c06e250379b29ec1082142993f9088015b1e9963b76050e9cd37c4
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 10, 2026.

Transparency log

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

Download URL zirium-0.0.13-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.2 MB
Tags CPython 3.14 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
c7a82ef891b1a05c95baaac1489acf9f5850d941b1a7ae77e5e6c9d73bbe4a2d
BLAKE2b-256 checksum
How to use checksums
bcbe957270e5e7817cbe1183b47bc544d1a87d5259d188df004be2267a19d379
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 10, 2026.

Transparency log

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

Download URL zirium-0.0.13-cp314-cp314-macosx_11_0_arm64.whl
Size 1.1 MB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8b53c613098985a11ad50007b0c9a3c95d5b7838d94716ae3772e087837185be
BLAKE2b-256 checksum
How to use checksums
62ecd40b8d404b923889bde476c887bf10c82fc2354fd3663d19bc4dda567c56
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 10, 2026.

Transparency log

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

Download URL zirium-0.0.13-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.2 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
31d077c706c6a59f32e1f536ef8c3e5cc72d011b4ed47f5dea3be32ca100b3b3
BLAKE2b-256 checksum
How to use checksums
e8ebe17c8c230c20a1e690ec4e1d8efb70cd835bd9502dec401c2b4f317239c1
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 10, 2026.

Transparency log

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

Download URL zirium-0.0.13-cp313-cp313-macosx_11_0_arm64.whl
Size 1.1 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a88ac2b46467dcf20b21f696f7ff019ecd94ff8dd63e480fa57f89642631f0d1
BLAKE2b-256 checksum
How to use checksums
2fca06c536f61bea1d4e69ce0708829b063206af6b940e96a89c474a4806086a
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 10, 2026.

Transparency log

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

Download URL zirium-0.0.13-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.2 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
f7a08827ed1f8f3f46ff312740bc2be651d1db6393458e0ceda2052929c1290e
BLAKE2b-256 checksum
How to use checksums
a3e7262d110d0354d07daa03f40935bddf6cd25929619c486b7d14dde6ad4580
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 10, 2026.

Transparency log

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

Download URL zirium-0.0.13-cp312-cp312-macosx_11_0_arm64.whl
Size 1.1 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e4ac13419e0919870e924e431e39ad44a1cfcdbc104977c859c6017d1658f12d
BLAKE2b-256 checksum
How to use checksums
cdd7a20d90b526c321eafc14f26f4a890b5397846948dd163a42cdc2e3e9d477
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 10, 2026.

Transparency log

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

Download URL zirium-0.0.13-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.2 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
540bc9d2c4758336b775b39c9557bd3e7b2f6f769cf332aa84e1aea39c1c8acf
BLAKE2b-256 checksum
How to use checksums
9b36fbf93955aaa50502b23af0acfbcfc95e6cb3cefc4f67a40c08b770b0ab2b
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 10, 2026.

Transparency log

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

Download URL zirium-0.0.13-cp311-cp311-macosx_11_0_arm64.whl
Size 1.1 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e6ef58153c91e6a9ba75d66d93c649200eac2d1751d2ff80cee289b19b5e956f
BLAKE2b-256 checksum
How to use checksums
01cdf2c482f41c1e0b0e344d6222a8074da95329b68659ac4413d178add3ec12
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 10, 2026.

Transparency log

Security for zirium 0.0.13

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.13.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 10, 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