Skip to content

Commit 24c220d

Browse files
committed
merging main
2 parents 8936264 + dbde9ca commit 24c220d

File tree

7 files changed

+1564
-1335
lines changed

7 files changed

+1564
-1335
lines changed

.github/workflows/deploy_latest.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: Wait for dev documentation to deploy
21-
uses: lewagon/wait-on-check-action@v1.3.4
21+
uses: lewagon/wait-on-check-action@v1.4.0
2222
with:
2323
ref: main
2424
check-name: 'Deploy dev documentation'

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
name: python-package-distributions
7171
path: dist/
7272
- name: Sign the dists with Sigstore
73-
uses: sigstore/gh-action-sigstore-python@v3.0.0
73+
uses: sigstore/gh-action-sigstore-python@v3.0.1
7474
with:
7575
inputs: >-
7676
./dist/*.tar.gz

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ nav:
1212
- Home: 'https://queracomputing.github.io/bloqade/latest/'
1313
- Digital Tutorials: 'https://queracomputing.github.io/bloqade/latest/digital/'
1414
- Analog Tutorials: 'https://queracomputing.github.io/bloqade-analog-examples/dev/'
15+
- qBook: 'https://qbook.quera.com'
1516
- Bloqade Analog:
1617
- index.md
1718
- Migration Guide to Bloqade Analog: home/migration.md

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "bloqade-analog"
3-
version = "0.16.5"
3+
version = "0.16.6"
44
description = "Analog neutral atom software development kit"
55
authors = [
66
{ name = "Roger-luo", email = "rluo@quera.com" },

src/bloqade/analog/factory.py

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
from beartype import beartype
44
from beartype.typing import TYPE_CHECKING, Any, Dict, List, Union, Optional
55

6+
from bloqade.analog.ir.scalar import Variable
67
from bloqade.analog.builder.typing import ScalarType
8+
from bloqade.analog.builder.pragmas import Assignable
79
from bloqade.analog.ir.routine.base import Routine
810
from bloqade.analog.ir.control.waveform import Linear, Constant, Waveform
911

@@ -92,12 +94,12 @@ def piecewise_linear(durations: List[ScalarType], values: List[ScalarType]) -> W
9294
"The length of values must be one greater than the length of durations"
9395
)
9496

95-
pwl_wf = None
96-
for duration, start, stop in zip(durations, values[:-1], values[1:]):
97-
if pwl_wf is None:
98-
pwl_wf = Linear(start, stop, duration)
99-
else:
100-
pwl_wf = pwl_wf.append(Linear(start, stop, duration))
97+
if len(durations) == 0:
98+
raise ValueError("The durations and values lists must not be empty.")
99+
100+
pwl_wf = Linear(values[0], values[1], durations[0])
101+
for duration, start, stop in zip(durations[1:], values[1:-1], values[2:]):
102+
pwl_wf = pwl_wf.append(Linear(start, stop, duration))
101103

102104
return pwl_wf
103105

@@ -128,12 +130,12 @@ def piecewise_constant(
128130
"The length of values must be the same as the length of durations"
129131
)
130132

131-
pwc_wf = None
132-
for duration, value in zip(durations, values):
133-
if pwc_wf is None:
134-
pwc_wf = Constant(value, duration)
135-
else:
136-
pwc_wf = pwc_wf.append(Constant(value, duration))
133+
if len(durations) == 0:
134+
raise ValueError("The durations and values lists must not be empty.")
135+
136+
pwc_wf = Constant(values[0], durations[0])
137+
for duration, value in zip(durations[1:], values[1:]):
138+
pwc_wf = pwc_wf.append(Constant(value, duration))
137139

138140
return pwc_wf
139141

@@ -146,7 +148,7 @@ def rydberg_h(
146148
phase: Optional[Waveform] = None,
147149
static_params: Dict[str, Any] = {},
148150
batch_params: Union[List[Dict[str, Any]], Dict[str, Any]] = [],
149-
args: List[str] = [],
151+
args: List[str | Variable] = [],
150152
) -> Routine:
151153
"""Create a rydberg program with uniform detuning, amplitude, and phase.
152154
@@ -181,10 +183,15 @@ def rydberg_h(
181183
prog = prog.rydberg.detuning.uniform.apply(detuning)
182184

183185
if amplitude is not None:
184-
prog = prog.amplitude.uniform.apply(amplitude)
186+
prog = prog.rydberg.rabi.amplitude.uniform.apply(amplitude)
185187

186188
if phase is not None:
187-
prog = prog.phase.uniform.apply(phase)
189+
prog = prog.rydberg.rabi.phase.uniform.apply(phase)
190+
191+
if not isinstance(prog, Assignable):
192+
raise ValueError(
193+
"At least one of detuning, amplitude, or phase must be provided."
194+
)
188195

189196
prog = prog.assign(**static_params)
190197

src/bloqade/analog/task/exclusive.py

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import os
2-
import abc
3-
import uuid
42
import re
3+
import abc
54
import time
5+
import uuid
6+
from dataclasses import field, dataclass
67

8+
from requests import get, request
79
from beartype.typing import Dict
8-
from dataclasses import dataclass, field
910

11+
from bloqade.analog.serialize import Serializer
1012
from bloqade.analog.task.base import Geometry, CustomRemoteTaskABC
1113
from bloqade.analog.builder.typing import ParamType
1214
from bloqade.analog.submission.ir.parallel import ParallelDecoder
@@ -15,8 +17,6 @@
1517
QuEraTaskStatusCode,
1618
)
1719
from bloqade.analog.submission.ir.task_specification import QuEraTaskSpecification
18-
from requests import request, get
19-
from bloqade.analog.serialize import Serializer
2020

2121

2222
class HTTPHandlerABC:
@@ -102,7 +102,7 @@ def submit_task_via_zapier(
102102
else:
103103
print(f"HTTP request failed with status code: {response.status_code}")
104104
print("HTTP responce: ", response.text)
105-
return "Failed"
105+
return "HTTP Request Failed"
106106

107107
def query_task_status(self, task_id: str):
108108
response = request(
@@ -115,21 +115,39 @@ def query_task_status(self, task_id: str):
115115
},
116116
)
117117
if response.status_code != 200:
118-
return "Not Found"
118+
return "HTTP Request Failed."
119119
response_data = response.json()
120120
# Get "matched" from the response
121121
matches = response_data.get("matches", None)
122122
# The return is a list of dictionaries
123123
# Verify if the list contains only one element
124124
if matches is None:
125125
print("No task found with the given ID.")
126-
return "Failed"
126+
return "Task searching Failed"
127127
elif len(matches) > 1:
128128
print("Multiple tasks found with the given ID.")
129-
return "Failed"
129+
return "Task searching Failed"
130+
131+
record = matches[0]
130132

131133
# Extract the status from the first dictionary
132-
status = matches[0].get("status")
134+
status = record.get("status")
135+
136+
if status == "Failed validation":
137+
googledoc = record.get("resultsFileUrl")
138+
139+
# convert the preview URL to download URL
140+
googledoc = convert_preview_to_download(googledoc)
141+
res = get(googledoc)
142+
res.raise_for_status()
143+
data = res.json()
144+
# get the "statusCode" and "message" from the data and print them out.
145+
status_code = data.get("statusCode", "NA")
146+
message = data.get("message", "NA")
147+
print(
148+
f"Task validation failed with status code: {status_code}, message: {message}"
149+
)
150+
133151
return status
134152

135153
def fetch_results(self, task_id: str):
@@ -283,7 +301,10 @@ def status(self) -> QuEraTaskStatusCode:
283301
return QuEraTaskStatusCode.Unsubmitted
284302
res = self._http_handler.query_task_status(self._task_id)
285303
if res == "Failed":
286-
raise ValueError("Query task status failed.")
304+
return QuEraTaskStatusCode.Failed
305+
elif res == "Failed validation":
306+
307+
return QuEraTaskStatusCode.Failed
287308
elif res == "Submitted":
288309
return QuEraTaskStatusCode.Enqueued
289310
# TODO: please add all possible status

0 commit comments

Comments
 (0)