QIR Runner for ARM64 Macs is now available

Β· 545 words Β· 3 minutes to read

In January I blogged about using the QIR Runner as an alternative (or even preferred!) way for simulating your Q# programs locally. The main reason behind that were performance gains (QIR runner is written in Rust), standardization (same intermediate format used as input into the simulator and the quantum hardware) and the complete incompatibility of the default QDK full state simulator with ARM64 processor architecture (even under x64 emulation).

One major limitation of the QIR Runner was that it was also x64 compatible only, but at least still worked well on ARM processors under emulation. This limitation has now been addressed.

Getting the QIR Runner on ARM64 πŸ”—

When I last wrote about QIR Runner, no official release was available yet, and the only way to get pre-built distribution was to download it as a build artifact from the project’s CI/CD pipeline. However, since February this year, the official releases are published on the project’s Github releases page and they include not only the x64 builds, but also a precompiled variant of QIR Runner for ARM64 Macs, which can be downloaded and used.

There is no ARM64 Windows package available, but on a Windows machine it can be built from source using the relevant Tier 2 Rust compilation target aarch64-pc-windows-msvc. Assuming Rust is already installed:

rustup add target aarch64-pc-windows-msvc
cargo build --release --target aarch64-pc-windows-msvc

Additional new features πŸ”—

Since version 0.2.0, there are also some changes to the way how we interact with the runner from the command line.

First of all, there is a breaking change regarding the positional arguments pattern the runner used in the past. The file to be executed is no longer the default nameless first argument, but instead needs to be passed in as an -f or –file named argument.

qir-runner --file {path to the file}

Secondly, and that is a very welcome addition, the runner now allows passing in the number of shots to be executed using the -s / –shots argument. This saves some of the effort of manually organizing such orchestration using scripts (you still need to parse the results though). The default amount of shots is, naturally, 1.

qir-runner --file {path to the file} --shots 1000

Finally, is it also possible to manually specify the entrypoint function name to be used (-e / –entrypoint) and provide a custom random number generator seed (-r / –rngseed), the latter of which can be helpful to provide more deterministic results in test scenarios.

QIR schemas πŸ”—

Another new thing is that the details of the result of the execution are wrapped in a dedicated QIR execution schema. Here is an example for a five shot execution of a program that returns a two element result array.

START
METADATA        EntryPoint
[Zero, Zero]
END     0
START
METADATA        EntryPoint
[One, One]
END     0
START
METADATA        EntryPoint
[One, One]
END     0
START
METADATA        EntryPoint
[One, One]
END     0
START
METADATA        EntryPoint
[Zero, Zero]
END     0

As it is apparent, each shot execution is delimited using START and END keywords. This is already initial ground work for the more advanced QIR schemas which are being currently fleshed out and is not officially merged yet, and which will allow conveying much more additional contextual information about the program’s execution. The schemas are provided in the ABNF grammar syntax.

About


Hi! I'm Filip W., a software architect from ZΓΌrich πŸ‡¨πŸ‡­. I like Toronto Maple Leafs πŸ‡¨πŸ‡¦, Rancid and quantum computing. Oh, and I love the Lowlands 🏴󠁧󠁒󠁳󠁣󠁴󠁿.

You can find me on Github, on Mastodon and on Bluesky.

My Introduction to Quantum Computing with Q# and QDK book
Microsoft MVP