Strong classical simulation
Closed this issue · 2 comments
Hi
I would like to use this implementation for strong classical simulation, as discussed in here.
I am not quite sure how I have to proceed. Assuming I have a QASM circuit in a text file, I assume I can use functions load and to_graph to obtain the corresponding VecGraph
.
But how do I get the probability of a given output? I assume I have to use full_simp somehow, but do not know how to get a number from it, or how to specify which output probability I am looking for.
Thanks for your help!
Hi,
It's the Decomposer
you want for computing amplitudes (or probabilities). Have a look at the code in bin/
for some examples (e.g. things named "hidden shift" or "pauli gadget").
In summary: load a circuit and convert it to a graph with to_graph
. Then, you can plug bra's and ket's into the inputs/outputs of a graph using the plug_inputs
and plug_outputs
methods, pass that graph to the decomposer, then retrieve the scalar:
g.plug_inputs(&vec![BasisElem::Z0; 20]);
g.plug_outputs(&vec![BasisElem::Z0; 20]);
let mut d = Decomposer::new(&g);
d.with_full_simp(); // set simplification method to full_simp
// optionally adjust some other parameters...
d.decomp_all();
println!("<0..0|C|0..0> = {}", d.scalar.float_value());
Thanks so much, this works!