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

[Frontend] A prototype for one_shot_dynamic transform #734

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

grwlf
Copy link
Contributor

@grwlf grwlf commented May 13, 2024

[sc-63049]

See also an internal document regarding this issue.

qreg_in = qreg_out
# (1.5) If user wanted the `dynamic_one_shot` transformation we apply it by re-tracing the
# function using the wrapper loop.
if qnode.needs_dynamic_one_shot and device.shots.total_shots != 1:
Copy link
Contributor

Choose a reason for hiding this comment

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

dynamic_one_shot may also be applied to a single shot tape, but we can neglect that case at first I would say.

Copy link

Hello. You may have forgotten to update the changelog!
Please edit doc/changelog.md on your branch 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.

@for_loop(0, orig_shots, 1)
def loop(i, s):
r = f(*args2, **kwargs2)
s = s.at[i].set(r)
Copy link
Contributor

Choose a reason for hiding this comment

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

It appears r comes out as a quantum measurements (e.g. qml.expval) instead of the results (e.g. 0.0) which throws off the rest of the tracing. Is it just me?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I did not pay attention to this. My idea is that it might be a correct resulting tracer of some kind. In the example I used catalyst.measure (returning a boolean tracer) but I hoped that measurements would just return a measurement tracer. The thing is - we do not know its value at the compile time.

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.

None yet

3 participants