Skip to content

Add tests for superposition#2

Merged
fedimser merged 9 commits into
mainfrom
superposition-tests
Aug 14, 2025
Merged

Add tests for superposition#2
fedimser merged 9 commits into
mainfrom
superposition-tests

Conversation

@fedimser
Copy link
Copy Markdown
Owner

@fedimser fedimser commented Jul 24, 2025

In addition to testing arithemtic operations on basis states, now we test them on superposition states.

The testing approach is:

  • Initialize each input to a superposition of two integers, with random (real) probabilities.
  • Apply operation.
  • Inspect state of the machine (using qsharp.dump_machine()), project it on last register and extract all non-zero basis states with their probabilties.
  • Compute what would be expected state classically.
  • Compare resulting superposition to the one predicted classically.

The logic to test superposition is in superposition_test_utils.py, and I used it to test correctness of some algorithms (addition, subtraction, multiplication and division).

Note that we must call qsharp.init() for each test, because these test do not release qubits.

@fedimser fedimser merged commit 4eba983 into main Aug 14, 2025
1 check passed
@fedimser fedimser deleted the superposition-tests branch November 28, 2025 03:33
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.

1 participant