CUDA-Q Logical — Develop and evaluate fault-tolerant quantum applications

These pages cover the cudaq-logical preview package only. For everything else, see the main CUDA-Q documentation.

Preview release

cudaq-logical is in preview. Its APIs, behavior, and documentation may change substantially in upcoming versions.

CUDA-Q Logical (cudaq.logical) expands CUDA-Q with an open, extensible logical layer for fault-tolerant quantum computing. Use it to express fault-tolerant workloads, evaluate them across different QEC codes and system architectures, and understand the resources they need to run.

Fault-tolerant quantum computing is a co-design problem. Choices in the application, QEC code, logical architecture, physical hardware, decoding, control, and classical computing can all change the qubits and runtime required for the same computation. CUDA-Q Logical keeps the workload fixed while these system choices change, so you can compare results directly and inspect the assumptions behind each one.

In this preview, you can start from a CUDA-Q kernel or author a portable logical program directly; configure codes, gadgets, placement, and distillation protocols; generate resource estimates; execute supported physical builds with cudaq.run; and emit realized programs for simulation and further analysis in tools such as Stim.

Installation

CUDA-Q Logical comes pre-installed with cudaq, so one command is enough:

pip install cudaq

For more installation options or to build from source, see Quick start.

An end-to-end estimate

As a first step, define a CUDA-Q Logical target that describes the desired QEC encoding: for instance, a distance-3 surface code with room for one logical qubit. You can then lower any cudaq.kernel to a fault-tolerant program. cudaq.estimate returns the required resources for the encoded computation:

An ordinary CUDA-Q kernel lowered through a surface-code encoding (examples/02_surface_code_resource_estimate.py).
import cudaq
import cudaq.logical as cql


# %%
# Prepare and measure one or more logical qubits in the Z basis.
@cudaq.kernel
def logical_zero_memory(logical_qubits: int):
    qubits = cudaq.qvector(logical_qubits)
    mz(qubits)


# %%
# Select a distance-11 surface-code target with room for three logical qubits.
logical_qubits = 3
target = cql.targets.surface_physical_target(
    logical_capacity=logical_qubits,
    distance=11,
)
cudaq.set_target(target)

# %%
# The target handles encoding, physical lowering, and scheduling.
estimate = cudaq.estimate(logical_zero_memory, logical_qubits)
print(estimate)

#%%
schedule = estimate.annotations["SCHEDULE"]

print("Surface-code memory resources:")
print(f"  physical qubits: {schedule['physical_qubits']}")
print(f"  makespan: {schedule['makespan_ns']:.1f} ns")

# %%
# The target is a stack of layers, one per level of abstraction in CUDA-Q
# Logical. Print the stack to see which layers it is made of.
target.print_stack()

#%%
# Each layer contributes its own annotations to the estimate. Print them all
# to see the full estimates across every layer.
for e in estimate.annotations:
    print(f"{e}:")
    for item in estimate.annotations[e]:
        print(f"    {item}: {estimate.annotations[e][item]}")

When you call cudaq.estimate, CUDA-Q Logical takes the kernel’s logical intent through placement, QEC realization, physical lowering, and scheduling. This example reports the physical qubits and scheduled runtime needed to prepare and measure a logical zero. For result layers and model assumptions, see Resource estimation. The examples page shows more of what CUDA-Q Logical can do.

CUDA-Q kernels are only one entry point. You can also author portable logical programs directly, define your own codes and gadgets, and place computations on a logical machine. The compiler refines a program through strict semantic stages, producing immutable evidence at each transition; see the architecture reference for the advanced staged model.

Choose your route

Start from the result you want:

If you want to…

Go to

Install and run a first estimate

Getting started

Compile, place, estimate, and run a CUDA-Q kernel

The logical programming stack

Do a specific job (define a code, place, distill, estimate, emit Stim)

Use cases

Browse runnable end-to-end examples

Examples

Inspect advanced internals or build against CUDA-Q

Reference