qiskit-community / qiskit-dynamics

Tools for building and solving models of quantum systems in Qiskit
https://qiskit-community.github.io/qiskit-dynamics/
Apache License 2.0
103 stars 61 forks source link

`DynamicsBackend.from_backend` doesn't work with subsystem measurements for backends with a qubit count greater than `32` #357

Open NotJustSid opened 3 months ago

NotJustSid commented 3 months ago

Informations

What is the current behavior?

A backend created through DynamicsBacked.from_backend and initialized with a subsystem_list errors out with

ValueError: maximum supported dimension for an ndarray is ..., found ...

Steps to reproduce the problem

from qiskit_ibm_runtime import QiskitRuntimeService
from qiskit_dynamics import DynamicsBackend

service = QiskitRuntimeService()
kyoto_backend = service.backend('ibm_kyoto')
kyoto_qubits = [1, 0]

dynamics_backend = DynamicsBackend.from_backend(kyoto_backend, subsystem_list=kyoto_qubits)

circuit = QuantumCircuit(2, 2) # example circuit
circuit.cx(0, 1)
circuit.x(0)
circuit.measure(0, 0)

transpiled_circuit = transpile(circuit, kyoto_backend)
sched = schedule(transpiled_circuit, kyoto_backend)

result = dynamics_backend.run(sched).result() # ValueError: maximum supported dimension for an ndarray is 32, found 127

What is the expected behavior?

Successful simulation followed by a Result object being returned.

Suggested solutions/workaround

As detailed in this Slack thread one would need to redefine options.subsystem_dims.

Making changes similar to this on a local fork acts as a temporary workaround.