You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+37-16Lines changed: 37 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,30 +28,51 @@ For Julia or optional features (LLVM, CUDA), see the [Getting Started Guide](doc
28
28
29
29
## Quick Example
30
30
31
-
Create and simulate a Bell state—an entangled pair of qubits using [Guppy](https://github.com/CQCL/guppylang), a pythonic quantum programming language:
31
+
Simulate a distance-3 repetition code with syndrome extraction using [Guppy](https://github.com/CQCL/guppylang), a pythonic quantum programming language:
32
32
33
33
```python
34
-
from pecos import sim, state_vector
34
+
from pecos importGuppy, sim, state_vector, depolarizing_noise
35
35
from guppylang import guppy
36
-
from guppylang.std.quantum import qubit, h, cx, measure
36
+
from guppylang.std.quantum import qubit, cx, measure
Copy file name to clipboardExpand all lines: docs/user-guide/getting-started.md
+52-29Lines changed: 52 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,16 +54,15 @@ This guide will help you get up and running with PECOS quickly.
54
54
55
55
## Your First Simulation
56
56
57
-
Now that PECOS is installed, let's create a simple quantum circuit. We'll create a **Bell state**—a fundamental entangled state used throughout quantum computing and quantum error correction.
57
+
Now that PECOS is installed, let's simulate a quantum error correction circuit. We'll create a **distance-3 repetition code**—a fundamental building block for protecting quantum information from errors.
58
58
59
59
### What We're Building
60
60
61
-
A Bell state is created by:
61
+
A repetition code encodes a single logical qubit across multiple physical qubits:
62
62
63
-
1. Applying a Hadamard gate (H) to put a qubit in superposition
64
-
2. Applying a CNOT gate to entangle two qubits
65
-
66
-
The result is the state $\frac{1}{\sqrt{2}}(|00\rangle + |11\rangle)$, where measuring either qubit always gives the same result as the other.
63
+
1.**3 data qubits** store the logical state: $|0\rangle_L = |000\rangle$, $|1\rangle_L = |111\rangle$
64
+
2.**2 ancilla qubits** measure parity between adjacent data qubits (syndrome extraction)
65
+
3.**Noise** introduces random errors that the syndromes detect
67
66
68
67
### Running the Simulation
69
68
@@ -72,27 +71,45 @@ The result is the state $\frac{1}{\sqrt{2}}(|00\rangle + |11\rangle)$, where mea
72
71
We'll use **Guppy**, a Python-embedded quantum programming language that offers type-safe qubit tracking and native control flow:
73
72
74
73
```python
74
+
from pecos import Guppy, sim, state_vector, depolarizing_noise
75
75
from guppylang import guppy
76
-
from guppylang.std.quantum import h, cx, measure, qubit
77
-
from pecos import sim, Guppy
78
-
from pecos_rslib import state_vector
76
+
from guppylang.std.quantum import qubit, cx, measure
// Load and run a pre-compiled repetition code circuit
124
+
let results = hugr_sim("repetition_code.hugr")
108
125
.seed(42)
109
126
.run(10)?;
110
127
111
128
// View results
112
129
for shot in &results.shots {
113
-
println!("Measurement: {:?}", shot.data);
130
+
println!("Syndrome: {:?}", shot.data);
114
131
}
115
132
Ok(())
116
133
}
@@ -122,10 +139,16 @@ The result is the state $\frac{1}{\sqrt{2}}(|00\rangle + |11\rangle)$, where mea
122
139
123
140
### Understanding the Output
124
141
125
-
Run the code multiple times (with different seeds). You'll notice:
142
+
The syndromes tell you which errors occurred:
143
+
144
+
| Syndrome | Meaning |
145
+
|----------|---------|
146
+
|`[0, 0]`| No detected errors |
147
+
|`[1, 0]`| Error on qubit d0 (left edge) |
148
+
|`[0, 1]`| Error on qubit d2 (right edge) |
149
+
|`[1, 1]`| Error on qubit d1 (middle) |
126
150
127
-
- Results contain values like `0` (binary `00`) and `3` (binary `11`)
128
-
- Both qubits **always** have the same value—this is quantum entanglement!
151
+
A decoder uses these syndromes to identify and correct errors—see the [Decoders](decoders.md) guide.
129
152
130
153
The `sim()` function is PECOS's unified simulation API. It accepts circuits in various formats (Guppy, HUGR, QASM) and provides a builder pattern for configuration.
0 commit comments