# Tag Info

6

The easiest way is to use the QuantumCircuit methods QuantumCircuit.from_qasm_file() or QuantumCircuit.from_qasm_str() depending on if your loading the QASM from a file or Python string, respectively.

4

Q# is not compiled into QASM, so that would be tricky. Q# compilation and execution process is approximately as follows: Q# code is parsed into an internal data structure representing an abstract syntax tree. This data structure undergoes some transformations (for example, to generate adjoint and controlled versions of operations used in the code). I don't ...

4

You'e just experienced code transpilation. Transpilation is when source-to-source compilation takes place, as you have mentioned here. You can prevent the rearranging of the gates by using the "barriers", the Barrier operation is used to make your quantum program more efficient, the compiler will try to combine gates. The barrier is an instruction ...

4

The issue is that you are transpiling for a backend with 5 qubits, but this circuit is defined over a 16 qubit register (line 3 qreg q[16];). To avoid this error you can either update your qasm to work over a register of 5 qubits, or transpile for a different backend. I think that the simulator is the only available device that will run up to 16 qubits.

3

How is correct that new scheme of Controlled-$G^\dagger$ gate may be constructed from this known scheme of Controlled-G gate by reversing the order of used gates ($U$) and each $U$ in this scheme changes to the corresponding $U^\dagger$ (if $U≠U^\dagger$ of course)? It's 100% correct: Inverting a composed quantum gate is done with the algorithm you gave. ...

3

This is a example for loading QASM, executing and displaying the result. from qiskit import QuantumCircuit, Aer, execute qasm_str = """OPENQASM 2.0; include "qelib1.inc"; qreg q[2]; creg c[2]; h q[0]; cx q[0],q[1]; measure q -> c; """ # From str. qc = QuantumCircuit.from_qasm_str(qasm_str) # If you want to read from file, use instead # qc = ...

3

From the spec, $U_2(\phi, \lambda) = U ( \frac{\pi}{2}, \phi, \lambda)$. We can use Cirq's QasmUGate. import cirq from cirq.circuits.qasm_output import QasmUGate q0 = cirq.NamedQubit('q[0]') u2_gate = QasmUGate(0.5, 0, 1) # The angles are normalized to the range [0, 2) half_turns circuit = cirq.Circuit(u2_gate(q0))

3

IF gate can be used for controlling gates based on value in classical register, i.e. measured values of qubits. Lets see at this circuit: In this case qubit $q_0$ is in state $|1\rangle$ and qubit $q_1$ in state $|0\rangle$. After measurement you have value 1 in classical bit $c_1$ and value 0 in classical bit $c_0$. So $c_1c_0 = 10$ in binary or $2$ in ...

3

There are many forms of QASM, so I'll answer for OpenQASM 2.0, as is currently used by IBM. Declaring a gate to be random means that it would be randomly generated at compile time. Since QASM is used as an expression of a compiled circuit, such randomness must be resolved by the time the QASM is created. It is true that are transpilation processes in the ...

3

This is the matrix for $Z^t$: $$Z^t = \begin{bmatrix} 1&0\\0&(-1)^t \end{bmatrix} = \begin{bmatrix} 1&0\\0&e^{i \pi t} \end{bmatrix}$$ This is the matrix for $R_Z(\pi t)$: $$R_Z(\pi t) = e^{-iZt/2} = \begin{bmatrix} e^{-i \pi t / 2}&0\\0&e^{+i \pi t / 2} \end{bmatrix} = e^{-i \pi t/2} Z^t$$ Which means that $$Z^t \equiv R_Z(\pi ... 2 Note that$$RX(\phi) = \begin{pmatrix} \cos(\phi/2) & -i\sin(\phi/2) \\-isin(\phi/2) & \cos(\phi/2)\end{pmatrix}$$Then$$RX(\pi q) = \begin{pmatrix} \cos(\pi q/2) & -i\sin(\pi q/2) \\-isin(\pi q/2) & \cos(\pi q/2)\end{pmatrix}. Now, using that $\cos(\pi k + \pi/2) = 0 = \sin(\pi k)$ and $\cos(\pi k) = 1 = \sin(\pi k + \pi/2)$ for $k\in \... 2 You need to extract the compiled qasm from a qobj object. You can create this by compiling from qiskit import compile qobj = compile(qc,backend,shots=shots) If you want to create a batch job, where you send many circuits in at once, you can replace the single circuit qc with a list of circuits. Information about the circuits, the backend on which they'll ... 2 If I understand the question correctly, you're assuming that you have some gate$V$that you've decomposed as$\prod_{i=1}^NU_i$and you want to show that$V^\dagger$is$\prod_{i=1}^NU_{N+1-i}^\dagger$where the product is taken in the opposite order? In that case, you just need to show that$VV^\dagger=\mathbb{I}$given that$U_iU_i^\dagger=\mathbb{I}\$. ...

2

According to the openqasm spec the include statement will insert the contents of the files with the name relative to the current working directory: https://github.com/Qiskit/openqasm/blob/master/spec/qasm2.rst#language If you're using qiskit-terra as your parser this should work unless you name the local file "qelib1.inc". The parser included in the qiskit-...

2

The ibmq_qasm_simulator is a cloud-based simulator. You need to say from qiskit import IBMQ provider = IBMQ.load_account() sim = provider.backends.ibmq_qasm_simulator

2

In the web based composer there is currently no way to adjust the optimization level. As a workaround, you can put a barrier before and after each gate. This will prevent them from being joined.

2

I don't know if this will help. I have tried the code and it worked: I created a new file named ccu1_circuit.qasm with the instruction written in the question. Then in a separate Python file, I have written: from qiskit import * circuit = QuantumCircuit.from_qasm_file('/...The path.../ccu1_circuit.qasm') backend = BasicAer.get_backend('qasm_simulator') ...

1

I believe there are several developments about this on Qiskit to make the use of Pulse easier. Try to check the PR or the issues regarding Pulse, maybe you'll find what you are looking for. I also found an issue about a QASM 3.0, I think this will interest you! :)

1

When you transpile (either when calling execute or transpile), you should be able to set optimization_level=0 so the transpiler only maps the qubits to the backend. You can see an example here.

1

I think its an error. If you want a poor temporary solution you can try to select the whole box starting at the big title Transpiled Circuit to the last code line. It will copy the line numbers together with the QASM code but I think it will be better than nothing.

1

I have just realized that web interface of IBM Q was updated and custom gates, i.e. gate ccu1 ( p ) c1, c2, t { cu1 ( p / 2 ) c1, c2; cx c2, t; cu1 ( - p / 2 ) c1, t; cx c2, t; cu1 ( p / 2 ) c1, t; }, is correctly transpiled to gates used in the custom gate and subsequently to basic gate set used on IBM Q. Overall, custom gate functionality is ...

1

Depth is the number of repetitions of the basic circuit of the variational form. By adding more repetitions the expectation is that it can cover a larger part of the Hilbert space and hopefully include the solution space that a shallower one could not. Now each basic circuit has parameters so it can be varied. Adding more repetitions adds more parameters and ...

1

OpenQasmReader was moved to another repository.

1

Unfortunately, I'm pretty sure that the functionality you desire does not exist. You'll need to do it by constructing the unitary yourself, for example via this method provided in the answer to another question. For reference, the full specification for OpenQASM 2.0 can be found here.

Only top voted, non community-wiki answers of a minimum length are eligible