Las traducciones son generadas a través de traducción automática. En caso de conflicto entre la traducción y la version original de inglés, prevalecerá la version en inglés.
Hello Pulse usando OpenPulse
OpenPulse
BraketOpenPulse se utiliza como representación intermedia subyacente para expresar pulsos en instrucciones nativas. OpenPulseadmite la adición de calibraciones de instrucciones en forma de declaracionesdefcal
(abreviatura de «definir calibración»). Con estas declaraciones, puede especificar una implementación de una instrucción de puerta dentro de una gramática de control de nivel inferior.
En este ejemplo, construiremos un circuito Bell con OpenQASM 3.0 yOpenPulse en un dispositivo con transmones ajustables en frecuencia. Recordemos que un circuito de Bell es un circuito de dos cúbits que consiste en una puerta de Hadamard en el primer cúbit seguida de unacnot
puerta entre los dos cúbits. Comocnot
las puertas se diferencian decz
las puertas solo por una transformación básica, aquí definiremos un par de Bell utilizando Hadamard ycz
puertas en su lugar, ya que el dispositivo proporciona una forma más sencilla de crearcz
puertas para esta demostración.
Empecemos por definir la puerta de Hadamard utilizando las puertas nativas del dispositivo.
client = boto3.client('braket', region_name='us-west-1') defcal h $10 { rz(pi) $10; rx(pi/2) $10; rz(pi/2) $10; rx(-pi/2) $10; } defcal h $113 { rz(pi) $113; rx(pi/2) $113; rz(pi/2) $113; rx(-pi/2) $113; }
Para la compuerta CZ, utilizaremos una forma de onda arbitraria con parámetros (amplitud, tiempo de subida/caída y duración) predeterminados de antemano. Esta forma de onda se aplicará en elq10_q113_cz_frame
.
cal { waveform q10_q113_cz_wfm = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.00021019328936380065, 0.0008644760431374357, 0.003028104466884364, 0.009058671036471382, 0.02322670104785881, 0.05128438687551476, 0.09812230691191462, 0.16403303942241076, 0.24221990600377236, 0.32040677258513395, 0.38631750509563006, 0.43315542513203, 0.4612131109596859, 0.4753811409710734, 0.4814117075406603, 0.48357533596440727, 0.48422961871818093, 0.4843963766398558, 0.4844321964728096, 0.4844386806183817, 0.4844396697373718, 0.48443979687791755, 0.48443981064783953, 0.48443981190433844, 0.4844398120009317, 0.48443981200718716, 0.4844398120075284, 0.48443981200754405, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.48443981200754405, 0.4844398120075284, 0.48443981200718716, 0.4844398120009317, 0.48443981190433844, 0.48443981064783953, 0.48443979687791755, 0.4844396697373718, 0.4844386806183817, 0.4844321964728096, 0.4843963766398558, 0.48422961871818093, 0.48357533596440727, 0.4814117075406603, 0.4753811409710734, 0.46121311095968553, 0.4331554251320285, 0.38631750509562957, 0.32040677258513167, 0.24221990600377236, 0.16403303942240913, 0.0981223069119151, 0.0512843868755143, 0.023226701047858084, 0.009058671036471328, 0.0030281044668842563, 0.0008644760431374626, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; } defcal cz $10, $113 { barrier q10_rf_frame, q113_rf_frame, q10_q113_cz_frame; play(q10_q113_cz_frame, q10_q113_cz_wfm); delay[124ns] q10_rf_frame; shift_phase(q10_rf_frame, 1.1733407221086924); delay[124ns] q113_rf_frame; shift_phase(q113_rf_frame, 6.269846678712192); barrier q10_rf_frame, q113_rf_frame, q10_q113_cz_frame; }
La duración de laq10_q113_cz_wfm
forma de onda es de 124 muestras, lo que corresponde a 124 ns, ya que el incremento de tiempo mínimodt
es de 1 ns.
Laq10_q113_cz_wfm
forma de onda se reproduce en un cuadro enlazado a un puerto de flujo rápido. Su función es cambiar la frecuencia de los cúbits para activar una interacción entre cúbits y cúbits. Para obtener más información, consulte Roles de marcos y puertos. A medida que la frecuencia varía, los cuadros de cúbits giran a diferentes velocidades en comparación con losrf
fotogramas de un solo cúbit que se mantienen intactos: estos últimos se desfasan. Esta desfasación se puede medir conRamsey secuencias durante una etapa de calibración y se puede compensar conshift_phase
instruccionesrf
yxy
marcos. Para obtener más información, consulte Caldwell et al.
Ahora podemos ejecutar el circuito de pares de Bell, en el quecnot
descompusimos la puerta con un par de Hadamard ycz
Gates.
bit[2] c; h $10; h $113; cz $10, $113; h $113; c[0] = measure $10; c[1] = measure $113;
La representación completa de OpenQASM 3.0 para el circuito Bell construido mediante una combinación de puertas y pulsos nativos es la siguiente.
// bell_pair_with_pulse.qasm OPENQASM 3.0; cal { waveform q10_q113_cz_wfm = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.00021019328936380065, 0.0008644760431374357, 0.003028104466884364, 0.009058671036471382, 0.02322670104785881, 0.05128438687551476, 0.09812230691191462, 0.16403303942241076, 0.24221990600377236, 0.32040677258513395, 0.38631750509563006, 0.43315542513203, 0.4612131109596859, 0.4753811409710734, 0.4814117075406603, 0.48357533596440727, 0.48422961871818093, 0.4843963766398558, 0.4844321964728096, 0.4844386806183817, 0.4844396697373718, 0.48443979687791755, 0.48443981064783953, 0.48443981190433844, 0.4844398120009317, 0.48443981200718716, 0.4844398120075284, 0.48443981200754405, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.4844398120075447, 0.48443981200754405, 0.4844398120075284, 0.48443981200718716, 0.4844398120009317, 0.48443981190433844, 0.48443981064783953, 0.48443979687791755, 0.4844396697373718, 0.4844386806183817, 0.4844321964728096, 0.4843963766398558, 0.48422961871818093, 0.48357533596440727, 0.4814117075406603, 0.4753811409710734, 0.46121311095968553, 0.4331554251320285, 0.38631750509562957, 0.32040677258513167, 0.24221990600377236, 0.16403303942240913, 0.0981223069119151, 0.0512843868755143, 0.023226701047858084, 0.009058671036471328, 0.0030281044668842563, 0.0008644760431374626, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; } defcal h $10 { rz(pi) $10; rx(pi/2) $10; rz(pi/2) $10; rx(-pi/2) $10; } defcal h $113 { rz(pi) $113; rx(pi/2) $113; rz(pi/2) $113; rx(-pi/2) $113; } defcal cz $10, $113 { barrier q10_rf_frame, q113_rf_frame, q10_q113_cz_frame; play(q10_q113_cz_frame, q10_q113_cz_wfm); delay[124ns] q10_rf_frame; shift_phase(q10_rf_frame, 1.1733407221086924); delay[124ns] q113_rf_frame; shift_phase(q113_rf_frame, 6.269846678712192); barrier q10_rf_frame, q113_rf_frame, q10_q113_cz_frame; } bit[2] c; h $10; h $113; cz $10, $113; h $113; c[0] = measure $10; c[1] = measure $113;
Ahora puede usar el SDK de Braket para ejecutar este programa OpenQASM 3.0 en elRigetti dispositivo mediante el siguiente código.
# import the device module from braket.aws import AwsDevice from braket.ir.openqasm import Program client = boto3.client('braket', region_name='us-west-1') with open("pulse.qasm", "r") as pulse: pulse_qasm_string = pulse.read() # choose the Rigetti device device = AwsDevice("arn:aws:braket:us-west-1::device/qpu/rigetti/Aspen-M-3") program = Program(source=pulse_qasm_string) my_task = device.run(program) # You can also specify an optional s3 bucket location and number of shots, # if you so choose, when running the program s3_location = ("amazon-braket-my-bucket", "openqasm-tasks") my_task = device.run( program, s3_location, shots=100, )