Closed DevelopDaily closed 3 years ago
I think staq
does the right thing in simply translating gate sets. The qubit ordering comes into play only when executing. In other words, the assembly code should be invariant, but execution will depend of course on how those bits are interpreted. I am very much tempted to leave staq as is, and only document the endianness (bit ordering) on the simulator part. That's because Rigetti still numbers qubits as we do, but only "interprets" them differently when writing down the state vector.
So, in other words, I still want
x q[0] // qasm
to be translated to
X 0 // Rigetti
and deal with endianness at the end of processing (i.e., when executing on a simulator). Otherwise, generating code with bits reversed will create a lot of misunderstandings and further issues down the line.
In a nutshell, our system is "Big-endian" (as well as most others in QC), but Rigetti's is "Little-endian". Code is portable up to qubit relabeling at the end. One option is to add an endianness flag to the executor's qpp::QEngine
, i.e.
explicit QEngine(const QCircuit& qc, bool big_endian = true)
Agreed. Well-thought-out. As long as it is a conscious design decision and well documented, that should be good enough.
Or, if possible, a utility standalone function to prepare/interpret endianness would be nice, leaving the critical QEngine
intact. If impossible, the current code can be kept as it is.
@DevelopDaily Good point, will think about it. I'll refer this to https://github.com/softwareQinc/qpp/issues/104, as they are closely related. I think this should be closed for staq, and kept open for qpp.
Great. Thanks.
Here is a simple test case:
The final state by a
qpp
run:The snippet of the
Rigetti Quil
code out of thestaq
:The final state by a
Rigetti
run:Rigetti
makes a very big deal of basis ordering, which is documented here.I quote the key point: