def setUp(self): # Set up QuaC simulators self.quac_sim = Quac.get_backend("fake_yorktown_density_simulator", t1=True, t2=False, meas=False, zz=False)
def main(): circuit = QuantumCircuit(2, 2) circuit.u2(0, math.pi, 0) circuit.cx(0, 1) circuit.measure_all() circuit2 = QuantumCircuit(2, 2) circuit2.h(0) circuit2.cx(0, 1) circuit2.measure_all() print("Available QuaC backends:") print(Quac.backends()) simulator = Quac.get_backend('generic_counts_simulator', n_qubits=2, max_shots=10000, max_exp=75, basis_gates=['u1', 'u2', 'u3', 'cx']) # generic backends require extra parameters # Noise model with T1, T2, and measurement error terms noise_model = QuacNoiseModel( [1000, 1000], [50000, 50000], [np.eye(2), np.array([[0.95, 0.1], [0.05, 0.9]])], None ) # Execute the circuit on the QuaC simulator job = execute([circuit, circuit2], simulator, shots=1000, quac_noise_model=noise_model) print(job.result()) print(job.result().get_counts()) plot_histogram(job.result().get_counts(), title="Bell States Example") plt.show()
def main(): circuit1 = QuantumCircuit(5, 5) circuit2 = QuantumCircuit(5, 5) circuit3 = QuantumCircuit(1, 1) circuit1.h(0) circuit2.u2(0, math.pi, 0) circuit3.u3(math.pi/2, math.pi, 0, 0) circuit1.measure(0, 0) circuit2.measure(0, 0) circuit3.measure(0, 0) print("Available QuaC backends:") print(Quac.backends()) simulator = Quac.get_backend('fake_vigo_density_simulator', meas=True) # Execute the circuit on the QuaC simulator job1 = execute(circuit1, simulator) job2 = execute(circuit2, simulator) job3 = execute(circuit3, simulator) print(f"Hadamard counts: {job1.result().get_counts()}") print(f"U2 counts: {job2.result().get_counts()}") print(f"U3 counts: {job3.result().get_counts()}") plot_histogram(job1.result().get_counts()) plot_histogram((job2.result().get_counts())) plot_histogram(job3.result().get_counts()) plt.show()
def main(): # Get backends IBMQ.load_account() provider = IBMQ.get_provider(hub="ibm-q-ornl", group="anl", project="chm168") backend = provider.get_backend("ibmq_burlington") plugin_backend = Quac.get_backend("fake_burlington_density_simulator", t1=True, t2=True, meas=False, zz=False) # Get calibration circuits hardware_properties = FakeBurlington().properties() num_gates = np.linspace(10, 500, 30, dtype='int') qubits = list(range(len(backend.properties().qubits))) t1_circs, t1_delay = t1_circuits(num_gates, hardware_properties.gate_length('id', [0]) * 1e9, qubits) t2_circs, t2_delay = t2_circuits((num_gates / 2).astype('int'), hardware_properties.gate_length('id', [0]) * 1e9, qubits) # Formulate real noise model real_noise_model = QuacNoiseModel( t1_times=[1234, 2431, 2323, 2222, 3454], t2_times=[12000, 14000, 14353, 20323, 30232] ) # Formulate initial guess noise model (only same order of magnitude) guess_noise_model = QuacNoiseModel( t1_times=[1000, 1000, 1000, 1000, 1000], t2_times=[10000, 10000, 10000, 10000, 10000] ) # Calculate calibration circuit reference results reference_job = execute(t1_circs + t2_circs, plugin_backend, quac_noise_model=real_noise_model, optimization_level=0) reference_result = reference_job.result() # Calculate optimized noise model new_noise_model = optimize_noise_model_ng( guess_noise_model=guess_noise_model, circuits=t1_circs + t2_circs, backend=plugin_backend, reference_result=reference_result, loss_function=angle_objective_function ) # Show original noise model and optimized noise model print(f"Original noise model: {real_noise_model}") print(f"New noise model: {new_noise_model}")
def setUp(self): # Set up QuaC simulator and QASM simulator self.quac_simulator = Quac.get_backend( "fake_yorktown_density_simulator") self.qasm_simulator = Aer.get_backend("statevector_simulator")
from quac_qiskit import Quac from quac_qiskit.format import quac_time_qasm_transpiler import matplotlib.pyplot as plt if __name__ == '__main__': # Note: measurement errors are included by setting the "meas" option to True # Qubit P(0 | 1) P(1 | 0) # 0 0.10799999999999998 0.024 # 1 0.039000000000000035 0.004 # 2 0.026 0.009000000000000008 # 3 0.03400000000000003 0.005 # 4 0.135 0.019 print(Quac.backends()) simulator = Quac.get_backend('fake_bogota_counts_simulator', t1=False, t2=False, meas=True, zz=True) # Build the GhZ circuit over five qubits quantum_register = QuantumRegister(4, "qreg") classical_register1 = ClassicalRegister(2, "creg1") classical_register2 = ClassicalRegister(2, "creg2") ghz_circ = QuantumCircuit() ghz_circ.add_register(quantum_register) ghz_circ.add_register(classical_register1) ghz_circ.add_register(classical_register2) ghz_circ.h(0) for qubit in range(1, 4):