11
22struct AerSimulator <: MQC.Simulator
33 python_interface:: PythonCall.Py
4+ circuit:: Circuit
45end
56"""
67 GPUStateVectorSimulator()
78
89A Qiskit Aer statevector simulator that runs on the GPU.
910"""
10- function GPUStateVectorSimulator ()
11+ function GPUStateVectorSimulator (nqubits :: Integer )
1112 _checkinit_qiskit_aer (; gpu= true )
1213 AerSimulator (qiskit_aer. AerSimulator (
1314 method= " statevector" ,
1415 device= " GPU" ,
1516 cuStateVec_enable= true ,
1617 enable_truncation= false ,
17- target= [0 ]
18- ))
18+ target= [0 ]),
19+ Circuit (nqubits + 1 ,nqubits + 1 ))
1920end
2021
2122"""
2223 StateVectorSimulator()
2324
2425A Qiskit Aer statevector simulator.
2526"""
26- function StateVectorSimulator ()
27+ function StateVectorSimulator (nqubits :: Integer )
2728 _checkinit_qiskit_aer ()
28- AerSimulator (qiskit_aer. AerSimulator (
29+ AerSimulator (
30+ qiskit_aer. AerSimulator (
2931 method= " statevector" ,
30- enable_truncation= false
31- ))
32+ enable_truncation= false ),
33+ Circuit (nqubits + 1 ,nqubits + 1 ))
3234end
3335
3436"""
3537 CliffordSimulator()
3638
3739A Qiskit Aer stabilizer simulator.
3840"""
39- function CliffordSimulator ()
41+ function CliffordSimulator (nqubits :: Integer )
4042 _checkinit_qiskit_aer ()
41- AerSimulator (qiskit_aer. AerSimulator (method= " stabilizer" ))
43+ AerSimulator (
44+ qiskit_aer. AerSimulator (method= " stabilizer" ),
45+ Circuit (nqubits+ 1 ,nqubits+ 1 ))
4246end
4347
4448"""
4549 GPUTensorNetworkSimulator()
4650
4751A Qiskit Aer tensor network simulator that runs on the GPU.
4852"""
49- function GPUTensorNetworkSimulator ()
53+ function GPUTensorNetworkSimulator (nqubits :: Integer )
5054 _checkinit_qiskit_aer (; gpu= true )
5155 AerSimulator (qiskit_aer. AerSimulator (
5256 method= " tensor_network" ,
5357 device= " GPU" ,
5458 cuStateVec_enable= true ,
5559 use_cuTensorNet_autotuning= true ,
5660 enable_truncation= false ,
57- target= [0 ]
58- ))
61+ target= [0 ]),
62+ Circuit (nqubits + 1 ,nqubits + 1 ))
5963end
6064function isSimulator (:: AerSimulator )
6165 return true
6266end
6367
6468function Base. show (io:: IO , :: MIME"text/plain" , obj:: AerSimulator )
65- println (io, " Name: $(obj. name) " )
66- println (io, " Qubits: $(obj. num_qubits) " )
69+ println (io, get_circuit (obj). python_interface)
6770end
6871
6972function Base. getproperty (qc:: AerSimulator , prop:: Symbol )
@@ -74,6 +77,24 @@ function Base.getproperty(qc::AerSimulator, prop::Symbol)
7477 end
7578end
7679
80+ function get_circuit (qc:: AerSimulator )
81+ return getfield (qc, :circuit )
82+ end
83+
84+ function aux (backend:: Union{AerSimulator,IBMBackend} )
85+ # Ancilla qubit is the last qubit in the circuit
86+ return nQubits (get_circuit (backend))
87+ end
88+
89+ function MQC. execute (backend:: AerSimulator ; shots= 1 )
90+ qc = get_circuit (backend)
91+ transpile! (qc, backend)
92+ sampler = Sampler (backend)
93+ job = run (sampler, qc; shots)
94+ nativeResult = job. result ()[0 ]
95+ return nativeResult
96+ end
97+
7798function MQC. execute (circuit:: MQC.CompiledCircuit , backend:: AerSimulator ; shots= 1024 )
7899 verbose = false
79100 verbose && print (" Transpiling circuit to Qiskit..." )
0 commit comments