Skip to content

Commit ad75c42

Browse files
authored
Revert "Rydberg h factory (#652)" (#653)
This reverts commit ce1cb35.
1 parent ce1cb35 commit ad75c42

17 files changed

+131
-369
lines changed

pdm.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ classifiers = [
1717
dependencies = [
1818
"juliacall>=0.9.14",
1919
"numpy>=1.25.2",
20-
"pydantic>=1.10.13",
20+
"pydantic>=1.10.12",
2121
"scipy>=1.9.3",
2222
"pandas>=2.1.0",
2323
"bokeh>=3.2.2",

src/bloqade/__init__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
from bloqade.ir import var, cast, Variable, Literal, start
2-
from bloqade.ir import to_waveform as waveform
32
from bloqade.serialize import load, save, loads, dumps
43

5-
from bloqade.factory import (
4+
from bloqade.builder.factory import (
65
piecewise_linear,
76
piecewise_constant,
87
linear,
98
constant,
10-
rydberg_h,
119
)
1210
import bloqade.ir as _ir
1311
from bloqade.constants import RB_C6
@@ -46,6 +44,4 @@ def tree_depth(depth: int = None):
4644
"save",
4745
"loads",
4846
"dumps",
49-
"rydberg_h",
50-
"waveform",
5147
]

src/bloqade/builder/assign.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,6 @@ def __init__(
9393

9494
super().__init__(parent)
9595

96-
if len(assignments) == 0:
97-
self._batch_params = []
98-
return
99-
10096
circuit = self.parse_circuit()
10197
variables = ScanVariablesAnalogCircuit().emit(circuit)
10298

src/bloqade/builder/factory.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from bloqade.ir.control.waveform import Waveform, Linear, Constant
2+
from bloqade.builder.typing import ScalarType
3+
from beartype import beartype
4+
from beartype.typing import List
5+
6+
# this part only for manually build sequences.
7+
8+
9+
@beartype
10+
def linear(duration: ScalarType, start: ScalarType, stop: ScalarType):
11+
return Linear(start, stop, duration)
12+
13+
14+
@beartype
15+
def constant(duration: ScalarType, value: ScalarType):
16+
return Constant(value, duration)
17+
18+
19+
@beartype
20+
def piecewise_linear(durations: List[ScalarType], values: List[ScalarType]) -> Waveform:
21+
pwl_wf = None
22+
for duration, start, stop in zip(durations, values[:-1], values[1:]):
23+
if pwl_wf is None:
24+
pwl_wf = Linear(start, stop, duration)
25+
else:
26+
pwl_wf = pwl_wf.append(Linear(start, stop, duration))
27+
28+
return pwl_wf
29+
30+
31+
@beartype
32+
def piecewise_constant(
33+
durations: List[ScalarType], values: List[ScalarType]
34+
) -> Waveform:
35+
pwc_wf = None
36+
for duration, value in zip(durations, values):
37+
if pwc_wf is None:
38+
pwc_wf = Constant(value, duration)
39+
else:
40+
pwc_wf = pwc_wf.append(Constant(value, duration))
41+
42+
return pwc_wf

src/bloqade/factory.py

Lines changed: 0 additions & 160 deletions
This file was deleted.

src/bloqade/ir/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
Interpolation,
1212
Sample,
1313
PythonFn,
14-
to_waveform,
14+
instruction,
1515
GaussianKernel,
1616
LogisticKernel,
1717
SigmoidKernel,
@@ -68,7 +68,7 @@
6868
"Sample",
6969
"Interpolation",
7070
"PythonFn",
71-
"to_waveform",
71+
"instruction",
7272
"GaussianKernel",
7373
"LogisticKernel",
7474
"SigmoidKernel",

src/bloqade/ir/control/waveform.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from numbers import Real
2-
from bloqade.builder.typing import ScalarType
32
from bloqade.ir.tree_print import Printer
43
from bloqade.ir.scalar import (
54
Scalar,
@@ -15,7 +14,6 @@
1514
from decimal import Decimal
1615
from pydantic.dataclasses import dataclass
1716
from beartype.typing import Any, Tuple, Union, List, Callable, Dict
18-
from beartype import beartype
1917
from enum import Enum
2018

2119
import numpy as np
@@ -25,8 +23,7 @@
2523
from bloqade.visualization import display_ir
2624

2725

28-
@beartype
29-
def to_waveform(duration: ScalarType) -> Callable[[Callable], "PythonFn"]:
26+
def instruction(duration: Any) -> "PythonFn":
3027
# turn python function into a waveform instruction."""
3128

3229
def waveform_wrapper(fn: Callable) -> "PythonFn":
@@ -489,11 +486,6 @@ def print_node(self):
489486
def children(self):
490487
return {"duration": self.duration, **{p.name: p for p in self.parameters}}
491488

492-
def sample(
493-
self, dt: ScalarType, interpolation: Union[str, "Interpolation"]
494-
) -> "Sample":
495-
return Sample(self, interpolation, cast(dt))
496-
497489

498490
@dataclass
499491
class SmoothingKernel:

src/bloqade/ir/routine/base.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
from bloqade.builder.base import Builder
66
from bloqade.ir.routine.params import Params
77

8-
from pydantic import ConfigDict
9-
from pydantic.dataclasses import dataclass
8+
9+
from dataclasses import dataclass
1010
from typing import TYPE_CHECKING, Union
1111

1212
if TYPE_CHECKING:
@@ -29,10 +29,7 @@ def parse(self: "RoutineBase") -> "Routine":
2929
return self
3030

3131

32-
__pydantic_dataclass_config__ = ConfigDict(arbitrary_types_allowed=True)
33-
34-
35-
@dataclass(frozen=True, config=__pydantic_dataclass_config__)
32+
@dataclass(frozen=True)
3633
class RoutineBase(RoutineParse):
3734
source: Builder
3835
circuit: AnalogCircuit
@@ -46,7 +43,7 @@ def __str__(self):
4643
return out
4744

4845

49-
@dataclass(frozen=True, config=__pydantic_dataclass_config__)
46+
@dataclass(frozen=True)
5047
class Routine(RoutineBase):
5148
"""Result of parsing a completed Builder string."""
5249

src/bloqade/ir/routine/bloqade.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
from collections import OrderedDict
2-
from bloqade.ir.routine.base import RoutineBase, __pydantic_dataclass_config__
2+
from bloqade.ir.routine.base import RoutineBase
33
from bloqade.builder.typing import LiteralType
44
from bloqade.task.batch import LocalBatch
55
from beartype import beartype
66
from beartype.typing import Optional, Tuple
7-
from pydantic.dataclasses import dataclass
7+
from dataclasses import dataclass
88

99

10-
@dataclass(frozen=True, config=__pydantic_dataclass_config__)
10+
@dataclass(frozen=True)
1111
class BloqadeServiceOptions(RoutineBase):
1212
def python(self):
1313
return BloqadePythonRoutine(self.source, self.circuit, self.params)
1414

1515

16-
@dataclass(frozen=True, config=__pydantic_dataclass_config__)
16+
@dataclass(frozen=True)
1717
class BloqadePythonRoutine(RoutineBase):
1818
def _compile(
1919
self,

0 commit comments

Comments
 (0)