C2QA / bosonic-qiskit

Extension of Qiskit to support hybrid boson-qubit simulations for the NQI C2QA effort.
BSD 2-Clause "Simplified" License
51 stars 14 forks source link

Stateread not working for 3 qubits per qumode #50

Closed EllaCrane closed 2 years ago

EllaCrane commented 2 years ago

`qubits_per_mode=3

qmr = c2qa.QumodeRegister(num_qumodes=2, num_qubits_per_qumode=qubits_per_mode, name="qmr")

circuit = c2qa.CVCircuit(qmr)

circuit.cv_initialize(2, qmr[0]) circuit.cv_initialize(0, qmr[1]) stateop, result = c2qa.util.simulate(circuit) occs = util.stateread(stateop, 0, 2, 4, verbose=True)`

tjstavenger-pnnl commented 2 years ago

Should your code be this, instead? Is the cutoff passed into stateread correct?

num_qumodes=2
qubits_per_mode=3        

qmr = c2qa.QumodeRegister(num_qumodes=num_qumodes, num_qubits_per_qumode=qubits_per_mode, name="qmr")

circuit = c2qa.CVCircuit(qmr)

circuit.cv_initialize(2, qmr[0])
circuit.cv_initialize(0, qmr[1])
state, result = c2qa.util.simulate(circuit)
occs = c2qa.util.stateread(state, numberofqubits=0, numberofmodes=num_qumodes, cutoff=circuit.cutoff, verbose=True)

My output with this is:

qumodes:  02  qubits:       with amplitude: 1.000 + i0.000
occupation modes  [0.0, 2.0]
occupation qubits  []
EllaCrane commented 2 years ago

YES!! Haha thank you Tim!