Skip to content

Commit b8246f4

Browse files
committed
complete the new example refactor
1 parent 635b13e commit b8246f4

File tree

466 files changed

+4842
-146672
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

466 files changed

+4842
-146672
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,4 +206,7 @@ examples/qml_param_v2.npy
206206

207207
#read the docs
208208
build_log.txt
209-
!docs/build/html/
209+
210+
#qoder
211+
.qoder/work_summary/
212+
.qoder/quests/

README.md

Lines changed: 87 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Directly use the TyxonQ cloud task submission API. For details, see the example:
2828
### Minimal circuit → simulator / hardware
2929
```python
3030
import tyxonq as tq
31-
from tyxonq.postprocessing import metrics
31+
from tyxonq.libs.quantum_library.kernels import quantum_info
3232
import getpass
3333
tq.set_backend("numpy")
3434

@@ -146,6 +146,77 @@ This document provides:
146146

147147
- **☁️ Quantum Cloud Services**: Scalable quantum computing as a service
148148

149+
### 🚀 Performance Leadership
150+
151+
TyxonQ delivers **industry-leading performance** in gradient computation:
152+
153+
| Framework | Time/Step | Method |
154+
|-----------|-----------|--------|
155+
| **TyxonQ** (PyTorch + Autograd) | **0.012s** | Automatic differentiation |
156+
| PennyLane (default.qubit) | 0.017s | Backpropagation |
157+
| Qiskit (Estimator) | 0.067s | Finite differences |
158+
159+
*Benchmark: LiH molecule VQE (4 qubits, 10 parameters), measured on M2 MacBook Pro*
160+
161+
**Key Performance Advantages**:
162+
-**PyTorch Autograd**: Complete automatic differentiation support with gradient chain preservation
163+
- 🎯 **Multi-Backend Architecture**: Seamless switching between NumPy/PyTorch/CuPy without code changes
164+
- 🔬 **Optimized Implementation**: Efficient gradient computation through proper autograd integration
165+
- 📊 **Production-Ready**: Validated on VQE benchmarks with H₂, LiH, BeH₂ molecules
166+
167+
### ✨ Advanced Quantum Features
168+
169+
#### Automatic Differentiation
170+
```python
171+
import tyxonq as tq
172+
import torch
173+
174+
# PyTorch autograd automatically tracks gradients
175+
tq.set_backend("pytorch")
176+
params = torch.randn(10, requires_grad=True)
177+
178+
def vqe_energy(p):
179+
circuit = build_ansatz(p)
180+
return circuit.run_energy(hamiltonian)
181+
182+
energy = vqe_energy(params)
183+
energy.backward() # Automatic gradient computation
184+
print(params.grad) # Gradients ready for optimization
185+
```
186+
187+
#### Quantum Natural Gradient (QNG)
188+
```python
189+
from tyxonq.compiler.stages.gradients.qng import compute_qng_metric
190+
191+
# Fubini-Study metric for quantum optimization
192+
metric = compute_qng_metric(circuit, params)
193+
natural_grad = torch.linalg.solve(metric, grad)
194+
params -= learning_rate * natural_grad
195+
```
196+
197+
#### Time Evolution with Trotter-Suzuki
198+
```python
199+
from tyxonq.libs.circuits_library.trotter_circuit import build_trotter_circuit
200+
201+
# Hamiltonian time evolution
202+
H = build_hamiltonian("HeisenbergXXZ")
203+
circuit = build_trotter_circuit(H, time=1.0, trotter_steps=10)
204+
result = circuit.run(shots=2048)
205+
```
206+
207+
#### Production-Ready Noise Simulation
208+
```python
209+
# Realistic noise models for NISQ algorithms
210+
circuit = tq.Circuit(2).h(0).cx(0, 1)
211+
212+
# Depolarizing noise
213+
result = circuit.with_noise("depolarizing", p=0.05).run(shots=1024)
214+
215+
# T1/T2 relaxation (amplitude/phase damping)
216+
result = circuit.with_noise("amplitude_damping", gamma=0.1).run(shots=1024)
217+
result = circuit.with_noise("phase_damping", l=0.05).run(shots=1024)
218+
```
219+
149220

150221

151222
### Quantum AIDD Key features
@@ -164,9 +235,23 @@ This document provides:
164235
- Expanded properties and excited states (VQD/pVQD) aligned with spectroscopy and binding‑relevant observables.
165236

166237

238+
## 📚 Comprehensive Example Library
239+
240+
TyxonQ includes **66 high-quality examples** covering:
241+
242+
- **Variational Algorithms**: VQE, QAOA, VQD with SciPy/PyTorch optimization
243+
- **Quantum Chemistry**: UCCSD, k-UpCCGSD, molecular properties (RDM, dipole)
244+
- **Quantum Machine Learning**: MNIST classification, hybrid GPU training
245+
- **Advanced Techniques**: Quantum Natural Gradient, Trotter evolution, slicing
246+
- **Noise Simulation**: T1/T2 calibration, readout mitigation, error analysis
247+
- **Performance Benchmarks**: Framework comparisons, optimization strategies
248+
- **Hardware Deployment**: Real quantum computer execution examples
249+
250+
Explore the full collection in [`examples/`](examples/) directory.
251+
167252
## Dependencies
168253
- Python >= 3.10 (supports Python 3.10, 3.11, 3.12+)
169-
- PyTorch >= 1.8.0
254+
- PyTorch >= 1.8.0 (required for autograd support)
170255

171256

172257
## 📧 Contact & Support

0 commit comments

Comments
 (0)