Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor [NoiseModelFrom]NoiseProperties #4866

Merged
merged 14 commits into from
Feb 7, 2022

Conversation

95-martin-orion
Copy link
Collaborator

This PR converts NoiseProperties to an interface and modifies NoiseModelFromNoiseProperties to match. It also temporarily removes the calibration_to_noise_properties and compare_generated_noise_to_metrics files which depended on the old versions of this code; these will be reinstated in a later PR.

This is part 1 of #4666. Remaining steps include:

  • Addition of SuperconductingQubitsNoiseProperties
  • Reinstatement of calibration_to_noise_properties using new types
  • Reinstatement of compare_generated_noise_to_metrics using new types

@CirqBot CirqBot added the size: XL lines changed >1000 label Jan 20, 2022
@MichaelBroughton MichaelBroughton self-assigned this Jan 20, 2022
Copy link
Collaborator

@MichaelBroughton MichaelBroughton left a comment

Choose a reason for hiding this comment

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

Looks good with some small nits. Also wondering why exactly does the noisy_moments function need this measurement splitting + noise add + measurement recombine stuff ? Why can't it look more like:

noisy_circuit = split_measure_circuit.copy()
for model in self.noise_models:
    noisy_circuit = noisy_circuit.with_noise(model)

and leave the NoiseModel to look after what's physical and what's virtual etc.

Device-specific subclasses should implement this method to mark any
operations which their device handles outside the quantum hardware.
"""
return False
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be False always ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In the general case, yes - outside of the Google device (which gets its own implementation of this), what gates are "virtual" varies between devices. I suppose we could check for VirtualTag here, but note that we don't use VirtualTag in the Google version (see google_noise_properties in #4733).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Discussed offline: keep the current behavior, but document it thoroughly (especially the virtual/non-virtual distinction).

cirq-core/cirq/devices/noise_properties.py Show resolved Hide resolved
cirq-core/cirq/devices/noise_properties.py Show resolved Hide resolved
cirq-core/cirq/devices/noise_properties.py Outdated Show resolved Hide resolved
Comment on lines 84 to 86
# Only subclasses will trigger this case.
if virtual_ops:
new_moments.append(ops.Moment(virtual_ops)) # coverage: ignore
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this because we expect subclasses to override what's virtual and what is not ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yup, both on the comment and the coverage: ignore.

Copy link
Collaborator Author

@95-martin-orion 95-martin-orion left a comment

Choose a reason for hiding this comment

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

@MichaelBroughton I'm not entirely clear on what you're suggesting for measurement splitting, but it exists here for a couple of reasons:

  • Populating an InsertionNoiseModel for all possible multi-qubit measurement gates is infeasible, since it uses a map of {base_gate: noise} instead of a function.
  • Handling "what is virtual" here prevents code duplication across noise models.

cirq-core/cirq/devices/noise_properties_test.py Outdated Show resolved Hide resolved
cirq-core/cirq/devices/noise_properties.py Show resolved Hide resolved
cirq-core/cirq/devices/noise_properties.py Show resolved Hide resolved
Copy link
Collaborator

@MichaelBroughton MichaelBroughton left a comment

Choose a reason for hiding this comment

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

LGTM, once we have a bit more description in docstring.

@MichaelBroughton MichaelBroughton added automerge Tells CirqBot to sync and merge this PR. (If it's running.) and removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) labels Feb 4, 2022
@95-martin-orion 95-martin-orion added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Feb 7, 2022
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Feb 7, 2022
@CirqBot
Copy link
Collaborator

CirqBot commented Feb 7, 2022

Automerge cancelled: A required status check is not present.

Missing statuses: ['Pytest Ubuntu (3.8)', 'Pytest Ubuntu (3.9)', 'Pytest Windows (3.7)', 'Pytest Windows (3.8)', 'Pytest Windows (3.9)', 'Typescript lint check', 'Typescript tests', 'Typescript tests coverage']

@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels Feb 7, 2022
@95-martin-orion 95-martin-orion merged commit 2d2226a into quantumlib:master Feb 7, 2022
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
* Update NoiseProperties class

* Update calibration-to-noise experiment

* Align with naming conventions

* Split off SuperconductingQubitNoiseProperties

* Two-qubit pauli err from calibrations

* Format fix

* Resolve trailing TODOs

* Reduce to noise_properties.

* Review comments

* Document (non)virtual behaviors.

* Align with moment move

Co-authored-by: Cirq Bot <[email protected]>
harry-phasecraft pushed a commit to PhaseCraft/Cirq that referenced this pull request Oct 31, 2024
* Update NoiseProperties class

* Update calibration-to-noise experiment

* Align with naming conventions

* Split off SuperconductingQubitNoiseProperties

* Two-qubit pauli err from calibrations

* Format fix

* Resolve trailing TODOs

* Reduce to noise_properties.

* Review comments

* Document (non)virtual behaviors.

* Align with moment move

Co-authored-by: Cirq Bot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: XL lines changed >1000
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants