Pipes should have their own plaquettes
Is your feature request related to a problem? Please describe.
Right now, pipes are implemented by SubstititionRule instances that describe how to substitute the plaquettes on the boundary of blocks depending on the pipe that link them.
The current default (and only) substitution rule perform the following replacement
on block plaquettes (pipe in the X direction shown above, Y and time dimensions follow the same algorithm).
This requires a few fixes at runtime because, for spatial replacements, the data qubits that are on the line between the two logical qubit instances should be initialized. We initially did that with
def _inplace_add_operation_on_data_qubits(
plaquette: Plaquette,
side: PlaquetteSide,
operation_basis: ResetBasis | MeasurementBasis,
moment_schedule: int,
) -> None:
# TODO: Remove that and make Plaquette frozen.
qubits = plaquette.qubits.get_qubits_on_side(side)
# Do not add resets on qubits that have already be reset
moment = plaquette.circuit.moment_at_schedule(moment_schedule)
q2i = plaquette.circuit.q2i
operations_to_add = stim.Circuit()
for q in qubits:
if moment.operates_on([q2i[q]]):
continue
operations_to_add.append(operation_basis.instruction_name, [q2i[q]], [])
plaquette.circuit.add_to_schedule_index(moment_schedule, Moment(operations_to_add))
but that heuristic fails to adhere to the specs provided by the user. What if the user asked for only Z-basis resets and measurements and wants a Hadamard gate inserted instead of RX? What if only some data qubits should have a Hadamard gate applied on them? (#345 requires that for ZXXZ code).
Describe the solution you'd like
Instead of taking plaquettes from the connected blocks, pipes should have their own "instantiation" (i.e., a Template instance and some Plaquettes).
I think that several changes will be needed:
- Removing the
_inplace_add_operation_on_data_qubitsshould allow us to makePlaquetteread-only (frozen=True). - The
PlaquetteBuilderprotocol introduced in #345 will likely have to be changed. I think that we should, for each "specs", define an instance (something like "PlaquetteLibrary"?) that lists all the plaquettes that might be needed. I do not know what is the best way of doing that, right now a map from identifiers toPlaquetteinstances seems a good option to me, something like
withplibrary = CSSPlaquetteLibrary(**options) xxxx_plaquette = plibrary.get("xxxx") xxxx_junction_left_plaquette = plibrary.get("xxxx_junction_left")"xxxx","xxxx_junction_left", ... identifiers that describe the associated plaquette and that are documented / enforced in the code. - Build the pipes into "PlaquetteLibrary" (naming?) instances.
- Change the substitution rules.
PlaquetteLibrary sounds like a good idea. Do you have begun working on this issue? If not, I would like to think more about it and give it a try.
PlaquetteLibrarysounds like a good idea. Do you have begun working on this issue? If not, I would like to think more about it and give it a try.
Not more than what was in #345, so go ahead :)