Metadata-Version: 2.4
Name: qubitos
Version: 0.3.0
Summary: Python modules for QubitOS quantum control kernel
Project-URL: Homepage, https://github.com/qubit-os/qubit-os-core
Project-URL: Documentation, https://qubit-os.github.io/qubit-os-core/
Project-URL: Repository, https://github.com/qubit-os/qubit-os-core
Project-URL: Issues, https://github.com/qubit-os/qubit-os-core/issues
Author: QubitOS Contributors
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: computing,control,grape,optimization,pulse,quantum
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Physics
Requires-Python: >=3.11
Requires-Dist: click>=8.0.0
Requires-Dist: grpcio>=1.60.0
Requires-Dist: httpx>=0.26.0
Requires-Dist: numpy>=1.26.0
Requires-Dist: protobuf>=4.25.0
Requires-Dist: pydantic>=2.5.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: qutip>=5.0.0
Requires-Dist: rich>=13.0.0
Requires-Dist: scipy>=1.12.0
Provides-Extra: dev
Requires-Dist: grpcio-tools>=1.60.0; extra == 'dev'
Requires-Dist: mypy>=1.8.0; extra == 'dev'
Requires-Dist: pre-commit>=3.6.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: ruff>=0.2.0; extra == 'dev'
Requires-Dist: scipy-stubs>=1.17.0; extra == 'dev'
Requires-Dist: types-grpcio>=1.0.0; extra == 'dev'
Requires-Dist: types-protobuf>=4.0.0; extra == 'dev'
Requires-Dist: types-pyyaml>=6.0.0; extra == 'dev'
Provides-Extra: docs
Requires-Dist: mkdocs-gen-files>=0.5.0; extra == 'docs'
Requires-Dist: mkdocs-jupyter>=0.24.0; extra == 'docs'
Requires-Dist: mkdocs-literate-nav>=0.6.0; extra == 'docs'
Requires-Dist: mkdocs-material>=9.5.0; extra == 'docs'
Requires-Dist: mkdocs>=1.5.0; extra == 'docs'
Requires-Dist: mkdocstrings[python]>=0.24.0; extra == 'docs'
Description-Content-Type: text/markdown

# QubitOS Core

[![CI](https://github.com/qubit-os/qubit-os-core/actions/workflows/ci.yaml/badge.svg)](https://github.com/qubit-os/qubit-os-core/actions/workflows/ci.yaml)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Python](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
[![Architecture](https://img.shields.io/badge/Architecture-Stable-green.svg)]()
[![Phase](https://img.shields.io/badge/Phase-Hardware_Integration-orange.svg)]()
[![Tests](https://img.shields.io/badge/tests-381_passing-brightgreen.svg)]()
[![Coverage](https://img.shields.io/badge/coverage-93%25-brightgreen.svg)]()

Open-source real-time quantum control system: pulse optimization, calibration management, and hardware abstraction.

## Why This Exists

Quantum processors drift. Gate fidelities measured during Tuesday's calibration are wrong by Thursday. Coherence times shift with temperature, TLS defects come and go, and crosstalk changes as you bring neighboring qubits online. So every serious quantum experiment starts the same way: recalibrate, re-optimize pulses, hope the hardware holds still long enough to run your circuit.

Most quantum software treats this as somebody else's problem. Qiskit and Cirq give you circuit-level abstractions and assume calibration data is accurate and static. But if you have actually tried to run a multi-qubit algorithm on real hardware, you know it is not. The gap between "my simulation says 99.9% fidelity" and "the QPU returned garbage" is almost always a calibration or pulse-level problem, and there is no open-source tool that closes that loop.

QubitOS is built to sit between your compiler output and the hardware. It takes circuit-level instructions, optimizes pulses against current calibration data (not last week's), and executes them through a hardware abstraction layer that talks to real backends. The control loop is designed to be fast enough for feedback-based protocols where you need microsecond-scale decisions.

This started because I kept running into the same problem across [QubitPulseOpt](https://github.com/rylanmalarchick/QubitPulseOpt), [qco-integration](https://github.com/rylanmalarchick/qco-integration), and the [circuit optimizer](https://github.com/rylanmalarchick/quantum-circuit-optimizer): optimizing gates in isolation does not help if the hardware has drifted since calibration. QubitOS is the system that ties all of those pieces together.

## Overview

QubitOS Core provides:

- **pulsegen** - GRAPE/DRAG pulse optimization with Lindblad noise modeling (99.9% single-qubit fidelity)
- **calibrator** - Live calibration tracking, drift detection, and automatic re-optimization triggers
- **client** - gRPC client for the Rust Hardware Abstraction Layer
- **cli** - Command-line interface for pulse generation, execution, and calibration management

## Installation

```bash
# From PyPI (when available)
pip install qubitos

# From source
git clone https://github.com/qubit-os/qubit-os-core.git
cd qubit-os-core
pip install -e ".[dev]"
```

## Quick Start

### Generate an X-gate pulse

```python
from qubitos.pulsegen import generate_pulse
from qubitos.client import HALClient

# Generate optimized pulse
pulse = generate_pulse(gate="X", duration_ns=20, target_fidelity=0.999)

# Execute on simulator
async with HALClient("localhost:50051") as client:
    result = await client.execute_pulse(
        i_envelope=pulse.i_envelope.tolist(),
        q_envelope=pulse.q_envelope.tolist(),
        duration_ns=20,
        target_qubits=[0],
        num_shots=1000,
    )
    print(f"Counts: {result.bitstring_counts}")
    if result.fidelity_estimate is not None:
        print(f"Fidelity: {result.fidelity_estimate:.4f}")
```

### CLI Usage

```bash
# Generate a pulse
qubit-os pulse generate --gate X --duration 20 --output x_gate.json

# Execute a pulse
qubit-os pulse execute x_gate.json --shots 1000

# Check backend health
qubit-os hal health

# Show calibration
qubit-os calibration show
```

## Architecture

```
qubitos/
├── client/         # HAL gRPC client
├── pulsegen/       # Pulse optimization (GRAPE, DRAG)
├── calibrator/     # Calibration management
├── validation/     # AgentBible integration
└── cli/            # Command-line interface
```

## Configuration

QubitOS uses a configuration hierarchy (later overrides earlier):

1. Built-in defaults
2. Environment variables (`QUBITOS_*`)
3. `config.yaml`
4. CLI arguments

```bash
# Environment variables
export QUBITOS_HAL_HOST=localhost
export QUBITOS_HAL_PORT=50051
export QUBITOS_LOG_LEVEL=info
```

## Development

### Setup

```bash
# Clone and install
git clone https://github.com/qubit-os/qubit-os-core.git
cd qubit-os-core
pip install -e ".[dev]"

# Run tests
pytest tests/

# Type checking
mypy src/qubitos/

# Linting
ruff check src/
ruff format src/
```

### Running Tests

```bash
# All tests
pytest

# With coverage
pytest --cov=qubitos --cov-report=html

# Specific module
pytest tests/unit/test_grape.py

# Integration tests (requires HAL running)
pytest tests/integration/
```

## Documentation

- [Design Document](docs/specs/QubitOS-Design-v0.5.0.md)
- [CLI Reference](docs/api/cli.md)
- [API Reference](docs/api/)
- [User Guide](docs/guides/)

## License

Apache 2.0 - See [LICENSE](LICENSE) for details.
