← Back to Dashboard

09. Factorization

Stage C - Calibrated

Shor's algorithm for N = 15 (8 qubits): order finding for a = 7, with modular multipliers and an inverse QFT checked against exact results. 20-run calibration ensemble. 61k physical qubits, 25 logical, 9 T-gates.

Algorithm
Shor's Algorithm (QPE + modular multiply)
Logical Qubits
8
Framework
Modern QDK (qsharp 1.31.0)

Resource Estimation (Azure Quantum RE)

Physical Qubits
60.7k
Logical Qubits
25
T-Gates
9
Rotations
9
Runtime
1.0ms

Resource Breakdown

Calibration Evidence (20-Run Ensemble)

Mean Value
7.200
95% CI
± 1.937
Runs
20
Std Dev
4.420

Noise Resilience (Depolarizing Simulation)

Ideal outcome: [Zero, Zero, Zero, Zero] (28% probability)

p = 0.001
98.4%
p = 0.01
80.3%
p = 0.05
53.2%

Cross-Platform Emulator Results (100 shots)

These histograms predate the current kernel

This run was recorded in April 2026 against a Shor kernel that did not find the period, rewritten in September 2026. The shot distribution below is a real measurement, but it is a measurement of a program that no longer exists in this repository, and it has not been re-run against the current kernel.

Quantinuum H2-1E
[0, 0, 0, 0]
48% of shots
Rigetti QVM
[0, 0, 0, 0]
50% of shots
✓ Cross-platform agreement: both simulators find the same dominant outcome
H2-1E Distribution
Rigetti QVM Distribution

Troyer Utility-Scale Classification

Proven Speedup
Quantum Speedup
Superpolynomial: O(n³) vs sub-exponential classical (GNFS)
Classical Competitor
General Number Field Sieve
Honest Assessment (Troyer Framework)

Shor's algorithm is the canonical example of superpolynomial quantum speedup. Utility requires factoring 2048+ bit integers our 4-bit toy instance demonstrates the algorithm but is far from utility scale.

These two numbers describe different programs

The resource estimate below is for Main.ShorPeriodFinding(7, 4), the algorithm at utility scale. The Azure Quantum runs executed ShorKernel(), a small kernel sized to fit today's hardware. Qubit counts and runtimes from the estimate are not measurements of the run, and the run histogram is not a sample of the estimated circuit.

Pareto Frontier: Qubits vs Runtime

The estimator returns 7 viable configurations, not one answer. Every headline figure on this page comes from the leftmost point, which uses the fewest qubits and is therefore also the slowest. Buying 2.3x the qubits cuts runtime to 0.49x.

qubit_gate_ns_e3 with surface_code, error budget 1e-3. Points are Pareto-optimal: no other configuration is better on both axes.

Multi-Model Resource Comparison

Physical qubit requirements across 6 qubit technologies × 2 QEC schemes (inspired by Troyer Architecture Series, Part 3).

■ Gate-based + Surface code (blue)
Qubit ModelQECPhysical QubitsLogical Qubits
Superconducting (ns, 1e-4)surface_code11,86525
Trapped Ion (μs, 1e-4)surface_code11,86525
Superconducting (ns, 1e-3)surface_code60,66525
Trapped Ion (μs, 1e-3)surface_code60,66525

Problem Documentation

Problem 09 · Quantum-Accelerated Integer Factorization

Overview

Breaking large RSA-style moduli showcases a flagship quantum advantage through Shor's algorithm. While practical quantum hardware remains distant, we can benchmark classical factoring effort and prepare a Q# scaffold for modular exponentiation, quantum Fourier transforms, and order finding experiments. This problem introduces a Pollard Rho classical baseline to estimate computational effort per instance and enables future integration with full period-finding implementations.

Directory Layout


09_factorization/
├── estimates/                  # JSON artifacts from classical / quantum workflows
├── instances/                  # Semi-prime inputs across difficulty scales
├── plots/                      # Generated figures from analyze.py
├── python/
│   ├── classical_baseline.py   # Pollard Rho factoring statistics per modulus
│   └── analyze.py              # Visualization of iterations / speed trends
└── qsharp/
    ├── qsharp.json            # Modern QDK project file
    └── Program.qs              # Placeholder quantum workflow

Quick Start


cd problems/09_factorization

# Classical factoring baseline (writes estimates/classical_baseline.json)
python python/classical_baseline.py

# Visualize iteration counts and effort
python python/analyze.py

# Quantum placeholder
 python -c "import qsharp; qsharp.init(project_root='qsharp'); print('Build OK')"
 python tooling/run_all_qsharp.py  # runs via qsharp Python package

