Skip to content

Add some utilities for T-rex error mitigation#8095

Draft
ddddddanni wants to merge 3 commits into
quantumlib:mainfrom
ddddddanni:trex
Draft

Add some utilities for T-rex error mitigation#8095
ddddddanni wants to merge 3 commits into
quantumlib:mainfrom
ddddddanni:trex

Conversation

@ddddddanni
Copy link
Copy Markdown
Collaborator

No description provided.

@github-actions github-actions Bot added the size: M 50< lines changed <250 label May 27, 2026
Copy link
Copy Markdown
Collaborator

@obriente obriente left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for submitting! The code seems ok, but I'm worried about some forward-compatibility issues, as well as making the workflow as easy as possible to combine with other error mitigation techniques. Would defer to other people on the team whether this is a significant issue or something that we can deal with later.

return sorted(all_qubits)


def _get_twirled_basis_gate(basis: cirq.Pauli, flip: bool) -> cirq.Gate:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The word 'twirl' is used for various things in the literature. Maybe it's better to call this 'trex-twirled' or 'readout-twirled'?

(Would defer to @zlatko-minev for an optimal name choice here.)

return cirq.Rx(rads=-np.pi / 2)


def _build_twirled_pauli_circuits(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name 'twirl' is used a lot in the literature, I'm not sure if 'twirled_pauli' is a good enough descriptor here? Would defer to @zlatko-minev for a decision here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I added trex prefix before twirled_pauli

"""Measures expectation values of Pauli strings using T-REX error mitigation.

Args:
circuits_to_pauli: Each object contains
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this planned to work with the above code? Is the idea that this will call _build_twirled_pauli_circuits for each circuit in circuits_to_pauli, run this through sampler, and then process the result?

I suggest that we use the workflow that the user takes a circuit, builds the twirled circuits given this input, then runs each twirled circuit through a sampler themselves, and then we provide a function to compile the resulting list of results (or list of expectation values). This would be easier to integrate with other forms of error mitigation.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I added a "generate_trex_and_readout_circuits" API which will return trex and readout circuits. I will add another method to compile the results.

)
twirl_circuits.append(twirled_circuit)

return twirl_circuits
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chriseclectic @eliottrosenberg - I think this is the best output one can give right now, but this requires the user keep track of twirl_choices themselves to know what to do with each circuit in twirl_circuits (which can be problematic, especially if we want to combine this with more error mitigation techniques).

Anyway, I guess the main question is - do you think that this will be forwards-compatible with any future changes to circuit data structures?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: M 50< lines changed <250

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants