Skip to content

RFC: quantum assertions/debugging tools #222

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
Roger-luo opened this issue Apr 18, 2025 · 1 comment
Open

RFC: quantum assertions/debugging tools #222

Roger-luo opened this issue Apr 18, 2025 · 1 comment
Labels
enhancement New feature or request rfc Request for Comments

Comments

@Roger-luo
Copy link
Member

Roger-luo commented Apr 18, 2025

Following the "off-topic" conversation from #218 (comment) and #218 (comment) (copying @cduck 's comment here to show the references)

As a side note, this reminds me that there is quantum programming language research that develops "quantum > assertions" like assert qubit_a entangled with qubit_b, assert qubit_a shares no entanglement with qubit_c, > assert qubit_d==|+>, or assert qubits_abcd are in a uniform superposition, etc. These assertions can be easily checked on the state vector. And you can approximately check these during execution at the cost of destroying the quantum state, but still useful for validation.
Here's one paper: https://arxiv.org/pdf/2303.01487
Also: https://docs.quantinuum.com/tket/user-guide/manual/manual_assertion.html

I think this is a good timing thinking about some academia results on this as we are trying to improve the UX of this package.

state recording for simulators

Idea proposed by @jon-wurtz

@bloqade.kernel
def main():
    qubits = bloqade.make_qubits()
    kernel_that_does_things_to(qubits)
    bloqade.state.record("label 1",qubits)
    if measure(qubits[0])==0:
        kernel2_that_does_things_to(qubits)
    else:
        kernel3_that_does_things_to(qubits)
    bloqade.state.record("label 2",qubits)

bloqade.emulator.statevector( main )
-> {"label 1": [(probability_A, measurement_outcomeA, statevectorA)], "label 2": [(probability_B, measurement_outcomeB, statevectorB), (probability_C, measurement_outcomeC, statevectorC), ...] }

I think this could be combined as part of the logging with debug dialect's debug.info which records a message and given object (QuEraComputing/kirin#342).

quantum assertions

I think Gushu Li has some work around this a few years ago, maybe a good feature to get some help from. We can add similar projector assertion here as well.

cc: @jon-wurtz @cduck

@Roger-luo Roger-luo added enhancement New feature or request triage request for triage. A decision will be made on the issue or PR. labels Apr 18, 2025
@cduck
Copy link

cduck commented Apr 18, 2025

Another academic reference: https://dl.acm.org/doi/pdf/10.1145/3307650.3322213

@Roger-luo Roger-luo added rfc Request for Comments and removed triage request for triage. A decision will be made on the issue or PR. labels May 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request rfc Request for Comments
Projects
None yet
Development

No branches or pull requests

2 participants