Skip to content

Commit

Permalink
Revert "Rydberg h factory (#652)" (#653)
Browse files Browse the repository at this point in the history
This reverts commit ce1cb35.
  • Loading branch information
weinbe58 authored Sep 29, 2023
1 parent ce1cb35 commit ad75c42
Show file tree
Hide file tree
Showing 17 changed files with 131 additions and 369 deletions.
8 changes: 4 additions & 4 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ classifiers = [
dependencies = [
"juliacall>=0.9.14",
"numpy>=1.25.2",
"pydantic>=1.10.13",
"pydantic>=1.10.12",
"scipy>=1.9.3",
"pandas>=2.1.0",
"bokeh>=3.2.2",
Expand Down
6 changes: 1 addition & 5 deletions src/bloqade/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from bloqade.ir import var, cast, Variable, Literal, start
from bloqade.ir import to_waveform as waveform
from bloqade.serialize import load, save, loads, dumps

from bloqade.factory import (
from bloqade.builder.factory import (
piecewise_linear,
piecewise_constant,
linear,
constant,
rydberg_h,
)
import bloqade.ir as _ir
from bloqade.constants import RB_C6
Expand Down Expand Up @@ -46,6 +44,4 @@ def tree_depth(depth: int = None):
"save",
"loads",
"dumps",
"rydberg_h",
"waveform",
]
4 changes: 0 additions & 4 deletions src/bloqade/builder/assign.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ def __init__(

super().__init__(parent)

if len(assignments) == 0:
self._batch_params = []
return

circuit = self.parse_circuit()
variables = ScanVariablesAnalogCircuit().emit(circuit)

Expand Down
42 changes: 42 additions & 0 deletions src/bloqade/builder/factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from bloqade.ir.control.waveform import Waveform, Linear, Constant
from bloqade.builder.typing import ScalarType
from beartype import beartype
from beartype.typing import List

# this part only for manually build sequences.


@beartype
def linear(duration: ScalarType, start: ScalarType, stop: ScalarType):
return Linear(start, stop, duration)


@beartype
def constant(duration: ScalarType, value: ScalarType):
return Constant(value, duration)


@beartype
def piecewise_linear(durations: List[ScalarType], values: List[ScalarType]) -> Waveform:
pwl_wf = None
for duration, start, stop in zip(durations, values[:-1], values[1:]):
if pwl_wf is None:
pwl_wf = Linear(start, stop, duration)
else:
pwl_wf = pwl_wf.append(Linear(start, stop, duration))

return pwl_wf


@beartype
def piecewise_constant(
durations: List[ScalarType], values: List[ScalarType]
) -> Waveform:
pwc_wf = None
for duration, value in zip(durations, values):
if pwc_wf is None:
pwc_wf = Constant(value, duration)
else:
pwc_wf = pwc_wf.append(Constant(value, duration))

return pwc_wf
160 changes: 0 additions & 160 deletions src/bloqade/factory.py

This file was deleted.

4 changes: 2 additions & 2 deletions src/bloqade/ir/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Interpolation,
Sample,
PythonFn,
to_waveform,
instruction,
GaussianKernel,
LogisticKernel,
SigmoidKernel,
Expand Down Expand Up @@ -68,7 +68,7 @@
"Sample",
"Interpolation",
"PythonFn",
"to_waveform",
"instruction",
"GaussianKernel",
"LogisticKernel",
"SigmoidKernel",
Expand Down
10 changes: 1 addition & 9 deletions src/bloqade/ir/control/waveform.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from numbers import Real
from bloqade.builder.typing import ScalarType
from bloqade.ir.tree_print import Printer
from bloqade.ir.scalar import (
Scalar,
Expand All @@ -15,7 +14,6 @@
from decimal import Decimal
from pydantic.dataclasses import dataclass
from beartype.typing import Any, Tuple, Union, List, Callable, Dict
from beartype import beartype
from enum import Enum

import numpy as np
Expand All @@ -25,8 +23,7 @@
from bloqade.visualization import display_ir


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

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

def sample(
self, dt: ScalarType, interpolation: Union[str, "Interpolation"]
) -> "Sample":
return Sample(self, interpolation, cast(dt))


@dataclass
class SmoothingKernel:
Expand Down
11 changes: 4 additions & 7 deletions src/bloqade/ir/routine/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from bloqade.builder.base import Builder
from bloqade.ir.routine.params import Params

from pydantic import ConfigDict
from pydantic.dataclasses import dataclass

from dataclasses import dataclass
from typing import TYPE_CHECKING, Union

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


__pydantic_dataclass_config__ = ConfigDict(arbitrary_types_allowed=True)


@dataclass(frozen=True, config=__pydantic_dataclass_config__)
@dataclass(frozen=True)
class RoutineBase(RoutineParse):
source: Builder
circuit: AnalogCircuit
Expand All @@ -46,7 +43,7 @@ def __str__(self):
return out


@dataclass(frozen=True, config=__pydantic_dataclass_config__)
@dataclass(frozen=True)
class Routine(RoutineBase):
"""Result of parsing a completed Builder string."""

Expand Down
8 changes: 4 additions & 4 deletions src/bloqade/ir/routine/bloqade.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
from collections import OrderedDict
from bloqade.ir.routine.base import RoutineBase, __pydantic_dataclass_config__
from bloqade.ir.routine.base import RoutineBase
from bloqade.builder.typing import LiteralType
from bloqade.task.batch import LocalBatch
from beartype import beartype
from beartype.typing import Optional, Tuple
from pydantic.dataclasses import dataclass
from dataclasses import dataclass


@dataclass(frozen=True, config=__pydantic_dataclass_config__)
@dataclass(frozen=True)
class BloqadeServiceOptions(RoutineBase):
def python(self):
return BloqadePythonRoutine(self.source, self.circuit, self.params)


@dataclass(frozen=True, config=__pydantic_dataclass_config__)
@dataclass(frozen=True)
class BloqadePythonRoutine(RoutineBase):
def _compile(
self,
Expand Down
Loading

0 comments on commit ad75c42

Please sign in to comment.