Skip to content

Add sample notebooks #2437

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Add sample notebooks #2437

wants to merge 5 commits into from

Conversation

idavis
Copy link
Collaborator

@idavis idavis commented May 20, 2025

This PR adds sample Python integration and resource estimation notebooks for OpenQASM. There is more here than just those changes as existing external issues require workarounds.

  • Qiskit and existing OpenQASM code incorrectly specify 0 for angles which isn't allowed in the spec. So this PR adds the ability to cast literals to angles with a value of 0 for compatibility. This also removes some casting calls as we can now directly create the angle from the literal.
  • There is a util bitstring function which allows the user to specify that they want the output of simulation to be converted into a bitstring if any of the outputs are bit registers. This matches what Qiskit output would be like. For the moment the code defaults to Q#'s typically output rendering.
  • The old parser couldn't handle gates, but with the new parser we don't have to fully transpile into the Q# canonical gates. This changes the resource estimation numbers.

@idavis idavis marked this pull request as ready for review May 20, 2025 15:52
@idavis idavis marked this pull request as draft May 20, 2025 15:52
@idavis idavis self-assigned this May 20, 2025
@idavis idavis marked this pull request as ready for review May 20, 2025 16:33
@idavis idavis requested a review from billti May 20, 2025 21:00
"from qsharp import run, DepolarizingNoise\n",
"from qsharp_widgets import Histogram\n",
"\n",
"Histogram(run(\"bell()\", shots=1000, noise=DepolarizingNoise(0.01)))"
Copy link
Collaborator

Choose a reason for hiding this comment

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

This works fine, but why not use the callable object like the other samples? I think there was a bug previously where this didn't work as expected, but now it seems to work just fine.

Suggested change
"Histogram(run(\"bell()\", shots=1000, noise=DepolarizingNoise(0.01)))"
"Histogram(run(bell, shots=1000, noise=DepolarizingNoise(0.01)))"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The text above this line talks about how to call it just like you would in a %%qsharp cell. We can change this but we need to update more for consistency.

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