3
$\begingroup$

(Copied from https://github.com/quantumlib/Stim/issues/708)

[In stim], is there any way to directly generate the samples starting from a tableau and not a circuit? I understand that the standard way is to compile the sampler starting from the circuit

import stim
c = stim.Circuit('''
    X 2
    M 0 1 2
''')
s = c.compile_sampler()
s.sample(shots=1)

but I was wondering whether the CompiledMeasurementSampler it produces could be directly initialized from a tableu, and maybe the qubits one wants to measure.

$\endgroup$

1 Answer 1

2
$\begingroup$

You can convert the tableau into a circuit, and then sample the circuit.

tableau = ...

sampling_circuit = tableau.to_circuit()
sampling_circuit.append("M", range(c.num_qubits))
sampler = sampling_circuit.compiler_sampler()

samples = sampler.sample(shots=256)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.