Next Quantum Milestones

1. Modular Exponentiation Kernel – Implement square-and-multiply circuits with controlled modular multipliers.

2. Quantum Fourier Transform – Integrate QFT-based phase estimation for order finding.

3. Semi-Prime Order Finding – Simulate Shor's algorithm for 15, 21, and 35; extend to 3–4 qubit work registers.

4. Resource Estimation – Analyze logical qubit counts and T-depth for RSA-1024 style moduli via Azure Quantum tools.

This scaffold keeps the classical baseline reproducible while we iterate toward full-scale quantum period finding demonstrations. 🔐⚛️

Objective Maturity Gate

  • **Current gate**: **Stage C complete** (hardware-aware validation evidence in place: Shor period-finding workflow runnable, calibration ensemble across runs, backend assumptions documented, estimator profile produced for both ns-e3 superconducting and surface-code-generic models, OpenQASM kernel `shor_n15_a7.qasm` exported for cross-platform validation).
  • **Next gate target**: **Stage D** (advantage evidence package hardening: fairness review against GNFS baseline, RSA-2048 scaling extrapolation with residual-risk callouts, claim category locked).

Stage C evidence references for this problem:

  • Calibration ensemble: `estimates/quantum_calibration_ensemble.json`, regenerated on 2026-09-25 after three corrections that day: the modular multiplier was right only for a = 2 and 4, the inverse QFT left the counting register uniform whatever the period, and the hardware kernel controlled its one multiplication from the wrong qubit. `estimates/calibration_evidence.json` (2026-03-25) predates them. `tooling/test_shor_kernel.py` now checks the multiplication table, the period for every coprime base, and the kernel.
  • Backend assumptions: `estimates/backend_assumptions.md`.
  • Estimator profile (ns-e3 + surface-code-generic): `estimates/estimator_profile_summary.md`, `estimates/latest_qubit_gate_ns_e3.json`, `estimates/latest_surface_code_generic_v1.json`. The estimate runs `Main.ShorPeriodFinding(7, 4)`; until 2026-09-25 it ran base 3, which shares a factor with 15, so it contained no modular arithmetic.
  • Cross-platform OpenQASM export: `estimates/shor_n15_a7.qasm`, OpenQASM 3 and the same circuit as `qsharp/HardwareKernel.qs`.
  • Azure smoke validation: `estimates/azure_smoke_report_small_d1.md`, `estimates/azure_job_manifest_small_d1.json` (2026-03-06, the kernel before the correction; the corrected kernel has not been submitted).
  • Reproducible quantum kernel: `qsharp/src/Main.qs` runnable via `qsharp.run('Main.RunShorFactorization()', 1)`.

DiVincenzo Readiness (Stage C/D Overlay)

| Criterion | Status | Evidence / Notes |

|---|---|---|

| Scalable qubit system | partial | Problem-scoped instance baselines are in place; full hardware-scale projections are tracked as Stage C work. |

| Initialization | partial | Input/state initialization path is defined for current workflows, with backend-ready loading fidelity still to be hardened. |

| Coherence vs gate time | not-yet | Backend-calibrated coherence-vs-depth evidence is pending and required for Stage C/D promotion. |

| Universal gate set | partial | Q# scaffold/build path exists; gate-basis decomposition and transpilation evidence remain Stage C tasks. |

| Qubit-specific measurement | partial | Measurement outputs are defined for current validation flows; hardware readout characterization is pending. |

Advantage Claim Contract

  • **Claim category (current)**: `theoretical`.
  • **Problem class and regime**: Problem-specific challenge instances defined in this directory.
  • **Fair baseline**: Problem-local classical baseline in `python/` outputs.
  • **Quantum resource scaling claim**: Expected asymptotic advantage depends on algorithm family and implementation assumptions; no hardware-demonstrated speedup claim yet.
  • **Data-loading and I/O assumptions**: Must be documented alongside future advantage claims.
  • **Noise/error model assumptions**: Backend-specific model and calibration assumptions to be added at Stage C.
  • **Confidence/uncertainty method**: To be reported using shot-based confidence intervals or equivalent statistical bounds.
  • **Residual risks**: Oracle/state-preparation/transpilation overhead may dominate for near-term instance sizes.

Reproduce It

cd problems/09_factorization make classical # Run classical baseline make analyze # Generate plots make build # Validate Q# compilation make run # Run Q# entry point

Key Files

  • qsharp/src/Main.qs Quantum algorithm implementation
  • qsharp/HardwareKernel.qs Azure-submittable QIR kernel
  • python/classical_baseline.py Classical reference implementation
  • estimates/classical_baseline.json Baseline metrics
View on GitHub →