Noise module: build a CycleChannel from a per-instruction rule, and expose MeasurementChannel back-action

Open
#1,900 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
api, backend

Research direction

Start with pyquil.noise._channels, especially CycleChannel.__post_init__, CycleChannel.expanded_instructions, ChannelBase.to_pauli_vector(), and MeasurementChannel; compare the existing expansion helper in pyquil.simulation._resolver. Decide how the two proposed APIs should expose instruction context and measurement back-action conventions, then add focused tests for cycle expansion and outcome-summed measurement behavior, including leakage for higher-dimensional instruments.

Written by the indexing model from the issue text.

Description

Two small API requests for the experimental Quax-based noise module (pyquil.noise._channels), related to the tracking issue #1863. Both come from downstream code that converts a NoiseModel into other representations (for example a Pauli/stabilizer simulator) and currently has to reach into private helpers or re-derive things the channel classes already know.

1. Build a CycleChannel from a rule for one instruction

CycleChannel.__post_init__ requires one channel for every instruction in the cycle's DefCircuit body. To supply them, a caller first has to expand the DEFCIRCUIT invocation into concrete instructions, and the only way to do that today is the private pyquil.simulation._resolver.expand_defcircuit_body:

body = list(expand_defcircuit_body(invocation, defcircuit, circuit_definitions={}))
channels = tuple(channel_for(inst, body) for inst in body)
cycle_channel = CycleChannel(inst=invocation, defcircuit=defcircuit, channels=channels)

This pattern is repeated wherever a model is described by a rule ("every CZ gets this channel, an idle lasts as long as the slowest operation in its cycle") instead of an explicit list.

Proposal: a constructor that does the expansion, e.g.

CycleChannel.from_rule(
    inst,                 # the Gate that invokes the cycle
    defcircuit,
    channel_for,          # Callable[[instruction, Sequence[instruction]], CycleConstituent]
)

where channel_for receives the concrete instruction and all concrete instructions of its cycle (so that idle durations and similar context-dependent quantities can be derived). Alternatively, making the expansion itself public (it already backs CycleChannel.expanded_instructions) would be enough.

2. Back-action of a MeasurementChannel as a Pauli vector (and leakage)

ChannelBase.to_pauli_vector() gives the Pauli-twirled error of a gate channel. MeasurementChannel has no equivalent, so consumers that need the post-measurement disturbance (the QND error) as a Pauli channel compute it themselves from process.total_channel(), and can easily choose slightly different conventions (for example conditioning on the reported outcome or not).

Proposal: a method on MeasurementChannel that returns the back-action in a documented convention, e.g.

MeasurementChannel.to_pauli_vector() -> Array   # [I, X, Y, Z] applied after the measurement

read from the outcome-summed channel: the bit-flip probability averaged over the computational basis states, conditioned on staying in the computational subspace. For instruments on more than two levels, the same populations also give the measurement-induced leakage and seepage probabilities, which would be useful to expose alongside it (possibly as separate methods).

Happy to open a PR for either if the shape of the API sounds right.

Dominant language
Python
Stars
1.5k
Forks
366
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rigetti/pyquil

All issues in rigetti/pyquil

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.