qtcodes icon indicating copy to clipboard operation
qtcodes copied to clipboard

[TCirc] Define and implement circuit description language for tcirc

Open Phionx opened this issue 2 years ago • 2 comments

We need a way to uniquely represent tcirc components (e.g. single/multi qubit gates, readout, etc).

Among other use cases, this is essential for properly decoding the a tcirc readout string.

Some potential resources include:

  • https://qiskit.github.io/openqasm/language/index.html
  • https://devblogs.microsoft.com/qsharp/introducing-quantum-intermediate-representation-qir/

Phionx avatar Aug 22 '21 15:08 Phionx

As discussed @jeffreyjgong, one option is to store a list of self.gates = [] in ToplogicalCircuit. This will help you keep track of the gates in the circuit.

Then, for printing the logical quantum circuit, you can either create another Qiskit QuantumCircuit that is equivalent to the logical quantum circuit, and print that out OR you can create your own circuit printing utility.

An example of adding an X gate and also tracking it in self.gates = []:

def x(self, tqubit_indx):
    self.treg[tqubit_indx].x()
    self.gates.append(("x", (tqubit_indx,))

However, this approach may not be extensible to decoding tcirc output, which is another use case for this circuit description language.

Phionx avatar Oct 23 '21 19:10 Phionx

I think we can store a list of tuples of type Tuple[qiskit.circuit.instruction.Instruction, List[qiskit.circuit.quantumregister.Qubit]] in self.gates, which can then be used for use cases such as drawing the logical circuit.

Phionx avatar Jan 08 '22 11:01 Phionx