Currently some tests are executing circuits using the circuit.execute()/circuit() interface, instead of backend.execute_circuit. This invokes the GlobalBackend which is set to an arbitrary value, potentially from a previous test, unless set_backend is used. More details in https://github.com/qiboteam/qibo/pull/1272#discussion_r1655006022.
A potential solution is to never use circuit() in tests and replace by backend.execute_circuit, except from very few tests that test the circuit() interface itself.
Another solution is to switch the global backend within the backend fixture, using for example something like
List of tests that execute circuits using the circuit.execute interface (which invokes the GlobalBackend()), found by inserting an assert False in circuit.execute:
test_backends_global::test_circuit_execution (sets to numpy)
test_measurements::test_measurement_compiled_circuit (does not set)
test_models_circuit_execution::test_compiled_execute (does not set)
Various tests in test_models_qcnn are using the GlobalBackend but setting it beforehand to qibojit or numpy without reseting it after.
test_models_variational::test_vqe (does not set)
test_models_variational::test_custom_loss (does not set)
Currently some tests are executing circuits using the
circuit.execute()
/circuit()
interface, instead ofbackend.execute_circuit
. This invokes theGlobalBackend
which is set to an arbitrary value, potentially from a previous test, unlessset_backend
is used. More details in https://github.com/qiboteam/qibo/pull/1272#discussion_r1655006022.A potential solution is to never use
circuit()
in tests and replace bybackend.execute_circuit
, except from very few tests that test thecircuit()
interface itself.Another solution is to switch the global backend within the
backend
fixture, using for example something likeList of tests that execute circuits using the
circuit.execute
interface (which invokes theGlobalBackend()
), found by inserting anassert False
incircuit.execute
:test_backends_global::test_circuit_execution
(sets to numpy)test_measurements::test_measurement_compiled_circuit
(does not set)test_models_circuit_execution::test_compiled_execute
(does not set)test_models_qcnn
are using theGlobalBackend
but setting it beforehand to qibojit or numpy without reseting it after.test_models_variational::test_vqe
(does not set)test_models_variational::test_custom_loss
(does not set)