Skip to content

Repository files navigation

Distributed Quantum Services

Quantum operations as discoverable peer-to-peer network services - orchestrated over py-libp2p, analyzed with Qiskit

PythonFastAPINext.jsQiskitLicense: MITLast CommitHits


What This Is

A research platform with two connected tracks:

Demo Video

Watch the demo here

Track 1 - Distributed Quantum Orchestration. A coordinator node (FastAPI + py-libp2p) discovers worker nodes via GossipSub pubsub, compiles OpenQASM circuits into distributed execution plans, routes fragments to workers over libp2p streams, and assembles full quantum results using Qiskit statevector simulation. A Next.js operator console gives real-time visibility into the peer network, job lifecycle, and quantum analysis output.

Track 2 - QAOA Portfolio Optimization. The same infrastructure drives a QAOA-based portfolio optimizer that runs rigorous empirical comparisons against classical baselines (Simulated Annealing) to characterize exactly where, and why, quantum computing gains a scaling advantage.


Platform Architecture

┌─────────────────────────────────────────────────────────────────┐
│ Next.js Operator Console │
│ /dashboard · /runs · /runs/new · /finance │
│ 3D peer graph · circuit builder · quantum analysis · QAOA │
└──────────────────────────┬──────────────────────────────────────┘
│ BFF proxy (REST polling)
▼
┌─────────────────────────────────────────────────────────────────┐
│ FastAPI Coordinator │
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────────────┐ │
│ │ Circuit Jobs │ │ Finance │ │ Enrollment & │ │
│ │ Service │ │ (QAOA) │ │ Discovery │ │
│ └──────────────┘ └──────────────┘ └──────────────────────┘ │
│ │
│ ┌──────────────────────────────────────────────────────────┐ │
│ │ py-libp2p Runtime (Trio) │ │
│ │ Ed25519 host · GossipSub pubsub · Stream RPC │ │
│ └──────────────────────────┬─────────────────────────────┘ │
└─────────────────────────────┼───────────────────────────────────┘
│ libp2p streams
┌──────────────────┼──────────────────┐
▼ ▼ ▼
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ Worker Peer │ │ Worker Peer │ │ Worker Peer │
│ hadamard/cnot│ │ qft/teleport │ │ programmable │
└───────────────┘ └───────────────┘ └───────────────┘
Persistence: Postgres (event-sourced) · MongoDB (projections) · JSONL (peer log)

Key Research Finding

97% of quantum runtime is classical COBYLA parameter search — not the quantum circuit.

Quantum runtime breakdown:
Parameter search (COBYLA): ████████████████████████████████████ 97%
Circuit execution: █ 2%
Overhead: ▌ 1%

