Skip to content

Add memory device option to support shotwise output#178

Open
radumarg wants to merge 34 commits into
PennyLaneAI:masterfrom
radumarg:add-memory-support
Open

Add memory device option to support shotwise output#178
radumarg wants to merge 34 commits into
PennyLaneAI:masterfrom
radumarg:add-memory-support

Conversation

@radumarg

@radumarg radumarg commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Shot results from IonQ for QPU jobs or noisy simulators jobs will be retrieved when user requests it by setting the "memory" argument to True on device. By default memory is False (opt-in behavior).
  • will not attempt to retrieve shotwise results for ideal simulation jobs since these are not available on the IonQ servers.
  • when the shotwise results will not be present, either because this is an ideal simulation or the user has not requested to be retrieved, and the user requests circuit/tape result other than probabilities, the memory (shotwise) results will be generated in software from retrieved probabilities as it is already done right now.
  • when "memory" is False and shots are needed, the current behavior where shots are generated by sampling the probability distribution will take over
  • for unlikely 4xx/5xx/RequestException errors on retrieving shots a warning will be generated but job will not fail, shots will be instead generated in software for that particular job

@radumarg radumarg changed the title Starting work on adding support for shotwise output. Adds memory to support shotwise output Apr 29, 2026
@radumarg radumarg changed the title Adds memory to support shotwise output Adds memory job option to support shotwise output Apr 29, 2026
@radumarg radumarg changed the title Adds memory job option to support shotwise output Adds memory device option to support shotwise output Apr 29, 2026
@radumarg radumarg changed the title Adds memory device option to support shotwise output Add memory device option to support shotwise output Apr 29, 2026
@splch

splch commented Apr 30, 2026

Copy link
Copy Markdown
Collaborator

Skimmed since this is still draft - just front-loading notes for the next push.

Main structural thing: shotwise_results is set but generate_samples doesn't read it, so qml.sample() output won't actually change yet. And memory=True default looks opposite of the "only when requested" intent. Smaller inline notes below.

Comment thread pennylane_ionq/device.py Outdated
Comment thread pennylane_ionq/device.py Outdated
Comment thread pennylane_ionq/device.py Outdated
Comment thread pennylane_ionq/device.py Outdated
Comment thread pennylane_ionq/device.py Outdated
Comment thread pennylane_ionq/device.py Outdated
Comment thread pennylane_ionq/device.py Outdated
Comment thread pennylane_ionq/api_client.py Outdated
@splch

splch commented Apr 30, 2026

Copy link
Copy Markdown
Collaborator

For the next push: would be good to cover request shape with memory on/off, ideal-sim opt-out, and a round-trip from raw shots into qml.sample() output.

Comment thread pennylane_ionq/api_client.py Outdated
@codecov

codecov Bot commented May 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.01%. Comparing base (2e61d26) to head (caaf22f).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #178      +/-   ##
==========================================
- Coverage   98.80%   90.01%   -8.80%     
==========================================
  Files           6        6              
  Lines         587      671      +84     
==========================================
+ Hits          580      604      +24     
- Misses          7       67      +60     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@radumarg
radumarg marked this pull request as ready for review May 13, 2026 15:25
radumarg and others added 2 commits May 13, 2026 19:24
Tests:
- New mocked single-circuit shotwise test exercises the LE->BE bit-reversal
  path with a fixture matching the live IonQ v0.4 shots response shape
  (list of base-10-integer strings). Closes the codecov/patch gap to 100%.

CHANGELOG:
- New-features entry for the shotwise device option under 0.46.0-dev.

Cleanup:
- Collapse the dead 'params = {"shotwise": True}' line in _submit_job into
  a single ternary; old version was always overwritten on the next line.
- Simplify ResourceManager.get with (params or {}) and a path ternary,
  drop the vestigial '# we need params later' comment and shorten the
  duplicated 'shotwise is not an API parameter' comments.
- Drop redundant blank lines inside generate_samples on both devices.
@splch

splch commented May 14, 2026

Copy link
Copy Markdown
Collaborator

Cross-SDK we settled on memory and off by default. Needed before merge:

  1. Rename shotwisememory everywhere (device kwargs, api_client.py, docstrings, test file).
  2. Flip default TrueFalse; update CHANGELOG to say opt-in.
  3. Drop the fake-query-param dance — pass a real fetch_shots: bool into refresh_data instead of api_params.pop("shotwise", True).
  4. Wrap the shots GET in _retrieve_child_job_shots with try/except + warn, matching qiskit-ionq, so a 5xx doesn't fail .result().

Multi-circuit logic stays — qiskit-ionq is copying it.

@splch

splch commented May 21, 2026

Copy link
Copy Markdown
Collaborator

qiskit-ionq#234 just merged with the same shape — opt-in, per-child fetch, ideal-sim skip. One behavior issue worth blocking on, one shape concern, a few nits inline.

Comment thread pennylane_ionq/api_client.py Outdated
Comment thread pennylane_ionq/device.py Outdated
Comment thread pennylane_ionq/device.py Outdated
Comment thread pennylane_ionq/api_client.py Outdated
Comment thread pennylane_ionq/device.py Outdated
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.

2 participants