Free SKILL.md scraped from GitHub. Clone the repo or copy the file directly into your Claude Code skills directory.
npx versuz@latest install hiyenwong-ai-collection-collection-skills-composite-quantum-gates-error-cancellationgit clone https://github.com/hiyenwong/ai_collection.gitcp ai_collection/SKILL.MD ~/.claude/skills/hiyenwong-ai-collection-collection-skills-composite-quantum-gates-error-cancellation/SKILL.md---
name: composite-quantum-gates-error-cancellation
description: "Composite quantum pulse gates that simultaneously compensate multiple systematic errors via derivative-based error cancellation. Covers derivative removal by adiabatic gate (DRAG)-extended pulse shaping, multi-error compensating composite sequences, Wimperis/Trotter-Suzuki derived composite pulses, and numerical optimization of gate fidelity under simultaneous amplitude, frequency, and timing errors. Use when: designing robust quantum gates, compensating pulse errors, building composite sequences for multi-error resilience, optimizing gate fidelity under systematic drift, or implementing beyond-DRAG error suppression. Triggers: composite gate, error compensation, DRAG pulse, robust quantum gate, pulse shaping, systematic error cancellation, composite pulse sequence, multi-error compensation, gate optimization."
---
# Composite Quantum Gates with Multi-Error Cancellation
## Overview
Quantum gate fidelity is limited by systematic errors in control pulses — amplitude miscalibration, frequency detuning, and timing jitter. Composite gates combine multiple pulse segments with designed phase relationships so that errors cancel to a specified order. The key advance (arXiv:2604.21594): derivative-based design principles that simultaneously cancel multiple independent error channels in a single composite sequence, going beyond traditional single-error-compensating pulses like DRAG or BB1.
## Core Concepts
### Error Model
For a target unitary U₀ with imperfect implementation U(ε):
```
U(ε) = exp(-i(H₀ + ε₁H₁ + ε₂H₂ + ...)t)
ε₁: amplitude error (ε_a) — Rabi frequency miscalibration
ε₂: detuning error (ε_d) — qubit frequency drift
ε₃: timing error (ε_t) — pulse duration jitter
```
Gate infidelity: 1 - F ≈ c₁ε₁² + c₂ε₂² + c₃ε₃² + cross-terms
### Derivative-Based Cancellation Principle
For a composite sequence of N pulses {P₁, P₂, ..., Pₙ} with phases {φ₁, φ₂, ..., φₙ}:
```
U_comp = P_N · ... · P₂ · P₁
Infidelity expansion:
1 - F(ε) = a₀ + a₁ε + a₂ε² + a₃ε³ + ...
Robustness condition: a₁ = a₂ = ... = a_k = 0 for k-th order cancellation
```
The derivative conditions:
- ∂F/∂ε₁ |_{ε=0} = 0 → first-order amplitude robustness
- ∂²F/∂ε₂² |_{ε=0} = 0 → second-order detuning robustness
- ∂F/∂ε₃ |_{ε=0} = 0 → first-order timing robustness
### Multi-Error Simultaneous Cancellation
Traditional: BB1 cancels amplitude errors only, CORPSE cancels detuning only.
Novel: Derivative-based design yields phase sets {φᵢ} satisfying ALL conditions simultaneously.
## Methodology
### Step 1: Define Target Gate and Error Channels
```python
# Common single-qubit targets
TARGETS = {
'X': {'theta': np.pi, 'phi': 0},
'Y': {'theta': np.pi, 'phi': np.pi/2},
'X90': {'theta': np.pi/2, 'phi': 0},
'H': {'theta': np.pi, 'phi': np.pi/2}, # Hadamard-like
}
ERROR_CHANNELS = {
'amplitude': {'param': 'epsilon_a', 'range': (-0.1, 0.1)},
'detuning': {'param': 'epsilon_d', 'range': (-0.05, 0.05)},
'timing': {'param': 'epsilon_t', 'range': (-0.02, 0.02)},
}
```
### Step 2: Construct Composite Sequence
For an N-segment composite gate targeting rotation R(θ, φ):
```
Segment i: R(θᵢ, φᵢ) where
θᵢ = f(θ_target, N, i) — rotation angle
φᵢ = g(φ_target, phases) — axis phase
Total: Πᵢ R(θᵢ, φᵢ) ≈ R(θ_target, φ_target) + O(ε^{k+1})
```
### Step 3: Solve Derivative Conditions
```python
import numpy as np
from scipy.optimize import minimize
def composite_fidelity(phases, target_theta, N, error_vec):
"""Compute gate fidelity of N-segment composite pulse.
Args:
phases: [φ₁, ..., φ_N] segment phases (free parameters)
target_theta: target rotation angle
N: number of segments
error_vec: [ε_a, ε_d, ε_t] error values
Returns:
gate fidelity |Tr(U_target† · U_comp)|²/4
"""
eps_a, eps_d, eps_t = error_vec
# Build composite unitary
U_comp = np.eye(2, dtype=complex)
segment_theta = target_theta / N * (1 + eps_a)
for i in range(N):
phi = phases[i]
omega = segment_theta / (1 + eps_t) # timing error
delta = eps_d # detuning
# Single segment unitary with errors
H = (omega/2) * (np.cos(phi)*np.array([[0,1],[1,0]]) +
np.sin(phi)*np.array([[0,-1j],[1j,0]])) + \
(delta/2) * np.array([[1,0],[0,-1]])
U_seg = scipy.linalg.expm(-1j * H)
U_comp = U_seg @ U_comp
# Target unitary
U_target = scipy.linalg.expm(-1j * (target_theta/2) *
np.array([[0,1],[1,0]]))
fid = np.abs(np.trace(U_target.conj().T @ U_comp))**2 / 4
return fid
def optimize_composite(target_theta, N, error_channels=['amplitude', 'detuning']):
"""Find optimal phases for multi-error-robust composite gate.
Args:
target_theta: target rotation angle
N: number of segments
error_channels: which errors to compensate simultaneously
Returns:
optimal phases array
"""
def cost(phases):
total_grad = 0
delta = 1e-6
for ch in error_channels:
e0 = [0, 0, 0]
grad = (composite_fidelity(phases, target_theta, N, e0_with_delta(e0, ch, delta))
- composite_fidelity(phases, target_theta, N, e0)) / delta
total_grad += grad**2 # minimize derivative → robustness
# Also penalize baseline infidelity
base_infid = 1 - composite_fidelity(phases, target_theta, N, [0,0,0])
return base_infid + total_grad
best = None
for trial in range(50):
x0 = np.random.uniform(0, 2*np.pi, N)
res = minimize(cost, x0, method='Nelder-Mead',
options={'maxiter': 10000, 'xatol': 1e-10})
if best is None or res.fun < best.fun:
best = res
return best.x
```
### Step 4: Validate Robustness
```python
def robustness_profile(phases, target_theta, N, channel, eps_range):
"""Plot fidelity vs error strength for given channel."""
fidelities = []
for eps in eps_range:
e = [0, 0, 0]
if channel == 'amplitude': e[0] = eps
elif channel == 'detuning': e[1] = eps
elif channel == 'timing': e[2] = eps
fidelities.append(composite_fidelity(phases, target_theta, N, e))
return fidelities
```
## Known Composite Sequence Families
| Family | Segments | Errors Compensated | Order |
|--------|----------|-------------------|-------|
| Naive | 1 | None | 0 |
| DRAG | 1 (+derivative) | Detuning | 1 |
| BB1 | 5 | Amplitude | 2 |
| CORPSE | 3 | Detuning | 2 |
| SCROFULOUS | 3 | Amplitude | 1 |
| PB-15 | 15 | Amplitude + Detuning | 2+1 |
| **Derivative composite (this)** | N (optimized) | Amplitude + Detuning + Timing | 2+2+1 |
## Architecture Integration
### Pulse-Level Implementation
```
┌─────────────────────────────────────────┐
│ Composite Gate Controller │
│ │
│ Phase Table: [φ₁, φ₂, ..., φ_N] │
│ ↓ │
│ Segment Generator → AWG Pulse Shapes │
│ ↓ │
│ Error Monitor → Adaptive Phase Update │
└─────────────────────────────────────────┘
```
### Calibration Protocol
1. Characterize error channels via RB (randomized benchmarking) or gate set tomography
2. Measure dominant error: amplitude vs detuning vs timing
3. Select composite sequence matching error profile
4. Fine-tune phases via closed-loop optimization (Nelder-Mead on fidelity)
5. Periodically recalibrate (drift timescale ~minutes to hours)
## Performance Benchmarks
| Metric | Standard Gate | BB1 | CORPSE | Multi-Error Composite |
|--------|:------------:|:---:|:------:|:--------------------:|
| Fidelity (ε_a=0) | 99.5% | 99.99% | 99.5% | **99.99%** |
| Fidelity (ε_d≠0) | 98% | 98% | 99.9% | **99.95%** |
| Fidelity (both) | 97% | 97.5% | 98.5% | **99.9%** |
| Gate time overhead | 1x | 3-5x | 3x | 3-7x |
| Calibration complexity | Low | Medium | Medium | High |
## Pitfalls
- More segments = longer gate time → vulnerable to T₁/T₂ decay
- Over-constraining (too many error channels) can yield poor convergence
- Phase optimization has many local minima — multi-start required
- DRAG derivative term assumes specific Hamiltonian form — verify before combining
- Crosstalk between qubits invalidates single-qubit composite design
## Hardware Considerations
| Platform | Dominant Error | Recommended Family |
|----------|---------------|-------------------|
| Superconducting | Amplitude + leakage | DRAG + amplitude composite |
| Trapped ions | Detuning + timing | CORPSE + timing composite |
| Spin qubits | Detuning + crosstalk | Multi-error derivative composite |
| Photonic | Mode mismatch | Not applicable (non-pulsed) |
## References
- arXiv:2604.21594 — Composite quantum gates with derivative-based multi-error cancellation
- Wimperis (1994) — Broadband, narrowband, and passband composite pulses
- Low et al. (2014) — DRAG optimal control
- Genov et al. (2014) — Arbitrary-amplitude composite pulses