Skip to content

Example added BasicSim docs that shows default shots - #549

Open
isaacdevlugt wants to merge 17 commits into
masterfrom
basicsim-docs-default-shots
Open

isaacdevlugt wants to merge 17 commits into
masterfrom
basicsim-docs-default-shots

Conversation

@isaacdevlugt

Copy link
Copy Markdown

In Qiskit, when you use this device / backend you’re hard-corded at shots=1024. I assume Qiskit users are aware of this. However, when I used this device in PennyLane, I ran this circuit not expecting it to work because I didn’t specify shots.

pl_qfunc = qml.from_qiskit(qc, measurements=[qml.classical_shadow(wires=range(n))])
pl_circuit = qml.QNode(pl_qfunc, device=qml.device("qiskit.basicsim", wires=n))
pl_circuit()

I had to go digging into the source code to figure out what was going on. As a PennyLane user, I found this confusing (does that matter? lol). Anyway, a simple addition to the docs seems fine to me.

@codecov

codecov Bot commented May 30, 2024

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.45%. Comparing base (eb865f7) to head (df21d54).

Current head df21d54 differs from pull request most recent head bd0e82a

Please upload reports for the commit bd0e82a to get more accurate results.

Additional details and impacted files
@@             Coverage Diff             @@
##            master     #549      +/-   ##
===========================================
- Coverage   100.00%   99.45%   -0.55%     
===========================================
  Files            7        7              
  Lines          557      550       -7     
===========================================
- Hits           557      547      -10     
- Misses           0        3       +3     

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

@austingmhuang

Copy link
Copy Markdown
Contributor

Hi @isaacdevlugt thanks for the PR! Just to clarify, when you say "hardcoded" do you mean that even if you specify e.g. shots=10000 on device initialization the device still runs with 1024? Or do you mean that the device has a default value of running with 1024 shots?

@isaacdevlugt

Copy link
Copy Markdown
Author

Hey @austingmhuang! I mean the latter. 1024 is hardcoded as the default number (can be overridden).

@trbromley

Copy link
Copy Markdown
Contributor

Why don't we update BasicSim to make shots a required argument?

@austingmhuang

austingmhuang commented Jun 3, 2024

Copy link
Copy Markdown
Contributor

@trbromley I think the idea is that when a User doesn't pass in a # of shots, there is supposed to be a warning that lets users know that analytic mode is not supported on the basicsim device and inform them that the circuit was ran with 1024 shots. Right now I think this warning is bugged so it isn't showing up but this is the way it's done when using the new QiskitDevice. Obviously we can just raise an error instead but I think this solution is a bit more consistent with how devices in pennylane generally work.

Comment thread tests/test_qiskit_device.py
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