Skip to content

Enhance GateModelResultData to support direct probability data #55

@WingCode

Description

@WingCode

Copied from qBraid/qBraid #785

The GateModelResultData.get_probabilities() method currently computes a probability distribution based on the measurement counts:

https://github.com/qBraid/qBraid/blob/03aa38b89081a3e6fc6890ac4e785eba96769847/qbraid/runtime/result.py#L163-L164

This works well for QPUs and for simulators that return raw measurement counts. However, many ideal quantum simulators compute the exact quantum state, providing deterministic results. These simulators do not involve probabilistic sampling, and the concept of shots does not apply. Consequently, these simulators do not return raw measurements or measurement counts, but instead provide direct probability data (histogram).

To better support these simulators, the GateModelResultData class should be updated to optionally accept pre-computed probabilities. This would allow get_probabilities() to return these probabilities directly, without needing to calculate them from counts.

TODO

  • Add an optional argument to the GateModelResultData class to accept pre-computed probabilities.
  • If probabilities are provided, get_probabilities() should return them directly.
  • If probabilities are not provided, get_probabilities() should maintain its current behavior of calculating probabilities based on get_counts().
  • Regardless of whether probabilities are computed from counts or provided directly, get_probabilities() should continue to respect the decimal=True/False option for formatting keys.
  • Since the function for normalizing data will now apply to both counts and direct probability histograms, consider renaming normalize_counts() to something more general, like normalize_histogram_data().

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions