Skip to content

Update PyQrack.run to match RFC #225

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

Closed
wants to merge 4 commits into from
Closed

Conversation

weinbe58
Copy link
Member

@weinbe58 weinbe58 commented May 1, 2025

@weinbe58 weinbe58 linked an issue May 1, 2025 that may be closed by this pull request
@weinbe58 weinbe58 added the breaking breaking changes or proposed changes that would break existing APIs label May 1, 2025
Copy link

codecov bot commented May 1, 2025

Codecov Report

Attention: Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/bloqade/pyqrack/target.py 90.90% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Contributor

github-actions bot commented May 1, 2025

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
6288 5403 86% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
src/bloqade/pyqrack/target.py 95% 🟢
TOTAL 95% 🟢

updated for commit: 543f22b by action🐍

@weinbe58 weinbe58 requested review from Roger-luo and johnzl-777 May 1, 2025 17:10
shots: int = 1,
args: tuple[Any, ...] = (),
kwargs: dict[str, Any] = {},
return_iterator: bool = False,
Copy link
Member

Choose a reason for hiding this comment

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

what's the use case of return_iterator?

Copy link
Member Author

Choose a reason for hiding this comment

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

This goes back to the discussion of memory conservation, if you return a register that will mean the full state will persist in memory if you store the simulator object in a list whereas if you return an iterator you have the option of only using the simulator object for that iteration and the gc can clean it up. Also, we get this for free since we need to loop for each shot anyway its just a slight difference in implementation.

The result of the simulation. If `return_iterator` is True,
an iterator that yields results for each shot is returned.
Otherwise, a list of results is returned if `shots > 1`, or
a single result is returned if `shots == 1`.
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if returning different data type here is a good idea. should we always return list or Iterator[RetType]? Maybe Iterable[RetType]?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a typo It should be Iterable

Copy link
Member Author

Choose a reason for hiding this comment

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

One option is we just always return the Iterable and then just let people capture those values into a list by default:

result = list(device.run(...))

@weinbe58 weinbe58 requested a review from Roger-luo May 1, 2025 17:36
@weinbe58 weinbe58 closed this May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking breaking changes or proposed changes that would break existing APIs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFC: shot execution interface
3 participants