Skip to content

QCDL Examples - #88

Open
qci-keen wants to merge 30 commits into
dwavesystems:mainfrom
qci-keen:qcdl-examples
Open

qci-keen wants to merge 30 commits into
dwavesystems:mainfrom
qci-keen:qcdl-examples

Conversation

@qci-keen

@qci-keen qci-keen commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

This PR adds QCDL/qiskit examples that demonstrate unique aspects of QCDL and dual-rail qubits.

@qci-keen qci-keen assigned qci-keen and unassigned qci-keen Sep 14, 2026
@codecov

codecov Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.99%. Comparing base (26c1c3b) to head (4650143).
⚠️ Report is 18 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #88   +/-   ##
=======================================
  Coverage   90.99%   90.99%           
=======================================
  Files          34       34           
  Lines        5683     5683           
=======================================
  Hits         5171     5171           
  Misses        512      512           

☔ 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.

@qci-keen
qci-keen requested review from qci-amos and thisac September 15, 2026 16:21
@qci-keen qci-keen added the enhancement New feature or request label Sep 15, 2026
@qci-keen
qci-keen marked this pull request as ready for review September 15, 2026 16:21
Comment thread examples/classical_registers.py
@qci-keen
qci-keen marked this pull request as draft September 15, 2026 16:52
@qci-keen qci-keen removed the enhancement New feature or request label Sep 15, 2026

@JoelPasvolsky JoelPasvolsky left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@qci-keen, I have made some suggestions on the Classical Arithmetic file, I will try to review additional ones this afternoon.

Comment thread examples/classical-arithmetic.py Outdated
Comment thread examples/classical-arithmetic.py Outdated
Comment thread examples/classical-arithmetic.py Outdated
Comment thread examples/classical-arithmetic.py Outdated
Comment thread examples/classical-arithmetic.py
Comment thread examples/classical-arithmetic.py Outdated
Comment thread examples/classical-arithmetic.py Outdated
Comment thread examples/classical-arithmetic.py Outdated
Comment thread examples/classical-arithmetic.py Outdated
Comment thread examples/classical-arithmetic.py Outdated
qci-keen and others added 10 commits September 15, 2026 12:27
Co-authored-by: Joel Pasvolsky <34041130+JoelPasvolsky@users.noreply.github.com>
Co-authored-by: Joel Pasvolsky <34041130+JoelPasvolsky@users.noreply.github.com>
Co-authored-by: Joel Pasvolsky <34041130+JoelPasvolsky@users.noreply.github.com>
Co-authored-by: Joel Pasvolsky <34041130+JoelPasvolsky@users.noreply.github.com>
Co-authored-by: Joel Pasvolsky <34041130+JoelPasvolsky@users.noreply.github.com>
Co-authored-by: Joel Pasvolsky <34041130+JoelPasvolsky@users.noreply.github.com>
Co-authored-by: Joel Pasvolsky <34041130+JoelPasvolsky@users.noreply.github.com>
Co-authored-by: Joel Pasvolsky <34041130+JoelPasvolsky@users.noreply.github.com>
Co-authored-by: Joel Pasvolsky <34041130+JoelPasvolsky@users.noreply.github.com>
Comment thread examples/error_detection_handling/bayesian_decoding/README.md

@JoelPasvolsky JoelPasvolsky left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Added some suggestions for classical registers and measurement-based feedback. Will go on to the next three JNs now

Comment thread examples/classical_registers.py Outdated
Comment thread examples/classical_registers.py Outdated
Comment thread examples/classical_registers.py Outdated
Comment thread examples/classical_registers.py Outdated
Comment thread examples/classical_registers.py Outdated
Comment thread examples/measurement_based_feedback.py Outdated
Comment thread examples/measurement_based_feedback.py Outdated
Comment thread examples/measurement_based_feedback.py Outdated
Comment thread examples/measurement_based_feedback.py Outdated
Comment thread examples/measurement_based_feedback.py Outdated

@JoelPasvolsky JoelPasvolsky left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Added suggestions on parallel Bell, RUS, and simple bell state JNs. Still need to look at the Bayesian example

Comment thread examples/parallel_bell.py Outdated
Comment thread examples/parallel_bell.py Outdated
Comment thread examples/parallel_bell.py Outdated
Comment thread examples/parallel_bell.py Outdated
Comment thread examples/parallel_bell.py Outdated
Comment thread examples/simple_bell_state.py Outdated
Comment thread examples/simple_bell_state.py Outdated
Comment thread examples/simple_bell_state.py Outdated
Comment thread examples/simple_bell_state.py Outdated
Comment thread examples/simple_bell_state.py Outdated
Comment thread examples/error_detection_handling/bayesian_decoding/README.md Outdated
Comment thread examples/error_detection_handling/bayesian_decoding/README.md Outdated
Comment thread examples/error_detection_handling/bayesian_decoding/README.md Outdated
Comment thread examples/error_detection_handling/bayesian_decoding/README.md Outdated
Comment thread examples/error_detection_handling/bayesian_decoding/README.md Outdated
Comment thread examples/error_detection_handling/bayesian_decoding/bayesian_decoding_example.py Outdated
Comment thread examples/error_detection_handling/bayesian_decoding/bayesian_decoding_example.py Outdated
Comment thread examples/error_detection_handling/bayesian_decoding/bayesian_decoding_example.py Outdated
Comment thread examples/error_detection_handling/bayesian_decoding/bayesian_decoding_example.py Outdated
Comment thread examples/error_detection_handling/bayesian_decoding/bayesian_decoding_example.py Outdated
qci-keen and others added 2 commits September 15, 2026 15:16
Formatting and language changes

