Skip to content

Fix factory bug #1029

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 22 additions & 15 deletions src/bloqade/analog/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
from beartype import beartype
from beartype.typing import TYPE_CHECKING, Any, Dict, List, Union, Optional

from bloqade.analog.ir.scalar import Variable
from bloqade.analog.builder.typing import ScalarType
from bloqade.analog.builder.pragmas import Assignable
from bloqade.analog.ir.routine.base import Routine
from bloqade.analog.ir.control.waveform import Linear, Constant, Waveform

Expand Down Expand Up @@ -92,12 +94,12 @@
"The length of values must be one greater than the length of durations"
)

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))
if len(durations) == 0:
raise ValueError("The durations and values lists must not be empty.")

Check warning on line 98 in src/bloqade/analog/factory.py

View check run for this annotation

Codecov / codecov/patch

src/bloqade/analog/factory.py#L98

Added line #L98 was not covered by tests

pwl_wf = Linear(values[0], values[1], durations[0])
for duration, start, stop in zip(durations[1:], values[1:-1], values[2:]):
pwl_wf = pwl_wf.append(Linear(start, stop, duration))

return pwl_wf

Expand Down Expand Up @@ -128,12 +130,12 @@
"The length of values must be the same as the length of durations"
)

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))
if len(durations) == 0:
raise ValueError("The durations and values lists must not be empty.")

Check warning on line 134 in src/bloqade/analog/factory.py

View check run for this annotation

Codecov / codecov/patch

src/bloqade/analog/factory.py#L134

Added line #L134 was not covered by tests

pwc_wf = Constant(values[0], durations[0])
for duration, value in zip(durations[1:], values[1:]):
pwc_wf = pwc_wf.append(Constant(value, duration))

return pwc_wf

Expand All @@ -146,7 +148,7 @@
phase: Optional[Waveform] = None,
static_params: Dict[str, Any] = {},
batch_params: Union[List[Dict[str, Any]], Dict[str, Any]] = [],
args: List[str] = [],
args: List[str | Variable] = [],
) -> Routine:
"""Create a rydberg program with uniform detuning, amplitude, and phase.

Expand Down Expand Up @@ -181,10 +183,15 @@
prog = prog.rydberg.detuning.uniform.apply(detuning)

if amplitude is not None:
prog = prog.amplitude.uniform.apply(amplitude)
prog = prog.rydberg.rabi.amplitude.uniform.apply(amplitude)

if phase is not None:
prog = prog.phase.uniform.apply(phase)
prog = prog.rydberg.rabi.phase.uniform.apply(phase)

if not isinstance(prog, Assignable):
raise ValueError(

Check warning on line 192 in src/bloqade/analog/factory.py

View check run for this annotation

Codecov / codecov/patch

src/bloqade/analog/factory.py#L192

Added line #L192 was not covered by tests
"At least one of detuning, amplitude, or phase must be provided."
)

prog = prog.assign(**static_params)

Expand Down
10 changes: 5 additions & 5 deletions src/bloqade/analog/task/exclusive.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import os
import abc
import uuid
import re
import abc
import time
import uuid
from dataclasses import field, dataclass

from requests import get, request
from beartype.typing import Dict
from dataclasses import dataclass, field

from bloqade.analog.serialize import Serializer
from bloqade.analog.task.base import Geometry, CustomRemoteTaskABC
from bloqade.analog.builder.typing import ParamType
from bloqade.analog.submission.ir.parallel import ParallelDecoder
Expand All @@ -15,8 +17,6 @@
QuEraTaskStatusCode,
)
from bloqade.analog.submission.ir.task_specification import QuEraTaskSpecification
from requests import request, get
from bloqade.analog.serialize import Serializer


class HTTPHandlerABC:
Expand Down
Loading