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

sample_probs is extracted out of sample_state #6354

Merged
merged 84 commits into from
Oct 11, 2024

Conversation

JerryChen97
Copy link
Contributor

@JerryChen97 JerryChen97 commented Oct 7, 2024

Context:
Currently, the sample_state helper function accepts a state vector, turns it into probabilities, and then samples it. This task is to break out the code for sample_probs from this function.

By breaking this code into it's own helper function, we can reuse it for a "sample density matrix" implementation.
Description of the Change:

  • Separate devices.qubit.sampling.sample_probs from sample_state
  • Separate devices.qubit.sampling.sample_probs_jax from _sample_state_jax
  • similar but for qutrit mixed
  • similar but for qutrit mixed

Benefits:
Better modularization; disentanglement

Future usage in new devices

Possible Drawbacks:

Related GitHub Issues:

Related ShortCut Stories:
[sc-73317]

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.

Looks good so far 🚀 . I've left a few comments that I think should be addressed before I can approve.

doc/releases/changelog-dev.md Outdated Show resolved Hide resolved
pennylane/devices/qubit/sampling.py Outdated Show resolved Hide resolved
pennylane/devices/qubit/sampling.py Outdated Show resolved Hide resolved
pennylane/devices/qubit/sampling.py Outdated Show resolved Hide resolved
pennylane/devices/qubit/sampling.py Outdated Show resolved Hide resolved
pennylane/devices/qubit/sampling.py Outdated Show resolved Hide resolved
JerryChen97 and others added 4 commits October 10, 2024 16:40
Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
@JerryChen97 JerryChen97 removed the WIP 🚧 Work-in-progress label Oct 10, 2024
Copy link
Contributor Author

@JerryChen97 JerryChen97 left a comment

Choose a reason for hiding this comment

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

Seems all resolved but somehow Github doesn't auto reset

@JerryChen97
Copy link
Contributor Author

Hi @lillian542 my implementation involved some refactoring over your previous design as well as some tests; fortunately all the tests seem smooth for now but I just want to double check to make sure there's no explicit missing point on my side

@JerryChen97 JerryChen97 enabled auto-merge (squash) October 11, 2024 15:03
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.

Looks good. I'm ready to approve once the incorrect docstring is fixed. None of the other comments are blockers from my end :)

pennylane/devices/qubit/sampling.py Show resolved Hide resolved
tests/devices/qubit/test_sampling.py Outdated Show resolved Hide resolved
tests/devices/qubit/test_sampling.py Outdated Show resolved Hide resolved
pennylane/devices/qubit/sampling.py Outdated Show resolved Hide resolved
pennylane/devices/qubit/sampling.py Outdated Show resolved Hide resolved
@mudit2812
Copy link
Contributor

First PR almost in 🎉 !

Copy link
Contributor

@lillian542 lillian542 left a comment

Choose a reason for hiding this comment

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

🚀

@JerryChen97 JerryChen97 merged commit 0848a36 into master Oct 11, 2024
38 checks passed
@JerryChen97 JerryChen97 deleted the isolate-probability-sampling-logic branch October 11, 2024 21:13
austingmhuang pushed a commit that referenced this pull request Oct 23, 2024
**Context:**
Currently, the sample_state helper function accepts a state vector,
turns it into probabilities, and then samples it. This task is to break
out the code for sample_probs from this function.

By breaking this code into it's own helper function, we can reuse it for
a "sample density matrix" implementation.
**Description of the Change:**
- [x] Separate `devices.qubit.sampling.sample_probs` from `sample_state`
- [x] Separate `devices.qubit.sampling.sample_probs_jax` from
`_sample_state_jax`
 - [x] similar but for qutrit mixed
 - [x] similar but for qutrit mixed

**Benefits:**
Better modularization; disentanglement

Future usage in new devices

**Possible Drawbacks:**

**Related GitHub Issues:**

**Related ShortCut Stories:**
[sc-73317]

---------

Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
mudit2812 added a commit that referenced this pull request Nov 11, 2024
**Context:**
Currently, the sample_state helper function accepts a state vector,
turns it into probabilities, and then samples it. This task is to break
out the code for sample_probs from this function.

By breaking this code into it's own helper function, we can reuse it for
a "sample density matrix" implementation.
**Description of the Change:**
- [x] Separate `devices.qubit.sampling.sample_probs` from `sample_state`
- [x] Separate `devices.qubit.sampling.sample_probs_jax` from
`_sample_state_jax`
 - [x] similar but for qutrit mixed
 - [x] similar but for qutrit mixed

**Benefits:**
Better modularization; disentanglement

Future usage in new devices

**Possible Drawbacks:**

**Related GitHub Issues:**

**Related ShortCut Stories:**
[sc-73317]

---------

Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants