microsoft / microsoft/qdk

Visualization of quantum state

Open
#579 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Rust
Stars
1k
Forks
212
Avg merge
3d 8h
Merged PRs (30d)
65

Description

We visualize quantum state in a few places (DumpMachine, playground, debugger...) It is a list of amplitudes for all basis vectors (maybe including additional information such as phase, probability, etc). Such visualization isn't always intuitive and is getting very large fast with larger number of qubits.

We should consider providing alternative ways of this visualization.

  1. We are omitting basis vectors with 0 (or near-0) amplitudes. If the space to display the state is limited, the output may be sorted by the magnitude of the amplitude and only top of the list shown with an option to expand.

  2. When we show basis state it is not clear which qubit corresponds to which variable. For example, we may have |010> basis state. An explanation may be added that the order is q0, q1, target. I.e., the first 0 is the value of q0, the second 1 is the value of q1, and the last 0 is the value of target.

  3. User may only be interested in a part of the quantum state - say, only state for qubits a and b. We could use something similar to the QDK's DumpRegister function to display only the relevant information. An open question is what to do if register qubits are entangled with the rest of the system. (Done https://github.com/microsoft/qsharp/pull/1173)

  4. For some interesting values of amplitudes, we may have representation in radicals. For example, instead of displaying 0.70710678118654, we may show √2 / 2. (Done https://github.com/microsoft/qsharp/pull/1162)

  5. We can recognize certain states, For example, instead of displaying

|0⟩	√2 / 2
|1⟩	√2 / 2

we can display a LaTeX formula with nice coefficients: √2/2 · ( |0⟩+|1⟩ ). (Partially done https://github.com/microsoft/qsharp/pull/1162)

Potential future items to recognize:

    * Recognize trigonometric form, such as sin(𝝅/8) or cos(1).
    * Recognize common normalization coefficient, such as 1/2 ( |00⟩ + |01⟩ + |10⟩ + |11⟩ )
    * Recognize well-known states such as: |0> |1> |+> |-> |Bell> |CATn>
  1. If the state is separable, it would be nice to show it as a tensor product.

For example, instead of displaying

|00⟩	0.5000+0.0000𝑖
|01⟩	0.5000+0.0000𝑖
|10⟩	0.5000+0.0000𝑖
|11⟩	0.5000+0.0000𝑖

We can display |+⟩⊗|+⟩. But we also should combine states for a more concise display, such as |10⟩ is preferable to |1⟩⊗|0⟩.

  1. (From discussion) Bring back DumpOperation. Potentially display matrix on hover for simple operations.

  2. (From discussion) What-if scenarios. Take current state in the debugger and show what would happen if some operation is applied.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing visualization entry points named in the issue: DumpMachine, the playground, and the debugger. The issue lists several possible directions, including filtering or sorting amplitudes, register-focused output, state recognition, tensor-product displays, and restoring DumpOperation, so a maintainer must first select and define one scope. Done would require an agreed behavior and corresponding visualization support.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
data-visualization, devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.