Skip to main content
Pre-release

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

ctrl-freeq

Ctrl-freeq is a numerical framework for the design of quantum gates and pulses via optimal control theory, implemented in Python with PyTorch. The control pulse optimization problem is formulated and solved using automatic differentiation, and the resulting software provides both a programmatic API and a graphical user interface for the configuration and execution of optimization workflows. Multiple physical platforms are supported through a Hamiltonian model abstraction layer, including spin-chain systems and superconducting (transmon) qubits.

  • PyPI package: ctrl-freeq
  • Import path: ctrl_freeq
  • Python: 3.11–3.14
  • CLI entry point: freeq-gui

Features

The framework supports two physical platforms—spin chains and superconducting (transmon) qubits—through a Hamiltonian model abstraction layer. The optimizer works with the standard bilinear control formulation H(t) = H_drift + Σ_k u_k(t) · H_ctrl_k, which is platform-agnostic. Gate optimization problems are defined through JSON configuration files, and a high-level Python API is provided for loading configurations, executing the optimizer, and post-processing results. A Tkinter-based GUI (launched via freeq-gui) offers an interactive alternative with dynamic field relabelling and platform-aware gate selection. Optimization results may be visualized through Panel dashboards exported as standalone HTML files, with a Bloch-sphere video of single-qubit pulses rendered by nutate (optional video extra). CPU thread management is handled automatically, and optional GPU acceleration is available via CUDA.

Installation

Ctrl-freeq depends on NumPy, PyTorch, Qiskit, pytorch-minimize, Panel, and other scientific packages.

# Install from source
uv sync

# Or with all development tools
uv sync --all-groups

Note: Dependency groups (dev, docs, tools) use PEP 735 and require uv — they are not pip extras.

For pip users:

pip install .

A detailed treatment of all installation methods is provided in the Installation documentation.

Quick Start

Launch the GUI

freeq-gui

Execution of this command launches the Tkinter-based graphical interface defined in ctrl_freeq/cli.py.

Use the API

from ctrl_freeq.api import CtrlFreeQAPI, run_from_config, load_single_qubit_config

# Load a built-in example configuration
config = load_single_qubit_config()

# Option A: one-shot helper
result = run_from_config(config)

# Option B: create an API instance to inspect and edit parameters
api = CtrlFreeQAPI(config)
print(api.get_config_summary())
api.update_parameter("optimization.max_iter", 500)
result = api.run_optimization()
print(f"Final fidelity: {api.parameters.final_fidelity:.6f}")

Project Structure

src/ctrl_freeq/       Core package
  api.py              High-level API
  cli.py              CLI entry point (freeq-gui)
  setup/              GUI and configuration setup
    hamiltonian_generation/
      base.py         HamiltonianModel ABC
      spin_chain.py   Spin-chain Hamiltonian
      superconducting.py  Transmon qubit Hamiltonian
  run/                Optimization engine
  utils/              Plotting, dashboards, helpers
examples/             Example configs and notebooks
tests/                Test suite
pyproject.toml        Build and packaging configuration

Development

Development tools are organized into dependency groups: dev (pytest, jupyter), docs (mkdocs), and tools (ruff, pre-commit).

# Install dev dependencies
uv sync --all-groups

# Run tests
uv run pytest -q

# Lint
uv run ruff format .
uv run ruff check --fix .

Compute Resource Selection (CPU/GPU)

Ctrl-freeq supports execution on both CPU and GPU (CUDA) hardware:

  • cpu (default) — PyTorch threads are limited to max(1, os.cpu_count() - 1). This default may be overridden with the cpu_cores field.
  • gpu — CUDA is used if available; the framework falls back to CPU with a warning if CUDA is not present.

API Configuration

config = {
    "compute_resource": "gpu",   # or "cpu" (default)
    "cpu_cores": 8,              # optional, CPU only
    ...
}

GUI

The compute resource may be selected from the Compute Resource dropdown in the Optimization Parameters section of the graphical interface.

Note: Only CUDA is supported for GPU acceleration. MPS is not currently supported.

A demonstration notebook is provided at examples/api_gpu_cpu_demo.ipynb, illustrating CPU vs CUDA selection and comparative timing.

License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.

Citation

If this software is used in academic work, please cite it using the metadata provided in CITATION.cff.

Metadata

Release files for ctrl-freeq 0.6.0b1

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

Source distribution (sdist)

Source distribution for ctrl-freeq 0.6.0b1
File Size Uploaded Provenance Actions
ctrl_freeq-0.6.0b1.tar.gz 154.4 kB With provenance Details for ctrl_freeq-0.6.0b1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ctrl-freeq 0.6.0b1
File Interpreter ABI Platform Actions
ctrl_freeq-0.6.0b1-py3-none-any.whl Python 3 none any Details for ctrl_freeq-0.6.0b1-py3-none-any.whl

Total release size: 272.1 kB

Release files / ctrl_freeq-0.6.0b1.tar.gz

Download URL ctrl_freeq-0.6.0b1.tar.gz
Size 154.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f524655facfc205a61e62ba6d423d600b36051ee597bd17ef059def41a330d87
BLAKE2b-256 checksum
How to use checksums
16261bde67c5b5c06356bb784068961d841647c318e7b7f0e441a62a5c06fddd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / ctrl_freeq-0.6.0b1-py3-none-any.whl

Download URL ctrl_freeq-0.6.0b1-py3-none-any.whl
Size 117.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4d0d58087436e1dcb80d092dd6ef98dbff6629afa9a8a57961e44057ce4cddf4
BLAKE2b-256 checksum
How to use checksums
d67f9d3a444ad78124371d404873eb5f557da572840c657f38c01d937937f743
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Security for ctrl-freeq 0.6.0b1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ctrl_freeq-0.6.0b1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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