Co-authored-by: Joel Pasvolsky <34041130+JoelPasvolsky@users.noreply.github.com>
qci-keen and others added 2 commits September 15, 2026 15:34
more formatting and language (the first batch was full so this is a second one).

Co-authored-by: Joel Pasvolsky <34041130+JoelPasvolsky@users.noreply.github.com>
Comment thread examples/rus_simple.py Outdated
remove old intialization

Co-authored-by: Joel Pasvolsky <34041130+JoelPasvolsky@users.noreply.github.com>
@qci-keen
qci-keen marked this pull request as ready for review September 16, 2026 16:21
Comment thread examples/rus_simple.py

@JoelPasvolsky JoelPasvolsky left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Comments from running the first 6 JNs, will do Bayesian and random circuit generation next.

One general thought: what about adding a README.rst file that gives a quick description of the examples and helps a new user decide in what order to run them (i.e., also ranks them from beginner to advanced)?

Comment thread examples/parallel_bell.py Outdated
Comment thread examples/measurement_based_feedback.py Outdated
Comment thread examples/measurement_based_feedback.py

# %% [markdown]
# ## Conditional Branching & Registers

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

As a new user, things that would be unclear to me and would appreciate having described here in markdown, are:

  • c0 is updated based on measure(q0, register=c0) but c1 does not seem to be updated in the RTCF part of th ealgorithm
  • Why measure(q0, register=c0) for the first qubit but just measure(q1) for the second
  • Why with q1.If(c0 | c1 == 1) selects q1 for the method (could sc or q0 be used instead)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@qci-amos could you help me with writing up an answer to this? Questions about scope and the inner workings of RTCF are not in my wheelhouse.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

the example isn't intended to be meaningful, just illustrate some mechanics... we could update it to be slightly more meaningful? @qci-keen if you can think of something cute to show then we can update it, otherwise I suggest we just keep this as is (or omit it) and we can find something else later.

with q1.If(c0 | c1 == 1):
x(q1) # X gate (bit flip)

measure(q1)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

would this example be better if the above algorithm was in a loop that executed a few times so measurement of q1 would be in the RTCF?

Comment thread examples/classical_arithmetic.py Outdated
Comment thread examples/classical_arithmetic.py Outdated
Comment thread examples/classical_arithmetic.py Outdated
Comment thread examples/classical_arithmetic.py Outdated
Comment thread examples/classical_arithmetic.py

@thisac thisac left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Don't forget to add license headers to all files (they were missing in more files than the ones I commented on). This (normally) includes the __init__.py files, although they shouldn't be necessary at all here since the examples aren't part of the package structure.

Comment thread examples/classical_arithmetic.py Outdated

@JoelPasvolsky JoelPasvolsky left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Okay, @qci-keen, I think I've gone through all of it. These JNs will be very helpful for users, thank you!

Comment thread examples/error_detection_handling/bayesian_decoding/bayesian_decoding_example.py Outdated
Comment thread examples/error_detection_handling/bayesian_decoding/bayesian_decoding_example.py Outdated
Comment thread examples/error_detection_handling/bayesian_decoding/bayesian_decoding_example.py Outdated
Comment thread examples/error_detection_handling/bayesian_decoding/bayesian_decoding_example.py Outdated

@thisac thisac left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd recommend removing the bayesian_decoding example from here and instead add it to the dwave-qiskit-plugin instead. It makes more sense having it where the dependencies are correct.

Comment thread examples/error_detection_handling/bayesian_decoding/bayesian_decoding_example.py Outdated
Comment thread examples/error_detection_handling/bayesian_decoding/bayesian_decoder.py Outdated
qci-keen and others added 3 commits September 16, 2026 14:31
Language and typos

Co-authored-by: Joel Pasvolsky <34041130+JoelPasvolsky@users.noreply.github.com>
@qci-amos

Copy link
Copy Markdown
Collaborator

Ideally we wouldn't direct people to more than one place to find end-user examples for our system...

Formatting and job labels

Co-authored-by: Joel Pasvolsky <34041130+JoelPasvolsky@users.noreply.github.com>
Comment thread examples/rus_simple.py Outdated

@thisac thisac left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @qci-keen for addressing my other comments. The examples look great, Just a couple of more things I noticed.

@@ -0,0 +1,15 @@
# Copyright &copy; 2026 D-Wave

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't think we need to add &copy here or elsewhere in the license headers. We don't have them in the other Python files. @JoelPasvolsky, do you know?

Suggested change
# Copyright &copy; 2026 D-Wave
# Copyright 2026 D-Wave

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Also, you should be able to remove the __init__.py files (this and one higher level) since this is not part of the package.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

removed notice from __init__.py, waiting for decision on &copy;.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Sorry, I meant remove the files altogether. If kept, they should have the license.

Comment thread examples/error_detection_handling/bayesian_decoding/bayesian_decoder.py Outdated
Comment on lines +33 to +34
parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
sys.path.append(parent_dir)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this only for the rand_circ_fixed_hamming_weight import? If so, I'd recommend skipping it and instead just do

from random_circuit_generation import rand_circ_fixed_hamming_weight

which now should work since you moved that file next to bayesian_decoding_example.py.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It doesn't work for me to do that, must be something with which directory my vscode thinks is the base directory.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Strange, I thought it could have something to do with running it as a notebook vs just Python, but it works both ways for me.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

what if you try:

from .random_circuit_generation import rand_circ_fixed_hamming_weight

?

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.

5 participants