Context: We currently allow -- either via our QuantumInstructionBuilder or parsing QASM2/3 files -- many different gates, that are ultimately implemented through decomposition down to the native gates typically available on hardware. While we have some tests that indirectly check some of these gates through simulators (e.g. by inspecting measurement distributions), they are not exhaustive and robust to the subtle details that might distinguish gates (for example, the Rx and Ry gate applied to a |0> state would give the same measurement distribution, but there are phase differences that wont be detected). Having more robust tests will allow us to move forwards with more trust in our internal and external definitions of gates. The most complete way to compare decompositions of gates against their standard definitions would be to compare unitary matrices of decomposed circuits against their expected outcomes.
These tests also detected that our implementation of the Hadamard gate at the level of the builder is incorrect (this is not a problem when running QASM programs due to the its overloaded definition).
Changes:
Added an augmented hardware model and instruction builder to our testing package to allow us describe circuits as unitary matrices.
These are used to test decompositions of gates supported in our QuantumInstructionBuilder against standard definitions.
Also tests decompositions of gates from the qelib1.inc library in QASM2.
Tests for QASM3 with the updated stdgates.inc library.
Hadamard patch
Tests currently fail as we need the QASM3 patch on main first :smile:
Context: We currently allow -- either via our
QuantumInstructionBuilder
or parsingQASM2/3
files -- many different gates, that are ultimately implemented through decomposition down to the native gates typically available on hardware. While we have some tests that indirectly check some of these gates through simulators (e.g. by inspecting measurement distributions), they are not exhaustive and robust to the subtle details that might distinguish gates (for example, theRx
andRy
gate applied to a|0>
state would give the same measurement distribution, but there are phase differences that wont be detected). Having more robust tests will allow us to move forwards with more trust in our internal and external definitions of gates. The most complete way to compare decompositions of gates against their standard definitions would be to compare unitary matrices of decomposed circuits against their expected outcomes.These tests also detected that our implementation of the Hadamard gate at the level of the builder is incorrect (this is not a problem when running QASM programs due to the its overloaded definition).
Changes:
QuantumInstructionBuilder
against standard definitions.qelib1.inc
library in QASM2.stdgates.inc
library.Tests currently fail as we need the QASM3 patch on main first :smile: