Skip to content

Commit f817844

Browse files
authored
Release-0.9.0 (#651)
1 parent 6670ef8 commit f817844

File tree

109 files changed

+5741
-4111
lines changed

Some content is hidden

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

109 files changed

+5741
-4111
lines changed

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
runs-on: ubuntu-latest
1919
steps:
2020
- name: Checkout repository
21-
uses: actions/checkout@v5
21+
uses: actions/checkout@v6
2222

2323
- name: Set up Python
2424
uses: actions/setup-python@v6

.github/workflows/tests.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
name: Static analysis
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@v5
17+
- uses: actions/checkout@v6
1818
- name: Set up Python
1919
uses: actions/setup-python@v6
2020
with:
@@ -44,7 +44,7 @@ jobs:
4444
- "3.13"
4545
runs-on: ${{ matrix.os }}
4646
steps:
47-
- uses: actions/checkout@v5
47+
- uses: actions/checkout@v6
4848
- name: Set up Python
4949
uses: actions/setup-python@v6
5050
with:

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,29 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1010
* **Fixed** for any bug fixes.
1111
* **Removed** for now removed features.
1212

13+
## [ 0.9.0 ] - [ 2025-12-19 ]
14+
15+
### Added
16+
17+
- `QGymMapper` mapper pass
18+
- `U`(theta, phi, lambda) gate to default single-qubit gates
19+
- `Z90` and `mZ90` pi-half rotation gates (equivalent to `S` and `Sdag` gates)
20+
- Operation duration in terms of execution cycles can be specified for the `QuantifySchedulerExporter`
21+
- `measurement_to_bit_map` property added to the Circuit class
22+
23+
### Changed
24+
25+
- `Circuit.export` expects an `Exporter` instance as input argument (instead of an `ExportFormat`)
26+
- Moved Bloch sphere rotation composition from the merger pass interface to Bloch sphere rotation semantic module
27+
- Refactor gate semantics as attributes of gates
28+
29+
### Removed
30+
31+
- The `QuantifySchedulerExporter` no longer returns a `bit_register_mapping`
32+
(use `Circuit.measurement_to_bit_map` property instead), it only returns a quantify-scheduler `Schedule`
33+
- The `ExportFormat` has been deprecated
34+
(exporters can be specified by providing an instance as input argument to `Circuit.export`)
35+
1336
## [ 0.8.0 ] - [ 2025-11-03 ]
1437

1538
### Added
202 KB
Binary file not shown.
150 KB
Binary file not shown.

data/static.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"backends": {
3+
"spin-2-plus": {
4+
"connectivity": {
5+
"0": [1],
6+
"1": [0]
7+
},
8+
"primitive_gate_set": ["I", "X90", "mX90", "Y90", "mY90", "Rz", "CZ", "measure", "wait", "init", "barrier"]
9+
},
10+
"starmon-7": {
11+
"connectivity": {
12+
"0": [2, 3],
13+
"1": [3, 4],
14+
"2": [0, 5],
15+
"3": [0, 1, 5, 6],
16+
"4": [1, 6],
17+
"5": [2, 3],
18+
"6": [3, 4]
19+
},
20+
"primitive_gate_set": ["I", "H", "X", "X90", "mX90", "Y", "Y90", "mY90", "Z", "S", "Sdag", "T", "Tdag", "Rx", "Ry", "Rz", "CNOT", "CZ", "CR", "CRk", "SWAP", "measure", "wait", "init", "barrier"]
21+
},
22+
"tuna-5": {
23+
"connectivity": {
24+
"0": [2],
25+
"1": [2],
26+
"2": [0, 1, 3, 4],
27+
"3": [2],
28+
"4": [2]
29+
},
30+
"primitive_gate_set": ["I", "X", "X90", "mX90", "Y", "Y90", "mY90", "Z", "S", "Sdag", "T", "Tdag", "Rx", "Ry", "Rz", "CNOT", "CZ", "measure", "wait", "init", "barrier"]
31+
}
32+
}
33+
}

