qprogram-qdac 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,140 @@
1
+ # Copyright 2026 Qilimanjaro Quantum Tech
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ """QDAC vendor extensions for QProgram.
15
+
16
+ This package provides three things:
17
+
18
+ 1. **Runtime registration.** Importing the package is the activation step. It registers the ``qdac``
19
+ vendor namespace on [`QProgram`][qprogram.QProgram], every QDAC operation with the ``.qp``
20
+ serializer, and the ``qdac-default-v1`` capability profile.
21
+ 2. **Typed mixin.** [`QdacMixin`][qprogram_qdac.QdacMixin] declares a typed ``.qdac`` property for editor autocomplete.
22
+ 3. **Pre-combined builder.** [`QProgram`][qprogram_qdac.QProgram] here is [`qprogram.QProgram`][] with that mixin
23
+ already applied.
24
+
25
+ A ``.qp`` file whose header says ``require qdac 0.1`` activates the package on load even when the
26
+ caller never imported it. `qprogram.loads` looks the vendor up in the ``qprogram.vendors``
27
+ entry-point group declared in ``pyproject.toml`` and imports this module for its side effects.
28
+
29
+ QDAC is a slow high-precision DAC, most often used for flux biasing on transmon platforms. The
30
+ operations it contributes are:
31
+
32
+ - [`QdacNamespace.play`][qprogram_qdac.QdacNamespace.play], which uploads an envelope to one channel's waveform engine;
33
+ - [`QdacNamespace.set_trigger`][qprogram_qdac.QdacNamespace.set_trigger] and
34
+ [`QdacNamespace.wait_trigger`][qprogram_qdac.QdacNamespace.wait_trigger], the trigger-network plumbing that lines a
35
+ QDAC sequence up with another instrument;
36
+ - [`QdacNamespace.set_offset`][qprogram_qdac.QdacNamespace.set_offset], a DC offset whose swept form lifts the enclosing
37
+ loop to host-side dispatch.
38
+
39
+ Usage, with the pre-combined builder::
40
+
41
+ from qprogram.waveforms import Ramp
42
+ from qprogram_qdac import QProgram
43
+
44
+ qp = QProgram(label="flux-sweep")
45
+ qp.qdac.set_offset("flux_q0", 0.42)
46
+ qp.qdac.set_trigger("flux_q0", 50, position="start", outputs={1, 2})
47
+ qp.qdac.play("flux_q0", Ramp(0.0, 1.0, 1000), dwell=10)
48
+ qp.qdac.wait_trigger("flux_q0", port=3)
49
+
50
+ That program serializes to::
51
+
52
+ #!QProgram 1.0
53
+
54
+ require qdac 0.1
55
+
56
+ metadata:
57
+ label: "flux-sweep"
58
+
59
+ body:
60
+ qdac.set_offset "flux_q0" 0.42
61
+ qdac.set_trigger "flux_q0" 50 outputs=[1, 2]
62
+ qdac.play "flux_q0" Ramp(from_amplitude=0.0, to_amplitude=1.0, duration=1000) dwell=10
63
+ qdac.wait_trigger "flux_q0" 3
64
+
65
+ Usage, with several vendors combined::
66
+
67
+ from qprogram import QProgram as BaseQProgram
68
+ from qprogram_qblox import QbloxMixin
69
+ from qprogram_qdac import QdacMixin
70
+
71
+
72
+ class QProgram(QbloxMixin, QdacMixin, BaseQProgram):
73
+ pass
74
+ """
75
+
76
+ from __future__ import annotations
77
+
78
+ from importlib.metadata import PackageNotFoundError, version
79
+
80
+ from qprogram.qprogram import QProgram as _BaseQProgram
81
+ from qprogram.serialization.registry import (
82
+ register_vendor_operation,
83
+ register_vendor_version,
84
+ )
85
+
86
+ from qprogram_qdac.mixin import QdacMixin
87
+ from qprogram_qdac.namespace import QdacNamespace
88
+ from qprogram_qdac.operations import (
89
+ Play,
90
+ SetOffset,
91
+ SetTrigger,
92
+ WaitTrigger,
93
+ )
94
+ from qprogram_qdac.profiles import QDAC_DEFAULT_V1
95
+ from qprogram_qdac.profiles import _register as _register_qdac_profile
96
+
97
+ # The installed distribution version is the single source of truth for the qdac vendor protocol
98
+ # version: the parser checks a file's ``require qdac <major.minor>`` against it.
99
+ try:
100
+ __version__ = version("qprogram-qdac")
101
+ except PackageNotFoundError: # pragma: no cover - source tree without installed metadata
102
+ __version__ = "0.0.0"
103
+
104
+ # Registering on the base class rather than on this package's QProgram is what makes
105
+ # ``program.qdac.<operation>()`` work on any program, mixin or no mixin.
106
+ _BaseQProgram.register_vendor("qdac", QdacNamespace)
107
+
108
+ register_vendor_version("qdac", __version__)
109
+
110
+ # Every operation takes the default signature-driven serialize / parse pair. SetTrigger's
111
+ # ``outputs`` tuple goes through the writer's generic sequence branch (``outputs=[1, 2, 3]``), the
112
+ # parser's bracket-aware tokenizer keeps that literal whole, and ``_normalize_outputs`` turns the
113
+ # reloaded list back into the canonical sorted tuple.
114
+ register_vendor_operation("qdac", "wait_trigger", WaitTrigger)
115
+ register_vendor_operation("qdac", "set_trigger", SetTrigger)
116
+ register_vendor_operation("qdac", "set_offset", SetOffset)
117
+ register_vendor_operation("qdac", "play", Play)
118
+
119
+ # Importing qprogram_qdac.profiles above already registered the vendor capability tokens, which the
120
+ # profile names, so the profile passes token validation here.
121
+ _register_qdac_profile()
122
+
123
+
124
+ class QProgram(QdacMixin, _BaseQProgram):
125
+ """[`QProgram`][qprogram.QProgram] pre-combined with [`QdacMixin`][qprogram_qdac.QdacMixin].
126
+
127
+ Behaves exactly like [`qprogram.QProgram`][], with editor autocomplete for ``qp.qdac.*``.
128
+ """
129
+
130
+
131
+ __all__ = [
132
+ "QDAC_DEFAULT_V1",
133
+ "Play",
134
+ "QProgram",
135
+ "QdacMixin",
136
+ "QdacNamespace",
137
+ "SetOffset",
138
+ "SetTrigger",
139
+ "WaitTrigger",
140
+ ]
qprogram_qdac/mixin.py ADDED
@@ -0,0 +1,71 @@
1
+ # Copyright 2026 Qilimanjaro Quantum Tech
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ """The typed mixin that spells ``.qdac`` out on a QProgram subclass.
15
+
16
+ The mixin exists for editor support and nothing else. At runtime the base
17
+ [`QProgram`][qprogram.QProgram]'s dynamic ``__getattr__`` already routes ``program.qdac.*`` to the
18
+ registered [`QdacNamespace`][qprogram_qdac.QdacNamespace]. Type checkers and editors cannot see
19
+ that dispatch, so the mixin declares the namespace as a typed ``@property``.
20
+
21
+ Usage, one vendor::
22
+
23
+ from qprogram_qdac import QProgram
24
+
25
+ qp = QProgram()
26
+ qp.qdac.set_offset("flux_q0", 0.42)
27
+
28
+ Usage, several vendors combined by a platform::
29
+
30
+ from qprogram import QProgram as BaseQProgram
31
+ from qprogram_qblox import QbloxMixin
32
+ from qprogram_qdac import QdacMixin
33
+
34
+
35
+ class QProgram(QbloxMixin, QdacMixin, BaseQProgram):
36
+ pass
37
+ """
38
+
39
+ from __future__ import annotations
40
+
41
+ from typing import TYPE_CHECKING
42
+
43
+ from qprogram_qdac.namespace import QdacNamespace
44
+
45
+ if TYPE_CHECKING:
46
+ from qprogram.qprogram import QProgram as _BaseQProgram
47
+
48
+
49
+ class QdacMixin:
50
+ """Mixin that adds a typed ``.qdac`` property to a QProgram subclass.
51
+
52
+ Combine it with [`qprogram.QProgram`][] through multiple inheritance, listing one mixin per
53
+ vendor. [`qprogram_qdac.QProgram`][] is that combination already made.
54
+ """
55
+
56
+ @property
57
+ def qdac(self: _BaseQProgram) -> QdacNamespace: # type: ignore[misc]
58
+ """This program's typed QDAC namespace.
59
+
60
+ The first access builds a [`QdacNamespace`][qprogram_qdac.QdacNamespace] bound to the program and stores it on
61
+ the instance, so every later access hands back the same object.
62
+ """
63
+ # Reading and writing the cache through ``object`` keeps it clear of any attribute hooks
64
+ # a QProgram subclass installs, and of the vendor lookup in ``QProgram.__getattr__``.
65
+ try:
66
+ return object.__getattribute__(self, "_qdac_ns") # ruff: ignore[unnecessary-dunder-call]
67
+ except AttributeError:
68
+ pass
69
+ ns = QdacNamespace(self)
70
+ object.__setattr__(self, "_qdac_ns", ns) # ruff: ignore[unnecessary-dunder-call]
71
+ return ns
@@ -0,0 +1,137 @@
1
+ # Copyright 2026 Qilimanjaro Quantum Tech
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ """The typed [`VendorNamespace`][qprogram.VendorNamespace] for QDAC operations.
15
+
16
+ Every method on [`QdacNamespace`][qprogram_qdac.QdacNamespace] constructs one
17
+ [`Operation`][qprogram.operations.Operation] subclass and appends it to the program's active block.
18
+ The typed signatures are the discoverable surface: the dynamic ``__getattr__`` on
19
+ [`QProgram`][qprogram.QProgram] dispatches the same calls, but says nothing about their arguments.
20
+ """
21
+
22
+ from __future__ import annotations
23
+
24
+ from typing import TYPE_CHECKING
25
+
26
+ from qprogram.vendor import VendorNamespace
27
+
28
+ from qprogram_qdac.operations import (
29
+ Play,
30
+ SetOffset,
31
+ SetTrigger,
32
+ TriggerPosition,
33
+ WaitTrigger,
34
+ )
35
+
36
+ if TYPE_CHECKING:
37
+ from collections.abc import Iterable
38
+
39
+ from qprogram.variable import Expression
40
+ from qprogram.waveforms.waveform import Waveform
41
+
42
+
43
+ class QdacNamespace(VendorNamespace):
44
+ """The QDAC vendor namespace, reached as ``program.qdac.<operation>()``.
45
+
46
+ Available on every [`QProgram`][qprogram.QProgram] instance once `qprogram_qdac` is imported.
47
+ Each method type-checks its arguments through the signature, builds the matching operation, and
48
+ appends it to whichever block the program has open.
49
+ """
50
+
51
+ def wait_trigger(self, bus: str, port: int) -> None:
52
+ """Append a [`WaitTrigger`][qprogram_qdac.WaitTrigger] operation.
53
+
54
+ Args:
55
+ bus (str): QDAC channel whose trigger input the sequencer listens on.
56
+ port (int): Trigger input port number on the chassis.
57
+
58
+ Raises:
59
+ ValidationError: If ``bus`` is a [`BusRef`][qprogram.BusRef] from another schema than the
60
+ one attached to the program.
61
+ """
62
+ self._append(WaitTrigger(bus=bus, port=port))
63
+
64
+ def set_trigger(
65
+ self,
66
+ bus: str,
67
+ duration: int,
68
+ position: TriggerPosition = "start",
69
+ outputs: Iterable[int] = (),
70
+ ) -> None:
71
+ """Append a [`SetTrigger`][qprogram_qdac.SetTrigger] operation.
72
+
73
+ Args:
74
+ bus (str): QDAC channel whose trigger outputs are being configured.
75
+ duration (int): Trigger-active duration in nanoseconds.
76
+ position (TriggerPosition): Sequence event at which the triggers fire, one of
77
+ ``"start"``, ``"step"``, ``"end"``, ``"end_step"``. Default ``"start"``.
78
+ outputs (Iterable[int]): Trigger output indices to arm. Any iterable of ints will do:
79
+ ``set``, ``list``, ``tuple``, generator. Empty by default, which the
80
+ ``qdac.empty-trigger-outputs`` predicate rejects at validation time.
81
+
82
+ Raises:
83
+ ValidationError: If ``bus`` is a [`BusRef`][qprogram.BusRef] from another schema than the
84
+ one attached to the program.
85
+ """
86
+ self._append(SetTrigger(bus=bus, duration=duration, position=position, outputs=outputs))
87
+
88
+ def set_offset(self, bus: str, offset: float | Expression) -> None:
89
+ """Append a [`SetOffset`][qprogram_qdac.SetOffset] operation.
90
+
91
+ Args:
92
+ bus (str): QDAC channel whose DC offset is being set.
93
+ offset (float | Expression): Target offset in volts. Accepts a literal or any
94
+ [`Expression`][qprogram.Expression], a loop-bound [`Variable`][qprogram.Variable] included.
95
+
96
+ Raises:
97
+ ValidationError: If ``bus`` is a [`BusRef`][qprogram.BusRef] from another schema than the
98
+ one attached to the program.
99
+ """
100
+ self._append(SetOffset(bus=bus, offset=offset))
101
+
102
+ def play( # ruff: ignore[too-many-arguments] bus, envelope and the engine's four timing controls
103
+ self,
104
+ bus: str,
105
+ waveform: Waveform,
106
+ dwell: int = 1,
107
+ delay: int = 0,
108
+ repetitions: int = 1,
109
+ stepped: bool = False,
110
+ ) -> None:
111
+ """Append a [`Play`][qprogram_qdac.Play] operation.
112
+
113
+ Args:
114
+ bus (str): QDAC channel that emits the waveform.
115
+ waveform (Waveform): Single-channel [`Waveform`][qprogram.waveforms.Waveform] to emit. A
116
+ ``str`` alias is accepted here too, to be resolved later by
117
+ [`with_waveforms`][qprogram.QProgram.with_waveforms].
118
+ dwell (int): Per-sample dwell time in nanoseconds. Default ``1``.
119
+ delay (int): Delay before the first sample, in nanoseconds. Default ``0``.
120
+ repetitions (int): How many times the envelope is emitted. Default ``1``.
121
+ stepped (bool): ``True`` for discrete-step output, ``False`` for continuous
122
+ interpolated output. Default ``False``.
123
+
124
+ Raises:
125
+ ValidationError: If ``bus`` is a [`BusRef`][qprogram.BusRef] from another schema than the
126
+ one attached to the program.
127
+ """
128
+ self._append(
129
+ Play(
130
+ bus=bus,
131
+ waveform=waveform,
132
+ dwell=dwell,
133
+ delay=delay,
134
+ repetitions=repetitions,
135
+ stepped=stepped,
136
+ ),
137
+ )
@@ -0,0 +1,213 @@
1
+ # Copyright 2026 Qilimanjaro Quantum Tech
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ """The QDAC operations, as AST nodes.
15
+
16
+ Each class is a concrete [`Operation`][qprogram.operations.Operation] subclass that a program holds in
17
+ its AST. They are typed attributes plus the capability tokens those attributes require.
18
+
19
+ QDAC is a slow high-precision DAC, most often used for flux biasing on transmon platforms. Its
20
+ waveform engine emits an envelope from a programmable sequencer with explicit dwell, delay,
21
+ repetition and stepping controls. These operations expose those controls, plus the trigger network
22
+ the engine listens to.
23
+ """
24
+
25
+ from __future__ import annotations
26
+
27
+ from typing import TYPE_CHECKING, ClassVar, Literal
28
+
29
+ from qprogram.operations.operation import Operation
30
+
31
+ if TYPE_CHECKING:
32
+ from collections.abc import Iterable
33
+
34
+ from qprogram.variable import Expression
35
+ from qprogram.waveforms.waveform import Waveform
36
+
37
+
38
+ TriggerPosition = Literal["start", "step", "end", "end_step"]
39
+ """The four trigger-fire positions the QDAC sequencer recognizes.
40
+
41
+ - ``"start"``: the trigger fires when the sequence begins.
42
+ - ``"step"``: the trigger fires at the start of every step of a stepped sequence.
43
+ - ``"end"``: the trigger fires when the sequence finishes.
44
+ - ``"end_step"``: the trigger fires at the end of every step.
45
+ """
46
+
47
+
48
+ def _normalize_outputs(value: Iterable[int] | str) -> tuple[int, ...]:
49
+ """Return ``value`` as a sorted tuple of unique output indices.
50
+
51
+ Accepts any iterable of integers (``set``, ``list``, ``tuple``, numpy array, ``range``,
52
+ generator), and the comma-separated string a hand-written ``.qp`` file may carry
53
+ (``outputs="1,2,3"``). Duplicates are dropped and the result is sorted, so two spellings of the
54
+ same set of outputs hash and compare the same. Coercion is ``int()``, so a real-numbered element
55
+ is truncated towards zero rather than rejected.
56
+
57
+ Args:
58
+ value (Iterable[int] | str): Output indices, or a comma-separated string of them.
59
+
60
+ Returns:
61
+ The indices as a sorted tuple, with duplicates removed.
62
+
63
+ Raises:
64
+ TypeError: If ``value`` is not iterable, or an element is of a type ``int()`` will not take.
65
+ ValueError: If a comma-separated field is not a valid integer literal.
66
+ """
67
+ if isinstance(value, str):
68
+ return tuple(sorted({int(p.strip()) for p in value.split(",") if p.strip()}))
69
+ return tuple(sorted({int(x) for x in value}))
70
+
71
+
72
+ class WaitTrigger(Operation):
73
+ """A halt on a QDAC channel until an external trigger arrives on one input port.
74
+
75
+ This is how a QDAC sequence lines up with hardware on another instrument, a qblox sequencer's
76
+ ``set_trigger`` for instance. The QDAC sequencer stops until the trigger fires, and emits no
77
+ waveform while it waits.
78
+
79
+ Args:
80
+ bus (str): QDAC channel whose trigger input the sequencer listens on.
81
+ port (int): Trigger input port number on the chassis, typically 1-based.
82
+ """
83
+
84
+ def __init__(self, bus: str, port: int) -> None:
85
+ self.bus = bus
86
+ self.port = port
87
+
88
+ def required_capabilities(self) -> set[str]:
89
+ """Return the single ``vendor.qdac.wait_trigger`` token."""
90
+ return {"vendor.qdac.wait_trigger"}
91
+
92
+
93
+ class SetTrigger(Operation):
94
+ """An arming of one or more QDAC trigger outputs at a chosen sequence position.
95
+
96
+ The QDAC chassis carries an internal trigger bus with several output lines. This operation arms
97
+ a subset of them to fire for ``duration`` nanoseconds at a sequence event: sequence start, every
98
+ step, sequence end, or every step's end.
99
+
100
+ Args:
101
+ bus (str): QDAC channel whose trigger outputs are being configured.
102
+ duration (int): Trigger-active duration in nanoseconds.
103
+ position (TriggerPosition): Sequence event at which the triggers fire, one of ``"start"``,
104
+ ``"step"``, ``"end"``, ``"end_step"``. Default ``"start"``.
105
+ outputs (Iterable[int] | str): Trigger output indices to arm. Any iterable of ints, or a
106
+ comma-separated string of them. Empty by default, which the
107
+ ``qdac.empty-trigger-outputs`` predicate rejects at validation time.
108
+
109
+ Attributes:
110
+ outputs (tuple[int, ...]): The argument as stored, sorted and deduplicated on the way in, so
111
+ ``{2, 1}`` and ``[1, 2, 1]`` produce equal operations.
112
+
113
+ Raises:
114
+ TypeError: If ``outputs`` is not iterable, or holds an element of a type ``int()`` will not
115
+ take.
116
+ ValueError: If ``outputs`` is a string whose comma-separated fields are not integers.
117
+ """
118
+
119
+ def __init__(
120
+ self,
121
+ bus: str,
122
+ duration: int,
123
+ position: TriggerPosition = "start",
124
+ outputs: Iterable[int] | str = (),
125
+ ) -> None:
126
+ self.bus = bus
127
+ self.duration = duration
128
+ self.position: TriggerPosition = position
129
+ self.outputs: tuple[int, ...] = _normalize_outputs(outputs)
130
+
131
+ def required_capabilities(self) -> set[str]:
132
+ """Return the single ``vendor.qdac.set_trigger`` token."""
133
+ return {"vendor.qdac.set_trigger"}
134
+
135
+
136
+ class SetOffset(Operation):
137
+ """A static DC offset on a QDAC channel.
138
+
139
+ The channel holds ``offset`` volts until another operation changes it.
140
+
141
+ Args:
142
+ bus (str): QDAC channel whose DC offset is being set.
143
+ offset (float | Expression): Target offset in volts. Accepts a literal or any
144
+ [`Expression`][qprogram.Expression], a loop-bound [`Variable`][qprogram.Variable] included. A
145
+ swept offset is re-uploaded once per iteration, which is what the
146
+ `qprogram_qdac.profiles` constraint on the enclosing loop expresses.
147
+ """
148
+
149
+ def __init__(self, bus: str, offset: float | Expression) -> None:
150
+ self.bus = bus
151
+ self.offset = offset
152
+
153
+ def required_capabilities(self) -> set[str]:
154
+ """Return ``vendor.qdac.set_offset`` plus the tokens contributed by the ``offset`` expression."""
155
+ from qprogram.protocol import expression_tokens # ruff: ignore[import-outside-top-level]
156
+
157
+ return {"vendor.qdac.set_offset"} | expression_tokens(self.offset)
158
+
159
+
160
+ class Play(Operation):
161
+ """An envelope emitted from a QDAC channel's waveform engine.
162
+
163
+ The channel comes from ``bus``, so the operation routes to that bus's capability slot like every
164
+ other QDAC operation. The rest of the arguments are the waveform-engine program: the envelope
165
+ and its timing.
166
+
167
+ Args:
168
+ bus (str): QDAC channel that emits the waveform.
169
+ waveform (Waveform): Single-channel [`Waveform`][qprogram.waveforms.Waveform] whose envelope is
170
+ uploaded to the waveform engine. A ``str`` alias is accepted here too, to be resolved
171
+ later by [`with_waveforms`][qprogram.QProgram.with_waveforms].
172
+ dwell (int): Per-sample dwell time in nanoseconds, which sets the emission rate. Default
173
+ ``1``.
174
+ delay (int): Delay in nanoseconds between sequence start and the first sample. Default
175
+ ``0``.
176
+ repetitions (int): How many times the engine emits the envelope in total, the first
177
+ emission included. Default ``1``.
178
+ stepped (bool): ``True`` to step through the samples discretely, re-arming the DAC for each
179
+ one, ``False`` for continuous interpolated output. Default ``False``.
180
+ """
181
+
182
+ WAVEFORM_ATTRS: ClassVar[tuple[str, ...]] = ("waveform",)
183
+
184
+ def __init__( # ruff: ignore[too-many-arguments] bus, envelope and the engine's four timing controls
185
+ self,
186
+ bus: str,
187
+ waveform: Waveform,
188
+ dwell: int = 1,
189
+ delay: int = 0,
190
+ repetitions: int = 1,
191
+ stepped: bool = False,
192
+ ) -> None:
193
+ self.bus = bus
194
+ self.waveform = waveform
195
+ self.dwell = dwell
196
+ self.delay = delay
197
+ self.repetitions = repetitions
198
+ self.stepped = stepped
199
+
200
+ def required_capabilities(self) -> set[str]:
201
+ """Return ``vendor.qdac.play`` plus the tokens describing the waveform.
202
+
203
+ ``waveform.single`` is always required, since the engine drives one channel. A registered
204
+ waveform class contributes its per-class token from [`qprogram.protocol.waveform_token`][]
205
+ on top, ``waveform.ramp`` for a [`Ramp`][qprogram.waveforms.Ramp] for instance.
206
+ """
207
+ from qprogram.protocol import waveform_token # ruff: ignore[import-outside-top-level]
208
+
209
+ caps = {"vendor.qdac.play", "waveform.single"}
210
+ tok = waveform_token(self.waveform)
211
+ if tok is not None:
212
+ caps.add(tok)
213
+ return caps
@@ -0,0 +1,234 @@
1
+ # Copyright 2026 Qilimanjaro Quantum Tech
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ """The capability profile bundle for the QDAC vendor extension.
15
+
16
+ Ships [`QDAC_DEFAULT_V1`][qprogram_qdac.QDAC_DEFAULT_V1], the bus-level profile listing what the QDAC waveform engine
17
+ supports on one bus (one channel). A qdac platform attaches it to the flux buses of its schema and leaves the drive and
18
+ readout buses to another vendor, qblox for instance. The platform-level slot is filled by the core-shipped
19
+ ``qprogram-base-v1``, the same as for any other vendor.
20
+
21
+ The profile carries two predicates:
22
+
23
+ - A soft [`DomainConstraint`][qprogram.DomainConstraint] excluding ``"rt"``, emitted whenever a qdac operation
24
+ reads a loop-bound [`Variable`][qprogram.Variable]. QDAC has no FPGA, so every swept parameter (a DC
25
+ offset, a waveform-engine setting, a waveform's own parameters) has to be re-uploaded from the
26
+ host between iterations. The constraint names the enclosing loop, which the classifier drops to
27
+ ``{host}`` and reports as a ``forced-host`` warning quoting the constraint's reason; everything
28
+ outside the qdac operation is left alone.
29
+ - A hard ``qdac.empty-trigger-outputs`` error [`Diagnostic`][qprogram.Diagnostic] for a
30
+ [`SetTrigger`][qprogram_qdac.SetTrigger] that arms no output.
31
+
32
+ Registered as a side effect of importing `qprogram_qdac`.
33
+ """
34
+
35
+ from __future__ import annotations
36
+
37
+ from typing import TYPE_CHECKING
38
+
39
+ from qprogram.protocol import (
40
+ Diagnostic,
41
+ DomainConstraint,
42
+ Profile,
43
+ ValidationContext,
44
+ register_capability_tokens,
45
+ register_profile,
46
+ )
47
+
48
+ from qprogram_qdac.operations import Play, SetOffset, SetTrigger, WaitTrigger
49
+
50
+ # Register the vendor tokens *before* constructing the profile that names them:
51
+ # Profile.__post_init__ checks every listed token against CAPABILITY_REGISTRY.
52
+ register_capability_tokens(
53
+ "vendor.qdac.wait_trigger",
54
+ "vendor.qdac.set_trigger",
55
+ "vendor.qdac.set_offset",
56
+ "vendor.qdac.play",
57
+ )
58
+
59
+ if TYPE_CHECKING:
60
+ from collections.abc import Iterable
61
+
62
+ from qprogram.blocks.block import Block
63
+ from qprogram.operations.operation import Operation
64
+
65
+
66
+ _QDAC_OP_CLASSES: tuple[type, ...] = (WaitTrigger, SetTrigger, SetOffset, Play)
67
+ """Every qdac [`Operation`][qprogram.operations.Operation] subclass.
68
+
69
+ `_qdac_op_with_swept_var_is_host_only` filters on it. A predicate runs on every node the
70
+ validator visits within its slot, core operations included, so it has to recognize its own nodes
71
+ rather than trusting routing to have done it.
72
+ """
73
+
74
+
75
+ def _qdac_op_with_swept_var_is_host_only(
76
+ node: Operation | Block,
77
+ ctx: ValidationContext,
78
+ ) -> Iterable[Diagnostic | DomainConstraint]:
79
+ """Constrain the binding loop of any variable a qdac operation reads to host-side dispatch.
80
+
81
+ QDAC has no FPGA. Every parameter change goes through the host's slow-control plane, at
82
+ millisecond latency, so a qdac operation that reads a variable bound by an enclosing
83
+ [`Sweep`][qprogram.blocks.Sweep] cannot sit inside a real-time hardware loop. The loop has to
84
+ dispatch host-side and re-upload the value once per iteration.
85
+
86
+ The constraint targets the **binding loop block**, never the qdac operation, which is what the
87
+ spec requires and what keeps the operation's own classification untouched. What changes is the
88
+ loop: its support drops from rt-or-host to host only.
89
+
90
+ Variables are read off the node with [`variables`][qprogram.operations.Operation.variables], which
91
+ descends into expression arguments and waveform parameters. A
92
+ ``play(bus, Square(amplitude=v))`` is therefore caught as surely as a ``set_offset(bus, v)``.
93
+
94
+ On a platform that fills only the host half of its qdac bus slots the constraint changes
95
+ nothing: the operation is host-only by construction there, and op-children consensus lifts the
96
+ loop on its own. What the constraint covers is a platform that fills both halves, and when it
97
+ does fire it supplies the reason text the loop's ``forced-host`` warning quotes.
98
+
99
+ Args:
100
+ node (Operation | Block): The AST node currently being checked.
101
+ ctx (ValidationContext): Validation context, used to find the loop that binds each variable.
102
+
103
+ Yields:
104
+ One [`DomainConstraint`][qprogram.DomainConstraint] excluding ``"rt"`` per distinct binding loop reached
105
+ from ``node``. Nothing when ``node`` is not a qdac operation, or reads no bound variable.
106
+ """
107
+ if not isinstance(node, _QDAC_OP_CLASSES):
108
+ return
109
+ seen_loops: set[int] = set()
110
+ for var in node.variables():
111
+ binding_loop = ctx.binding_loop_of(var)
112
+ if binding_loop is None or id(binding_loop) in seen_loops:
113
+ continue
114
+ seen_loops.add(id(binding_loop))
115
+ yield DomainConstraint(
116
+ node=binding_loop,
117
+ exclude=frozenset({"rt"}),
118
+ reason=(
119
+ f"qdac.{type(node).__name__} references loop-bound variable {var.id!r}; "
120
+ f"qdac has no FPGA, so the loop must dispatch host-side."
121
+ ),
122
+ )
123
+
124
+
125
+ def _set_trigger_outputs_required(
126
+ node: Operation | Block,
127
+ ctx: ValidationContext, # ruff: ignore[unused-function-argument] a purely structural check
128
+ ) -> Iterable[Diagnostic | DomainConstraint]:
129
+ """Reject a [`SetTrigger`][qprogram_qdac.SetTrigger] that arms no output.
130
+
131
+ A trigger with an empty ``outputs`` set fires onto nothing, which is a mistake in every domain
132
+ rather than something host-side dispatch could rescue. That makes it a
133
+ [`Diagnostic`][qprogram.Diagnostic] and not a [`DomainConstraint`][qprogram.DomainConstraint].
134
+
135
+ Args:
136
+ node (Operation | Block): The AST node currently being checked.
137
+ ctx (ValidationContext): Validation context. Unused: the check reads only the node.
138
+
139
+ Yields:
140
+ One ``qdac.empty-trigger-outputs`` error [`Diagnostic`][qprogram.Diagnostic] when ``node`` is a
141
+ ``SetTrigger`` with no outputs. Nothing otherwise.
142
+ """
143
+ if not isinstance(node, SetTrigger):
144
+ return
145
+ if not node.outputs:
146
+ yield Diagnostic(
147
+ severity="error",
148
+ code="qdac.empty-trigger-outputs",
149
+ message=(
150
+ "SetTrigger has no outputs configured. Specify at least one output index, e.g. "
151
+ "outputs={1} or outputs=[1, 2]."
152
+ ),
153
+ node=node,
154
+ )
155
+
156
+
157
+ _BUS_OPS: frozenset[str] = frozenset(
158
+ {
159
+ "vendor.qdac.wait_trigger",
160
+ "vendor.qdac.set_trigger",
161
+ "vendor.qdac.set_offset",
162
+ "vendor.qdac.play",
163
+ },
164
+ )
165
+ """The qdac vendor operation tokens.
166
+
167
+ Every qdac operation carries a ``bus`` attribute, so it routes to the per-bus
168
+ [`BusCapabilities`][qprogram.BusCapabilities] slot the platform attaches qdac to rather than to the
169
+ platform-level slot.
170
+ """
171
+
172
+ _WAVEFORMS: frozenset[str] = frozenset(
173
+ {
174
+ "waveform.single",
175
+ "waveform.arbitrary",
176
+ "waveform.chained",
177
+ "waveform.cosine",
178
+ "waveform.flat_top",
179
+ "waveform.gaussian",
180
+ "waveform.ramp",
181
+ "waveform.sine",
182
+ "waveform.square",
183
+ "waveform.sech",
184
+ "waveform.snz",
185
+ "waveform.tukey",
186
+ },
187
+ )
188
+ """The single-channel waveform tokens the QDAC waveform engine renders.
189
+
190
+ Waveform tokens live on the bus profile because a waveform reaches the hardware through a bus. QDAC
191
+ drives one channel per bus, so ``waveform.iq`` and the IQ waveform classes are left out on purpose:
192
+ a program playing an [`IQDrag`][qprogram.waveforms.IQDrag] on a qdac bus fails validation with a
193
+ ``missing-capability`` diagnostic.
194
+ """
195
+
196
+
197
+ QDAC_DEFAULT_V1 = Profile(
198
+ name="qdac-default-v1",
199
+ version=(0, 1, 0),
200
+ extends=None,
201
+ capabilities=_BUS_OPS | _WAVEFORMS,
202
+ limits={
203
+ # The waveform engine has a hard floor on dwell time, below which its output interpolation
204
+ # breaks down. No core check reads this limit; it is published here for platforms that wire
205
+ # in a predicate of their own.
206
+ "min_dwell_ns": 100,
207
+ },
208
+ predicates=(
209
+ _qdac_op_with_swept_var_is_host_only,
210
+ _set_trigger_outputs_required,
211
+ ),
212
+ vendor_versions={"qdac": (0, 1, 0)},
213
+ )
214
+ """The default QDAC bus-level capability profile.
215
+
216
+ Because qdac has no FPGA, a platform fills the ``host`` half of each qdac-driven bus slot with this
217
+ profile and leaves the ``rt`` half empty. Every qdac operation is then host-side by design, and a
218
+ loop whose operations are all qdac classifies as host-side through op-children consensus alone. A
219
+ platform that does fill both halves gets the same outcome for swept programs, this time from the
220
+ profile's own [`DomainConstraint`][qprogram.DomainConstraint] predicate.
221
+
222
+ The profile holds every qdac vendor token (``wait_trigger``, ``set_trigger``, ``set_offset``,
223
+ ``play``) plus the single-channel waveforms the engine renders. The platform-level slot of a qdac
224
+ platform's [`PlatformCapabilities`][qprogram.PlatformCapabilities] uses the core-shipped ``qprogram-base-v1``
225
+ directly: qdac has no bus-less operations, so it contributes nothing at that level.
226
+ """
227
+
228
+
229
+ def _register() -> None:
230
+ """Idempotently register [`QDAC_DEFAULT_V1`][qprogram_qdac.QDAC_DEFAULT_V1] on the global profile registry."""
231
+ register_profile(QDAC_DEFAULT_V1)
232
+
233
+
234
+ __all__ = ["QDAC_DEFAULT_V1"]
qprogram_qdac/py.typed ADDED
File without changes
@@ -0,0 +1,149 @@
1
+ Metadata-Version: 2.5
2
+ Name: qprogram-qdac
3
+ Version: 0.1.0
4
+ Summary: QDevil QDAC vendor extensions for the QProgram pulse-level quantum programming DSL.
5
+ Project-URL: Homepage, https://github.com/qilimanjaro-tech/qprogram-qdac
6
+ Project-URL: Documentation, https://qilimanjaro-tech.github.io/qprogram-qdac/
7
+ Project-URL: Source, https://github.com/qilimanjaro-tech/qprogram-qdac
8
+ Project-URL: Issues, https://github.com/qilimanjaro-tech/qprogram-qdac/issues
9
+ Author-email: Qilimanjaro Quantum Tech <info@qilimanjaro.tech>
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ Keywords: dsl,pulse programming,qdac,qdevil,qilimanjaro,quantum computing,quantum control
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Environment :: Console
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: Operating System :: MacOS
18
+ Classifier: Operating System :: Microsoft :: Windows
19
+ Classifier: Operating System :: POSIX :: Linux
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Programming Language :: Python :: 3.14
25
+ Classifier: Topic :: Scientific/Engineering
26
+ Classifier: Topic :: Scientific/Engineering :: Physics
27
+ Classifier: Topic :: Scientific/Engineering :: Quantum Computing
28
+ Classifier: Typing :: Typed
29
+ Requires-Python: >=3.11
30
+ Requires-Dist: qprogram>=0.1.0
31
+ Description-Content-Type: text/markdown
32
+
33
+ # QProgram QDAC
34
+
35
+ [![Tests](https://github.com/qilimanjaro-tech/qprogram-qdac/actions/workflows/tests.yml/badge.svg)](https://github.com/qilimanjaro-tech/qprogram-qdac/actions/workflows/tests.yml)
36
+ [![Code Quality](https://github.com/qilimanjaro-tech/qprogram-qdac/actions/workflows/code_quality.yml/badge.svg)](https://github.com/qilimanjaro-tech/qprogram-qdac/actions/workflows/code_quality.yml)
37
+ [![Python](https://img.shields.io/badge/python-3.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue)](https://www.python.org/)
38
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue)](LICENSE)
39
+
40
+ QDevil QDAC extensions for
41
+ [QProgram](https://github.com/qilimanjaro-tech/qprogram), the pulse-level
42
+ quantum programming DSL. The QDAC is a slow high-precision DAC, used most
43
+ often for flux biasing.
44
+
45
+ The core DSL knows nothing about any instrument. This package adds the
46
+ `qdac` vendor namespace to it: four operations covering DC offsets, the
47
+ waveform engine, and the chassis trigger network, a capability profile that
48
+ says what a QDAC channel can do, and `.qp` serialization for all of it.
49
+ Importing the package is what turns those on.
50
+
51
+ ## Installation
52
+
53
+ ```bash
54
+ pip install qprogram-qdac
55
+ ```
56
+
57
+ The only dependency is `qprogram` itself.
58
+
59
+ ## A first program
60
+
61
+ ```python
62
+ import qprogram as qp
63
+ from qprogram import BusSchema
64
+ from qprogram.waveforms import IQPair, Square
65
+ from qprogram_qdac import QProgram
66
+
67
+ schema = BusSchema.flux_tunable_transmon()
68
+ q = schema.q
69
+
70
+ program = QProgram(label="flux-spectroscopy", schema=schema)
71
+ bias = program.variable("bias", units="V")
72
+
73
+ with program.sweep(bias).from_range(-0.2, 0.2, 0.01):
74
+ program.qdac.set_offset(q[0].flux, bias)
75
+ with program.average(shots=100):
76
+ program.play(q[0].drive, "pi_pulse")
77
+ program.sync([q[0].drive, q[0].readout])
78
+ m0 = program.measure(q[0].readout, "readout", "weights")
79
+
80
+ resolved = program.with_waveforms(
81
+ {
82
+ "pi_pulse": IQPair(Square(0.5, 40), Square(0.0, 40)),
83
+ "readout": IQPair(Square(1.0, 2000), Square(0.0, 2000)),
84
+ "weights": IQPair(Square(1.0, 2000), Square(1.0, 2000)),
85
+ }
86
+ )
87
+
88
+ result = qp.simulate(resolved)
89
+ data = result.get(m0)
90
+ print(data.dims, data.shape) # ('bias', 'IQ') (41, 2)
91
+ ```
92
+
93
+ The flux bias comes from the QDAC, the drive and readout from whatever
94
+ vendor owns those buses. One program describes both, and the nesting is
95
+ what makes a mixed platform accept it: the bias sweep dispatches from the
96
+ host, one upload per point, while the `average` block under it runs in the
97
+ real-time sequencer. Flatten the two into one block and no domain runs
98
+ both. `sync` names its buses because the argument-less form syncs every bus
99
+ in the program, and a QDAC channel is not something a real-time barrier can
100
+ wait on.
101
+
102
+ ## What you get
103
+
104
+ - **Four operations under one namespace.** `set_offset` holds a DC voltage
105
+ on a channel, `play` uploads an envelope to the channel's waveform engine
106
+ with explicit dwell, delay, repetitions and stepped mode, and
107
+ `set_trigger` / `wait_trigger` wire the channel into the chassis trigger
108
+ network so QDAC sequences line up with instruments driving other buses.
109
+ - **Host-side sweeps, declared rather than guessed.** The QDAC has no FPGA,
110
+ so a swept parameter has to be re-uploaded from the host between
111
+ iterations. The `qdac-default-v1` profile says so through a domain
112
+ constraint, and `qp.explain(program, capabilities)` prints the enclosing
113
+ loop as `[host]` instead of failing at compile time.
114
+ - **Single-channel by declaration.** The profile lists only single-channel
115
+ waveform tokens. An IQ waveform on a QDAC bus is a `missing-capability`
116
+ error from `qp.validate`, not a runtime surprise.
117
+ - **Serialization included.** Every operation round-trips through the `.qp`
118
+ text format, under a `require qdac 0.1` header line. A file that names
119
+ `qdac` activates this package on load through its entry point, so the
120
+ reader does not have to import it first.
121
+ - **Typed access.** `QProgram` from this package is the core builder with a
122
+ typed `.qdac` property. `QdacMixin` composes with other vendor mixins
123
+ when a platform spans several instruments.
124
+
125
+ ## Documentation
126
+
127
+ Full documentation, including the operation reference, the capability
128
+ profile, and the generated API reference, lives at
129
+ <https://qilimanjaro-tech.github.io/qprogram-qdac/>.
130
+
131
+ ## Development
132
+
133
+ The project uses [uv](https://docs.astral.sh/uv/).
134
+
135
+ ```bash
136
+ git clone https://github.com/qilimanjaro-tech/qprogram-qdac
137
+ cd qprogram-qdac
138
+
139
+ uv sync --group dev # create .venv and install everything
140
+ uv run pytest # run the test suite
141
+ uv run ruff check . # lint
142
+ uv run ruff format . # format
143
+ uv run ty check # type-check
144
+ uv run --group docs zensical serve # preview the documentation
145
+ ```
146
+
147
+ ## License
148
+
149
+ Apache License 2.0 - see [LICENSE](LICENSE).
@@ -0,0 +1,11 @@
1
+ qprogram_qdac/__init__.py,sha256=18PQ2W9tv58qqjTws7JJNqRZ2ip55F1rlwWx-rN-tzo,5408
2
+ qprogram_qdac/mixin.py,sha256=ULTqY8EDEUEOqvvFHPy4DlsZQd3cTT_R9e2ew-mpi_k,2693
3
+ qprogram_qdac/namespace.py,sha256=WLPFJpBRSCxlHyEhq4dre2bhJDQWiZ6txCZSVPgGk4o,5614
4
+ qprogram_qdac/operations.py,sha256=sNnffPNaLKRK62PTCzrIEBbfT5gWBojOj_MHuuFoshs,9078
5
+ qprogram_qdac/profiles.py,sha256=8rd0GEwzpYM67v85YU6TIPhQqnKsEYp5bh4VBb2J1zg,9783
6
+ qprogram_qdac/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ qprogram_qdac-0.1.0.dist-info/METADATA,sha256=91E2nz_aBQ9hw4uv3Gx01bZUmMvCMPyP-nt6Cbdd1e0,6374
8
+ qprogram_qdac-0.1.0.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
9
+ qprogram_qdac-0.1.0.dist-info/entry_points.txt,sha256=80U8nhMlMenZhw4rw7umW9yH4wuUe8SsmXb0JC5wmCA,40
10
+ qprogram_qdac-0.1.0.dist-info/licenses/LICENSE,sha256=SSd4NLHKeN_X9uu9A5TnY3vpro7w7I9ZduIIsjtIBlo,11354
11
+ qprogram_qdac-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.32.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [qprogram.vendors]
2
+ qdac = qprogram_qdac
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 Qilimanjaro Quantum Tech
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.