Skip to content

v1.32.0

Latest

Choose a tag to compare

@billti billti released this 03 Sep 14:38
· 7 commits to main since this release
3362b9e

The 1.32 release of the QDK is packed with new features and capabilities, along with numerous bug fixes and performance improvements. Highlights include new interactive learning content for quantum chemistry, a Bloch sphere visualizer, QDK-Stim support, non-Clifford stabilizer simulation, the new Q# parallel keyword, improved circuit rendering, and more.

QDK Learning Chemistry notebooks

We've expanded our learning content with a new Ground-state molecular energies with quantum phase estimation tutorial for the qdk-chemistry library. The course consists of several notebooks that are tightly integrated with advanced VS Code and GitHub Copilot features. (See the docs at https://aka.ms/qdk, or the walkthrough videos at https://aka.ms/qdk.install and https://aka.ms/qdk.copilot, for details on setting up VS Code, Python, and GitHub Copilot).

To get started, open a directory in VS Code where you'd like to save your progress, and ensure you have a Python environment with the qdk-chemistry package installed. (The new QDK Python environment creation command, described below, can help with this). Then go to the Microsoft Quantum area in the Activity Bar and select Start Learning. This adds both the Katas and Chemistry courses to your workspace, ready for you to work through at your own pace.

qdk-chemistry-course

Note: If using a qdk-chemistry version earlier than 2.2, Python for Windows is not supported. On Windows, you must be using the Windows Subsystem for Linux (WSL) to install the required qdk-chemistry Python dependencies.

QDK Python environment creation command

Setting up a Python environment for the QDK is now easier. A new VS Code command creates a virtual environment named .venv in the current workspace and installs the QDK packages you select. This is especially useful for setting up the QDK Chemistry learning experience described above - just make sure qdk-chemistry[jupyter] is selected.

From the Command Palette, select QDK: Create a Microsoft Quantum Python virtual environment:

qdk-env-command

Then choose the Python packages you want to install. The packages selected by default are shown below:

qdk-env-libraries

If a virtual environment named .venv already exists, the command will offer to update it instead.

Bloch sphere visualizer

This release also introduces an interactive Bloch sphere visualizer, providing a new way to explore and understand single-qubit states and operations. In VS Code, launch it from the Command Palette using QDK: Bloch sphere. In Jupyter notebooks, use the BlochSphere widget.

bloch-sphere

The Bloch sphere animates rotations as gates are applied and can also show a trace of the state vector updates as unitary matrices are applied.

Rotations can be applied directly or through rotation synthesis, using a sequence of Hadamard and T gates.

bloch-decomp

In either the VS Code visualizer or Jupyter widget, you can specify a sequence of gates using a string. For example:

from qdk.widgets import BlochSphere
display(BlochSphere('H T H'))

QDK-Stim

This release introduces experimental support for QDK-Stim, a Stim-like language in the QDK. QDK-Stim supports the instruction set made popular by Stim, additional non-Clifford operations similar to those supported by Cliftt and tsim, and several QDK-specific instructions as described below.

QDK-Stim programs are compiled to QIR and can then run on any of our simulators that accept QIR, including the CPU and GPU state-vector simulators, stabilizer decomposition simulator, and density matrix simulator.

Additional instructions unique to QDK-Stim include:

  • SELECT / REQUIRE / NOTLEAKED for post-selection or repeat-until-success patterns based on parity measurements and qubit-loss checks.
  • PEEK_LOSS / LOSS_ERROR for additional qubit-loss modeling and handling.

See the notebook at samples/notebooks/qdk_stim.ipynb for more details and usage examples.

Note: QDK-Stim is currently experimental, and its features will continue to be expanded and refined. Please log an issue if you encounter a problem or would like to request a feature.

Q# 'parallel' keyword

Q# now includes the parallel keyword, which can be used as a prefix on expressions to control the space/time trade-off in generated code. As a simple example, consider the following for loop:

operation Main() : Result[] {
    mutable results = [];
    for i in 1..4 {
        use q = Qubit();
        results += [MResetX(q)];
    }
    results
}

By default, the compiler tries to minimize qubit requirements. In this example, it reuses the qubit allocated within the loop, resulting in the circuit below. This requires only one qubit, at the expense of serializing the operations and therefore taking more time:

parallel-before

Prefixing the loop with the parallel keyword tells the compiler to try to run iterations in parallel where possible. In this case, it uses a distinct qubit for each iteration — requiring more qubits, but reducing execution time:

operation Main() : Result[] {
    mutable results = [];
    parallel for i in 1..4 {
        use q = Qubit();
        results += [MResetX(q)];
    }
    results
}
parallel-after

See PRs #3298 and #3588 for more details.

Stabilizer decomposition (non-Clifford simulation)

The QDK's stabilizer simulator has always been able to scale to large numbers of qubits, but until now it was limited to Clifford operations. This release adds stabilizer branching, enabling the simulator to handle circuits containing a small number of non-Clifford operations while retaining the scalability of stabilizer simulation.

The required state space grows exponentially with the number of non-Clifford operations, so shot throughput decreases significantly as more non-Clifford operations are added. See samples/notebooks/stabilizer_branching.ipynb for an example of a 111-qubit OpenQASM circuit containing 10 non-Clifford operations, which can still achieve a few hundred shots per second on a typical laptop.

Circuit rendering options

You can now control how a circuit for a Q# operation is rendered by adding the @CircuitRenderingOptions attribute to the operation definition.

The following options are currently supported:

  • hideBox (true or false): If true, the operation's group box is omitted and its contents are rendered directly in the containing scope.
  • inputSizes (array of positive integers): Specifies the lengths of qubit-array arguments (Qubit[], Qubit[][], etc.) used to render the operation. Values apply to inputs in declaration order and to each input's dimensions from outermost to innermost. Missing values default to 2, and extra values are ignored.

For example:

@CircuitRenderingOptions(hideBox=true, inputSizes=[3,4])
operation Foo(a: Qubit[], b: Qubit[]) : Unit {
    for q in a { X(q); }
    for q in b { H(q); }
}

Pretty-printed circuit angles

Circuit diagrams are now easier to read, with common rotation angles rendered in a more natural mathematical form instead of as decimal floating-point values. For example, the image below shows the before-and-after rendering of a rotation by π/4:

friendly-angles

Deprecation of the qsharp Python package

The qsharp Python package is now deprecated and will no longer receive updates. Install the QDK using the qdk Python package instead, and update imports to use qdk and its submodules.

Other noteable changes

Full Changelog: v1.31.0...v1.32.0