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

Lightning qubit2 supports shots #630

Merged
merged 252 commits into from
Mar 19, 2024
Merged

Lightning qubit2 supports shots #630

merged 252 commits into from
Mar 19, 2024

Conversation

vincentmr
Copy link
Contributor

@vincentmr vincentmr commented Mar 7, 2024

Before submitting

Please complete the following checklist when submitting a PR:

  • All new features must include a unit test.
    If you've fixed a bug or added code that should be tested, add a test to the
    tests directory!

  • All new functions and code must be clearly commented and documented.
    If you do make documentation changes, make sure that the docs build and
    render correctly by running make docs.

  • Ensure that the test suite passes, by running make test.

  • Add a new entry to the .github/CHANGELOG.md file, summarizing the
    change, and including a link back to the PR.

  • Ensure that code is properly formatted by running make format.

When all the above are checked, delete everything above the dashed
line and fill in the pull request template.


Context:
The new LQ device must support shots.

Description of the Change:
Add shots support in LQ2.
Add shots tests in test_measurements.py.
Fix bugs uncovered in LQ by new shots tests.

Benefits:

Possible Drawbacks:

Related GitHub Issues:

@vincentmr vincentmr marked this pull request as ready for review March 18, 2024 15:04
@vincentmr vincentmr requested a review from AmintorDusko March 18, 2024 18:10
Copy link
Contributor

@AmintorDusko AmintorDusko left a comment

Choose a reason for hiding this comment

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

Great work, I left just a few comments.

Copy link
Member

@mlxd mlxd left a comment

Choose a reason for hiding this comment

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

Thanks @vincentmr
Just a few comments --- ignore anything that isn't sensible.

@vincentmr vincentmr requested review from mlxd and AmintorDusko March 19, 2024 13:29
Copy link
Contributor

@AmintorDusko AmintorDusko left a comment

Choose a reason for hiding this comment

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

Nice work on that!

@vincentmr vincentmr merged commit 4aa532e into master Mar 19, 2024
84 of 85 checks passed
@vincentmr vincentmr deleted the lightning-qubit2-add-shots branch March 19, 2024 13:52
@AmintorDusko AmintorDusko restored the lightning-qubit2-add-shots branch March 19, 2024 13:59
@AmintorDusko AmintorDusko deleted the lightning-qubit2-add-shots branch March 19, 2024 13:59
Copy link
Member

@maliasadi maliasadi left a comment

Choose a reason for hiding this comment

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

I didn't thoroughly review this PR.. just a few high-level questions/concerns while scrolling the support,

Comment on lines +289 to +290
if circuit.shots.has_partitioned_shots:
return tuple(res[0] for res in results)
Copy link
Member

Choose a reason for hiding this comment

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

when is it triggered?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When one has something like dev = qml.device(name, shots=[10, 20, 30]).

if len(circuit.measurements) == 1:
return self.measurement(circuit.measurements[0])

return tuple(self.measurement(mp) for mp in circuit.measurements)
Copy link
Member

Choose a reason for hiding this comment

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

Isn't PL added support for PyTrees as return values? I'm concerned for users requested a non-tuple return value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure, but I think the device's job is to bring the measurements in a format that the QNode can handle, and the QNode does the final reshaping, casting, etc.

Comment on lines +76 to +78
mcmc: bool = None,
kernel_name: str = None,
num_burnin: int = None,
Copy link
Member

Choose a reason for hiding this comment

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

We could use a data-class encapsulate all MCMC options in the whole pipeline.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't use those, but we could. Good idea.

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.

6 participants