Implication (Amdahl's Law): adding more quantum nodes yields at most 1.03× speedup. Quantum advantage comes from scaling behavior, not raw speed:

Portfolio SizeClassical (SA)Quantum (QAOA)Winner
10 assets20 ms1,500 msClassical 75× faster
20 assets600 ms1,700 msClassical 2.8× faster
40 assets6,000 ms1,900 msQuantum 3.2× faster
60 assets20,000 ms2,100 msQuantum 9.5× faster

Quick Start

Prerequisites

  • Python 3.11+ with uv
  • Node.js 20+ with npm
  • Docker (for full-stack deployment)

Run the Backend

cd backend
make install # uv sync --extra dev
make run # FastAPI on http://localhost:8081

Swagger docs at http://localhost:8081/docs. To restart with a clean runtime state: make run-clean.

Run the Frontend

cd frontend
npm install
npm run dev # Next.js on http://localhost:3000

Create frontend/.env.local:

QUANTUM_BACKEND_URL=http://localhost:8081
NEXT_PUBLIC_TRIAL_DISABLED=true

Full Stack with Docker

cp .env.example .env # fill in Neon Postgres + Atlas MongoDB credentials
docker compose up --build

Frontend → localhost:3000 · Backend API → localhost:8081 · Swagger → localhost:8081/docs


Documentation

Apple-style navigation — pick your goal, go directly there. No guessing needed.

🎓 I'm a researcher or academic

→ Start here: docs/research/RESEARCH_PAPER_DRAFT.md

~15,000 words · 9 sections · publication-ready draft. All experiments, benchmarks, and findings from bottleneck analysis through scaling characterization.

Then read:


🔧 I'm a developer contributing to the platform

→ Start here: CONTEXT.md

Deep contributor context — package layout, critical caveats (Trio/asyncio bridge, auth model, embedded dev swarm), and entry points for every type of change.

Then read:

  • docs/ARCHITECTURE.md — full system architecture: control/execution/data planes, every component, state machines, Mermaid diagrams
  • docs/design.md — design rationale, cost model, failure model, protocol contracts
  • docs/requirements.md — FR-001–FR-014 with implementation status

🖥️ I want to understand the operator console (frontend)

→ Start here: frontend/DESIGN.md

The Clay design system — oklch colors, component patterns, shadcn/ui conventions used throughout the UI.

Then read:

  • docs/ARCHITECTURE.md §Frontend — BFF proxy pattern, Zustand stores, polling hooks
  • /runs/new — visual circuit builder with drag-and-drop gate palette + OpenQASM editor
  • /runs/[id] — full quantum analysis: Bloch spheres, fragment DAG, entanglement entropy, density matrices

📊 I want to replicate or extend the benchmarks

→ Start here: docs/technical/IMPLEMENTATION_NOTES.md

Complete technical timeline from initial 600× slowdown through three optimization phases to the final scaling result.

Then read:


🚀 I want to deploy the platform

→ Start here: DEPLOYMENT-MANUAL.md

Full production runbook: frontend on Vercel, backend on AWS Lightsail, Neon Postgres, MongoDB Atlas, Caddy HTTPS. ~$40/month all-in.

Then read:


💰 I want to understand the finance/quantum use case

→ Start here: docs/FINANCIAL_MODELING_FOUNDATIONS.md

What "financial modeling" actually means, Track A (corporate finance) vs Track B (quantum-finance optimization), and why portfolio optimization maps naturally to QAOA.

Then read:


🗺️ I want the long-term product vision

→ Start here: docs/FUTURE_ROADMAP.md

Five-milestone evolution: SDK platform → open node network → autonomous research engine → torrent-native service swarm → self-healing distributed organism.

Then read:


⚡ I'm new and want the fastest possible orientation

docs/START_HERE.md — the full documentation navigator in one page


Research: Optimization Phases

PhaseApproachResult
BaselineDefault COBYLA (150 iters × 12 starts)10,000 ms · 77% parameter search
Phase 1Reduced iterations + parameter caching1,400 ms · 97% parameter search — Amdahl limit hit
Phase 2Parameter-shift gradients + L-BFGS-B2–3× slower — 8× evaluation overhead dominated
Phase 3Focus on scaling N, not speedQuantum wins at N ≥ 40 assets

Full paper: docs/research/RESEARCH_PAPER_DRAFT.md · Failure analysis: docs/technical/GRADIENT_OPTIMIZATION_POSTMORTEM.md


Future Roadmap

MilestoneTheme
M1Production SDK & Platform
M2Bring Your Own Node Network
M3Autonomous Research & Drug Discovery Platform
M4Torrent-Native Service Network
M5Hydra Self-Healing Network

Details: docs/FUTURE_ROADMAP.md


Contributing

  1. Fork and create a feature branch.
  2. Read CONTEXT.md first — the Trio/asyncio bridge and event-sourced persistence have constraints that aren't obvious.
  3. make lint && make test must pass in backend/ before submitting.
  4. npm run build must succeed in frontend/ (no TypeScript errors).
  5. Surgical changes only — match existing style, don't refactor adjacent code.

Citation

@article{bhoir2026quantum,
title={Quantum Portfolio Optimization: Bottleneck Analysis and Scaling Studies},
author={Bhoir, Soham and Gupta, Manusheel},
journal={[Pending submission]},
year={2026},
note={QAOA bottleneck profiling, Amdahl's Law analysis, and quantum advantage characterization for financial portfolio optimization using distributed py-libp2p infrastructure}
}

Acknowledgments


docs/START_HERE.md · Research Paper · Architecture · Deployment

Built with quantum circuits, debugged with patience, documented with care.

About

Autonomous research lab with distributed quantum infrastructure for computational chemistry, molecular simulation, quantum finance, and scientific discovery - powered by libp2p and IPFS for peer-to-peer collaboration.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages