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

fix jax jit with broadcasted probs #4742

Merged
merged 5 commits into from
Oct 27, 2023
Merged

fix jax jit with broadcasted probs #4742

merged 5 commits into from
Oct 27, 2023

Conversation

albi3ro
Copy link
Contributor

@albi3ro albi3ro commented Oct 26, 2023

Fixes Issue #4738

The ProbabilityMP.shape did not take into account probabilities that broadcasted across all available wires.

[sc-48626]

@albi3ro albi3ro requested a review from a team October 26, 2023 14:57
@github-actions
Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

@codecov
Copy link

codecov bot commented Oct 26, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (v0.33.0-rc0@cd72f35). Click here to learn what that means.

Additional details and impacted files
@@              Coverage Diff               @@
##             v0.33.0-rc0    #4742   +/-   ##
==============================================
  Coverage               ?   99.64%           
==============================================
  Files                  ?      380           
  Lines                  ?    33995           
  Branches               ?        0           
==============================================
  Hits                   ?    33873           
  Misses                 ?      122           
  Partials               ?        0           

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

Copy link
Contributor

@mudit2812 mudit2812 left a comment

Choose a reason for hiding this comment

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

This problem exists for sample().shape and state().shape as well. I think it's worthwhile updating them in this PR as well.

@albi3ro
Copy link
Contributor Author

albi3ro commented Oct 26, 2023

This problem exists for sample().shape and state().shape as well. I think it's worthwhile updating them in this PR as well.

jax-jit does not work with sample or state anyway, but it looks like they don't have the problem:

>>> qml.state().shape(qml.device('default.qubit', wires=(0,1)), qml.measurements.Shots(None))
(4,)
>>> qml.sample().shape(qml.device('default.qubit', wires=(0,1)), qml.measurements.Shots(5))
(5, 2)

@mudit2812
Copy link
Contributor

jax-jit does not work with sample or state anyway, but it looks like they don't have the problem:

Sorry, I meant for cases when devices without wires are used.

@albi3ro albi3ro requested a review from a team October 26, 2023 21:20
@albi3ro
Copy link
Contributor Author

albi3ro commented Oct 27, 2023

jax-jit does not work with sample or state anyway, but it looks like they don't have the problem:

Sorry, I meant for cases when devices without wires are used.

For devices without wires we are going to need to make a breaking change to the call signature of MeasurementProcess.shape. We will need to change from (device, shots) to (wires, shots) as the wires may be coming from the tape instead of from the device. I don't quite want to make a change like that this week.

Copy link
Contributor

@mudit2812 mudit2812 left a comment

Choose a reason for hiding this comment

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

Thanks!

@mudit2812 mudit2812 added this to the v0.33 milestone Oct 27, 2023
@albi3ro albi3ro enabled auto-merge (squash) October 27, 2023 15:34
@albi3ro albi3ro merged commit cf2bd9d into v0.33.0-rc0 Oct 27, 2023
32 checks passed
@albi3ro albi3ro deleted the fix-jit-probs branch October 27, 2023 15:50
@timmysilv
Copy link
Contributor

@albi3ro we might not need a breaking change. I used to just replace device with some object that also had wires defined (at the time, it was self) but we can do anything. I added it early in the device port, but I removed it from qscript.py here

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.

3 participants