Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

qdk

The Quantum Development Kit (QDK) provides a single, cohesive Python entry point for compiling, simulating, and estimating resources for quantum programs (Q# and OpenQASM), with optional extras for visualization, cloud workflows, and interoperability with Qiskit and Cirq.

Install

To install the core functionality, which include Q# & OpenQASM simulation, compilation, and resource estimation support:

pip install qdk

To include the Jupyter extra, which adds visualizations using Jupyter Widgets in the qdk.widgets submodule and syntax highlighting for Jupyter notebooks in the browser:

pip install "qdk[jupyter]"

To add the Azure Quantum extra, which includes functionality for working with the Azure Quantum service in the qdk.azure submodule:

pip install "qdk[azure]"

For Qiskit integration, which exposes Qiskit interop utilities in the qdk.qiskit submodule:

pip install "qdk[qiskit]"

For Cirq integration, which exposes Cirq interop utilities in the qdk.cirq submodule:

pip install "qdk[cirq]"

To easily install all the above extras:

pip install "qdk[all]"

Quick Start

from qdk import qsharp

result = qsharp.run("{ use q = Qubit(); H(q); return MResetZ(q); }", shots=100)
print(result)

To use widgets (installed via qdk[jupyter] extra):

from qdk.qsharp import eval, run
from qdk.widgets import Histogram

eval("""
operation BellPair() : Result[] {
    use qs = Qubit[2];
    H(qs[0]);CX(qs[0], qs[1]);
    MResetEachZ(qs)
}
""")
results = run("BellPair()", shots=1000, noise=(0.005, 0.0, 0.0))
Histogram(results)

OpenQASM parsing and analysis

The preview qdk.openqasm.parser and qdk.openqasm.semantic modules expose read-only syntax and semantic trees. parse is recovery-oriented and returns diagnostics on its result rather than raising; analyze additionally resolves symbols, checks types, and evaluates constants. Node, symbol, and diagnostic spans are global, half-open UTF-8 byte ranges resolved through the immutable document the result owns.

from qdk.openqasm import analyze, dumps, parse

parsed = parse(
    'OPENQASM 3.0; include "defs.inc"; qubit q; local q;',
    path="memory://workspace/main.qasm",
    includes={"memory://workspace/defs.inc": "gate local q { x q; }"},
)
assert not parsed.has_errors
assert parsed.program.document is parsed.document
assert dumps(parsed.program).startswith("OPENQASM 3.0;")

analysis = analyze("OPENQASM 3.0; int value = missing;")
assert analysis.has_errors
diagnostic = analysis.diagnostics[0]
source_range = analysis.document.source_map.range_from_span(diagnostic.labels[0].span)
assert source_range.source_id == analysis.document.entry.id

Both trees compare and hash structurally, ignoring source position and the document a node came from, so the same construct written twice compares equal. Resolved types and constant values are structured nodes rather than strings, so dispatch over them with isinstance. QASMVisitor walks either tree, and dumps writes canonical source for a whole syntactic program. Most class names appear in both layers, so parser.SyntaxNode and semantic.SemanticNode answer which tree a value came from.

These APIs are in preview and may change between QDK releases. Run help(qdk.openqasm.parser) and help(qdk.openqasm.semantic) for the full contracts, including include resolution, the shared-class exception, the canonical format's guarantees, and the visitor's context protocol.

Public API Surface

Submodules:

  • qdk.qsharp – Q# interpreter functions: init, eval, run, compile, circuit, estimate, dump_machine, dump_circuit, dump_operation, and related types.
  • qdk.openqasm – OpenQASM compilation, execution, parsing, semantic analysis, source navigation, visitors, and canonical serialization.
  • qdk.estimator – resource estimation utilities.
  • qdk.simulation – noise-aware simulation utilities: NeutralAtomDevice, NoiseConfig, run_qir, DensityMatrixSimulator, StateVectorSimulator, and related types.
  • qdk.code – dynamic namespace populated at runtime with user-defined Q# and OpenQASM callables.
  • qdk.qre – quantum resource estimation v3: estimate, Application, Architecture, ISA, ISATransform, and related types.
  • qdk.applications – domain-specific quantum applications (e.g. qdk.applications.magnets).
  • qdk.widgets – Jupyter widgets for visualization (requires the qdk[jupyter] extra).
  • qdk.azure – Azure Quantum service integration (requires the qdk[azure] extra).
  • qdk.qiskit – Qiskit interop: QSharpBackend, NeutralAtomBackend, and related types (requires the qdk[qiskit] extra).
  • qdk.cirq – Cirq interop: NeutralAtomSampler (requires the qdk[cirq] extra).

Top level exports

For convenience, the following helpers and types are also importable directly from the qdk root (e.g. from qdk import code, Result). Algorithm execution APIs (like run / estimate) remain under qdk.qsharp or qdk.openqasm.

Symbol Type Origin Description
code module qdk.code Exposes operations defined in Q# or OpenQASM
init function qdk.qsharp.init Initialize/configure the QDK interpreter (target profile, options).
set_quantum_seed function qdk.qsharp.set_quantum_seed Deterministic seed for quantum randomness (simulators).
set_classical_seed function qdk.qsharp.set_classical_seed Deterministic seed for classical host RNG.
dump_machine function qdk.qsharp.dump_machine Emit a structured dump of full quantum state (simulator dependent).
Result class qdk.qsharp.Result Measurement result token.
TargetProfile class qdk.qsharp.TargetProfile Target capability / profile descriptor.
StateDump class qdk.qsharp.StateDump Structured state dump object.
ShotResult class qdk.qsharp.ShotResult Multi-shot execution results container.
PauliNoise class qdk.qsharp.PauliNoise Pauli channel noise model spec.
DepolarizingNoise class qdk.qsharp.DepolarizingNoise Depolarizing noise model spec.
BitFlipNoise class qdk.qsharp.BitFlipNoise Bit-flip noise model spec.
PhaseFlipNoise class qdk.qsharp.PhaseFlipNoise Phase-flip noise model spec.
Context class qdk.Context Isolated Q# and OpenQASM interpreter context for independent sessions.

Configuration Map

You can provide configuration at initialization time as a Python dictionary.

In Python, pass qdk_config: dict[str, int | float | str | bool] to Context(...). If qdk_config is omitted, the configuration map is empty. The map is immutable after initialization. To use different configuration values, create a new Context.

In Q#, read values with Std.Core.ConfigValue(name, defaultValue). In Q# code, config values are immutable: in the same program, repeated calls with the same (name, defaultValue) produce the same result.

Supported types: int, float, str, and bool (corresponding to Int, Double, String and Bool in Q#). The type of each value in qdk_config must match the type of its corresponding default value.

Example:

import qdk
context = qdk.Context(qdk_config={"experiment_name": "baseline", "shots": 1000})
assert context.eval('Std.Core.ConfigValue("experiment_name", "")') == "baseline"
assert context.eval('Std.Core.ConfigValue("shots", 100)') == 1000
assert context.eval('Std.Core.ConfigValue("noise_level", 0.01)') == 0.01

Telemetry

This library sends telemetry. Minimal anonymous data is collected to help measure feature usage and performance. All telemetry events can be seen in the source file telemetry_events.py.

To disable sending telemetry from this package, set the environment variable QDK_PYTHON_TELEMETRY=none

Support

For more information about the Microsoft Quantum Development Kit, visit https://aka.ms/qdk.

Contributing

Q# welcomes your contributions! Visit the Q# GitHub repository at [https://github.com/microsoft/qdk] to find out more about the project.

Release files for qdk 1.32.5.dev0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for qdk 1.32.5.dev0
File
qdk-1.32.5.dev0-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details
qdk-1.32.5.dev0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
qdk-1.32.5.dev0-cp310-abi3-manylinux_2_35_x86_64.whl CPython 3.10 abi3 Linux glibc 2.35+ x86-64 Details
qdk-1.32.5.dev0-cp310-abi3-manylinux_2_35_aarch64.whl CPython 3.10 abi3 Linux glibc 2.35+ ARM64 Details
qdk-1.32.5.dev0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
qdk-1.32.5.dev0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 45.9 MB

Release files / qdk-1.32.5.dev0-cp310-abi3-win_arm64.whl

Download URL qdk-1.32.5.dev0-cp310-abi3-win_arm64.whl
Size 8.0 MB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
218c05ced906d99b59160f83bbd988bcac49a4132245ae4068b0e7bd4d5f633c
BLAKE2b-256 checksum
How to use checksums
2fc5915a0c814e76be39619601eab8879920d936a1b48c7b2d33909c6c76c51f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / qdk-1.32.5.dev0-cp310-abi3-win_amd64.whl

Download URL qdk-1.32.5.dev0-cp310-abi3-win_amd64.whl
Size 8.6 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
ff2142bdd253a8f9497c782f8daa6d4d7b62e540724a26ce399b7cc4743cd54e
BLAKE2b-256 checksum
How to use checksums
7612b98141f69f0affc360ff9e16ca567654b6ce8926c844448c5fc6756db3a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / qdk-1.32.5.dev0-cp310-abi3-manylinux_2_35_x86_64.whl

Download URL qdk-1.32.5.dev0-cp310-abi3-manylinux_2_35_x86_64.whl
Size 8.1 MB
Tags CPython 3.10 Linux glibc 2.35+ x86-64 abi3
SHA-256 checksum
How to use checksums
b7e0dd0cdc625c5153b6ebcb39040ebc1b71e28782d9aeaaf882f9ca7764d0a5
BLAKE2b-256 checksum
How to use checksums
019aeabf85583ef6424ccc387fa4d6dd0435c202b9a294375205a1d8ece78cf3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / qdk-1.32.5.dev0-cp310-abi3-manylinux_2_35_aarch64.whl

Download URL qdk-1.32.5.dev0-cp310-abi3-manylinux_2_35_aarch64.whl
Size 7.4 MB
Tags CPython 3.10 Linux glibc 2.35+ ARM64 abi3
SHA-256 checksum
How to use checksums
162b20120b3faa7e199c6f01d9b33c742b01b2c2f51c058edf6c4b99dab27463
BLAKE2b-256 checksum
How to use checksums
9af84d3b6f9492a853214e992d2f044b3b4cab3d526d122bb0e9c57618905f16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / qdk-1.32.5.dev0-cp310-abi3-macosx_11_0_arm64.whl

Download URL qdk-1.32.5.dev0-cp310-abi3-macosx_11_0_arm64.whl
Size 6.7 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
18b55a71a45141ac996050721b9b859bc82e77a546f5fc5640261f52621016ca
BLAKE2b-256 checksum
How to use checksums
8702fcb74592280a7e9636ef2231d3db1b896315abffed3e3fd2692874436918
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / qdk-1.32.5.dev0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL qdk-1.32.5.dev0-cp310-abi3-macosx_10_12_x86_64.whl
Size 7.1 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
3e5607c1ef07bf8ea950b6ee67f4e39ad00d4024ebcccc4deeffb84b26bb51e8
BLAKE2b-256 checksum
How to use checksums
491b5cca8564a7c9b357766a82e3f097b8ab6f855af534a3be43bb2c74d2a622
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release history Release notifications | RSS feed

This release

1.32.5.dev0 This release

6 release files

1.32.3

6 release files

1.31.0

6 release files

1.29.1

6 release files

1.28.0

1 release file

1.27.0

1 release file

1.26.1

1 release file

1.26.0

1 release file

1.25.1

1 release file

1.25.0

1 release file

1.23.0

1 release file

1.22.0

1 release file

1.21.0

1 release file

0.29.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page