Skip to content

qiskit-community/qiskit-quimb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

qiskit-quimb

Simulate Qiskit circuits using quimb.

Installation

pip install qiskit-quimb

Usage

The qiskit_quimb module exposes two functions:

  • quimb_circuit: Converts a Qiskit circuit to a quimb circuit. This is probably the function you want to use.
  • quimb_gates: Converts a Qiskit circuit to a list of quimb gates, which is a bit more flexible.

Code example

import quimb.tensor
from qiskit.circuit import QuantumCircuit, QuantumRegister
from qiskit_quimb import quimb_circuit

# Build a Qiskit circuit
qubits = QuantumRegister(2)
circuit = QuantumCircuit(qubits)
a, b = qubits
circuit.h(a)
circuit.cx(a, b)

# Convert it to a quimb circuit
quimb_circ = quimb_circuit(circuit)

# Sample 10 bitstrings
samples = list(quimb_circ.sample(10, seed=1234))
print(samples)

# You can specify the quimb Circuit subclass and keyword arguments for the constructor
quimb_circ = quimb_circuit(
    circuit, quimb_circuit_class=quimb.tensor.CircuitMPS, max_bond=20
)
samples = list(quimb_circ.sample(10, seed=1234))
print(samples)
['00', '00', '11', '00', '11', '00', '11', '00', '11', '11']
['11', '11', '00', '00', '11', '00', '11', '11', '11', '00']