The fusion-qec-sim project now supports dual quantum computing backends: QuTiP and Qiskit. This provides users with flexibility to choose the framework that best suits their needs.
Choose your preferred quantum computing framework:
- QuTiP (default): Quantum Toolbox in Python - lightweight, fast for small systems
- Qiskit: IBM's industry-standard quantum computing framework - extensive ecosystem, real hardware integration
Both backends implement the same interface:
from src.qec_steane import create_steane_code
# Create with QuTiP (default)
code = create_steane_code('qutip')
# Create with Qiskit
code = create_steane_code('qiskit')
# Both support the same methods:
state = code.encode_logical_zero()
noisy = code.apply_depolarizing_noise(state, 0.01)
spectrum = code.compute_pauli_spectrum(noisy)
p_log = code.calculate_logical_error_rate(0.01, n_trials=100)Switch backends dynamically in the IRC bot:
User: !backend
Bot: Current backend: QUTIP | Use: !backend [qutip|qiskit]
User: !backend qiskit
Bot: Switched to QISKIT backend
User: !threshold
Bot: Steane [[7,1,3]] pseudo-threshold: η_thr ≈ 9.30e-05 | Below this rate, QEC provides net benefit | Backend: QISKIT
Set default backend via environment variable:
# Use QuTiP (default)
python run_bot.py --demo
# Use Qiskit
export QEC_BACKEND=qiskit
python run_bot.py --demoThe implementation uses a factory pattern with two parallel implementations:
SteaneCode: QuTiP-based implementation (original)SteaneCodeQiskit: Qiskit-based implementation (new)create_steane_code(backend): Factory function for instantiation
-
src/qec_steane.py
- Added Qiskit imports with graceful fallback
- Implemented
SteaneCodeQiskitclass - Added
create_steane_code()factory function - Added
demo_backend_comparison()function
-
src/integrated_bot.py
- Added
backendparameter to__init__() - Implemented
cmd_backend()for runtime switching - Updated
cmd_threshold()to show current backend - Added help text for
!backendcommand
- Added
-
requirements.txt
- Added
qiskit>=0.45.0 - Added
qiskit-aer>=0.13.0
- Added
-
tests/test_qec_backends.py (new)
- 13 comprehensive tests for both backends
- Tests for factory function
- Comparison tests between backends
- Skip Qiskit tests if not installed
- QuTiP remains the default backend
- All existing code works without modification
- Qiskit is an optional dependency (gracefully handled if not installed)
- No breaking changes to existing API
from src.qec_steane import create_steane_code
# QuTiP backend
qutip_code = create_steane_code('qutip')
qutip_state = qutip_code.encode_logical_zero()
print(f"QuTiP state: {qutip_state.shape}")
# Qiskit backend
qiskit_code = create_steane_code('qiskit')
qiskit_state = qiskit_code.encode_logical_zero()
print(f"Qiskit state: {len(qiskit_state)} dimensions")from src.qec_steane import create_steane_code
backends = ['qutip', 'qiskit']
for backend in backends:
code = create_steane_code(backend)
p_log = code.calculate_logical_error_rate(0.01, n_trials=100)
print(f"{backend.upper()}: p_log = {p_log:.6f}")# Compare both backends
python examples/backend_comparison_demo.py
# Or use built-in comparison
python src/qec_steane.py --compareAll functionality is fully tested:
# Run all tests
python -m pytest tests/
# Run only backend tests
python -m pytest tests/test_qec_backends.py -v
# Run with coverage
python -m pytest tests/test_qec_backends.py --cov=src.qec_steaneTest coverage:
- Factory function creation
- Backend initialization
- State encoding
- Noise application
- Pauli spectrum computation
- Logical error rate calculation
- Backend comparison
- Graceful fallback when Qiskit unavailable
- Pros: Lightweight, fast for small systems, simpler installation
- Cons: Limited to simulation, no real hardware access
- Best for: Quick prototyping, education, small-scale simulations
- Pros: Industry standard, extensive ecosystem, real hardware integration
- Cons: Heavier installation, more complex setup
- Best for: Production use, integration with IBM Quantum, large-scale projects
Potential additions:
- Additional QEC codes (Surface codes, Color codes)
- Hardware backend integration via IBM Quantum
- Performance benchmarking between backends
- Circuit visualization for Qiskit backend
- Transpiler optimization options
- Noise model customization
qutip>=4.6.0
numpy>=1.22.0
scipy>=1.7.0
qiskit>=0.45.0
qiskit-aer>=0.13.0
For issues or questions:
- Check the documentation in
docs/IRC_BOT_GUIDE.md - Run the demo:
python examples/backend_comparison_demo.py - Open an issue on GitHub
Last Updated: 2025-10-11
Version: 0.3.0
Status: Production Ready ✓