Skip to content

Commit

Permalink
Fix type of basis_gates in BasicSimulator configuration (#13385)
Browse files Browse the repository at this point in the history
`basis_gates` was getting set to `Target.operation_names`, which is a
`dict_keys` instance (maybe that should be changed to a more basic
type?), while typically `basis_gates` is a list. `dict_keys` instances
can not be deep copied, so code that usually deep copies a backend's
configuration could not work. Deep copying the configuration can happen
for example when using the `BasicSimulator` with sampler class like
`qiskit_ibm_runtime.SamplerV2` that puts the backend into its options
and then tries to deep copy the options.
  • Loading branch information
wshanks authored Oct 31, 2024
1 parent c6efb76 commit 09d1006
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion qiskit/providers/basic_provider/basic_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def configuration(self) -> BackendConfiguration:
backend_name=self.name,
backend_version=self.backend_version,
n_qubits=self.num_qubits,
basis_gates=self.target.operation_names,
basis_gates=list(self.target.operation_names),
gates=gates,
local=True,
simulator=True,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
fixes:
- |
For :class:`~.BasicSimulator`, the ``basis_gates`` entry in the
configuration instance returned by the ``configuration()`` is now a list
rather than a ``dict_keys`` instance, matching the expected type and
allowing for configuration instance to be deep copied.

0 comments on commit 09d1006

Please sign in to comment.