def test_amplitude_damping_error(self): """Test amplitude damping error damps to correct state""" qr = QuantumRegister(1, 'qr') cr = ClassicalRegister(1, 'cr') circuit = QuantumCircuit(qr, cr) circuit.x(qr) # prepare + state for _ in range(30): # Add noisy identities circuit.barrier(qr) circuit.i(qr) circuit.barrier(qr) circuit.measure(qr, cr) shots = 4000 backend = AerSimulator() # test noise model error = amplitude_damping_error(0.75, 0.25) noise_model = NoiseModel() noise_model.add_all_qubit_quantum_error(error, 'id') # Execute target = {'0x0': 3 * shots / 4, '0x1': shots / 4} circuit = transpile(circuit, basis_gates=noise_model.basis_gates, optimization_level=0) result = backend.run(circuit, shots=shots, noise_model=noise_model).result() self.assertSuccess(result) self.compare_counts(result, [circuit], [target], delta=0.05 * shots)
def test_noise_model_from_mumbai(self): circ = QuantumCircuit(2) circ.x(0) circ.x(1) circ.measure_all() backend = mock.FakeMumbai() noise_model = NoiseModel.from_backend(backend) circ = transpile(circ, backend, optimization_level=0) result = AerSimulator().run(circ, noise_model=noise_model).result() self.assertTrue(result.success)
def test_can_run_circuits_with_delay_noise(self): circ = QuantumCircuit(2) circ.h(0) circ.cx(0, 1) circ.measure_all() backend = mock.FakeLagos() noise_model = NoiseModel.from_backend(backend) qc = transpile(circ, backend, scheduling_method="alap") result = AerSimulator().run(qc, noise_model=noise_model).result() self.assertTrue(result.success) # test another path noisy_sim = AerSimulator().from_backend(backend) qc = transpile(circ, noisy_sim, scheduling_method="alap") result = noisy_sim.run(qc).result() self.assertTrue(result.success) # no scheduling = no delay noise qc = transpile(circ, backend) result = AerSimulator().run(qc, noise_model=noise_model).result() self.assertTrue(result.success)
def test_mappable_qasm(self): """Test that the qasm controller can be mapped.""" cfunc = aer_controller_execute() sim = AerSimulator() fqobj = self._create_qobj(sim) self._map_and_test(cfunc, fqobj)