-
Notifications
You must be signed in to change notification settings - Fork 945
Qiskit Backend
Trevor Grant edited this page Aug 16, 2024
·
1 revision
This section covers the usage of the Qiskit backend in the QuMat library.
To initialize the Qiskit backend, use the initialize_backend
function. This function accepts a backend_config
dictionary.
from qumat.qiskit_backend import initialize_backend
backend_config = {
'backend_options': {
'simulator_type': 'qasm_simulator',
'shots': 1024
}
}
backend = initialize_backend(backend_config)
To create an empty circuit, use the create_empty_circuit function.
from qumat.qiskit_backend import create_empty_circuit
circuit = create_empty_circuit(num_qubits=2)
To apply different quantum gates, use the following functions:
from qumat.qiskit_backend import apply_not_gate
apply_not_gate(circuit, qubit_index=0)
from qumat.qiskit_backend import apply_hadamard_gate
apply_hadamard_gate(circuit, qubit_index=0)
from qumat.qiskit_backend import apply_cnot_gate
apply_cnot_gate(circuit, control_qubit_index=0, target_qubit_index=1)
To execute the circuit, use the execute_circuit function.
from qumat.qiskit_backend import execute_circuit
result = execute_circuit(circuit, backend, backend_config)
print(result)
To get the final state vector, use the get_final_state_vector function.
from qumat.qiskit_backend import get_final_state_vector
state_vector = get_final_state_vector(circuit, backend, backend_config)
print(state_vector)