BlyxDocumentation
Browse chapters
Documentation / Workflow recipes

Quail · Compare a real-qubit circuit with observed shots

Simulate a short real-amplitude single-qubit circuit and compare shot counts.

Compare a real-qubit circuit with observed shots

Shot frequencies can differ from circuit predictions. Keep amplitudes through the gate sequence and compare probabilities only at readout. The X and Z sequence prepares a state whose probability of one is 1. Six ones in eight measured shots give a 0.25 discrepancy.

Run the framework with your own input

Install Blyx 0.2.1 and a Rust toolchain with a host linker, then run the versioned project. Each positional argument is a number or a comma-separated numerical vector. The CLI accepts up to 16 entries per vector. The imported module accepts longer inputs.

git clone --depth 1 --branch v0.1.0 https://github.com/Rahulchaube1/blyx-quail.git
cd blyx-quail
blyxc native-run project.blyx -- "1,0" "1,2" 2 6

API and return values

Returns [predicted P(1), observed P(1), absolute discrepancy]. Gates are applied left to right. Complex phase gates and hardware execution require a different state representation. Invalid input returns an empty vector.

ArgumentAccepted input
stateVector of: finite number
gatesVector of: nonnegative exact integer
zerononnegative exact integer
onenonnegative exact integer

Use the libraries independently

The framework vendors the same library source published in these two repositories. Each module has its own package page, input contract and regression suite.

Try the program

Output Ready
Expected output
1
0.75
0.25
Open in the full playground →

Practice

Change gates = [], zero = 4.0, one = 0.0. Predict the result, then run the program.

Hint

Returns [predicted P(1), observed P(1), absolute discrepancy]. Gates are applied left to right. Complex phase gates and hardware execution require a different state representation.

Worked solution

The result vector is [0, 0, 0]. Compare its fields with the return layout in the API section.

Find

    let gates = [1, 2];

Replace with

    let gates = [];

Find

    let zero = 2.0;

Replace with

    let zero = 4.0;

Find

    let one = 6.0;

Replace with

    let one = 0.0;

Output after the change

0
0
0