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

feat: result appending post-processing #713

Merged
merged 2 commits into from
Jan 3, 2025
Merged

feat: result appending post-processing #713

merged 2 commits into from
Jan 3, 2025

Conversation

ss2165
Copy link
Member

@ss2165 ss2165 commented Dec 12, 2024

To enable e.g. all the elements of an array to be collated in to the same bitstrings, see tests

Flattens lists so can be used once entire arrays can be printed too.

So some guppy that looks like for a given shot:

vals = (1, 0, 1, 0)
for v in vals:
    result("c", v)

results in post-processed output, over 100 shots

Counter({(("c", 1010"),): 100})

@codecov-commenter
Copy link

codecov-commenter commented Dec 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.83%. Comparing base (647ad3d) to head (54c2582).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #713      +/-   ##
==========================================
+ Coverage   92.81%   92.83%   +0.01%     
==========================================
  Files          71       71              
  Lines        8159     8178      +19     
==========================================
+ Hits         7573     7592      +19     
  Misses        586      586              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

"d": Counter({"11111": 10, "10": 1}),
"e": Counter({"1": 1}),
"lst": Counter({"101101": 1}),
}
Copy link
Contributor

Choose a reason for hiding this comment

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

In this counter, are we losing information about the correlation between different tags across shots?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, but it is still preserved in the full results object. The conversion to pytket preserves it for example.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. I think those correlations would be important in most cases. No harm in offering this format, but I think we should also offer a counter-like result format that doesn't lose any information except for the shot ordering. I guess this would have to be something like Counter({(("c", "111"), ("d", "10")): 1, ...})?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah maybe that makes more sense as a default

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, although even that format isn't sufficient to capture the order of results within a shot (e.g. whether the "d" came between the first and second "c" or not), representing different control-flow paths. For that, we may need a format like Counter({("c", 1), ("c", 1), ("d", 1), ("c", 1), ("d", 0)) : 1, ...}).

Copy link
Member Author

Choose a reason for hiding this comment

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

that's too noisy to be useful in this context I think

Copy link
Contributor

Choose a reason for hiding this comment

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

We may need to offer several different "views" into results to serve different use cases.

Copy link
Member Author

Choose a reason for hiding this comment

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

yep, we already have register_counts for serving the traditional "classical register" style use, this RFC is effectively view number 2

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good to me.

Copy link
Member Author

@ss2165 ss2165 Dec 23, 2024

Choose a reason for hiding this comment

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

representing different control-flow paths

I think Counter(shots.results) where shots is an instance of HShots already gets you this

To enable e.g. all the elements of an array to be collated in to the same bitstrings, see tests

Flattens lists so can be used once entire arrays can be printed too.
@ss2165 ss2165 marked this pull request as ready for review December 23, 2024 12:21
@ss2165 ss2165 requested a review from a team as a code owner December 23, 2024 12:21
@ss2165 ss2165 requested review from tatiana-s and cqc-alec December 23, 2024 12:21
@ss2165 ss2165 changed the title [RFC] feat: result appending post-processing feat: result appending post-processing Dec 23, 2024
Copy link
Contributor

@tatiana-s tatiana-s 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 to me

@ss2165 ss2165 added this pull request to the merge queue Jan 3, 2025
Merged via the queue into main with commit d0ec1ce Jan 3, 2025
3 of 5 checks passed
@ss2165 ss2165 deleted the ss/collate branch January 3, 2025 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants