# How do you map an X gate to a constant pulse?

I was wondering how to map an X gate to a constant pulse shape. This https://qiskit.org/documentation/tutorials/circuits_advanced/05_pulse_gates.html is the link that I am working off. It shows an example of a Hadamard on a Gaussian pulse and how to do custom gates. I cannot figure out what changes I should make to the code in the Custom gates section of the link that would result in an X gate on a constant pulse shape.

Following the tutorial, you can change the Gaussian and the add_calibration.

To build a constant pulse shape, there is qiskit.pulse.library.Constant, and for the mapping, change the gate from 'h' to 'x' in circ.add_calibration.

Here's the code:

from qiskit import QuantumCircuit, pulse, transpile
from qiskit.test.mock import FakeValencia
from qiskit.pulse.library import Constant
backend = FakeValencia()

# build a simple circuit that only contain one x gate and measurement
circ = QuantumCircuit(1, 1)
circ.x(0)
circ.measure(0, 0)
with pulse.build(backend) as my_schedule:
pulse.play(Constant(duration=10, amp=0.1), pulse.drive_channel(0)) # build the constant pulse

circ.add_calibration('x', [0], my_schedule) # map x gate in qubit 0 to my_schedule
circ = transpile(circ, backend)
circ.draw('mpl', idle_wires=False)

• Thank for your help. Do you know if there is any way to verify the output of the X gate? – Brian Lynch Jul 14 at 2:47
• Sorry, I don't quite understand. Maybe you can try asking that in new question so the others can help. Cheers. – 316327 Jul 14 at 5:50

The pulse shape you specify in Qiskit is the envelop function of the drive, so you will need to set the area under the constant pulse to be the same as the area under the original $$X$$ gate pulse, which is usually a Gaussian or DRAG pulse.

Specifically, suppose the qubit Hamiltonian is $$\hat{H}_d = -\frac{1}{2}\omega_q\hat{\sigma}_z + QV(t)\hat{\sigma}_x,$$ where $$\omega_q$$ is the qubit frequency, $$V(t)$$ is the drive and $$Q$$ is a constant that has the unit of electric charge. Suppose the drive has the form $$V(t) = A(t)\cos(\omega_d t).$$ with envelop function $$A(t)$$ and frequency $$\omega_d$$. If we are driving on resonance, i.e. $$\omega_d = \omega_q$$, the unitary transformation applied to the qubit from time 0 to $$t$$ is $$\hat{U}_d = \exp\Big(-i\underbrace{\frac{Q}{2}\int_0^t A(t')dt'}_{\Theta(t)} \hat{\sigma}_x\Big).$$ Using an envelop function such that $$\Theta(t) = \pi$$ will give us the $$X$$ gate. The above is theoretically how you would obtain the $$X$$ gate. In practice this procedure usually includes sweeping multiple parameters.

Also usually you wouldn't want a constant pulse for your gate because it would contain high-frequency components that lead to excitations to unwanted modes, whereas with a Gaussian pulse you get a relatively narrow excitation bandwidth.