catalyst
catalyst copied to clipboard
Fix ZNE with measurements_from_samples
trafficstars
Context:
-
Jax generates additional const arguments with [...], and take.
-
The
mitigate_with_znedoes not work when using themeasurements_from_samplefunction. The root of the the issue is the functionremoveQuantumMeasurementsthat tries to remove all users of the measurments. But potentially users are located in a block of an operations, therefore emptying the block but not the operation.
Description of the Change:
- The JaxPr const are added to the ZNE op args.
- removeQuantumMeasurements is replaced by replaceQuantumMeasurements, this functions is replacing quantum measurements with empty tensors. The tensors are remove in the bufferization pass. (
--inline, --canonicalize)
Benefits: ZNE with shots works with hardware devices (counts and samples)