Quantum operations as discoverable peer-to-peer network services - orchestrated over py-libp2p, analyzed with Qiskit
A research platform with two connected tracks:
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.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 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)
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 Size | Classical (SA) | Quantum (QAOA) | Winner |
|---|---|---|---|
| 10 assets | 20 ms | 1,500 ms | Classical 75Γ faster |
| 20 assets | 600 ms | 1,700 ms | Classical 2.8Γ faster |
| 40 assets | 6,000 ms | 1,900 ms | Quantum 3.2Γ faster |
| 60 assets | 20,000 ms | 2,100 ms | Quantum 9.5Γ faster |
- Python 3.11+ with uv
- Node.js 20+ with npm
- Docker (for full-stack deployment)
cd backend
make install # uv sync --extra dev
make run # FastAPI on http://localhost:8081Swagger docs at http://localhost:8081/docs. To restart with a clean runtime state: make run-clean.
cd frontend
npm install
npm run dev # Next.js on http://localhost:3000Create frontend/.env.local:
QUANTUM_BACKEND_URL=http://localhost:8081
NEXT_PUBLIC_TRIAL_DISABLED=true
cp .env.example .env # fill in Neon Postgres + Atlas MongoDB credentials
docker compose up --buildFrontend β localhost:3000 Β· Backend API β localhost:8081 Β· Swagger β localhost:8081/docs
Apple-style navigation β pick your goal, go directly there. No guessing needed.
β 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:
- docs/research/MATHEMATICAL_APPENDIX.md β rigorous proofs: QUBOβIsing conversion, parameter-shift rule, Amdahl's Law, complexity comparisons
- docs/research/QUANTUM_SCALING_STRATEGY.md β why we pivoted from speed to scaling, crossover predictions, success criteria
- docs/research/ALTERNATIVE_QUANTUM_FINANCE_PROBLEMS.md β option pricing QAE (proven 100Γ speedup) as backup
β 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
β 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
β 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:
- docs/technical/BENCHMARK.md β original bottleneck discovery (77% β 97% parameter search)
- docs/technical/GRADIENT_OPTIMIZATION_POSTMORTEM.md β honest analysis of why parameter-shift gradients made it 2β3Γ slower
- docs/technical/QAOA_OPTIMIZATION_RESEARCH.md β literature survey of 10+ QAOA optimization papers (2024β2025)
backend/scripts/β benchmark scripts used to produce all results
β 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:
- docs/LIGHTSAIL-DEPLOYMENT.md β Lightsail-specific setup with cost breakdown
- .env.example β all environment variables with descriptions
β 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:
- docs/research/RESEARCH_PAPER_DRAFT.md Β§1 β the computational crisis in modern financial modeling
- docs/research/ALTERNATIVE_QUANTUM_FINANCE_PROBLEMS.md β option pricing, credit risk, yield curves
β 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:
- docs/future-roadmap/ β per-milestone detail docs (M1βM5)
- docs/IPFS_INTEGRATION_STRATEGIC_VISION.md β VAULT: browser-native Helia nodes for peer-to-peer circuit sharing (Phase 1 planned)
β docs/START_HERE.md β the full documentation navigator in one page
| Phase | Approach | Result |
|---|---|---|
| Baseline | Default COBYLA (150 iters Γ 12 starts) | 10,000 ms Β· 77% parameter search |
| Phase 1 β | Reduced iterations + parameter caching | 1,400 ms Β· 97% parameter search β Amdahl limit hit |
| Phase 2 β | Parameter-shift gradients + L-BFGS-B | 2β3Γ slower β 8Γ evaluation overhead dominated |
| Phase 3 β | Focus on scaling N, not speed | Quantum wins at N β₯ 40 assets |
Full paper: docs/research/RESEARCH_PAPER_DRAFT.md Β· Failure analysis: docs/technical/GRADIENT_OPTIMIZATION_POSTMORTEM.md
| Milestone | Theme |
|---|---|
| M1 | Production SDK & Platform |
| M2 | Bring Your Own Node Network |
| M3 | Autonomous Research & Drug Discovery Platform |
| M4 | Torrent-Native Service Network |
| M5 | Hydra Self-Healing Network |
Details: docs/FUTURE_ROADMAP.md
- Fork and create a feature branch.
- Read CONTEXT.md first β the Trio/asyncio bridge and event-sourced persistence have constraints that aren't obvious.
make lint && make testmust pass inbackend/before submitting.npm run buildmust succeed infrontend/(no TypeScript errors).- Surgical changes only β match existing style, don't refactor adjacent code.
@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}
}- Qiskit (IBM) β quantum computing framework
- py-libp2p β peer-to-peer networking
- FastAPI β async Python API framework
- shadcn/ui β UI component library
- Yahoo Finance / Prof. Aswath Damodaran (NYU Stern) β market data
docs/START_HERE.md Β· Research Paper Β· Architecture Β· Deployment
Built with quantum circuits, debugged with patience, documented with care.