Feat adjust measure#198
Conversation
| @@ -484,47 +481,8 @@ def _check_targets_order(self): | |||
| """Ensures target qubits are ordered and contiguous, rearranging them if | |||
| necessary (private).""" | |||
|
|
|||
| if len(self.targets) == 0: | |||
| self._pre_measure: list[Gate] = [] | |||
| return | |||
|
|
|||
| if self.nb_qubits != self.observables[0].nb_qubits: | |||
| raise NumberQubitsError( | |||
| f"Target size {self.nb_qubits} doesn't match observable size " | |||
| f"{self.observables[0].nb_qubits}." | |||
| ) | |||
|
|
|||
| self.rearranged_targets = list(self.targets) | |||
| self._pre_measure: list[Gate] = [] | |||
There was a problem hiding this comment.
is this function still needed ?
There was a problem hiding this comment.
Done 59fd820
Removed rearranged_targets, it was only used by the old swap path. Also removed pre_measure since Measure.pre_measure already returns [ ]
There was a problem hiding this comment.
I wonder if you didn't mixed things up, I was talking about the function @MathieuG-Colibri removed in 4dfbb16
| ] | ||
| for circuit in pre_measure: | ||
| for instr in circuit.instructions: | ||
| instr.targets[0] = job.measure.targets[instr.targets[0]] |
There was a problem hiding this comment.
why are you changing just the first target ? the logic looks a bit dodgy here
There was a problem hiding this comment.
Yeah, instr.targets[0] was originally used because find_qubitwise_rotations(...) return single qubit instructions., so each generated instruction has one target. But yeah, this assumption is not obvious, so I agree it looks fragile
| ] | ||
| for circuit in pre_measure: | ||
| for instr in circuit.instructions: | ||
| instr.targets[0] = job.measure.targets[instr.targets[0]] |
…nto feat-adjust-measure
…nto feat-adjust-measure
| ) | ||
|
|
||
| for i in range(nb_qubits): | ||
| qcircuit.add(rng.choice(gates)(i)) |
There was a problem hiding this comment.
don't we have a function for that ?
Updated the way to treat expectation measures.
If the measure doesn't cover the whole registry we pad the pauli string with Identities, or is not ordered (instead of swap gates reorganize the matrix or pauli string).
Isn't necessary for braket with optimize_measure set at true (does the pauli grouping).