Web UI
QPyth includes a modern web interface built with FastAPI (backend) and React (frontend) for interactive quantum computing exploration.
Installation
First, install QPyth with web UI support:
Starting the Web UI
Backend (FastAPI)
The backend will start on http://localhost:8000
Frontend (React)
In a separate terminal:
The frontend will start on http://localhost:3000
Features
Bloch Sphere Visualization
Interactive visualization of quantum states on the Bloch sphere.
Features: - Adjustable theta (θ) and phi (φ) angles - Real-time statevector display - Measurement probability visualization - Preset states: |0⟩, |1⟩, |+⟩, |−⟩, |i+⟩
API Endpoint:
Circuit Explorer
Explore quantum circuits including Bell pairs, Hadamard sweeps, and teleportation.
Features: - Bell pair entanglement - Hadamard sweep with configurable depth - Quantum teleportation circuit - Circuit diagram display - Measurement counts
API Endpoints:
VQE (Variational Quantum Eigensolver)
Interactive VQE simulation for molecular ground states.
Features: - Multiple molecule support (H₂, LiH, HeH⁺, BeH₂, H₂O) - Three execution modes: - Ideal simulator - Noisy simulator (with IBM calibration data) - IBM Quantum hardware - Energy convergence visualization - Real-time progress tracking
API Endpoint:
GET /vqe?molecule=H2&use_hardware=false&use_noisy_simulator=true&noise_profile=ibm_brisbane&max_iters=50
QRNG (Quantum Random Number Generator)
Generate quantum random numbers with golden ratio scaling.
Features: - Configurable number of qubits (4-12) - Configurable sequence length (8-32) - Sacred geometry scaling (φ = 1.618...) - Statistical analysis (mean, min, max)
API Endpoint:
Noise Profiles
View available IBM Quantum calibration profiles for noisy simulation.
API Endpoint:
Response:
{
"profiles": ["ibm_brisbane", "ibm_sherbrooke", ...],
"profile_info": {
"ibm_brisbane": {
"name": "ibm_brisbane",
"num_qubits": 127,
"avg_t1_us": 123.45,
"avg_t2_us": 98.76,
"avg_readout_error": 0.0123
}
}
}
API Documentation
Interactive API documentation is available at:
This provides: - Complete API reference - Request/response schemas - Try-it-out functionality - Authentication information
Configuration
Backend Configuration
Configure the FastAPI backend via environment variables:
# Host and port
export QPYTH_HOST="0.0.0.0"
export QPYTH_PORT="8000"
# Rate limiting
export QPYTH_RATE_LIMIT="true"
# IBM Quantum
export QISKIT_IBM_TOKEN="your-token"
Frontend Configuration
The React frontend can be configured in web/src/config.ts (create if needed):
Building for Production
Backend
The backend is production-ready with Uvicorn:
Frontend
Build the React frontend:
This creates an optimized production build in web/dist/.
Serve with any static file server:
# Using Python
python -m http.server 3000 --directory web/dist
# Using Node.js
npx serve web/dist -l 3000
Deployment
Vercel (Recommended)
Deploy the frontend to Vercel:
Docker
Build and run with Docker:
# Dockerfile
FROM python:3.11-slim
# Install backend dependencies
WORKDIR /app
COPY pyproject.toml .
RUN pip install QPyth[web]
# Copy backend code
COPY server.py .
# Build frontend
COPY web /web
WORKDIR /web
RUN npm install && npm run build
# Expose ports
EXPOSE 8000 3000
# Run both services
CMD ["sh", "-c", "uvicorn server:app --host 0.0.0.0 --port 8000 & npx serve dist -l 3000"]
Troubleshooting
Backend Won't Start
Check if port 8000 is already in use:
Frontend Won't Start
Ensure dependencies are installed:
API Connection Errors
Check that the backend is running:
Verify CORS settings in server.py if needed.
Performance Issues
- Reduce number of shots in simulations
- Use simulator instead of hardware for testing
- Enable rate limiting to prevent abuse
- Use caching for repeated requests
Next Steps
- CLI Usage - Learn about the command-line interface
- VQE - Deep dive into Variational Quantum Eigensolver
- Noisy Simulation - Learn about realistic noise modeling
- API Reference - Complete API documentation