docs/compilation-passes/exporting/cqasm-v1-exporter.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The cQASM v1 exporter (`ExportFormat.CQASM_V1`) exports the circuit to a string that adheres to the
1+
The cQASM v1 exporter (`CQasmV1Exporter`) exports the circuit to a string that adheres to the
22
[cQASM version 1.0 language specification](https://libqasm.readthedocs.io/).
33

44
Here are some important differences to take note of:
@@ -40,7 +40,7 @@ cQASM v1.
4040

4141
```python
4242
from opensquirrel import Circuit
43-
from opensquirrel.passes.exporter import ExportFormat
43+
from opensquirrel.passes.exporter import CQasmV1Exporter
4444
```
4545

4646
```python
@@ -57,7 +57,7 @@ cQASM v1.
5757
"""
5858
)
5959

60-
exported_circuit = circuit.export(fmt=ExportFormat.CQASM_V1)
60+
exported_circuit = circuit.export(exporter=CQasmV1Exporter)
6161
print(exported_circuit)
6262
```
6363

@@ -81,7 +81,7 @@ cQASM v1.
8181

8282
```python
8383
from opensquirrel import Circuit
84-
from opensquirrel.passes.exporter import ExportFormat
84+
from opensquirrel.passes.exporter import CQasmv1Exporter
8585
```
8686

8787
```python
@@ -108,7 +108,7 @@ cQASM v1.
108108
"""
109109
)
110110

111-
exported_circuit = circuit.export(fmt=ExportFormat.CQASM_V1)
111+
exported_circuit = circuit.export(exporter=CQasmv1Exporter)
112112
print(exported_circuit)
113113
```
114114

@@ -150,7 +150,7 @@ cQASM v1.
150150

151151
```python
152152
from opensquirrel import Circuit
153-
from opensquirrel.passes.exporter import ExportFormat
153+
from opensquirrel.passes.exporter import CQasmV1Exporter
154154
```
155155

156156
```python
@@ -176,7 +176,7 @@ cQASM v1.
176176
"""
177177
)
178178

179-
exported_circuit = circuit.export(fmt=ExportFormat.CQASM_V1)
179+
exported_circuit = circuit.export(exporter=CQasmV1Exporter)
180180
print(exported_circuit)
181181
```
182182

@@ -215,7 +215,7 @@ cQASM v1.
215215

216216
```python
217217
from opensquirrel import Circuit
218-
from opensquirrel.passes.exporter import ExportFormat
218+
from opensquirrel.passes.exporter import CQasmV1Exporter
219219
```
220220

221221
```python
@@ -252,7 +252,7 @@ cQASM v1.
252252
"""
253253
)
254254

255-
exported_circuit = circuit.export(fmt=ExportFormat.CQASM_V1)
255+
exported_circuit = circuit.export(exporter=CQasmV1Exporter)
256256
print(exported_circuit)
257257
```
258258

docs/compilation-passes/exporting/index.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
Instead of writing the circuit out to the [default cQASM format](https://qutech-delft.github.io/cQASM-spec/),
22
one can also use a custom exporter pass to export the circuit to a particular output format.
33

4-
Exporting can be done by calling the `export` method on the circuit object and providing the desired output
5-
format `fmt` as an input argument to the call, _e.g._,
4+
Exporting can be done by calling the `export` method on the circuit object and providing the desired exporter
5+
`exporter` as an input argument to the call, _e.g._,
66

77
!!! example ""
88

99
```python
10-
from opensquirrel import ExportFormat
10+
from opensquirrel import CQasmV1Exporter
1111

12-
exported_circuit = circuit.export(fmt=ExportFormat.CQASM_V1)
12+
exported_circuit = circuit.export(exporter=CQasmV1Exporter)
1313
```
1414

1515
As shown in the example above, the exported circuit is given as the return value.
1616

1717
The following exporting passes are available in OpenSquirrel:
1818

19-
- [cQASMv1 exporter](cqasm-v1-exporter.md) (`ExportFormat.CQASM_V1`)
20-
- [quantify-scheduler exporter](quantify-scheduler-exporter.md) (`ExportFormat.QUANTIFY_SCHEDULER`)
19+
- [cQASMv1 exporter](cqasm-v1-exporter.md) (`CQasmV1Exporter`)
20+
- [quantify-scheduler exporter](quantify-scheduler-exporter.md) (`QuantifySchedulerExporter`)
2121

2222
!!! warning "Unsupported language features"
2323

docs/compilation-passes/exporting/quantify-scheduler-exporter.md

Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
1-
The [quantify-scheduler](https://quantify-os.org/docs/quantify-scheduler/) exporter (`ExportFormat.QUANTIFY_SCHEDULER`)
2-
exports the circuit to [`Schedule`](https://quantify-os.org/docs/quantify-scheduler/v0.25.0/autoapi/quantify_scheduler/index.html#quantify_scheduler.Schedule)
3-
object and a _bitstring mapping_.
1+
The [quantify-scheduler](https://quantify-os.org/docs/quantify-scheduler/) exporter (`QuantifySchedulerExporter`)
2+
exports the circuit to a [`Schedule`](https://quantify-os.org/docs/quantify-scheduler/v0.25.0/autoapi/quantify_scheduler/index.html#quantify_scheduler.Schedule)
3+
object.
44

5-
The latter can be used to relate the measurement outcomes to the (virtual) bit variables they have
6-
been assigned to in the cQASM circuit: this connection is lost in the `Schedule`.
5+
!!! warning "The _bit string mapping_ has been deprecated"
76

8-
!!! warning "Under active development"
9-
10-
The bitstring mapping, currently, consists of a list of ordered pairs; the first element denotes the acquisition
11-
index $i$ and the second element denotes the qubit index $j$.
12-
The acquisition index represents the $i$-th measurement on qubit at index $j$.
13-
The index $k$ of the ordered pair in the bitstring mapping corresponds to the index of the (virtual) bit register,
14-
referring to the (virtual) bit variable the outcome of measurement $(i,j)$ has been assigned to in the
15-
cQASM circuit.
7+
The `QuantifySchedulerExporter` used to return a bit string mapping next to the `Schedule`.
8+
This bit string mapping has been deprecated.
9+
To obtain a mapping from the measurements to the bit register index their outcomes are assigned to,
10+
use the circuit property `Circuit.measurement_to_bit_map`, instead.
11+
This mapping has the following structure:
1612

1713
```python
18-
[
19-
(<acquisition-index-i: int>, <qubit-index-j: int>),
20-
(<acquisition-index-i: int>, <qubit-index-j: int>),
21-
...
22-
<(i,j)-at-index-k: tuple[int, int]>,
14+
{
15+
<qubit-index: str> : [
16+
<bit-index: int>,
17+
<bit-index: int>,
18+
...
19+
],
20+
<qubit-index: str> : [ ... ],
2321
...
24-
]
22+
}
2523
```
2624

27-
_A redesign of the bitstring mapping is under active development._
25+
Each qubit at index $i$ contains a list of bit indices.
26+
The index $j$ of this list is the measurement index and denotes the order in which the qubit was measured.
27+
The values at $j$ denote the bit register index $k$ to which the measurement outcome was assigned in the circuit.
28+
Qubits that are not measured do not have an entry in the measurement to bit mapping.
2829

2930
Here are some important differences to take note of:
3031

@@ -35,8 +36,8 @@ and [assignments of measurement outcomes to bit register variables](https://qute
3536
are discarded; quantify-scheduler does not support bit registers or variables.
3637
Note that the measurement statement is not discarded; the `measure` instruction is translated to
3738
[`Measure`](https://quantify-os.org/docs/quantify-scheduler/v0.25.0/autoapi/quantify_scheduler/operations/gate_library/index.html#quantify_scheduler.operations.gate_library.Measure).
38-
Furthermore, measurement outcomes are related to the (virtual) bit registers they were assigned to in the cQASM circuit
39-
through the _bitstring mapping_, as described above.
39+
Furthermore, measurement outcomes are related to the (virtual) bit registers they were assigned to in the cQASM circuit.
40+
Their mapping can be obtained through the `Circuit.measurement_to_bit_map` property, as described above.
4041
3. The non-unitary [`init`](https://qutech-delft.github.io/cQASM-spec/latest/language_specification/statements/instructions/non_unitary_instructions/init_instruction.html)
4142
instruction is ignored and [`reset`](https://qutech-delft.github.io/cQASM-spec/latest/language_specification/statements/instructions/non_unitary_instructions/reset_instruction.html)
4243
instruction is translated to [`Reset`](https://quantify-os.org/docs/quantify-scheduler/v0.25.0/autoapi/quantify_scheduler/operations/gate_library/index.html#quantify_scheduler.operations.gate_library.Reset).
@@ -72,7 +73,7 @@ The four examples below show how circuits written in [cQASM](https://qutech-delf
7273

7374
```python
7475
from opensquirrel import Circuit
75-
from opensquirrel.passes.exporter import ExportFormat
76+
from opensquirrel.passes.exporter import QuantifySchedulerExporter
7677
```
7778

7879
```python
@@ -89,11 +90,11 @@ The four examples below show how circuits written in [cQASM](https://qutech-delf
8990
"""
9091
)
9192

92-
exported_schedule, bitstring_mapping = circuit.export(fmt=ExportFormat.QUANTIFY_SCHEDULER)
93+
exported_schedule = circuit.export(exporter=QuantifySchedulerExporter)
9394

9495
for schedulable in exported_schedule.schedulables.values():
9596
print(exported_schedule.operations[schedulable["operation_id"]].name)
96-
print('\n', "bitstring mapping: ", bitstring_mapping)
97+
print('\n', "measurement to bit map: ", circuit.measurement_to_bit_map)
9798
```
9899

99100
```
@@ -103,23 +104,23 @@ The four examples below show how circuits written in [cQASM](https://qutech-delf
103104
Measure q[0]
104105
Measure q[1]
105106

106-
bitstring mapping: [(0, 0), (0, 1)]
107+
measurement to bit map: {"0": [0], "1": [1]}
107108
```
108109

109110
Note that the bit register declaration and assignment to bit variables have been discarded (2.),
110111
the SGMQ notation has been unpacked (4.), and the angles have been translated from radians to degrees (6.).
111112
_The numbers refer to the differences listed above._
112113

113-
According to the description of the _bitstring mapping_ above, note that the outcome of the first measurement on
114-
qubit at index $0$, $(i,j) = (0,0)$, is mapped to the (virtual) bit variable ($k=0$; the first ordered pair),
115-
and the outcome of the first measurement on qubit at index $1$, $(i,j) = (0,1)$, is mapped to the (virtual) bit
116-
variable ($k=1$; the second ordered pair).
114+
According to the description of the _measurement to bit mapping_ above,
115+
note that the outcome of the first measurement ($j=0$) on qubit at index $i=0$, is mapped to the (virtual)
116+
bit variable at index $k=0$, and the outcome of the first measurement ($j=0$) on qubit at index $i=1$,
117+
is mapped to the (virtual) bit variable at index $k=1$.
117118

118119
=== "Registers"
119120

120121
```python
121122
from opensquirrel import Circuit
122-
from opensquirrel.passes.exporter import ExportFormat
123+
from opensquirrel.passes.exporter import QuantifySchedulerExporter
123124
```
124125

125126
```python
@@ -146,10 +147,10 @@ The four examples below show how circuits written in [cQASM](https://qutech-delf
146147
"""
147148
)
148149

149-
exported_circuit = circuit.export(fmt=ExportFormat.QUANTIFY_SCHEDULER)
150+
exported_circuit = circuit.export(exporter=QuantifySchedulerExporter)
150151
for schedulable in exported_schedule.schedulables.values():
151152
print(exported_schedule.operations[schedulable["operation_id"]].name)
152-
print('\n', "bitstring mapping: ", bitstring_mapping)
153+
print('\n', "measurement to bit map: ", circuit.measurement_to_bit_map)
153154
```
154155

155156
```
@@ -164,7 +165,7 @@ The four examples below show how circuits written in [cQASM](https://qutech-delf
164165
Measure q[3]
165166
Measure q[1]
166167

167-
bitstring mapping: [(None, None), (0, 0), (0, 1), (0, 3), (1, 1)]
168+
measurement to bit map: {"0": [1], "1": [2, 4], "3": [3]}
168169
```
169170

170171
Note that all qubit register declarations are combined into a single (virtual) qubit register (1.), the bit
@@ -178,27 +179,25 @@ The four examples below show how circuits written in [cQASM](https://qutech-delf
178179
The qubit registers are concatenated in the order they are declared.
179180

180181
Moreover, even though the bit registers have been discarded in the circuit, the mapping from meausurement to
181-
(virtual) bit variable has been stored in the _bitstring mapping_.
182+
(virtual) bit variable has been stored in the _measurement to bit mapping_.
182183
Note that, just like with the translation of the qubit register declarations to the single virtual register `q`,
183184
the bit register declarations are also concatenated in the order they are declared into a single bit register
184185
`b`.
185186
In this example, the virtual bit register translation is as follows: `bA[0], bA[1], bA[2] = b[0], b[1], b[2]`
186187
and `bB[0], bB[1] = b[3], b[4]`.
187-
Accodingly, the $k$-th element in the bitstring mapping corresponds to the $k$-th element of the bit register.
188188

189-
For instance, the statement `bB[1] = measure qA[1]` in the original circuit becomes, in terms of virtual
190-
registers, `b[4] = measure q[1]`.
191-
Since this is the second measurement on `q[1]`, the acquisition index is $i = 1$ (counting starts at $0$) and
192-
the qubit index is $j = 1$, such that the measurement is given by the ordered pair $(1, 1)$.
193-
Because the outcome of this measurement is stored in `b[4]`,
194-
the ordered pair is at index $4$ in the bitregister mapping.
189+
For instance, the statement `bB[1] = measure qA[1]` in the original circuit becomes,
190+
in terms of virtual registers, `b[4] = measure q[1]`.
191+
Note that in the measurement to bit mapping the outcome of the second measurement (measurement index $j=1$)
192+
on `q[1]`, _i.e._ qubit at index $i=1$, is assigned to the bit at index $k=4$.
193+
195194

196195

197196
=== "`init` and `reset`"
198197

199198
```python
200199
from opensquirrel import Circuit
201-
from opensquirrel.passes.exporter import ExportFormat
200+
from opensquirrel.passes.exporter import QuantifySchedulerExporter
202201
```
203202

204203
```python
@@ -224,10 +223,10 @@ The four examples below show how circuits written in [cQASM](https://qutech-delf
224223
"""
225224
)
226225

227-
exported_circuit = circuit.export(fmt=ExportFormat.QUANTIFY_SCHEDULER)
226+
exported_circuit = circuit.export(exporter=QuantifySchedulerExporter())
228227
for schedulable in exported_schedule.schedulables.values():
229228
print(exported_schedule.operations[schedulable["operation_id"]].name)
230-
print('\n', "bitstring mapping: ", bitstring_mapping)
229+
print('\n', "measurement to bit map: ", circuit.measurement_to_bit_map)
231230
```
232231

233232
```
@@ -247,7 +246,7 @@ The four examples below show how circuits written in [cQASM](https://qutech-delf
247246
Measure q[0]
248247
Measure q[1]
249248

250-
bitstring mapping: [(1, 0), (1, 1)]
249+
measurement to bit map: {"0": [0, 0], "1": [1, 1]}
251250
```
252251

253252
Note that the bit register declaration and assignment to bit variables have been discarded (2.),

0 commit comments

Comments
 (0)