research experiment
Open experiments in quantum computing
physical layer experiment
from spinqlablink import SpinQLabLink, ExperimentType, Pulse, Gradient
from spinqlablink import print_graph
# Constants for Pauli component measurement steps
# These represent different measurement configurations for Pauli operators
XI_XZ_YI_YZ = 1 # X⊗I, X⊗Z, Y⊗I, Y⊗Z measurements
XI_XX_YI_YX = 2 # X⊗I, X⊗X, Y⊗I, Y⊗X measurements
XI_XY_YI_YX = 3 # X⊗I, X⊗Y, Y⊗I, Y⊗X measurements
ZI_ZZ_YI_YZ = 4 # Z⊗I, Z⊗Z, Y⊗I, Y⊗Z measurements
IX_ZX_IY_ZY = 5 # I⊗X, Z⊗X, I⊗Y, Z⊗Y measurements
IZ_ZZ_IY_ZY = 6 # I⊗Z, Z⊗Z, I⊗Y, Z⊗Y measurements
# Experiment type constants
CUSTOMIZED_MEASUREMENT = 0 # User-defined custom measurement
PAULI_COMPONENT_MEASUREMENT = 1 # Measurement of Pauli components
QUANTUM_STATE_TOMOGRAPHY = 2 # Full quantum state tomography
def main():
# Create connection
spinqlablink = SpinQLabLink("192.168.15.4", 8181, "anyword", "anyword")
spinqlablink.connect()
if not spinqlablink.wait_for_login():
print("Login failed")
return
exp_physical_layer, exp_physical_layer_para = spinqlablink.register_experiment(ExperimentType.PHYSICAL_LAYER_EXPERIMENT)
# Set other parameters
exp_type = CUSTOMIZED_MEASUREMENT # CUSTOMIZED_MEASUREMENT = 0, PAULI_COMPONENT_MEASUREMENT = 1, QUANTUM_STATE_TOMOGRAPHY = 2
exp_physical_layer_para.type_setting = exp_type # which type of experiment to run
exp_physical_layer_para.pulses = [Pulse(path=0, amplitude=100, phase=90, width=40)] # pulse sequence
exp_physical_layer_para.gradients = [] # gradient sequence
exp_physical_layer_para.relaxation_delay = 15 # relaxation delay(S)
exp_physical_layer_para.h_freShift = 0 # hydrogen frequency shift(Hz)
exp_physical_layer_para.p_freShift = 0 # phosphorus frequency shift(Hz)
exp_physical_layer_para.h_freDemo = 0 # hydrogen frequency demo(Hz)
exp_physical_layer_para.p_freDemo = 0 # phosphorus frequency demo(Hz)
if exp_type == CUSTOMIZED_MEASUREMENT:
exp_physical_layer_para.state_initialization = True # whether to initialize the state
exp_physical_layer_para.sampleFre = 10000 # sample frequency(Hz)
exp_physical_layer_para.sampleCount = 16000 # sample count
exp_physical_layer_para.sampleDelay = 0 # sample delay(us)
exp_physical_layer_para.samplePath = 0 # sample path 0:hydrogen, 1:phosphorus
elif exp_type == PAULI_COMPONENT_MEASUREMENT:
exp_physical_layer_para.stepList = [XI_XZ_YI_YZ, XI_XX_YI_YX, XI_XY_YI_YX, ZI_ZZ_YI_YZ, IX_ZX_IY_ZY, IZ_ZZ_IY_ZY] # step list
elif exp_type == QUANTUM_STATE_TOMOGRAPHY:
exp_physical_layer_para.samplePath = -1 # sample path 0:hydrogen, 1:phosphorus, -1:both
spinqlablink.run_experiment()
print("Waiting for experiment completion")
spinqlablink.wait_for_experiment_completion()
exp_info = spinqlablink.get_experiment_result()
spinqlablink.deregister_experiment()
spinqlablink.disconnect()
if "result" in exp_info:
exp_result = exp_info["result"]
for key, value in exp_result.items():
if key != "graph":
print(f"{key}: {value}")
print_graph(exp_info["result"])
else:
print("Experiment failed")
if __name__ == "__main__":
main()
Analysis of experimental parameters
ExperimentType: Experiment type, select PHYSICAL_LAYER_EXPERIENCE, and set the experiment type (see:class:spinqlablink. Experiment Type class for details)
type_setting: Experiment type, select PAULI_COMPONENT_MEASURE
CUSTOMIZED_MEASURE = 0: User-defined measurement
PAULI_COMPONENT_MEASURE = 1: Pauli component measurement
QUANTUM_STATE_TOMOGRAPHY = 2: Quantum State Tomographic Reconstruction
stepList: Step list for Pauli component measurement
XI_XZ_YI_YZ: X I, X Z, Y I, Y Z measurement
XI_XX_YI_YX: X I, X X, Y I, Y X measurement
XI_XY_YI_YX: X I, X Y, Y I, Y X measurement
ZI_ZZ_YI_YZ: Z I, Z Z, Y I, Y Z measurement
IX_ZX_IY_ZY: I X, Z X, I Y, Z Y measurement
IZ_ZZ_IY_ZY: I Z, Z Z, I Y, Z Y measurement
Pulse: Define the pulse sequence and set the path, width, amplitude, phase and frequency offset of the pulse (see:class:spinqlablink.Pulse class for details)
samplePath: Sampling path,-1= dual channel, 0= hydrogen channel, 1= phosphorus channel [-1,0,1]
sampleCount: sampling points [4000-16000]
sampleFre: Sampling frequency [10000-100000]
sampleDelay: sampling delay (us) [0- 2000000]
relaxation_delay: relaxation delay (s) [0- 2000000]
h_freShift: Hydrogen frequency offset (hz) [0-10000]
h_freDemo: Hydrogen frequency demodulation (hz) [0-10000]
p_freShift: Phosphorus frequency offset (hz) [0-10000]
p_freDemo: Phosphorus frequency demodulation (hz) [0-10000]
Analysis of experimental results
{
"result":{
"graph":[
{ # step 0
"fidRe": [[x,y],...],
"fidIm":[[x,y],...],
"fftRe":[[x,y],...],
"fftIm":[[x,y],...],
"lorenz":[[x,y],...],
"fftRe":[[x,y],...],
"fftIm":[[x,y],...],
"fftMod":[[x,y],...],
"fidMod":[[x,y],...],
"fftFit":[[x,y],...]
},
{ # step 1},
...
],
"pauli_matrix":{
"II":0.2,
"IX":0.3,
"IY":0.4,
...
"XX":0.5
},
"matrix":{
"real":[0.1,0.2,...],
"imag":[0.1,0.2,...],
},
"probability":[0.1,0.2,0.3,0.4]
}
}
graph: Chart data, including real and imaginary parts, and the graph contains 1-6 steps
pauli_matrix: Pauli matrix
I/X/Y/Z: 16 Pauli matrix coefficients
matrix: Matrix data
real: Real data
imag: virtual data
probability: probability data
Line layer experiment
from spinqlablink import SpinQLabLink, ExperimentType, Pulse, Gradient, Gate, CustomGate, Circuit
from spinqlablink import print_graph
def main():
# Create connection
spinqlablink = SpinQLabLink("192.168.15.4", 8181, "anyword", "anyword")
spinqlablink.connect()
if not spinqlablink.wait_for_login():
print("Login failed")
return
exp_circuit_layer, exp_circuit_layer_para = spinqlablink.register_experiment(ExperimentType.CIRCUIT_LAYER_EXPERIMENT)
using_pulse = True
if using_pulse:
exp_circuit_layer_para.pulses = [Pulse(path=0, phase=90, amplitude=100, width=40)]
else:
circuit = Circuit(2)
circuit << Gate(type='H', qubitIndex=0)
circuit << CustomGate(type='H',customType='H1_custom_gate',qubitIndex=1,pulses=[Pulse(path=1,phase=90,amplitude=100,width=40)])
circuit.print_circuit()
exp_circuit_layer_para.set_circuit(circuit)
# Set other parameters
exp_circuit_layer_para.using_pulse = using_pulse # True: using pulse to testing gate, False: using circuit to get result
exp_circuit_layer_para.gradients = [Gradient(delay=0,value=0)] # gradient sequence
exp_circuit_layer_para.relaxation_delay = 15 #S
exp_circuit_layer_para.h_freShift = 0 # hydrogen frequency shift(Hz)
exp_circuit_layer_para.p_freShift = 0 # phosphorus frequency shift(Hz)
exp_circuit_layer_para.h_freDemo = 0 # hydrogen frequency demo(Hz)
exp_circuit_layer_para.p_freDemo = 0 # phosphorus frequency demo(Hz)
exp_circuit_layer_para.sampleFre = 10000 # sample frequency(Hz)
exp_circuit_layer_para.sampleCount = 16000 # sample count
exp_circuit_layer_para.sampleDelay = 0 # sample delay(us)
exp_circuit_layer_para.samplePath = -1 # Sampling path: 0=Hydrogen channel, 1=Phosphorus channel, -1=both channels
spinqlablink.run_experiment()
print("Waiting for experiment completion")
spinqlablink.wait_for_experiment_completion()
exp_info = spinqlablink.get_experiment_result()
spinqlablink.deregister_experiment()
spinqlablink.disconnect()
if "result" in exp_info:
exp_result = exp_info["result"]
for key, value in exp_result.items():
if key != "graph":
print(f"{key}: {value}")
print_graph(exp_info["result"])
else:
print("Experiment failed")
if __name__ == "__main__":
main()
Analysis of experimental parameters
ExperimentType: Experiment type, select CIRCUIT_LAYER_EXPERIENCE, and set the experiment type (see:class:spinqlablink. Experiment Type class for details)
using_pulse: Use pulse sequence, True: Use pulse sequence, False: Use quantum circuit [True,False]
gradients: Gradient sequence for gradient measurement (see:class:spinqlablink.Gradient class for details)
Pulse: Define the pulse sequence and set the path, width, amplitude, phase and frequency offset of the pulse (see:class:spinqlablink.Pulse class for details)
Circuit: Define the quantum circuit, set the gates and qubits of the quantum circuit (see:class:spinqlablink.Circuit class for details)
samplePath: Sampling path,-1= dual channel, 0= hydrogen channel, 1= phosphorus channel [-1,0,1]
sampleCount: sampling points [4000-16000]
sampleFre: Sampling frequency [10000-100000]
sampleDelay: sampling delay (us) [0- 2000000]
relaxation_delay: relaxation delay (s) [0- 2000000]
h_freShift: Hydrogen frequency offset (hz) [0-10000]
h_freDemo: Hydrogen frequency demodulation (hz) [0-10000]
p_freShift: Phosphorus frequency offset (hz) [0-10000]
p_freDemo: Phosphorus frequency demodulation (hz) [0-10000]
Analysis of experimental results
{
"result":{
"graph":[
{ # step 0
"fidRe": [[x,y],...],
"fidIm":[[x,y],...],
"fftRe":[[x,y],...],
"fftIm":[[x,y],...],
"lorenz":[[x,y],...],
"fftRe":[[x,y],...],
"fftIm":[[x,y],...],
"fftMod":[[x,y],...],
"fidMod":[[x,y],...],
"fftFit":[[x,y],...]
},
{ # step 1},
...
],
"fidelity": 0.99,
"gateNums": 2,
"hFre_offset": 0,
"pFre_offset": 0,
"pulseControlTime": 1000,
"pureTime": 1000,
"purity": 0.99,
"relaxtion": 15,
"sampleTime": 1000,
"smt": 6,
"matrix": {
"real":[0.1,0.2,...],
"imag":[0.1,0.2,...],
},
"probability":[0.1,0.2,0.3,0.4]
}
}
graph: Chart data, including real and imaginary parts, and the graph contains 2/6 steps
matrix: Matrix data
real: Real data
imag: virtual data
probability: probability data
fidelity: fidelity
gateNums: Total number of doors
hFre_offset: Hydrogen frequency offset (hz)
pFre_offset: Phosphorus frequency offset (hz)
pulseControlTime: pulse control time (us)
pureTime: Pseudopure state time (us)
purity: Purity (%)
** relaxation **: relaxation time (us)
sampleTime: sampling time (us)
smt: The number of comprehensive measurements by the system