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

Caching grouped results and refactor sampling estimator #302

Merged
merged 23 commits into from
Jan 18, 2024

Conversation

dchung0741
Copy link
Contributor

New changes

  • Caching mechanism: The CachedMeasurementFactory class decorator is supported to cache the outputs of measurement factories.
  • The function body of (concurrent_)sampling_estimate is refactored while keeping the interface intact.
    • helper functions provided:
      • distribute_shots_among_pauli_sets: distribute shots among distinct commuting sets.
      • CircuitShotPairPreparationFunction: type alias that represents a function that prepares the (circuit, shot) pairs for performing sampling estimation on a state.
      • get_sampling_circuits_and_shots: default CircuitShotPairPreparationFunction that concatenates measurement circuit after state preparation circuits.
      • get_estimate_from_sampling_result: returns the estimate from sampling count.
    • Slight change in the interface (not breaking): New circuit_shot_pair_prep_fn argument is added to (concurrent_)sampling_estimate. It is default to the get_sampling_circuits_and_shots helper function, so old codes are still supported

Examples

  • How caching is supported
cached_measurement_factory = CachedMeasurementFactory(bitwise_commuting_pauli_measurement)
estimate = sampling_estimate(
    Operator({pauli_label("Z0 Z7"): 1, pauli_label("X1 Y2"): 8}),
    quantum_state(8, bits=1),
    1000,
    concurrent_sampler,
    cached_measurement_factory,
    allocator,
)

Copy link

@github-actions github-actions bot temporarily deployed to pull request January 17, 2024 01:29 Inactive
Copy link
Contributor

@rykojima rykojima left a comment

Choose a reason for hiding this comment

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

Thank you for the implementation. LGTM!

@rykojima rykojima merged commit e04ca67 into main Jan 18, 2024
8 checks passed
@rykojima rykojima deleted the refactor_sampling_estimate branch January 18, 2024 01:39
@github-actions github-actions bot locked and limited conversation to collaborators Jan 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants