diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000000..e69de29bb2 diff --git a/dev/404.html b/dev/404.html new file mode 100644 index 0000000000..59b3194885 --- /dev/null +++ b/dev/404.html @@ -0,0 +1 @@ +
Our development environment contains a set of tools we use for development, testing, and documentation. This section describes how to set up the development environment. We primarily use pdm to manage python environments and dependencies.
We use pdm to manage dependencies and virtual environment. After cloning the repository, run the following command to install dependencies:
You can also install different dependency groups:
You can run tests via
Or run tests and generate coverage via
You can build documentation via
Or run a local server to preview documentation via
You can sync jupyter notebooks and python scripts via
this will help you development examples in jupyter notebook and python scripts simultaneously.
We primarily use ruff - an extremely fast linter for Python, and black as formatter. These has been configured into pre-commit hooks. You can install pre-commit hooks to git via
from bloqade import start, cast
+from bloqade.task import HardwareBatchResult
+
+import os
+import numpy as np
+
+from bokeh.io import output_notebook
+from bokeh.plotting import figure, show
+from bokeh.models import HoverTool, ColumnDataSource, CrosshairTool
+
+output_notebook()
+
define program with one atom, with constant detuning but variable Rabi frequency, ramping up to "rabi_value" and then returning to 0.0.
durations = cast(["ramp_time", "run_time", "ramp_time"])
+
+rabi_oscillations_program = (
+ start.add_position((0, 0))
+ .rydberg.rabi.amplitude.uniform.piecewise_linear(
+ durations=durations, values=[0, "rabi_value", "rabi_value", 0]
+ )
+ .detuning.uniform.constant(duration=sum(durations), value=0)
+)
+
Assign values to the variables in the program, allowing the run_time
(time the Rabi amplitude stays at the value of "rabi_frequency" ) to sweep across a range of values.
rabi_oscillation_job = rabi_oscillations_program.assign(
+ ramp_time=0.06, rabi_value=15, detuning_value=0.0
+).batch_assign(run_time=np.around(np.arange(0, 21, 1) * 0.05, 13))
+
Run the program in emulation, obtaining a report object. For each possible set of variable values to simulate (in this case, centered around the run_time
variable), let the task have 10000 shots.
emu_report = rabi_oscillation_job.braket_local_simulator(10000).submit().report()
+
Submit the same program to hardware, this time using .parallelize
to make a copy of the original geometry (a single atom) that fills the FOV (Field-of-View Space), with at least 24 micrometers of distance between each atom.
Unlike the emulation above, we only let each task run with 100 shots. A collection of tasks is known as a "Job" in Bloqade and jobs can be saved in JSON format so you can reload them later (a necessity considering how long it may take for the machine to handle tasks in the queue)
"""
+(
+ rabi_oscillation_job.parallelize(24)
+ .braket(100)
+ .submit()
+ .save_json("rabi-job.json")
+)
+"""
+
'\n(\n rabi_oscillation_job.parallelize(24)\n .braket(100)\n .submit()\n .save_json("rabi-job.json")\n)\n'
Load JSON and pull results from Braket
hw_future = HardwareBatchResult.load_json(
+ os.getcwd() + "/docs/docs/examples/" + "rabi-job.json"
+)
+hw_rydberg_densities = hw_future.report().rydberg_densities()
+
We can now plot the results from the hardware and emulation together.
data = {
+ "times": np.around(np.arange(0, 21, 1) * 0.05, 13),
+ "emu_densities": emu_report.rydberg_densities()[0].to_list(),
+ "hw_densities": hw_rydberg_densities[0].to_list(),
+}
+source = ColumnDataSource(data=data)
+
+p = figure(
+ x_axis_label="Time (μs)",
+ y_axis_label="Rydberg Density",
+ toolbar_location="right",
+ tools=["pan,wheel_zoom,box_zoom,reset,save"],
+)
+
+p.axis.axis_label_text_font_size = "15pt"
+p.axis.major_label_text_font_size = "10pt"
+
+emu_line = p.line(
+ x="times",
+ y="emu_densities",
+ source=source,
+ legend_label="Emulator",
+ color="grey",
+ line_width=2,
+)
+p.circle(x="times", y="emu_densities", source=source, color="grey", size=8)
+# hardware densities
+hw_line = p.line(
+ x="times",
+ y="hw_densities",
+ source=source,
+ legend_label="Hardware",
+ color="purple",
+ line_width=2,
+)
+p.circle(x="times", y="hw_densities", source=source, color="purple", size=8)
+
+hw_hover_tool = HoverTool(
+ renderers=[hw_line],
+ tooltips=[
+ ("Backend", "Hardware"),
+ ("Density", "@hw_densities"),
+ ("Time", "@times μs"),
+ ],
+ mode="vline",
+ attachment="right",
+)
+p.add_tools(hw_hover_tool)
+emu_hover_tool = HoverTool(
+ renderers=[emu_line],
+ tooltips=[
+ ("Backend", "Emulator"),
+ ("Density", "@emu_densities"),
+ ("Time", "@times μs"),
+ ],
+ mode="vline",
+ attachment="left",
+)
+p.add_tools(emu_hover_tool)
+cross_hair_tool = CrosshairTool(dimensions="height")
+p.add_tools(cross_hair_tool)
+
+show(p)
+
For full documentation visit mkdocs.org.
mkdocs new [dir-name]
- Create a new project.mkdocs serve
- Start the live-reloading docs server.mkdocs build
- Build the documentation site.mkdocs -h
- Print help message and exit.mkdocs.yml # The configuration file.
+docs/
+ index.md # The documentation homepage.
+ ... # Other markdown pages, images and other files.
+
Bases: LevelCoupling
This node represent level coupling between hyperfine state.
Examples:
Bases: Builder
property
¶Possible Next:
-> ...detuning.location(int)
:: Address atom at specific location
-> ...detuning.uniform
:: Address all atoms in register
-> ...detuning.var(str)
:: Address atom at location labeled by variable
property
¶Possible Next:
-> ...rabi.amplitude
:: address rabi amplitude
-> ...rabi.phase
:: address rabi phase
Bases: LevelCoupling
This node represent level coupling of rydberg state.
Examples:
Bases: Builder
src/bloqade/builder/emit.py
property
¶property
¶Get the register
from the current builder.
Returns:
Type | Description |
---|---|
Union[AtomArrangement, ParallelRegister] | register (Union["AtomArrangement", "ParallelRegister"]) |
If the program is built with parallelize()
, The the register will be a ParallelRegister
. Otherwise it will be a AtomArrangement
.
property
¶Get the sequence
from the current builder.
Returns:
Type | Description |
---|---|
sequence (Sequence) |
Assign values to variables declared previously in the program.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
assignments | Dict[str, Union[Number]] | {} |
Examples:
>>> reg = bloqade.start
+... .add_positions([(0,0),(1,1),(2,2),(3,3)])
+>>> seq = reg.rydberg.detuning.uniform
+... .linear(start="ival",stop=1,duration="span_time")
+>>> seq = seq.assign(span_time = 0.5, ival = 0.0)
+
src/bloqade/builder/emit.py
Assign values to variables declared previously in the program for launching batch jobs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
batch | Dict[str, Union[Number]] | The batch assignments of variables, | {} |
Examples:
>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])
+>>> seq = reg.rydberg.detuning.uniform
+... .linear(start="ival",stop=1,duration="span_time")
+>>> job = seq.batch_assign(span_time = [0.6,0.8], ival = [0.0,0.5]).mock(10)
+
the length of the lists of values should be the same for each variable.
src/bloqade/builder/emit.py
Compile the current builder to a Amazon braket HardwareBatchTask
, which can be submit to run on QPU through braket service.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nshots | int | The number of shots to run. | required |
Returns:
Type | Description |
---|---|
HardwareBatchTask | HardwareBatchTask |
src/bloqade/builder/emit.py
Compile the current builder to a BraketEmulatorBatchTask
, which can be submit to run on braket local simulator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nshots | int | The number of shots to run. | required |
Returns:
Type | Description |
---|---|
BraketEmulatorJob |
src/bloqade/builder/emit.py
Compile the current builder to a Dummy mock HardwareBatchTask
, which can be used for testing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nshots | int | The number of shots to run. | required |
state_file | str | The file to store the state of the mock backend. | '.mock_state.txt' |
Returns:
Type | Description |
---|---|
HardwareBatchTask | HardwareBatchTask |
src/bloqade/builder/emit.py
Parallelize the current problem (register & sequnece) to fill entire FOV with the given cluster spacing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cluster_spacing | Any, should be Real | required |
Examples:
>>> prob = (
+ bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])
+ .rydberg.detuning.uniform
+ .linear(start=0,stop=1,duration=1)
+ )
+>>> prob = prob.parallelize(7.2)
+
src/bloqade/builder/emit.py
Compile the current builder to a QuEra HardwareBatchTask
, which can be submit to run on QPU through QuEra service.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nshots | int | The number of shots to run. | required |
config_file | Optional[str] | The path to the config file. | None |
api_config | Dict[str, Any] | The api config. | {} |
Returns:
Type | Description |
---|---|
HardwareBatchTask | HardwareBatchTask |
src/bloqade/builder/emit.py
Bases: SpatialModulation
This node represent amplitude of a rabi field.
Examples:
>>> node = bloqade.start.rydberg.rabi.amplitude
+>>> type(node)
+<class 'bloqade.builder.field.Amplitude'>
+
>>> node = bloqade.start.hyperfine.rabi.amplitude
+>>> type(node)
+<class 'bloqade.builder.field.Amplitude'>
+
This node is a SpatialModulation node. See SpatialModulation
for additional options.
Bases: SpatialModulation
This node represent detuning field of a specified level coupling (rydberg or hyperfine) type.
Examples:
>>> node = bloqade.start.rydberg.detuning
+>>> type(node)
+<class 'bloqade.builder.field.Detuning'>
+
>>> node = bloqade.start.hyperfine.detuning
+>>> type(node)
+<class 'bloqade.builder.field.Detuning'>
+
This node is a SpatialModulation node. See SpatialModulation
for additional options.
Bases: SpatialModulation
This node represent phase of a rabi field.
Examples:
>>> node = bloqade.start.rydberg.rabi.phase
+>>> type(node)
+<class 'bloqade.builder.field.Phase'>
+
>>> node = bloqade.start.hyperfine.rabi.phase
+>>> type(node)
+<class 'bloqade.builder.field.Phase'>
+
This node is a SpatialModulation node. See SpatialModulation
for additional options.
Bases: Builder
This node represent rabi field of a specified level coupling (rydberg or hyperfine) type.
Examples:
property
¶Possible Next:
-> ...amplitude.location(int)
:: Address atom at specific location
-> ...amplitude.uniform
:: Address all atoms in register
-> ...amplitude.var(str)
:: Address atom at location labeled by variable
Examples:
Amplitude
)Amplitude
)property
¶Possible Next:
-> ...phase.location(int)
:: Address atom at specific location
-> ...phase.uniform
:: Address all atoms in register
-> ...phase.var(str)
:: Address atom at location labeled by variable
Examples:
Phase
)Phase
) Bases: Waveform
src/bloqade/builder/location.py
Append another location to the current location(s)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
label | int | The label of the location | required |
Examples:
>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])
+>>> loc = reg.rydberg.detuning.location(0)
+>>> loc = loc.location(1)
+
>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])
+>>> loc = reg.rydberg.detuning.location(0)
+>>> loc = loc.location(1).location(2)
+
Possible Next
-> ...location(int).location(int)
:: keep adding location into current list
-> ...location(int).scale(float)
:: specify scaling factor to current location for the preceeding waveform
Possible Next
-> ...location(int).linear()
:: apply linear waveform
-> ...location(int).constant()
:: apply constant waveform
-> ...location(int).ploy()
:: apply polynomial waveform
-> ...location(int).apply()
:: apply pre-constructed waveform
-> ...location(int).piecewise_linear()
:: apply piecewise linear waveform
-> ...location(int).piecewise_constant()
:: apply piecewise constant waveform
-> ...location(int).fn()
:: apply callable as waveform.
src/bloqade/builder/location.py
Scale the preceeding waveform by the specified factor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scale | float | The factor to scale (amplitude of) | required |
Examples:
>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])
+>>> scaled = reg.rydberg.detuning.location(0).scale(1.2)
+
>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])
+>>> loc = reg.rydberg.detuning.location(0)
+>>> loc = loc.scale(1.2).location(1).scale(0.5)
+
>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])
+>>> scaled = reg.rydberg.detuning.location(0).location(1).scale(1.2)
+
Possible Next
-> ...scale(float).location(int)
:: keep adding location into current list
Possible Next
-> ...scale(float).linear()
:: apply linear waveform
-> ...scale(float).constant()
:: apply constant waveform
-> ...scale(float).ploy()
:: apply polynomial waveform
-> ...scale(float).apply()
:: apply pre-constructed waveform(s)
-> ...scale(float).piecewise_linear()
:: apply piecewise linear waveform
-> ...scale(float).piecewise_constant()
:: apply piecewise constant waveform
-> ...scale(float).fn()
:: apply callable as waveform.
src/bloqade/builder/location.py
Bases: Waveform
src/bloqade/builder/location.py
Parameters:
Name | Type | Description | Default |
---|---|---|---|
label | int | The label of the location | required |
Examples:
>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])
+>>> loc = reg.rydberg.detuning.location(0).scale(1.2)
+>>> loc = loc.location(1)
+
Possible Next
-> ...location(int).location(int)
:: keep adding location into current list
-> ...location(int).scale(float)
:: specify scaling factor to current location for the preceeding waveform
Possible Next
-> ...location(int).linear()
:: apply linear waveform
-> ...location(int).constant()
:: apply constant waveform
-> ...location(int).ploy()
:: apply polynomial waveform
-> ...location(int).apply()
:: apply pre-constructed waveform
-> ...location(int).piecewise_linear()
:: apply piecewise linear waveform
-> ...location(int).piecewise_constant()
:: apply piecewise constant waveform
-> ...location(int).fn()
:: apply callable as waveform.
src/bloqade/builder/location.py
Bases: Waveform
The node specify a uniform spacial modulation. Which is ready to apply waveform (See Waveform
for available waveform options)
Examples:
>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])
+>>> loc = reg.rydberg.detuning.uniform
+
Bases: Builder
SpatialModulation specifies which atom(s) should be addressed to apply the preceeding waveform ((See Waveform
for available waveforms onward)
property
¶Possible Next:
-> ...uniform.linear()
:: apply linear waveform
-> ...uniform.constant()
:: apply constant waveform
-> ...uniform.ploy()
:: apply polynomial waveform
-> ...uniform.apply()
:: apply pre-constructed waveform
-> ...uniform.piecewise_linear()
:: apply piecewise linear waveform
-> ...uniform.piecewise_constant()
:: apply piecewise constant waveform
-> ...uniform.fn()
:: apply callable as waveform.
Examples:
Addressing one or multiple specific location(s) for preceeding waveform.
(See Location
for more details])
Parameters:
Name | Type | Description | Default |
---|---|---|---|
label | int | The label of the location to apply the following waveform to. | required |
Examples:
>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])
+>>> loc = reg.rydberg.detuning.location(1)
+
>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])
+>>> loc = reg.rydberg.detuning.location(1).location(2)
+
label index start with 0, and should be positive.
Possible Next
-> ...location(int).location(int)
:: adding location into current list
-> ...location(int).scale(float)
:: specify scaling factor to current location for the preceeding waveform
Possible Next
-> ...location(int).linear()
:: apply linear waveform
-> ...location(int).constant()
:: apply constant waveform
-> ...location(int).ploy()
:: apply polynomial waveform
-> ...location(int).apply()
:: apply pre-constructed waveform
-> ...location(int).piecewise_linear()
:: apply piecewise linear waveform
-> ...location(int).piecewise_constant()
:: apply piecewise constant waveform
-> ...location(int).fn()
:: apply callable as waveform.
src/bloqade/builder/spatial.py
Possible Next
-> ...location(int).linear()
:: apply linear waveform
-> ...location(int).constant()
:: apply constant waveform
-> ...location(int).ploy()
:: apply polynomial waveform
-> ...location(int).apply()
:: apply pre-constructed waveform
-> ...location(int).piecewise_linear()
:: apply piecewise linear waveform
-> ...location(int).piecewise_constant()
:: apply piecewise constant waveform
-> ...location(int).fn()
:: apply callable as waveform.
Examples:
myatom
in the system with 4 sites>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])
+>>> loc = reg.rydberg.detuning.var('myatom')
+
src/bloqade/builder/spatial.py
Bases: Builder
ProgramStart is the base class for a starting/entry node for building a program.
property
¶Possible Next:
-> ...hyperfine.rabi
:: address rabi term
-> ...hyperfine.detuning
:: address detuning field
Examples:
Hyperfine level coupling have two reachable field nodes:
See Hyperfine for more details.
property
¶Possible Next:
-> ...rydberg.rabi
:: address rabi term
-> ...rydberg.detuning
:: address detuning field
Examples:
Rydberg level coupling have two reachable field nodes:
See Rydberg
for more details.
apply an existing pulse sequence to the program.
src/bloqade/builder/start.py
Record the value of the current waveform to a variable.
Possible Next:
Possible Next
-> .location(int)
:: creating new channel to address another location(s)
Possible Next
-> .slice()
:: slice the current waveform
-> .record(str)
:: record the value of waveform at current time
Possible Next
:: Append waveform into current channel
-> .linear()
-> .constant()
-> .ploy()
-> .apply()
-> .piecewise_linear()
-> .piecewise_constant()
-> .fn()
Possible Next
-> .rydberg
:: Create/Switch to new rydberg level coupling channel
-> .hyperfine
:: Create/Switch to new hyperfine level coupling channel
Possible Next
-> .assign()
:: assign varialbe an actual value/number
-> .batch_assign()
:: create batch job with different sets of values assign to each variable.
Possible Next
-> .quera()
:: Compile current program to QuEra job
-> .braket()
:: Compile current program to Amazon Braket job
-> .braket_local_simulator()
:: Compile current program to local simulator job
src/bloqade/builder/waveform.py
701 +702 +703 +704 +705 +706 +707 +708 +709 +710 +711 +712 +713 +714 +715 +716 +717 +718 +719 +720 +721 +722 +723 +724 +725 +726 +727 +728 +729 +730 +731 +732 +733 +734 +735 +736 +737 +738 +739 +740 +741 +742 +743 +744 +745 +746 +747 +748 +749 +750 +751 +752 +753 +754 +755 +756 +757 +758 +759 +760 +761 +762 +763 +764 +765 +766 +767 +768 +769 |
|
Slice current waveform
Possible Next:
Possible Next
-> .location(int)
:: creating new channel to address another location(s)
Possible Next
-> .record(str)
:: record the value of waveform at current time
Possible Next
:: Append waveform into current channel
-> .linear()
-> .constant()
-> .ploy()
-> .apply()
-> .piecewise_linear()
-> .piecewise_constant()
-> .fn()
Possible Next
-> .rydberg
:: Create/Switch to new rydberg level coupling channel
-> .hyperfine
:: Create/Switch to new hyperfine level coupling channel
Possible Next
-> .assign()
:: assign varialbe an actual value/number
-> .batch_assign()
:: create batch job with different sets of values assign to each variable.
Possible Next
-> .quera()
:: Compile current program to QuEra job
-> .braket()
:: Compile current program to Amazon Braket job
-> .braket_local_simulator()
:: Compile current program to local simulator job
src/bloqade/builder/waveform.py
630 +631 +632 +633 +634 +635 +636 +637 +638 +639 +640 +641 +642 +643 +644 +645 +646 +647 +648 +649 +650 +651 +652 +653 +654 +655 +656 +657 +658 +659 +660 +661 +662 +663 +664 +665 +666 +667 +668 +669 +670 +671 +672 +673 +674 +675 +676 +677 +678 +679 +680 +681 +682 +683 +684 +685 +686 +687 +688 +689 +690 +691 +692 +693 +694 +695 +696 +697 |
|
Bases: Builder
Apply a pre-defined waveform to the current location.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wf | ir.Waveform | the waveform | required |
Examples:
>>> node = bloqade.start.rydberg.detuning.uniform
+>>> wv = bloqade.ir.Linear(0,10,0.5)
+>>> node = node.apply(wv)
+
Possible Next:
Possible Next
-> .location(int)
:: creating new channel to address another location(s)
Possible Next
-> .slice()
:: slice current waveform
-> .record(str)
:: record the value of waveform at current time
Possible Next
:: Append waveform into current channel
-> .linear()
-> .constant()
-> .ploy()
-> .apply()
-> .piecewise_linear()
-> .piecewise_constant()
-> .fn()
Possible Next
-> .rydberg
:: Create/Switch to new rydberg level coupling channel
-> .hyperfine
:: Create/Switch to new hyperfine level coupling channel
Possible Next
-> .assign()
:: assign varialbe an actual value/number
-> .batch_assign()
:: create batch job with different sets of values assign to each variable.
Possible Next
-> .quera()
:: Compile current program to QuEra job
-> .braket()
:: Compile current program to Amazon Braket job
-> .braket_local_simulator()
:: Compile current program to local simulator job
src/bloqade/builder/waveform.py
256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 |
|
Append/assign a constant waveform to the current location.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value | ScalarType Union[float, str] | The value of the waveform | required |
duration | ScalarType Union[float, str] | The duration of the waveform | required |
Examples:
Possible Next:
Possible Next
-> .location(int)
:: creating new channel to address another location(s)
Possible Next
-> .slice()
:: slice current waveform
-> .record(str)
:: record the value of waveform at current time
Possible Next
:: Append waveform into current channel
-> .linear()
-> .constant()
-> .ploy()
-> .apply()
-> .piecewise_linear()
-> .piecewise_constant()
-> .fn()
Possible Next
-> .rydberg
:: Create/Switch to new rydberg level coupling channel
-> .hyperfine
:: Create/Switch to new hyperfine level coupling channel
Possible Next
-> .assign()
:: assign varialbe an actual value/number
-> .batch_assign()
:: create batch job with different sets of values assign to each variable.
Possible Next
-> .quera()
:: Compile current program to QuEra job
-> .braket()
:: Compile current program to Amazon Braket job
-> .braket_local_simulator()
:: Compile current program to local simulator job
src/bloqade/builder/waveform.py
90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 |
|
Append/assign a waveform defined by a python function to the current location.
This function create a waveform with user-defined python function fn(t)
with duration duration
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fn | Callable | The python function defining the waveform | required |
duration | ScalarType | The durations of each constant segment | required |
t
and return a float.Examples:
>>> import numpy as np
+>>> def my_fn(t):
+>>> return np.cos(2*np.pi*t)
+>>> node = bloqade.start.rydberg.detuning.uniform
+>>> node = node.fn(my_fn,duration=0.5)
+
Possible Next:
Possible Next
-> .location(int)
:: creating new channel to address another location(s)
Possible Next
-> .slice()
:: slice current waveform
-> .record(str)
:: record the value of waveform at current time
-> .sample()
:: sample current callable at given time points
Possible Next
:: Append waveform into current channel
-> .linear()
-> .constant()
-> .ploy()
-> .apply()
-> .piecewise_linear()
-> .piecewise_constant()
-> .fn()
Possible Next
-> .rydberg
:: Create/Switch to new rydberg level coupling channel
-> .hyperfine
:: Create/Switch to new hyperfine level coupling channel
Possible Next
-> .assign()
:: assign varialbe an actual value/number
-> .batch_assign()
:: create batch job with different sets of values assign to each variable.
Possible Next
-> .quera()
:: Compile current program to QuEra job
-> .braket()
:: Compile current program to Amazon Braket job
-> .braket_local_simulator()
:: Compile current program to local simulator job
src/bloqade/builder/waveform.py
527 +528 +529 +530 +531 +532 +533 +534 +535 +536 +537 +538 +539 +540 +541 +542 +543 +544 +545 +546 +547 +548 +549 +550 +551 +552 +553 +554 +555 +556 +557 +558 +559 +560 +561 +562 +563 +564 +565 +566 +567 +568 +569 +570 +571 +572 +573 +574 +575 +576 +577 +578 +579 +580 +581 +582 +583 +584 +585 +586 +587 +588 +589 +590 +591 +592 +593 +594 +595 +596 +597 +598 +599 +600 +601 +602 +603 +604 +605 +606 +607 +608 +609 +610 +611 +612 +613 +614 +615 +616 +617 +618 +619 +620 +621 +622 |
|
Append/assign a linear waveform to the current location.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start | ScalarType Union[float, str] | The start value of the waveform | required |
stop | ScalarType Union[float, str] | The stop value of the waveform | required |
duration | ScalarType Union[float, str] | The duration of the waveform | required |
Examples:
>>> node = bloqade.start.rydberg.detuning.uniform
+>>> node = node.linear(start=0,stop=1,duration=0.5)
+
Possible Next:
Possible Next
-> .location(int)
:: creating new channel to address another location(s)
Possible Next
-> .slice()
:: slice current waveform
-> .record(str)
:: record the value of waveform at current time
Possible Next
:: Append waveform into current channel
-> .linear()
-> .constant()
-> .ploy()
-> .apply()
-> .piecewise_linear()
-> .piecewise_constant()
-> .fn()
Possible Next
-> .rydberg
:: Create/Switch to new rydberg level coupling channel
-> .hyperfine
:: Create/Switch to new hyperfine level coupling channel
Possible Next
-> .assign()
:: assign varialbe an actual value/number
-> .batch_assign()
:: create batch job with different sets of values assign to each variable.
Possible Next
-> .quera()
:: Compile current program to QuEra job
-> .braket()
:: Compile current program to Amazon Braket job
-> .braket_local_simulator()
:: Compile current program to local simulator job
src/bloqade/builder/waveform.py
10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 |
|
Append/assign a piecewise constant waveform to the current location. The durations should have number of elements = len(values).
This function create a waveform of piecewise_constant of values[i]
with duration durations[i]
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
durations | List[ScalarType] | The durations of each constant segment | required |
values | List[ScalarType] | The values of each constant segment | required |
ScalarType can be either float or str.
Examples:
>>> node = bloqade.start.rydberg.detuning.uniform
+>>> node = node.piecewise_constant(values=[0.5,1.5],durations=[0.1,3.8])
+
Possible Next:
Possible Next
-> .location(int)
:: creating new channel to address another location(s)
Possible Next
-> .slice()
:: slice current waveform
-> .record(str)
:: record the value of waveform at current time
Possible Next
:: Append waveform into current channel
-> .linear()
-> .constant()
-> .ploy()
-> .apply()
-> .piecewise_linear()
-> .piecewise_constant()
-> .fn()
Possible Next
-> .rydberg
:: Create/Switch to new rydberg level coupling channel
-> .hyperfine
:: Create/Switch to new hyperfine level coupling channel
Possible Next
-> .assign()
:: assign varialbe an actual value/number
-> .batch_assign()
:: create batch job with different sets of values assign to each variable.
Possible Next
-> .quera()
:: Compile current program to QuEra job
-> .braket()
:: Compile current program to Amazon Braket job
-> .braket_local_simulator()
:: Compile current program to local simulator job
src/bloqade/builder/waveform.py
431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 +498 +499 +500 +501 +502 +503 +504 +505 +506 +507 +508 +509 +510 +511 +512 +513 +514 +515 +516 +517 +518 +519 +520 +521 +522 +523 +524 +525 |
|
Append/assign a piecewise linear waveform to the current location. The durations should have number of elements = len(values) - 1.
This function create a waveform by connecting values[i], values[i+1]
with linear segments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
durations | List[ScalarType] | The durations of each linear segment | required |
values | List[ScalarType] | The values of each linear segment | required |
Examples:
>>> node = bloqade.start.rydberg.detuning.uniform
+>>> node = node.piecewise_linear(values=[0,1,1,0],durations=[0.1,3.8,0.1])
+
ScalarType can be either float or str.
Possible Next:
Possible Next
-> .location(int)
:: creating new channel to address another location(s)
Possible Next
-> .slice()
:: slice current waveform
-> .record(str)
:: record the value of waveform at current time
Possible Next
:: Append waveform into current channel
-> .linear()
-> .constant()
-> .ploy()
-> .apply()
-> .piecewise_linear()
-> .piecewise_constant()
-> .fn()
Possible Next
-> .rydberg
:: Create/Switch to new rydberg level coupling channel
-> .hyperfine
:: Create/Switch to new hyperfine level coupling channel
Possible Next
-> .assign()
:: assign varialbe an actual value/number
-> .batch_assign()
:: create batch job with different sets of values assign to each variable.
Possible Next
-> .quera()
:: Compile current program to QuEra job
-> .braket()
:: Compile current program to Amazon Braket job
-> .braket_local_simulator()
:: Compile current program to local simulator job
src/bloqade/builder/waveform.py
337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 |
|
Append/assign a waveform with polynomial profile to the current location.
wv(t) = coeffs[0] + coeffs[1]*t + coeffs[2]*t^2 + ... + coeffs[n]*t^n
Parameters:
Name | Type | Description | Default |
---|---|---|---|
coeffs | ScalarType Union[float, str] | The coefficients of the polynomial | required |
duration | ScalarType Union[float, str] | The duration of the waveform | required |
Examples:
>>> node = bloqade.start.rydberg.detuning.uniform
+>>> node = node.poly(coeffs=[1,2,3],duration=0.5)
+
Possible Next:
Possible Next
-> .location(int)
:: creating new channel to address another location(s)
Possible Next
-> .slice()
:: slice current waveform
-> .record(str)
:: record the value of waveform at current time
Possible Next
:: Append waveform into current channel
-> .linear()
-> .constant()
-> .ploy()
-> .apply()
-> .piecewise_linear()
-> .piecewise_constant()
-> .fn()
Possible Next
-> .rydberg
:: Create/Switch to new rydberg level coupling channel
-> .hyperfine
:: Create/Switch to new hyperfine level coupling channel
Possible Next
-> .assign()
:: assign varialbe an actual value/number
-> .batch_assign()
:: create batch job with different sets of values assign to each variable.
Possible Next
-> .quera()
:: Compile current program to QuEra job
-> .braket()
:: Compile current program to Amazon Braket job
-> .braket_local_simulator()
:: Compile current program to local simulator job
src/bloqade/builder/waveform.py
171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 |
|
module-attribute
¶Possible Next
-> start.rydberg
:: address rydberg level coupling
-> start.hyperfine
:: address hyperfine level coupling
Possible Next
-> start.add_locations(List[Tuple[int]])
:: add multiple atoms to current register
-> start.add_location(Tuple[int])
:: add atom to current register
Bases: Real
class-attribute
¶Scalar Literal, which stores a decimaal value instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value | Decimal | decimal value instance | required |
Bases: Real
Variable, which stores a variable name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | variable instance. | required |
cast Real number (or list/tuple of Real numbers) to Scalar Literal
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
py | Union[Real, Tuple[Real], List[Real]] | python object to cast | required |
Returns:
Type | Description |
---|---|
Any | Union[Literal,Tuple[Literal],List[Literal]] |
src/bloqade/ir/scalar.py
cast string (or list/tuple of strings) to Variable
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
py | Union[str, List[str], Tuple[str]] | a string or list/tuple of strings | required |
Returns:
Type | Description |
---|---|
Any | Union[Variable, List[Variable], Tuple[Variable]] |
src/bloqade/ir/scalar.py
Bases: SequenceExpr
Sequence of a program, which includes pulses informations.
src/bloqade/ir/control/sequence.py
Bases: Waveform
<padded waveform> ::= <waveform> | <waveform> <alignment> <value>
+
+<alignment> ::= 'left aligned' | 'right aligned'
+<value> ::= 'left value' | 'right value' | <scalar expr>
+
Bases: Instruction
f(t=0:duration) = value
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value | Scalar | the constant value | required |
duration | Scalar | the time span of the constant waveform. | required |
src/bloqade/ir/control/waveform.py
Bases: Instruction
f(t=0:duration) = start + (stop-start)/duration * t
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start | Scalar | start value | required |
stop | Scalar | stop value | required |
duration | Scalar | the time span of the linear waveform. | required |
src/bloqade/ir/control/waveform.py
Bases: Instruction
f(t=0:duration) = c[0] + c[1]t + c[2]t^2 + ... + c[n-1]t^n-1 + c[n]t^n
Parameters:
Name | Type | Description | Default |
---|---|---|---|
checkpoints | List[Scalar] | the coefficients c[] of the polynomial. | required |
duration | Scalar | the time span of the waveform. | required |
src/bloqade/ir/control/waveform.py
Bases: Instruction
src/bloqade/ir/control/waveform.py
Waveform node in the IR.
<waveform> ::= <instruction>
+ | <smooth>
+ | <slice>
+ | <append>
+ | <negative>
+ | <scale>
+ | <add>
+ | <record>
+ | <sample>
+
Plot the waveform.
Returns:
Name | Type | Description |
---|---|---|
figure | a bokeh figure |
src/bloqade/ir/control/waveform.py
Bases: Waveform
<padded waveform> ::= <waveform> | <waveform> <alignment> <value>
+
+<alignment> ::= 'left aligned' | 'right aligned'
+<value> ::= 'left value' | 'right value' | <scalar expr>
+
Bases: Instruction
f(t=0:duration) = value
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value | Scalar | the constant value | required |
duration | Scalar | the time span of the constant waveform. | required |
src/bloqade/ir/control/waveform.py
Bases: Instruction
f(t=0:duration) = start + (stop-start)/duration * t
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start | Scalar | start value | required |
stop | Scalar | stop value | required |
duration | Scalar | the time span of the linear waveform. | required |
src/bloqade/ir/control/waveform.py
Bases: Real
class-attribute
¶Scalar Literal, which stores a decimaal value instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value | Decimal | decimal value instance | required |
Bases: Instruction
f(t=0:duration) = c[0] + c[1]t + c[2]t^2 + ... + c[n-1]t^n-1 + c[n]t^n
Parameters:
Name | Type | Description | Default |
---|---|---|---|
checkpoints | List[Scalar] | the coefficients c[] of the polynomial. | required |
duration | Scalar | the time span of the waveform. | required |
src/bloqade/ir/control/waveform.py
Program is a dummy type that bundle register and sequence together.
src/bloqade/ir/program.py
property
¶Get the register of the program.
Returns:
Type | Description |
---|---|
register (Union["AtomArrangement", "ParallelRegister"]) |
If the program is built with parallelize()
, The the register will be a ParallelRegister
. Otherwise it will be a AtomArrangement
.
Bases: Instruction
src/bloqade/ir/control/waveform.py
Base class for all scalar expressions.
<scalar> ::= <literal>
+| <variable>
+| <default>
+| <negative>
+| <add>
+| <mul>
+| <min>
+| <max>
+| <slice>
+| <inverval>
+
+<mul> ::= <scalar> '*' <scalar>
+<add> ::= <scalar> '+' <scalar>
+<min> ::= 'min' <scalar>+
+<max> ::= 'max' <scalar>+
+<slice> ::= <scalar expr> '[' <interval> ']'
+<interval> ::= <scalar expr> '..' <scalar expr>
+<real> ::= <literal> | <var>
+
Bases: SequenceExpr
Sequence of a program, which includes pulses informations.
src/bloqade/ir/control/sequence.py
Bases: Real
Variable, which stores a variable name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | variable instance. | required |
Waveform node in the IR.
<waveform> ::= <instruction>
+ | <smooth>
+ | <slice>
+ | <append>
+ | <negative>
+ | <scale>
+ | <add>
+ | <record>
+ | <sample>
+
Plot the waveform.
Returns:
Name | Type | Description |
---|---|---|
figure | a bokeh figure |
src/bloqade/ir/control/waveform.py
cast Real number (or list/tuple of Real numbers) to Scalar Literal
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
py | Union[Real, Tuple[Real], List[Real]] | python object to cast | required |
Returns:
Type | Description |
---|---|
Any | Union[Literal,Tuple[Literal],List[Literal]] |
src/bloqade/ir/scalar.py
cast string (or list/tuple of strings) to Variable
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
py | Union[str, List[str], Tuple[str]] | a string or list/tuple of strings | required |
Returns:
Type | Description |
---|---|
Any | Union[Variable, List[Variable], Tuple[Variable]] |
src/bloqade/ir/scalar.py
Bases: ProgramStart
src/bloqade/ir/location/base.py
add a position to existing atom arrangement.
src/bloqade/ir/location/base.py
add a list of positions to existing atom arrangement.
src/bloqade/ir/location/base.py
apply n_defects randomly to existing atom arrangement.
src/bloqade/ir/location/base.py
apply defect_probability randomly to existing atom arrangement.
src/bloqade/ir/location/base.py
obtain a figure object from the atom arrangement.
src/bloqade/ir/location/base.py
46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 |
|
scale the atom arrangement with a given factor
src/bloqade/ir/location/base.py
Bases: ProgramStart
Parallel Register
src/bloqade/ir/location/base.py
Bases: AtomArrangement
Base classe for Bravais lattices AtomArrangement
.
src/bloqade/ir/location/bravais.py
property
¶number of atoms
Returns:
Name | Type | Description |
---|---|---|
int | number of atoms in the lattice |
property
¶dimension of the lattice
Returns:
Name | Type | Description |
---|---|---|
int | dimension of the lattice |
calculate the coordinates of a cell in the lattice given the cell index.
src/bloqade/ir/location/bravais.py
Scale the current location with a factor.
(x,y) -> factor*(x,y)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
factor | float | Scalar | scale factor | required |
Returns:
Name | Type | Description |
---|---|---|
BoundedBravais | BoundedBravais | The lattice with the scaled locations |
src/bloqade/ir/location/bravais.py
Bases: BoundedBravais
Chain lattice.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
L | int | number of sites in the chain | required |
lattice_spacing | Scalar, Real | lattice spacing. Defaults to 1.0. | 1.0 |
.
to see possible next step in auto-prompt supported setting (IPython, IDE ...)src/bloqade/ir/location/bravais.py
Bases: BoundedBravais
Honeycomb lattice.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
L | int | number of sites in linear direction. n_atoms = L * L * 2. | required |
lattice_spacing | Scalar, Real | lattice spacing. Defaults to 1.0. | 1.0 |
.
to see possible next step in auto-prompt supported setting (IPython, IDE ...)src/bloqade/ir/location/bravais.py
Bases: BoundedBravais
Kagome lattice.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
L | int | number of sites in linear direction. n_atoms = L * L. | required |
lattice_spacing | Scalar, Real | lattice spacing. Defaults to 1.0. | 1.0 |
.
to see possible next step in auto-prompt supported setting (IPython, IDE ...)src/bloqade/ir/location/bravais.py
Bases: BoundedBravais
Lieb lattice.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
L | int | number of sites in linear direction. n_atoms = L * L. | required |
lattice_spacing | Scalar, Real | lattice spacing. Defaults to 1.0. | 1.0 |
.
to see possible next step in auto-prompt supported setting (IPython, IDE ...)src/bloqade/ir/location/bravais.py
Bases: BoundedBravais
Rectangular lattice.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
width | int | number of sites in x direction. | required |
height | int | number of sites in y direction. | required |
lattice_spacing_x | Scalar, Real | lattice spacing. Defaults to 1.0. | 1.0 |
lattice_spacing_y | Scalar, Real | lattice spacing in y direction. optional. | None |
.
to see possible next step in auto-prompt supported setting (IPython, IDE ...)src/bloqade/ir/location/bravais.py
Bases: BoundedBravais
Square lattice.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
L | int | number of sites in linear direction. n_atoms = L * L. | required |
lattice_spacing | Scalar, Real | lattice spacing. Defaults to 1.0. | 1.0 |
.
to see possible next step in auto-prompt supported setting (IPython, IDE ...)src/bloqade/ir/location/bravais.py
Bases: BoundedBravais
Triangular lattice.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
L | int | number of sites in linear direction. n_atoms = L * L. | required |
lattice_spacing | Scalar, Real | lattice spacing. Defaults to 1.0. | 1.0 |
.
to see possible next step in auto-prompt supported setting (IPython, IDE ...)src/bloqade/ir/location/bravais.py
module-attribute
¶Possible Next
-> start.rydberg
:: address rydberg level coupling
-> start.hyperfine
:: address hyperfine level coupling
Possible Next
-> start.add_locations(List[Tuple[int]])
:: add multiple atoms to current register
-> start.add_location(Tuple[int])
:: add atom to current register
Bases: ProgramStart
src/bloqade/ir/location/base.py
add a position to existing atom arrangement.
src/bloqade/ir/location/base.py
add a list of positions to existing atom arrangement.
src/bloqade/ir/location/base.py
apply n_defects randomly to existing atom arrangement.
src/bloqade/ir/location/base.py
apply defect_probability randomly to existing atom arrangement.
src/bloqade/ir/location/base.py
obtain a figure object from the atom arrangement.
src/bloqade/ir/location/base.py
46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 |
|
scale the atom arrangement with a given factor
src/bloqade/ir/location/base.py
Bases: BoundedBravais
Chain lattice.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
L | int | number of sites in the chain | required |
lattice_spacing | Scalar, Real | lattice spacing. Defaults to 1.0. | 1.0 |
.
to see possible next step in auto-prompt supported setting (IPython, IDE ...)src/bloqade/ir/location/bravais.py
Bases: BoundedBravais
Honeycomb lattice.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
L | int | number of sites in linear direction. n_atoms = L * L * 2. | required |
lattice_spacing | Scalar, Real | lattice spacing. Defaults to 1.0. | 1.0 |
.
to see possible next step in auto-prompt supported setting (IPython, IDE ...)src/bloqade/ir/location/bravais.py
Bases: BoundedBravais
Kagome lattice.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
L | int | number of sites in linear direction. n_atoms = L * L. | required |
lattice_spacing | Scalar, Real | lattice spacing. Defaults to 1.0. | 1.0 |
.
to see possible next step in auto-prompt supported setting (IPython, IDE ...)src/bloqade/ir/location/bravais.py
Bases: BoundedBravais
Lieb lattice.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
L | int | number of sites in linear direction. n_atoms = L * L. | required |
lattice_spacing | Scalar, Real | lattice spacing. Defaults to 1.0. | 1.0 |
.
to see possible next step in auto-prompt supported setting (IPython, IDE ...)src/bloqade/ir/location/bravais.py
Bases: BoundedBravais
Rectangular lattice.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
width | int | number of sites in x direction. | required |
height | int | number of sites in y direction. | required |
lattice_spacing_x | Scalar, Real | lattice spacing. Defaults to 1.0. | 1.0 |
lattice_spacing_y | Scalar, Real | lattice spacing in y direction. optional. | None |
.
to see possible next step in auto-prompt supported setting (IPython, IDE ...)src/bloqade/ir/location/bravais.py
Bases: BoundedBravais
Square lattice.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
L | int | number of sites in linear direction. n_atoms = L * L. | required |
lattice_spacing | Scalar, Real | lattice spacing. Defaults to 1.0. | 1.0 |
.
to see possible next step in auto-prompt supported setting (IPython, IDE ...)src/bloqade/ir/location/bravais.py
Bases: BoundedBravais
Triangular lattice.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
L | int | number of sites in linear direction. n_atoms = L * L. | required |
lattice_spacing | Scalar, Real | lattice spacing. Defaults to 1.0. | 1.0 |
.
to see possible next step in auto-prompt supported setting (IPython, IDE ...)src/bloqade/ir/location/bravais.py
module-attribute
¶Possible Next
-> start.rydberg
:: address rydberg level coupling
-> start.hyperfine
:: address hyperfine level coupling
Possible Next
-> start.add_locations(List[Tuple[int]])
:: add multiple atoms to current register
-> start.add_location(Tuple[int])
:: add atom to current register
Bases: BaseModel
converts from shot results to probabilities
Returns:
Name | Type | Description |
---|---|---|
TaskProbabilities | TaskProbabilities | The task results as probabilties |
src/bloqade/ir/location/quera_task_result.py
Program is a dummy type that bundle register and sequence together.
src/bloqade/ir/program.py
property
¶Get the register of the program.
Returns:
Type | Description |
---|---|
register (Union["AtomArrangement", "ParallelRegister"]) |
If the program is built with parallelize()
, The the register will be a ParallelRegister
. Otherwise it will be a AtomArrangement
.
Bases: Real
class-attribute
¶Scalar Literal, which stores a decimaal value instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value | Decimal | decimal value instance | required |
Base class for all scalar expressions.
<scalar> ::= <literal>
+| <variable>
+| <default>
+| <negative>
+| <add>
+| <mul>
+| <min>
+| <max>
+| <slice>
+| <inverval>
+
+<mul> ::= <scalar> '*' <scalar>
+<add> ::= <scalar> '+' <scalar>
+<min> ::= 'min' <scalar>+
+<max> ::= 'max' <scalar>+
+<slice> ::= <scalar expr> '[' <interval> ']'
+<interval> ::= <scalar expr> '..' <scalar expr>
+<real> ::= <literal> | <var>
+
Bases: Real
Variable, which stores a variable name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | variable instance. | required |
cast Real number (or list/tuple of Real numbers) to Scalar Literal
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
py | Union[Real, Tuple[Real], List[Real]] | python object to cast | required |
Returns:
Type | Description |
---|---|
Any | Union[Literal,Tuple[Literal],List[Literal]] |
src/bloqade/ir/scalar.py
cast string (or list/tuple of strings) to Variable
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
py | Union[str, List[str], Tuple[str]] | a string or list/tuple of strings | required |
Returns:
Type | Description |
---|---|
Any | Union[Variable, List[Variable], Tuple[Variable]] |
src/bloqade/ir/scalar.py
Bases: BaseModel
Class that stores the mapping of batched jobs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cluster_index | int | the index of the cluster a site belongs to | required |
global_location_index | int | the index of the site in the multplexed system | required |
cluster_location_index | int | the index of the site in the original system | required |
Bases: BaseModel
converts from shot results to probabilities
Returns:
Name | Type | Description |
---|---|---|
TaskProbabilities | TaskProbabilities | The task results as probabilties |
src/bloqade/submission/ir/task_results.py
Class that defines base methods for API requests.
@param qpu_id: The QPU ID, for example qpu1-mock
. @param api_stage: Specify which version of the API to call from this object. @param proxy: Optional, the hostname for running the API via some proxy endpoint.
src/bloqade/submission/quera_api_client/api.py
AwsApiRequest(
+ api_hostname,
+ qpu_id,
+ api_stage="v0",
+ proxy=None,
+ region="us-east-1",
+ access_key=None,
+ secret_key=None,
+ session_token=None,
+ session_expires=3600,
+ role_arn=None,
+ role_session_name="awsrequest",
+ profile=None,
+)
+
Bases: ApiRequest
@param qpu_id: The QPU ID, for example qpu1-mock
. @param api_stage: Specify which version of the API to call from this object. @param proxy: Optional, the hostname for running the API via some proxy endpoint. @param region: AWS region, default value: "us-east-1" @param access_key: Optional, AWS account access key @param secret_key: Optional, AWS account secret key @param session_token: Optional, AWS session token @param session_expires: int, time before current tokens expire, default value 3600 @param role_arn: Optional, AWS role ARN @param role_session_name: AWS role session name, defualy value: 'awsrequest', @param profile: Optional, AWS profile to use credentials for.
src/bloqade/submission/quera_api_client/api.py
Simple interface to the QCS task API.
Example (replace URIs, QPU ID with correct values):
task_json = { ... "nshots": 10, ... "lattice": { ... "sites":[[0,0]], ... "filling":[1], ... }, ... "effective_hamiltonian": { ... "rydberg": { ... "rabi_frequency_amplitude":{ ... "global": { ... "times":[0.0, 0.1e-6, 3.9e-6, 4.0e-6], ... "values":[0.0, 15.0e6, 15.0e6, 0.0], ... } ... }, ... "rabi_frequency_phase": { ... "global": { ... "times":[0.0, 4.0e-6], ... "values":[0.0, 0.0], ... } ... }, ... "detuning":{ ... "global": { ... "times":[0.0, 4.0e-6], ... "values":[0.0, 0.0], ... } ... } ... } ... } ... } To Use this class with API-Gateway: api_hostname = "XXX.execute-api.us-east-1.amazonaws.com" vpce_uri = "vpce-XXX-XXX.execute-api.us-east-1.vpce.amazonaws.com" api = QueueApi(api_hostname, "qpu1-mock", proxy=vpce_uri) print(api.get_capabilities())
@param qpu_id: The QPU ID, for example qpu1-mock
. @param api_stage: Specify which version of the API to call from this object. @param proxy: Optional, the hostname for running the API via some proxy endpoint.
request_sigv4_kwargs:
@param region: AWS region, default value: "us-east-1" @param access_key: Optional, AWS account access key @param secret_key: Optional, AWS account secret key @param session_token: Optional, AWS session token @param session_expires: int, time before current tokens expire, default value 3600 @param role_arn: Optional, AWS role ARN @param role_session_name: AWS role session name, defualy value: 'awsrequest', @param profile: Optional, AWS profile to use credentials for.
src/bloqade/submission/quera_api_client/api.py
Request the QPU capabilities from the task API. @return: dictionary containing different fields for capabilities.
src/bloqade/submission/quera_api_client/api.py
Return task results as given by API. @return: Parsed JSON of the task results. @param task_id: Task ID.
src/bloqade/submission/quera_api_client/api.py
Request task status in a queue for a given task. @param task_id: Task ID. @return: Parsed JSON of the task status.
src/bloqade/submission/quera_api_client/api.py
Request the task summary for a given task. The summary contains the status of the current task. @param task_id: Task ID. @return: Parsed JSON of the task summary. @see: TaskSummary
in https://github.com/QuEra-QCS/QCS-API/blob/master/qcs-api/openapi.yaml
src/bloqade/submission/quera_api_client/api.py
Check whether a task is stopped (because it is completed, failed, or cancelled). @param task_id: @return: True
if task is stopped.
src/bloqade/submission/quera_api_client/api.py
Submit a task to the QPU via the task API. @param content: Task specification as a JSON string or dictionary.
src/bloqade/submission/quera_api_client/api.py
checks if aws has log-in, and performs attempt of sso login if not. by default profile should be set as env variable AWS_PROFILE
, but can be specified as a parameter.
src/bloqade/submission/quera_api_client/aws_login.py
Bases: JSONInterface
, BatchTask[BraketEmulatorTask, BraketEmulatorBatchResult]
A compiled batch-tasks that can be submitted to run on Amazon Braket's local simulator.
Submit the batch tasks to run on Amazon Braket's local simulator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
multiprocessing | bool | Running with multiprocess. Defaults to False. | False |
max_workers | Optional[int] | None | |
progress_bar | bool | Display progess bar. Defaults to False. | False |
Returns:
Type | Description |
---|---|
BraketEmulatorBatchResult | BraketEmulatorBatchResult |
src/bloqade/task/braket_simulator.py
Bases: CloudBatchTask[HardwareTask, HardwareBatchResult]
A compiled batch-tasks that can be submitted to run on quantum hardware with specified backend.
Bases: CloudBatchTask[HardwareTask, HardwareBatchResult]
A compiled batch-tasks that can be submitted to run on quantum hardware with specified backend.
For full documentation visit mkdocs.org.
"},{"location":"#commands","title":"Commands","text":"mkdocs new [dir-name]
- Create a new project.mkdocs serve
- Start the live-reloading docs server.mkdocs build
- Build the documentation site.mkdocs -h
- Print help message and exit.mkdocs.yml # The configuration file.\ndocs/\n index.md # The documentation homepage.\n ... # Other markdown pages, images and other files.\n
"},{"location":"contributing/","title":"Contributing","text":""},{"location":"contributing/#how-to-contribute","title":"How to contribute","text":"Our development environment contains a set of tools we use for development, testing, and documentation. This section describes how to set up the development environment. We primarily use pdm to manage python environments and dependencies.
"},{"location":"contributing/setup/#setup-development-environment","title":"Setup development environment","text":"We use pdm to manage dependencies and virtual environment. After cloning the repository, run the following command to install dependencies:
pdm install\n
You can also install different dependency groups:
pdm install --dev\n# or\npdm install -d\n
pdm install -G doc\n
"},{"location":"contributing/setup/#useful-pdm-scripts","title":"Useful PDM scripts","text":""},{"location":"contributing/setup/#tests","title":"Tests","text":"You can run tests via
pdm run test\n
Or run tests and generate coverage via
pdm run coverage\n
"},{"location":"contributing/setup/#documentation","title":"Documentation","text":"You can build documentation via
pdm run doc_build\n
Or run a local server to preview documentation via
pdm run doc\n
"},{"location":"contributing/setup/#jupytext","title":"Jupytext","text":"You can sync jupyter notebooks and python scripts via
pdm run jupytext\n
this will help you development examples in jupyter notebook and python scripts simultaneously.
"},{"location":"contributing/setup/#lint","title":"Lint","text":"We primarily use ruff - an extremely fast linter for Python, and black as formatter. These has been configured into pre-commit hooks. You can install pre-commit hooks to git via
pre-commit install\n
"},{"location":"examples/rabi/","title":"Single Qubit Rabi Oscillations","text":"In\u00a0[1]: Copied! from bloqade import start, cast\nfrom bloqade.task import HardwareBatchResult\n\nimport os\nimport numpy as np\n\nfrom bokeh.io import output_notebook\nfrom bokeh.plotting import figure, show\nfrom bokeh.models import HoverTool, ColumnDataSource, CrosshairTool\n\noutput_notebook()\nfrom bloqade import start, cast from bloqade.task import HardwareBatchResult import os import numpy as np from bokeh.io import output_notebook from bokeh.plotting import figure, show from bokeh.models import HoverTool, ColumnDataSource, CrosshairTool output_notebook() Loading BokehJS ...
define program with one atom, with constant detuning but variable Rabi frequency, ramping up to \"rabi_value\" and then returning to 0.0.
In\u00a0[2]: Copied!durations = cast([\"ramp_time\", \"run_time\", \"ramp_time\"])\n\nrabi_oscillations_program = (\n start.add_position((0, 0))\n .rydberg.rabi.amplitude.uniform.piecewise_linear(\n durations=durations, values=[0, \"rabi_value\", \"rabi_value\", 0]\n )\n .detuning.uniform.constant(duration=sum(durations), value=0)\n)\ndurations = cast([\"ramp_time\", \"run_time\", \"ramp_time\"]) rabi_oscillations_program = ( start.add_position((0, 0)) .rydberg.rabi.amplitude.uniform.piecewise_linear( durations=durations, values=[0, \"rabi_value\", \"rabi_value\", 0] ) .detuning.uniform.constant(duration=sum(durations), value=0) )
Assign values to the variables in the program, allowing the run_time
(time the Rabi amplitude stays at the value of \"rabi_frequency\" ) to sweep across a range of values.
rabi_oscillation_job = rabi_oscillations_program.assign(\n ramp_time=0.06, rabi_value=15, detuning_value=0.0\n).batch_assign(run_time=np.around(np.arange(0, 21, 1) * 0.05, 13))\nrabi_oscillation_job = rabi_oscillations_program.assign( ramp_time=0.06, rabi_value=15, detuning_value=0.0 ).batch_assign(run_time=np.around(np.arange(0, 21, 1) * 0.05, 13))
Run the program in emulation, obtaining a report object. For each possible set of variable values to simulate (in this case, centered around the run_time
variable), let the task have 10000 shots.
emu_report = rabi_oscillation_job.braket_local_simulator(10000).submit().report()\nemu_report = rabi_oscillation_job.braket_local_simulator(10000).submit().report()
Submit the same program to hardware, this time using .parallelize
to make a copy of the original geometry (a single atom) that fills the FOV (Field-of-View Space), with at least 24 micrometers of distance between each atom.
Unlike the emulation above, we only let each task run with 100 shots. A collection of tasks is known as a \"Job\" in Bloqade and jobs can be saved in JSON format so you can reload them later (a necessity considering how long it may take for the machine to handle tasks in the queue)
In\u00a0[5]: Copied!\"\"\"\n(\n rabi_oscillation_job.parallelize(24)\n .braket(100)\n .submit()\n .save_json(\"rabi-job.json\")\n)\n\"\"\"\n\"\"\" ( rabi_oscillation_job.parallelize(24) .braket(100) .submit() .save_json(\"rabi-job.json\") ) \"\"\" Out[5]:
'\\n(\\n rabi_oscillation_job.parallelize(24)\\n .braket(100)\\n .submit()\\n .save_json(\"rabi-job.json\")\\n)\\n'
Load JSON and pull results from Braket
In\u00a0[6]: Copied!hw_future = HardwareBatchResult.load_json(\n os.getcwd() + \"/docs/docs/examples/\" + \"rabi-job.json\"\n)\nhw_rydberg_densities = hw_future.report().rydberg_densities()\nhw_future = HardwareBatchResult.load_json( os.getcwd() + \"/docs/docs/examples/\" + \"rabi-job.json\" ) hw_rydberg_densities = hw_future.report().rydberg_densities()
We can now plot the results from the hardware and emulation together.
In\u00a0[7]: Copied!data = {\n \"times\": np.around(np.arange(0, 21, 1) * 0.05, 13),\n \"emu_densities\": emu_report.rydberg_densities()[0].to_list(),\n \"hw_densities\": hw_rydberg_densities[0].to_list(),\n}\nsource = ColumnDataSource(data=data)\n\np = figure(\n x_axis_label=\"Time (\u03bcs)\",\n y_axis_label=\"Rydberg Density\",\n toolbar_location=\"right\",\n tools=[\"pan,wheel_zoom,box_zoom,reset,save\"],\n)\n\np.axis.axis_label_text_font_size = \"15pt\"\np.axis.major_label_text_font_size = \"10pt\"\n\nemu_line = p.line(\n x=\"times\",\n y=\"emu_densities\",\n source=source,\n legend_label=\"Emulator\",\n color=\"grey\",\n line_width=2,\n)\np.circle(x=\"times\", y=\"emu_densities\", source=source, color=\"grey\", size=8)\n# hardware densities\nhw_line = p.line(\n x=\"times\",\n y=\"hw_densities\",\n source=source,\n legend_label=\"Hardware\",\n color=\"purple\",\n line_width=2,\n)\np.circle(x=\"times\", y=\"hw_densities\", source=source, color=\"purple\", size=8)\n\nhw_hover_tool = HoverTool(\n renderers=[hw_line],\n tooltips=[\n (\"Backend\", \"Hardware\"),\n (\"Density\", \"@hw_densities\"),\n (\"Time\", \"@times \u03bcs\"),\n ],\n mode=\"vline\",\n attachment=\"right\",\n)\np.add_tools(hw_hover_tool)\nemu_hover_tool = HoverTool(\n renderers=[emu_line],\n tooltips=[\n (\"Backend\", \"Emulator\"),\n (\"Density\", \"@emu_densities\"),\n (\"Time\", \"@times \u03bcs\"),\n ],\n mode=\"vline\",\n attachment=\"left\",\n)\np.add_tools(emu_hover_tool)\ncross_hair_tool = CrosshairTool(dimensions=\"height\")\np.add_tools(cross_hair_tool)\n\nshow(p)\ndata = { \"times\": np.around(np.arange(0, 21, 1) * 0.05, 13), \"emu_densities\": emu_report.rydberg_densities()[0].to_list(), \"hw_densities\": hw_rydberg_densities[0].to_list(), } source = ColumnDataSource(data=data) p = figure( x_axis_label=\"Time (\u03bcs)\", y_axis_label=\"Rydberg Density\", toolbar_location=\"right\", tools=[\"pan,wheel_zoom,box_zoom,reset,save\"], ) p.axis.axis_label_text_font_size = \"15pt\" p.axis.major_label_text_font_size = \"10pt\" emu_line = p.line( x=\"times\", y=\"emu_densities\", source=source, legend_label=\"Emulator\", color=\"grey\", line_width=2, ) p.circle(x=\"times\", y=\"emu_densities\", source=source, color=\"grey\", size=8) # hardware densities hw_line = p.line( x=\"times\", y=\"hw_densities\", source=source, legend_label=\"Hardware\", color=\"purple\", line_width=2, ) p.circle(x=\"times\", y=\"hw_densities\", source=source, color=\"purple\", size=8) hw_hover_tool = HoverTool( renderers=[hw_line], tooltips=[ (\"Backend\", \"Hardware\"), (\"Density\", \"@hw_densities\"), (\"Time\", \"@times \u03bcs\"), ], mode=\"vline\", attachment=\"right\", ) p.add_tools(hw_hover_tool) emu_hover_tool = HoverTool( renderers=[emu_line], tooltips=[ (\"Backend\", \"Emulator\"), (\"Density\", \"@emu_densities\"), (\"Time\", \"@times \u03bcs\"), ], mode=\"vline\", attachment=\"left\", ) p.add_tools(emu_hover_tool) cross_hair_tool = CrosshairTool(dimensions=\"height\") p.add_tools(cross_hair_tool) show(p)"},{"location":"examples/rabi/#single-qubit-rabi-oscillations","title":"Single Qubit Rabi Oscillations\u00b6","text":""},{"location":"examples/rabi/#introduction","title":"Introduction\u00b6","text":"
In this example we show how to use Bloqade to emulate a Rabi oscillation as well as run it on hardware.
"},{"location":"reference/bloqade/","title":"Index","text":""},{"location":"reference/bloqade/#bloqade.start","title":"startmodule-attribute
","text":"start = ListOfLocations()\n
Possible Next
-> start.rydberg
:: address rydberg level coupling
-> start.hyperfine
:: address hyperfine level coupling
Possible Next
-> start.add_locations(List[Tuple[int]])
:: add multiple atoms to current register
-> start.add_location(Tuple[int])
:: add atom to current register
Bases: Real
class-attribute
","text":"value: Decimal\n
Scalar Literal, which stores a decimaal value instance.
Parameters:
Name Type Description Defaultvalue
Decimal
decimal value instance
required"},{"location":"reference/bloqade/#bloqade.Variable","title":"Variable","text":" Bases: Real
Variable, which stores a variable name.
Parameters:
Name Type Description Defaultname
str
variable instance.
required"},{"location":"reference/bloqade/#bloqade.cast","title":"cast","text":"cast(py)\n
cast Real number (or list/tuple of Real numbers) to Scalar Literal
.
Parameters:
Name Type Description Defaultpy
Union[Real, Tuple[Real], List[Real]]
python object to cast
requiredReturns:
Type DescriptionAny
Union[Literal,Tuple[Literal],List[Literal]]
Source code insrc/bloqade/ir/scalar.py
def cast(py) -> Any:\n\"\"\"cast Real number (or list/tuple of Real numbers)\n to [`Scalar Literal`][bloqade.ir.scalar.Literal].\n Args:\n py (Union[Real,Tuple[Real],List[Real]]): python object to cast\n Returns:\n Union[Literal,Tuple[Literal],List[Literal]]\n \"\"\"\nret = trycast(py)\nif ret is None:\nraise TypeError(f\"Cannot cast {type(py)} to Scalar Literal\")\nreturn ret\n
"},{"location":"reference/bloqade/#bloqade.var","title":"var","text":"var(py)\n
cast string (or list/tuple of strings) to Variable
.
Parameters:
Name Type Description Defaultpy
Union[str, List[str], Tuple[str]]
a string or list/tuple of strings
requiredReturns:
Type DescriptionAny
Union[Variable, List[Variable], Tuple[Variable]]
Source code insrc/bloqade/ir/scalar.py
def var(py: Union[str, List[str]]) -> Any:\n\"\"\"cast string (or list/tuple of strings)\n to [`Variable`][bloqade.ir.scalar.Variable].\n Args:\n py (Union[str, List[str], Tuple[str]]): a string or list/tuple of strings\n Returns:\n Union[Variable, List[Variable], Tuple[Variable]]\n \"\"\"\nret = tryvar(py)\nif ret is None:\nraise TypeError(f\"Cannot cast {type(py)} to Variable\")\nreturn ret\n
"},{"location":"reference/bloqade/builder/","title":"Index","text":""},{"location":"reference/bloqade/builder/coupling/","title":"Coupling","text":""},{"location":"reference/bloqade/builder/coupling/#bloqade.builder.coupling.Hyperfine","title":"Hyperfine","text":" Bases: LevelCoupling
This node represent level coupling between hyperfine state.
Examples:
>>> node = bloqade.start.hyperfine\n>>> type(node)\n<class 'bloqade.builder.coupling.Hyperfine'>\n
Hyperfine level coupling have two reachable field nodes:
Detuning
)Rabi
)>>> hyp_detune = bloqade.start.hyperfine.detuning\n>>> hyp_rabi = bloqade.start.hyperfine.rabi\n
"},{"location":"reference/bloqade/builder/coupling/#bloqade.builder.coupling.LevelCoupling","title":"LevelCoupling","text":" Bases: Builder
property
","text":"detuning\n
Possible Next:
-> ...detuning.location(int)
:: Address atom at specific location
-> ...detuning.uniform
:: Address all atoms in register
-> ...detuning.var(str)
:: Address atom at location labeled by variable
property
","text":"rabi\n
Possible Next:
-> ...rabi.amplitude
:: address rabi amplitude
-> ...rabi.phase
:: address rabi phase
Bases: LevelCoupling
This node represent level coupling of rydberg state.
Examples:
>>> node = bloqade.start.rydberg\n>>> type(node)\n<class 'bloqade.builder.coupling.Rydberg'>\n
Rydberg level coupling have two reachable field nodes:
Detuning
)Rabi
)>>> ryd_detune = bloqade.start.rydberg.detuning\n>>> ryd_rabi = bloqade.start.rydberg.rabi\n
"},{"location":"reference/bloqade/builder/emit/","title":"Emit","text":""},{"location":"reference/bloqade/builder/emit/#bloqade.builder.emit.Emit","title":"Emit","text":"Emit(\nbuilder,\nassignments={},\nbatch={},\nregister=None,\nsequence=None,\n)\n
Bases: Builder
src/bloqade/builder/emit.py
def __init__(\nself,\nbuilder: Builder,\nassignments: Dict[str, Union[numbers.Real, List[numbers.Real]]] = {},\nbatch: Dict[str, Union[List[numbers.Real], List[List[numbers.Real]]]] = {},\nregister: Optional[Union[\"AtomArrangement\", \"ParallelRegister\"]] = None,\nsequence: Optional[ir.Sequence] = None,\n) -> None:\nsuper().__init__(builder)\nself.__batch__ = {}\nif batch:\nfirst_key, *other_keys = batch.keys()\nfirst_value = batch[first_key]\nbatch_size = len(first_value)\nself.__batch__[first_key] = first_value\nfor key in other_keys:\nvalue = batch[key]\nother_batch_size = len(value)\nif other_batch_size != batch_size:\nraise ValueError(\n\"mismatch in size of batches, found batch size \"\nf\"{batch_size} for {first_key} and a batch size of \"\nf\"{other_batch_size} for {key}\"\n)\nself.__batch__[key] = value\nself.__assignments__ = assignments\nself.__sequence__ = sequence\nself.__register__ = register\n
"},{"location":"reference/bloqade/builder/emit/#bloqade.builder.emit.Emit.program","title":"program property
","text":"program: Program\n
Get the Program from the current builder. See also Program
Returns:
Type DescriptionProgram
prog (Program)
"},{"location":"reference/bloqade/builder/emit/#bloqade.builder.emit.Emit.register","title":"registerproperty
","text":"register: Union[AtomArrangement, ParallelRegister]\n
Get the register
from the current builder.
Returns:
Type DescriptionUnion[AtomArrangement, ParallelRegister]
register (Union[\"AtomArrangement\", \"ParallelRegister\"])
NoteIf the program is built with parallelize()
, The the register will be a ParallelRegister
. Otherwise it will be a AtomArrangement
.
property
","text":"sequence\n
Get the sequence
from the current builder.
Returns:
Type Descriptionsequence (Sequence)
"},{"location":"reference/bloqade/builder/emit/#bloqade.builder.emit.Emit.assign","title":"assign","text":"assign(**assignments)\n
Assign values to variables declared previously in the program.
Parameters:
Name Type Description Defaultassignments
Dict[str, Union[Number]]
{}
Examples:
>>> reg = bloqade.start\n... .add_positions([(0,0),(1,1),(2,2),(3,3)])\n>>> seq = reg.rydberg.detuning.uniform\n... .linear(start=\"ival\",stop=1,duration=\"span_time\")\n>>> seq = seq.assign(span_time = 0.5, ival = 0.0)\n
Source code in src/bloqade/builder/emit.py
def assign(self, **assignments):\n\"\"\"\n Assign values to variables declared previously in the program.\n Args:\n assignments (Dict[str, Union[Number]]):\n The assignments, which should be a kwargs\n where the key is the variable name and the\n value is the value to assign to the variable.\n Examples:\n - Assign the value 0.0 to the variable \"ival\"\n and 0.5 to the variable \"span_time\".\n >>> reg = bloqade.start\n ... .add_positions([(0,0),(1,1),(2,2),(3,3)])\n >>> seq = reg.rydberg.detuning.uniform\n ... .linear(start=\"ival\",stop=1,duration=\"span_time\")\n >>> seq = seq.assign(span_time = 0.5, ival = 0.0)\n \"\"\"\n# these methods terminate no build steps can\n# happens after this other than updating parameters\nnew_assignments = dict(self.__assignments__)\nnew_assignments.update(**assignments)\nreturn Emit(\nself,\nassignments=new_assignments,\nbatch=self.__batch__,\nregister=self.__register__,\nsequence=self.__sequence__,\n)\n
"},{"location":"reference/bloqade/builder/emit/#bloqade.builder.emit.Emit.batch_assign","title":"batch_assign","text":"batch_assign(**batch)\n
Assign values to variables declared previously in the program for launching batch jobs.
Parameters:
Name Type Description Defaultbatch
Dict[str, Union[Number]]
The batch assignments of variables,
{}
Examples:
>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])\n>>> seq = reg.rydberg.detuning.uniform\n... .linear(start=\"ival\",stop=1,duration=\"span_time\")\n>>> job = seq.batch_assign(span_time = [0.6,0.8], ival = [0.0,0.5]).mock(10)\n
Note the length of the lists of values should be the same for each variable.
Source code insrc/bloqade/builder/emit.py
def batch_assign(self, **batch):\n\"\"\"\n Assign values to variables declared previously in the program\n for launching batch jobs.\n Args:\n batch (Dict[str, Union[Number]]): The batch assignments of variables,\n which should be a kwargs where the key is the variable name\n and the value is the list of value assign to the variable.\n Examples:\n - Assign the value [0.0,0.5] to the variable \"ival\" and [0.6,0.8]\n to the variable \"span_time\".\n This will create a job with two tasks\n of (value,ival) = (0.0,0.6) and (0.5,0.8) with each has 10 shots.\n >>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])\n >>> seq = reg.rydberg.detuning.uniform\n ... .linear(start=\"ival\",stop=1,duration=\"span_time\")\n >>> job = seq.batch_assign(span_time = [0.6,0.8], ival = [0.0,0.5]).mock(10)\n Note:\n the length of the lists of values should be the same for each variable.\n \"\"\"\nnew_batch = dict(self.__batch__)\nnew_batch.update(**batch)\nreturn Emit(\nself,\nassignments=self.__assignments__,\nbatch=new_batch,\nregister=self.__register__,\nsequence=self.__sequence__,\n)\n
"},{"location":"reference/bloqade/builder/emit/#bloqade.builder.emit.Emit.braket","title":"braket","text":"braket(nshots)\n
Compile the current builder to a Amazon braket HardwareBatchTask
, which can be submit to run on QPU through braket service.
Parameters:
Name Type Description Defaultnshots
int
The number of shots to run.
requiredReturns:
Type DescriptionHardwareBatchTask
HardwareBatchTask
Source code insrc/bloqade/builder/emit.py
def braket(self, nshots: int) -> \"HardwareBatchTask\":\n\"\"\"\n Compile the current builder to a Amazon braket\n [`HardwareBatchTask`][bloqade.task.hardware.HardwareBatchTask]\n , which can be submit to run on QPU through braket service.\n Args:\n nshots (int): The number of shots to run.\n Returns:\n HardwareBatchTask\n \"\"\"\nbackend = BraketBackend()\nreturn self.__compile_hardware(nshots, backend)\n
"},{"location":"reference/bloqade/builder/emit/#bloqade.builder.emit.Emit.braket_local_simulator","title":"braket_local_simulator","text":"braket_local_simulator(nshots)\n
Compile the current builder to a BraketEmulatorBatchTask
, which can be submit to run on braket local simulator.
Parameters:
Name Type Description Defaultnshots
int
The number of shots to run.
requiredReturns:
Type DescriptionBraketEmulatorJob
Source code insrc/bloqade/builder/emit.py
def braket_local_simulator(self, nshots: int):\n\"\"\"\n Compile the current builder to a\n [`BraketEmulatorBatchTask`][bloqade.task.braket_simulator.BraketEmulatorBatchTask]\n , which can be submit to run on braket local simulator.\n Args:\n nshots (int): The number of shots to run.\n Returns:\n BraketEmulatorJob\n \"\"\"\nfrom bloqade.codegen.hardware.quera import SchemaCodeGen\nif isinstance(self.register, ParallelRegister):\nraise TypeError(\"Braket emulator doesn't support parallel registers.\")\ntasks = OrderedDict()\nfor task_number, assignments in enumerate(self.__assignments_iterator()):\nschema_compiler = SchemaCodeGen(assignments)\ntask_ir = schema_compiler.emit(nshots, self.program)\ntask = BraketEmulatorTask(task_ir=to_braket_task_ir(task_ir))\ntasks[task_number] = task\nreturn BraketEmulatorBatchTask(braket_emulator_tasks=tasks)\n
"},{"location":"reference/bloqade/builder/emit/#bloqade.builder.emit.Emit.mock","title":"mock","text":"mock(nshots, state_file='.mock_state.txt')\n
Compile the current builder to a Dummy mock HardwareBatchTask
, which can be used for testing.
Parameters:
Name Type Description Defaultnshots
int
The number of shots to run.
requiredstate_file
str
The file to store the state of the mock backend.
'.mock_state.txt'
Returns:
Type DescriptionHardwareBatchTask
HardwareBatchTask
Source code insrc/bloqade/builder/emit.py
def mock(\nself, nshots: int, state_file: str = \".mock_state.txt\"\n) -> \"HardwareBatchTask\":\n\"\"\"\n Compile the current builder to a Dummy mock\n [`HardwareBatchTask`][bloqade.task.hardware.HardwareBatchTask]\n , which can be used for testing.\n Args:\n nshots (int): The number of shots to run.\n state_file (str): The file to store the state of the mock backend.\n Returns:\n HardwareBatchTask\n \"\"\"\nbackend = DumbMockBackend(state_file=state_file)\nreturn self.__compile_hardware(nshots, backend)\n
"},{"location":"reference/bloqade/builder/emit/#bloqade.builder.emit.Emit.parallelize","title":"parallelize","text":"parallelize(cluster_spacing)\n
Parallelize the current problem (register & sequnece) to fill entire FOV with the given cluster spacing.
Parameters:
Name Type Description Defaultcluster_spacing
Any, should be Real
required Examples:
>>> prob = (\n bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])\n .rydberg.detuning.uniform\n .linear(start=0,stop=1,duration=1)\n )\n>>> prob = prob.parallelize(7.2)\n
Source code in src/bloqade/builder/emit.py
def parallelize(self, cluster_spacing: Any) -> \"Emit\":\n\"\"\"\n Parallelize the current problem (register & sequnece) to fill entire FOV\n with the given cluster spacing.\n Args:\n cluster_spacing (Any, should be Real):\n the spacing between parallel clusters.\n Examples:\n - Parallelize the current problem with cluster spacing 7.2 um.\n >>> prob = (\n bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])\n .rydberg.detuning.uniform\n .linear(start=0,stop=1,duration=1)\n )\n >>> prob = prob.parallelize(7.2)\n \"\"\"\nif isinstance(self.register, ParallelRegister):\nraise TypeError(\"cannot parallelize a parallel register.\")\nparallel_register = ParallelRegister(self.register, cluster_spacing)\nreturn Emit(\nself,\nassignments=self.__assignments__,\nbatch=self.__batch__,\nregister=parallel_register,\nsequence=self.__sequence__,\n)\n
"},{"location":"reference/bloqade/builder/emit/#bloqade.builder.emit.Emit.quera","title":"quera","text":"quera(nshots, config_file=None, **api_config)\n
Compile the current builder to a QuEra HardwareBatchTask
, which can be submit to run on QPU through QuEra service.
Parameters:
Name Type Description Defaultnshots
int
The number of shots to run.
requiredconfig_file
Optional[str]
The path to the config file.
None
api_config
Dict[str, Any]
The api config.
{}
Returns:
Type DescriptionHardwareBatchTask
HardwareBatchTask
Source code insrc/bloqade/builder/emit.py
def quera(\nself, nshots: int, config_file: Optional[str] = None, **api_config\n) -> \"HardwareBatchTask\":\n\"\"\"\n Compile the current builder to a QuEra\n [`HardwareBatchTask`][bloqade.task.hardware.HardwareBatchTask]\n , which can be submit to run on QPU through QuEra service.\n Args:\n nshots (int): The number of shots to run.\n config_file (Optional[str]): The path to the config file.\n api_config (Dict[str, Any]): The api config.\n Returns:\n HardwareBatchTask\n \"\"\"\nif config_file is None:\npath = os.path.dirname(__file__)\nconfig_file = os.path.join(\npath,\n\"..\",\n\"submission\",\n\"quera_api_client\",\n\"config\",\n\"integ_quera_api.json\",\n)\nif len(api_config) == 0:\nwith open(config_file, \"r\") as io:\napi_config.update(**json.load(io))\nbackend = QuEraBackend(**api_config)\nreturn self.__compile_hardware(nshots, backend)\n
"},{"location":"reference/bloqade/builder/field/","title":"Field","text":""},{"location":"reference/bloqade/builder/field/#bloqade.builder.field.Amplitude","title":"Amplitude","text":" Bases: SpatialModulation
This node represent amplitude of a rabi field.
Examples:
>>> node = bloqade.start.rydberg.rabi.amplitude\n>>> type(node)\n<class 'bloqade.builder.field.Amplitude'>\n
>>> node = bloqade.start.hyperfine.rabi.amplitude\n>>> type(node)\n<class 'bloqade.builder.field.Amplitude'>\n
Note This node is a SpatialModulation node. See SpatialModulation
for additional options.
Bases: SpatialModulation
This node represent detuning field of a specified level coupling (rydberg or hyperfine) type.
Examples:
>>> node = bloqade.start.rydberg.detuning\n>>> type(node)\n<class 'bloqade.builder.field.Detuning'>\n
>>> node = bloqade.start.hyperfine.detuning\n>>> type(node)\n<class 'bloqade.builder.field.Detuning'>\n
Note This node is a SpatialModulation node. See SpatialModulation
for additional options.
Bases: SpatialModulation
This node represent phase of a rabi field.
Examples:
>>> node = bloqade.start.rydberg.rabi.phase\n>>> type(node)\n<class 'bloqade.builder.field.Phase'>\n
>>> node = bloqade.start.hyperfine.rabi.phase\n>>> type(node)\n<class 'bloqade.builder.field.Phase'>\n
Note This node is a SpatialModulation node. See SpatialModulation
for additional options.
Bases: Builder
This node represent rabi field of a specified level coupling (rydberg or hyperfine) type.
Examples:
>>> node = bloqade.start.rydberg.rabi\n<class 'bloqade.builder.field.Rabi'>\n
>>> node = bloqade.start.hyperfine.rabi\n>>> type(node)\n<class 'bloqade.builder.field.Rabi'>\n
"},{"location":"reference/bloqade/builder/field/#bloqade.builder.field.Rabi.amplitude","title":"amplitude property
","text":"amplitude\n
Possible Next:
-> ...amplitude.location(int)
:: Address atom at specific location
-> ...amplitude.uniform
:: Address all atoms in register
-> ...amplitude.var(str)
:: Address atom at location labeled by variable
Examples:
Amplitude
)>>> ryd_rabi = bloqade.start.rydberg.rabi\n>>> ryd_rabi_amp = ryd_rabi.amplitude\n
Amplitude
)>>> hyp_rabi = bloqade.start.hyperfine.rabi\n>>> hyp_rabi_amp = hyp_rabi.amplitude\n
"},{"location":"reference/bloqade/builder/field/#bloqade.builder.field.Rabi.phase","title":"phase property
","text":"phase\n
Possible Next:
-> ...phase.location(int)
:: Address atom at specific location
-> ...phase.uniform
:: Address all atoms in register
-> ...phase.var(str)
:: Address atom at location labeled by variable
Examples:
Phase
)>>> ryd_rabi = bloqade.start.rydberg.rabi\n>>> ryd_rabi_ph = ryd_rabi.phase\n
Phase
)>>> hyp_rabi = bloqade.start.hyperfine.rabi\n>>> hyp_rabi_ph = hyp_rabi.phase\n
"},{"location":"reference/bloqade/builder/location/","title":"Location","text":""},{"location":"reference/bloqade/builder/location/#bloqade.builder.location.Location","title":"Location","text":"Location(parent, label)\n
Bases: Waveform
src/bloqade/builder/location.py
def __init__(self, parent: Builder, label: int) -> None:\nsuper().__init__(parent)\nself._label = label\n
"},{"location":"reference/bloqade/builder/location/#bloqade.builder.location.Location.location","title":"location","text":"location(label)\n
Append another location to the current location(s)
Parameters:
Name Type Description Defaultlabel
int
The label of the location
requiredExamples:
>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])\n>>> loc = reg.rydberg.detuning.location(0)\n>>> loc = loc.location(1)\n
>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])\n>>> loc = reg.rydberg.detuning.location(0)\n>>> loc = loc.location(1).location(2)\n
Possible Next :
-> ...location(int).location(int)
:: keep adding location into current list
-> ...location(int).scale(float)
:: specify scaling factor to current location for the preceeding waveform
Possible Next :
-> ...location(int).linear()
:: apply linear waveform
-> ...location(int).constant()
:: apply constant waveform
-> ...location(int).ploy()
:: apply polynomial waveform
-> ...location(int).apply()
:: apply pre-constructed waveform
-> ...location(int).piecewise_linear()
:: apply piecewise linear waveform
-> ...location(int).piecewise_constant()
:: apply piecewise constant waveform
-> ...location(int).fn()
:: apply callable as waveform.
src/bloqade/builder/location.py
def location(self, label: int):\n\"\"\"\n Append another location to the current location(s)\n Args:\n label (int): The label of the location\n Examples:\n - Append location 1 to the current location 0.\n >>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])\n >>> loc = reg.rydberg.detuning.location(0)\n >>> loc = loc.location(1)\n - One can keep appending by concatenating location()\n >>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])\n >>> loc = reg.rydberg.detuning.location(0)\n >>> loc = loc.location(1).location(2)\n - Possible Next <Location>:\n -> `...location(int).location(int)`\n :: keep adding location into current list\n -> `...location(int).scale(float)`\n :: specify scaling factor to current location\n for the preceeding waveform\n - Possible Next <WaveForm>:\n -> `...location(int).linear()`\n :: apply linear waveform\n -> `...location(int).constant()`\n :: apply constant waveform\n -> `...location(int).ploy()`\n :: apply polynomial waveform\n -> `...location(int).apply()`\n :: apply pre-constructed waveform\n -> `...location(int).piecewise_linear()`\n :: apply piecewise linear waveform\n -> `...location(int).piecewise_constant()`\n :: apply piecewise constant waveform\n -> `...location(int).fn()`\n :: apply callable as waveform.\n \"\"\"\nreturn Location(self, label)\n
"},{"location":"reference/bloqade/builder/location/#bloqade.builder.location.Location.scale","title":"scale","text":"scale(scale)\n
Scale the preceeding waveform by the specified factor.
Parameters:
Name Type Description Defaultscale
float
The factor to scale (amplitude of)
requiredExamples:
>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])\n>>> scaled = reg.rydberg.detuning.location(0).scale(1.2)\n
>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])\n>>> loc = reg.rydberg.detuning.location(0)\n>>> loc = loc.scale(1.2).location(1).scale(0.5)\n
>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])\n>>> scaled = reg.rydberg.detuning.location(0).location(1).scale(1.2)\n
Possible Next :
-> ...scale(float).location(int)
:: keep adding location into current list
Possible Next :
-> ...scale(float).linear()
:: apply linear waveform
-> ...scale(float).constant()
:: apply constant waveform
-> ...scale(float).ploy()
:: apply polynomial waveform
-> ...scale(float).apply()
:: apply pre-constructed waveform(s)
-> ...scale(float).piecewise_linear()
:: apply piecewise linear waveform
-> ...scale(float).piecewise_constant()
:: apply piecewise constant waveform
-> ...scale(float).fn()
:: apply callable as waveform.
src/bloqade/builder/location.py
def scale(self, scale: float):\n\"\"\"\n Scale the preceeding waveform by the specified factor.\n Args:\n scale (float): The factor to scale (amplitude of)\n the preceeding waveform.\n Examples:\n - Scale the preceeding waveform that addressing location(0) by 1.2.\n >>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])\n >>> scaled = reg.rydberg.detuning.location(0).scale(1.2)\n - Scale multiple locations with different factors.\n (ex. loc 0 by 1.2, loc 1 by 0.5)\n >>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])\n >>> loc = reg.rydberg.detuning.location(0)\n >>> loc = loc.scale(1.2).location(1).scale(0.5)\n - Scale multiple locations with the same factor. (ex. loc 0 and 1 by 1.2)\n >>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])\n >>> scaled = reg.rydberg.detuning.location(0).location(1).scale(1.2)\n - Possible Next <Location>:\n -> `...scale(float).location(int)`\n :: keep adding location into current list\n - Possible Next <WaveForm>:\n -> `...scale(float).linear()`\n :: apply linear waveform\n -> `...scale(float).constant()`\n :: apply constant waveform\n -> `...scale(float).ploy()`\n :: apply polynomial waveform\n -> `...scale(float).apply()`\n :: apply pre-constructed waveform(s)\n -> `...scale(float).piecewise_linear()`\n :: apply piecewise linear waveform\n -> `...scale(float).piecewise_constant()`\n :: apply piecewise constant waveform\n -> `...scale(float).fn()`\n :: apply callable as waveform.\n \"\"\"\nreturn Scale(self, scale)\n
"},{"location":"reference/bloqade/builder/location/#bloqade.builder.location.Scale","title":"Scale","text":"Scale(parent, scale)\n
Bases: Waveform
src/bloqade/builder/location.py
def __init__(self, parent: Builder, scale) -> None:\nsuper().__init__(parent)\nself._scale = cast(scale)\n
"},{"location":"reference/bloqade/builder/location/#bloqade.builder.location.Scale.location","title":"location","text":"location(label)\n
Parameters:
Name Type Description Defaultlabel
int
The label of the location
requiredExamples:
>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])\n>>> loc = reg.rydberg.detuning.location(0).scale(1.2)\n>>> loc = loc.location(1)\n
Possible Next :
-> ...location(int).location(int)
:: keep adding location into current list
-> ...location(int).scale(float)
:: specify scaling factor to current location for the preceeding waveform
Possible Next :
-> ...location(int).linear()
:: apply linear waveform
-> ...location(int).constant()
:: apply constant waveform
-> ...location(int).ploy()
:: apply polynomial waveform
-> ...location(int).apply()
:: apply pre-constructed waveform
-> ...location(int).piecewise_linear()
:: apply piecewise linear waveform
-> ...location(int).piecewise_constant()
:: apply piecewise constant waveform
-> ...location(int).fn()
:: apply callable as waveform.
src/bloqade/builder/location.py
def location(self, label: int):\n\"\"\"\n - Append another location to the current location after scale the previous one\n Args:\n label (int): The label of the location\n Examples:\n - Append location 1 after scale location 0 by 1.2.\n >>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])\n >>> loc = reg.rydberg.detuning.location(0).scale(1.2)\n >>> loc = loc.location(1)\n - Possible Next <Location>:\n -> `...location(int).location(int)`\n :: keep adding location into current list\n -> `...location(int).scale(float)`\n :: specify scaling factor to current location\n for the preceeding waveform\n - Possible Next <WaveForm>:\n -> `...location(int).linear()`\n :: apply linear waveform\n -> `...location(int).constant()`\n :: apply constant waveform\n -> `...location(int).ploy()`\n :: apply polynomial waveform\n -> `...location(int).apply()`\n :: apply pre-constructed waveform\n -> `...location(int).piecewise_linear()`\n :: apply piecewise linear waveform\n -> `...location(int).piecewise_constant()`\n :: apply piecewise constant waveform\n -> `...location(int).fn()`\n :: apply callable as waveform.\n \"\"\"\nreturn Location(self, label)\n
"},{"location":"reference/bloqade/builder/location/#bloqade.builder.location.Uniform","title":"Uniform","text":" Bases: Waveform
The node specify a uniform spacial modulation. Which is ready to apply waveform (See Waveform
for available waveform options)
Examples:
>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])\n>>> loc = reg.rydberg.detuning.uniform\n
>>> wv = bloqade.ir.Linear(start=0,stop=1,duration=0.5)\n>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])\n>>> loc = reg.rydberg.detuning.uniform.apply(wv)\n
"},{"location":"reference/bloqade/builder/spatial/","title":"Spatial","text":""},{"location":"reference/bloqade/builder/spatial/#bloqade.builder.spatial.SpatialModulation","title":"SpatialModulation","text":" Bases: Builder
SpatialModulation specifies which atom(s) should be addressed to apply the preceeding waveform ((See Waveform
for available waveforms onward)
property
","text":"uniform\n
Possible Next:
-> ...uniform.linear()
:: apply linear waveform
-> ...uniform.constant()
:: apply constant waveform
-> ...uniform.ploy()
:: apply polynomial waveform
-> ...uniform.apply()
:: apply pre-constructed waveform
-> ...uniform.piecewise_linear()
:: apply piecewise linear waveform
-> ...uniform.piecewise_constant()
:: apply piecewise constant waveform
-> ...uniform.fn()
:: apply callable as waveform.
Examples:
>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])\n>>> loc = reg.rydberg.detuning.uniform\n
"},{"location":"reference/bloqade/builder/spatial/#bloqade.builder.spatial.SpatialModulation.location","title":"location","text":"location(label)\n
Addressing one or multiple specific location(s) for preceeding waveform.
(See Location
for more details])
Parameters:
Name Type Description Defaultlabel
int
The label of the location to apply the following waveform to.
requiredExamples:
>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])\n>>> loc = reg.rydberg.detuning.location(1)\n
>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])\n>>> loc = reg.rydberg.detuning.location(1).location(2)\n
Note label index start with 0, and should be positive.
Possible Next :
-> ...location(int).location(int)
:: adding location into current list
-> ...location(int).scale(float)
:: specify scaling factor to current location for the preceeding waveform
Possible Next :
-> ...location(int).linear()
:: apply linear waveform
-> ...location(int).constant()
:: apply constant waveform
-> ...location(int).ploy()
:: apply polynomial waveform
-> ...location(int).apply()
:: apply pre-constructed waveform
-> ...location(int).piecewise_linear()
:: apply piecewise linear waveform
-> ...location(int).piecewise_constant()
:: apply piecewise constant waveform
-> ...location(int).fn()
:: apply callable as waveform.
src/bloqade/builder/spatial.py
def location(self, label: int):\n\"\"\"\n Addressing one or multiple specific location(s) for preceeding waveform.\n (See [`Location`][bloqade.builder.location.Location] for more details])\n Args:\n label (int): The label of the location to apply the following waveform to.\n Examples:\n - Addressing rydberg detuning to location 1 on a system with 4 sites.\n >>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])\n >>> loc = reg.rydberg.detuning.location(1)\n - Addressing rydberg detuning on both location\n 0 and 2 on a system with 4 sites.\n >>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])\n >>> loc = reg.rydberg.detuning.location(1).location(2)\n Note:\n label index start with 0, and should be positive.\n - Possible Next <Location>:\n -> `...location(int).location(int)`\n :: adding location into current list\n -> `...location(int).scale(float)`\n :: specify scaling factor to current location\n for the preceeding waveform\n - Possible Next <WaveForm>:\n -> `...location(int).linear()`\n :: apply linear waveform\n -> `...location(int).constant()`\n :: apply constant waveform\n -> `...location(int).ploy()`\n :: apply polynomial waveform\n -> `...location(int).apply()`\n :: apply pre-constructed waveform\n -> `...location(int).piecewise_linear()`\n :: apply piecewise linear waveform\n -> `...location(int).piecewise_constant()`\n :: apply piecewise constant waveform\n -> `...location(int).fn()`\n :: apply callable as waveform.\n \"\"\"\nfrom .location import Location\nreturn Location(self, label)\n
"},{"location":"reference/bloqade/builder/spatial/#bloqade.builder.spatial.SpatialModulation.var","title":"var","text":"var(name)\n
Possible Next :
-> ...location(int).linear()
:: apply linear waveform
-> ...location(int).constant()
:: apply constant waveform
-> ...location(int).ploy()
:: apply polynomial waveform
-> ...location(int).apply()
:: apply pre-constructed waveform
-> ...location(int).piecewise_linear()
:: apply piecewise linear waveform
-> ...location(int).piecewise_constant()
:: apply piecewise constant waveform
-> ...location(int).fn()
:: apply callable as waveform.
Examples:
myatom
in the system with 4 sites>>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])\n>>> loc = reg.rydberg.detuning.var('myatom')\n
Source code in src/bloqade/builder/spatial.py
def var(self, name: str):\n\"\"\"\n - Addressing atom location associate with given variable for preceeding waveform\n - Possible Next <WaveForm>:\n -> `...location(int).linear()`\n :: apply linear waveform\n -> `...location(int).constant()`\n :: apply constant waveform\n -> `...location(int).ploy()`\n :: apply polynomial waveform\n -> `...location(int).apply()`\n :: apply pre-constructed waveform\n -> `...location(int).piecewise_linear()`\n :: apply piecewise linear waveform\n -> `...location(int).piecewise_constant()`\n :: apply piecewise constant waveform\n -> `...location(int).fn()`\n :: apply callable as waveform.\n Examples:\n - Addressing rydberg detuning to atom location `myatom` in the system with\n 4 sites\n >>> reg = bloqade.start.add_positions([(0,0),(1,1),(2,2),(3,3)])\n >>> loc = reg.rydberg.detuning.var('myatom')\n \"\"\"\nfrom .location import Var\nreturn Var(self, name)\n
"},{"location":"reference/bloqade/builder/start/","title":"Start","text":""},{"location":"reference/bloqade/builder/start/#bloqade.builder.start.ProgramStart","title":"ProgramStart","text":" Bases: Builder
ProgramStart is the base class for a starting/entry node for building a program.
"},{"location":"reference/bloqade/builder/start/#bloqade.builder.start.ProgramStart.hyperfine","title":"hyperfineproperty
","text":"hyperfine\n
Possible Next:
-> ...hyperfine.rabi
:: address rabi term
-> ...hyperfine.detuning
:: address detuning field
Examples:
>>> node = bloqade.start.hyperfine\n>>> type(node)\n<class 'bloqade.builder.coupling.Hyperfine'>\n
Hyperfine level coupling have two reachable field nodes:
Detuning
)Rabi
)>>> hyp_detune = bloqade.start.hyperfine.detuning\n>>> hyp_rabi = bloqade.start.hyperfine.rabi\n
See Hyperfine for more details.
"},{"location":"reference/bloqade/builder/start/#bloqade.builder.start.ProgramStart.rydberg","title":"rydbergproperty
","text":"rydberg\n
Possible Next:
-> ...rydberg.rabi
:: address rabi term
-> ...rydberg.detuning
:: address detuning field
Examples:
>>> node = bloqade.start.rydberg\n>>> type(node)\n<class 'bloqade.builder.coupling.Rydberg'>\n
Rydberg level coupling have two reachable field nodes:
Detuning
)Rabi
)>>> ryd_detune = bloqade.start.rydberg.detuning\n>>> ryd_rabi = bloqade.start.rydberg.rabi\n
See Rydberg
for more details.
apply(sequence)\n
apply an existing pulse sequence to the program.
Source code insrc/bloqade/builder/start.py
def apply(self, sequence: SequenceExpr) -> \"Emit\":\n\"\"\"apply an existing pulse sequence to the program.\"\"\"\nfrom .emit import Emit\nif getattr(self, \"__sequence__\", None) is not None:\nraise NotImplementedError(\"Cannot apply multiple sequences\")\nreturn Emit(self, register=self.__register__, sequence=sequence)\n
"},{"location":"reference/bloqade/builder/waveform/","title":"Waveform","text":""},{"location":"reference/bloqade/builder/waveform/#bloqade.builder.waveform.Recordable","title":"Recordable","text":""},{"location":"reference/bloqade/builder/waveform/#bloqade.builder.waveform.Recordable.record","title":"record","text":"record(name)\n
Record the value of the current waveform to a variable.
Possible Next:
Possible Next :
-> .location(int)
:: creating new channel to address another location(s)
Possible Next :
-> .slice()
:: slice the current waveform
-> .record(str)
:: record the value of waveform at current time
Possible Next :
:: Append waveform into current channel
-> .linear()
-> .constant()
-> .ploy()
-> .apply()
-> .piecewise_linear()
-> .piecewise_constant()
-> .fn()
Possible Next :
-> .rydberg
:: Create/Switch to new rydberg level coupling channel
-> .hyperfine
:: Create/Switch to new hyperfine level coupling channel
Possible Next :
-> .assign()
:: assign varialbe an actual value/number
-> .batch_assign()
:: create batch job with different sets of values assign to each variable.
Possible Next :
-> .quera()
:: Compile current program to QuEra job
-> .braket()
:: Compile current program to Amazon Braket job
-> .braket_local_simulator()
:: Compile current program to local simulator job
src/bloqade/builder/waveform.py
def record(self, name: str):\n\"\"\"\n Record the value of the current waveform to a variable.\n Possible Next:\n - Possible Next <Location>:\n -> `.location(int)`\n :: creating new channel to address\n another location(s)\n - Possible Next <WaveForm:: current>:\n -> `.slice()`\n :: slice the current waveform\n -> `.record(str)`\n :: record the value of waveform at current time\n - Possible Next <WaveForm:: append>:\n :: Append waveform into current channel\n -> `.linear()`\n -> `.constant()`\n -> `.ploy()`\n -> `.apply()`\n -> `.piecewise_linear()`\n -> `.piecewise_constant()`\n -> `.fn()`\n - Possible Next <LevelCoupling>:\n -> `.rydberg`\n :: Create/Switch to new rydberg level coupling channel\n -> `.hyperfine`\n :: Create/Switch to new hyperfine level coupling channel\n - Possible Next <Emit:: Linking Vars>:\n -> `.assign()`\n :: assign varialbe an actual value/number\n -> `.batch_assign()`\n :: create batch job with different sets\n of values assign to each variable.\n - Possible Next <Compile>:\n -> `.quera()`\n :: Compile current program to QuEra job\n -> `.braket()`\n :: Compile current program to Amazon Braket job\n -> `.braket_local_simulator()`\n :: Compile current program to local simulator job\n \"\"\"\nreturn Record(self, name)\n
"},{"location":"reference/bloqade/builder/waveform/#bloqade.builder.waveform.Sliceable","title":"Sliceable","text":""},{"location":"reference/bloqade/builder/waveform/#bloqade.builder.waveform.Sliceable.slice","title":"slice","text":"slice(start=None, stop=None)\n
Slice current waveform
Possible Next:
Possible Next :
-> .location(int)
:: creating new channel to address another location(s)
Possible Next :
-> .record(str)
:: record the value of waveform at current time
Possible Next :
:: Append waveform into current channel
-> .linear()
-> .constant()
-> .ploy()
-> .apply()
-> .piecewise_linear()
-> .piecewise_constant()
-> .fn()
Possible Next :
-> .rydberg
:: Create/Switch to new rydberg level coupling channel
-> .hyperfine
:: Create/Switch to new hyperfine level coupling channel
Possible Next :
-> .assign()
:: assign varialbe an actual value/number
-> .batch_assign()
:: create batch job with different sets of values assign to each variable.
Possible Next :
-> .quera()
:: Compile current program to QuEra job
-> .braket()
:: Compile current program to Amazon Braket job
-> .braket_local_simulator()
:: Compile current program to local simulator job
src/bloqade/builder/waveform.py
def slice(\nself, start: Optional[ScalarType] = None, stop: Optional[ScalarType] = None\n):\n\"\"\"\n Slice current waveform\n Possible Next:\n - Possible Next <Location>:\n -> `.location(int)`\n :: creating new channel to address\n another location(s)\n - Possible Next <WaveForm:: current>:\n -> `.record(str)`\n :: record the value of waveform at current time\n - Possible Next <WaveForm:: append>:\n :: Append waveform into current channel\n -> `.linear()`\n -> `.constant()`\n -> `.ploy()`\n -> `.apply()`\n -> `.piecewise_linear()`\n -> `.piecewise_constant()`\n -> `.fn()`\n - Possible Next <LevelCoupling>:\n -> `.rydberg`\n :: Create/Switch to new rydberg level coupling channel\n -> `.hyperfine`\n :: Create/Switch to new hyperfine level coupling channel\n - Possible Next <Emit:: Linking Vars>:\n -> `.assign()`\n :: assign varialbe an actual value/number\n -> `.batch_assign()`\n :: create batch job with different sets\n of values assign to each variable.\n - Possible Next <Compile>:\n -> `.quera()`\n :: Compile current program to QuEra job\n -> `.braket()`\n :: Compile current program to Amazon Braket job\n -> `.braket_local_simulator()`\n :: Compile current program to local simulator job\n \"\"\"\nreturn Slice(self, start, stop)\n
"},{"location":"reference/bloqade/builder/waveform/#bloqade.builder.waveform.Waveform","title":"Waveform","text":" Bases: Builder
apply(wf)\n
Apply a pre-defined waveform to the current location.
Parameters:
Name Type Description Defaultwf
ir.Waveform
the waveform
requiredExamples:
>>> node = bloqade.start.rydberg.detuning.uniform\n>>> wv = bloqade.ir.Linear(0,10,0.5)\n>>> node = node.apply(wv)\n
Possible Next:
Possible Next :
-> .location(int)
:: creating new channel to address another location(s)
Possible Next :
-> .slice()
:: slice current waveform
-> .record(str)
:: record the value of waveform at current time
Possible Next :
:: Append waveform into current channel
-> .linear()
-> .constant()
-> .ploy()
-> .apply()
-> .piecewise_linear()
-> .piecewise_constant()
-> .fn()
Possible Next :
-> .rydberg
:: Create/Switch to new rydberg level coupling channel
-> .hyperfine
:: Create/Switch to new hyperfine level coupling channel
Possible Next :
-> .assign()
:: assign varialbe an actual value/number
-> .batch_assign()
:: create batch job with different sets of values assign to each variable.
Possible Next :
-> .quera()
:: Compile current program to QuEra job
-> .braket()
:: Compile current program to Amazon Braket job
-> .braket_local_simulator()
:: Compile current program to local simulator job
src/bloqade/builder/waveform.py
def apply(self, wf: ir.Waveform):\n\"\"\"\n Apply a pre-defined waveform to the current location.\n Args:\n wf (ir.Waveform): the waveform\n Examples:\n - apply a pre-defined waveform object to current sequence.\n >>> node = bloqade.start.rydberg.detuning.uniform\n >>> wv = bloqade.ir.Linear(0,10,0.5)\n >>> node = node.apply(wv)\n Possible Next:\n - Possible Next <Location>:\n -> `.location(int)`\n :: creating new channel to address another location(s)\n - Possible Next <WaveForm:: current>:\n -> `.slice()`\n :: slice current waveform\n -> `.record(str)`\n :: record the value of waveform at current time\n - Possible Next <WaveForm:: append>:\n :: Append waveform into current channel\n -> `.linear()`\n -> `.constant()`\n -> `.ploy()`\n -> `.apply()`\n -> `.piecewise_linear()`\n -> `.piecewise_constant()`\n -> `.fn()`\n - Possible Next <LevelCoupling>:\n -> `.rydberg`\n :: Create/Switch to new rydberg level coupling channel\n -> `.hyperfine`\n :: Create/Switch to new hyperfine level coupling channel\n - Possible Next <Emit:: Linking Vars>:\n -> `.assign()`\n :: assign varialbe an actual value/number\n -> `.batch_assign()`\n :: create batch job with different sets\n of values assign to each variable.\n - Possible Next <Compile>:\n -> `.quera()`\n :: Compile current program to QuEra job\n -> `.braket()`\n :: Compile current program to Amazon Braket job\n -> `.braket_local_simulator()`\n :: Compile current program to local simulator job\n \"\"\"\nreturn Apply(self, wf)\n
"},{"location":"reference/bloqade/builder/waveform/#bloqade.builder.waveform.Waveform.constant","title":"constant","text":"constant(value, duration)\n
Append/assign a constant waveform to the current location.
Parameters:
Name Type Description Defaultvalue
ScalarType Union[float, str]
The value of the waveform
requiredduration
ScalarType Union[float, str]
The duration of the waveform
requiredExamples:
>>> node = bloqade.start.rydberg.detuning.uniform\n>>> node = node.constant(value=1,duration=0.5)\n
Possible Next:
Possible Next :
-> .location(int)
:: creating new channel to address another location(s)
Possible Next :
-> .slice()
:: slice current waveform
-> .record(str)
:: record the value of waveform at current time
Possible Next :
:: Append waveform into current channel
-> .linear()
-> .constant()
-> .ploy()
-> .apply()
-> .piecewise_linear()
-> .piecewise_constant()
-> .fn()
Possible Next :
-> .rydberg
:: Create/Switch to new rydberg level coupling channel
-> .hyperfine
:: Create/Switch to new hyperfine level coupling channel
Possible Next :
-> .assign()
:: assign varialbe an actual value/number
-> .batch_assign()
:: create batch job with different sets of values assign to each variable.
Possible Next :
-> .quera()
:: Compile current program to QuEra job
-> .braket()
:: Compile current program to Amazon Braket job
-> .braket_local_simulator()
:: Compile current program to local simulator job
src/bloqade/builder/waveform.py
def constant(self, value: ScalarType, duration: ScalarType):\n\"\"\"\n Append/assign a constant waveform to the current location.\n Args:\n value (ScalarType Union[float, str]): The value of the waveform\n duration (ScalarType Union[float, str]): The duration of the waveform\n Examples:\n - specify a constant waveform of value 1 with duration 0.5\n for (spatial) uniform rydberg detuning\n >>> node = bloqade.start.rydberg.detuning.uniform\n >>> node = node.constant(value=1,duration=0.5)\n Possible Next:\n - Possible Next <Location>:\n -> `.location(int)`\n :: creating new channel to address another location(s)\n - Possible Next <WaveForm:: current>:\n -> `.slice()`\n :: slice current waveform\n -> `.record(str)`\n :: record the value of waveform at current time\n - Possible Next <WaveForm:: append>:\n :: Append waveform into current channel\n -> `.linear()`\n -> `.constant()`\n -> `.ploy()`\n -> `.apply()`\n -> `.piecewise_linear()`\n -> `.piecewise_constant()`\n -> `.fn()`\n - Possible Next <LevelCoupling>:\n -> `.rydberg`\n :: Create/Switch to new rydberg level coupling channel\n -> `.hyperfine`\n :: Create/Switch to new hyperfine level coupling channel\n - Possible Next <Emit:: Linking Vars>:\n -> `.assign()`\n :: assign varialbe an actual value/number\n -> `.batch_assign()`\n :: create batch job with different sets\n of values assign to each variable.\n - Possible Next <Compile>:\n -> `.quera()`\n :: Compile current program to QuEra job\n -> `.braket()`\n :: Compile current program to Amazon Braket job\n -> `.braket_local_simulator()`\n :: Compile current program to local simulator job\n \"\"\"\nreturn Constant(self, value, duration)\n
"},{"location":"reference/bloqade/builder/waveform/#bloqade.builder.waveform.Waveform.fn","title":"fn","text":"fn(fn, duration)\n
Append/assign a waveform defined by a python function to the current location.
This function create a waveform with user-defined python function fn(t)
with duration duration
.
Parameters:
Name Type Description Defaultfn
Callable
The python function defining the waveform
requiredduration
ScalarType
The durations of each constant segment
required Notet
and return a float.Examples:
>>> import numpy as np\n>>> def my_fn(t):\n>>> return np.cos(2*np.pi*t)\n>>> node = bloqade.start.rydberg.detuning.uniform\n>>> node = node.fn(my_fn,duration=0.5)\n
Possible Next:
Possible Next :
-> .location(int)
:: creating new channel to address another location(s)
Possible Next :
-> .slice()
:: slice current waveform
-> .record(str)
:: record the value of waveform at current time
-> .sample()
:: sample current callable at given time points
Possible Next :
:: Append waveform into current channel
-> .linear()
-> .constant()
-> .ploy()
-> .apply()
-> .piecewise_linear()
-> .piecewise_constant()
-> .fn()
Possible Next :
-> .rydberg
:: Create/Switch to new rydberg level coupling channel
-> .hyperfine
:: Create/Switch to new hyperfine level coupling channel
Possible Next :
-> .assign()
:: assign varialbe an actual value/number
-> .batch_assign()
:: create batch job with different sets of values assign to each variable.
Possible Next :
-> .quera()
:: Compile current program to QuEra job
-> .braket()
:: Compile current program to Amazon Braket job
-> .braket_local_simulator()
:: Compile current program to local simulator job
src/bloqade/builder/waveform.py
def fn(self, fn: Callable, duration: ScalarType):\n\"\"\"\n Append/assign a waveform defined by a python function to the current location.\n This function create a waveform with user-defined\n python function `fn(t)` with duration `duration`.\n Args:\n fn (Callable): The python function defining the waveform\n duration (ScalarType): The durations of each constant segment\n Note:\n - ScalarType can be either float or str.\n - The python function should take a single argument `t` and return a float.\n Examples:\n - create a cosine waveform with duration 0.5\n for (spatial) uniform rydberg detuning.\n >>> import numpy as np\n >>> def my_fn(t):\n >>> return np.cos(2*np.pi*t)\n >>> node = bloqade.start.rydberg.detuning.uniform\n >>> node = node.fn(my_fn,duration=0.5)\n Possible Next:\n - Possible Next <Location>:\n -> `.location(int)`\n :: creating new channel to address another location(s)\n - Possible Next <WaveForm:: current>:\n -> `.slice()`\n :: slice current waveform\n -> `.record(str)`\n :: record the value of waveform at current time\n -> `.sample()`\n :: sample current callable at given time points\n - Possible Next <WaveForm:: append>:\n :: Append waveform into current channel\n -> `.linear()`\n -> `.constant()`\n -> `.ploy()`\n -> `.apply()`\n -> `.piecewise_linear()`\n -> `.piecewise_constant()`\n -> `.fn()`\n - Possible Next <LevelCoupling>:\n -> `.rydberg`\n :: Create/Switch to new rydberg level coupling channel\n -> `.hyperfine`\n :: Create/Switch to new hyperfine level coupling channel\n - Possible Next <Emit:: Linking Vars>:\n -> `.assign()`\n :: assign varialbe an actual value/number\n -> `.batch_assign()`\n :: create batch job with different sets\n of values assign to each variable.\n - Possible Next <Compile>:\n -> `.quera()`\n :: Compile current program to QuEra job\n -> `.braket()`\n :: Compile current program to Amazon Braket job\n -> `.braket_local_simulator()`\n :: Compile current program to local simulator job\n \"\"\"\nreturn PythonFn(self, fn, duration)\n
"},{"location":"reference/bloqade/builder/waveform/#bloqade.builder.waveform.Waveform.linear","title":"linear","text":"linear(start, stop, duration)\n
Append/assign a linear waveform to the current location.
Parameters:
Name Type Description Defaultstart
ScalarType Union[float, str]
The start value of the waveform
requiredstop
ScalarType Union[float, str]
The stop value of the waveform
requiredduration
ScalarType Union[float, str]
The duration of the waveform
requiredExamples:
>>> node = bloqade.start.rydberg.detuning.uniform\n>>> node = node.linear(start=0,stop=1,duration=0.5)\n
Possible Next:
Possible Next :
-> .location(int)
:: creating new channel to address another location(s)
Possible Next :
-> .slice()
:: slice current waveform
-> .record(str)
:: record the value of waveform at current time
Possible Next :
:: Append waveform into current channel
-> .linear()
-> .constant()
-> .ploy()
-> .apply()
-> .piecewise_linear()
-> .piecewise_constant()
-> .fn()
Possible Next :
-> .rydberg
:: Create/Switch to new rydberg level coupling channel
-> .hyperfine
:: Create/Switch to new hyperfine level coupling channel
Possible Next :
-> .assign()
:: assign varialbe an actual value/number
-> .batch_assign()
:: create batch job with different sets of values assign to each variable.
Possible Next :
-> .quera()
:: Compile current program to QuEra job
-> .braket()
:: Compile current program to Amazon Braket job
-> .braket_local_simulator()
:: Compile current program to local simulator job
src/bloqade/builder/waveform.py
def linear(self, start: ScalarType, stop: ScalarType, duration: ScalarType):\n\"\"\"\n Append/assign a linear waveform to the current location.\n Args:\n start (ScalarType Union[float, str]): The start value of the waveform\n stop (ScalarType Union[float, str]): The stop value of the waveform\n duration (ScalarType Union[float, str]): The duration of the waveform\n Examples:\n - specify a linear waveform for (spatial) uniform rydberg detuning\n from 0 to 1 in 0.5 us.\n >>> node = bloqade.start.rydberg.detuning.uniform\n >>> node = node.linear(start=0,stop=1,duration=0.5)\n Possible Next:\n - Possible Next <Location>:\n -> `.location(int)`\n :: creating new channel to address another location(s)\n - Possible Next <WaveForm:: current>:\n -> `.slice()`\n :: slice current waveform\n -> `.record(str)`\n :: record the value of waveform at current time\n - Possible Next <WaveForm:: append>:\n :: Append waveform into current channel\n -> `.linear()`\n -> `.constant()`\n -> `.ploy()`\n -> `.apply()`\n -> `.piecewise_linear()`\n -> `.piecewise_constant()`\n -> `.fn()`\n - Possible Next <LevelCoupling>:\n -> `.rydberg`\n :: Create/Switch to new rydberg level coupling channel\n -> `.hyperfine`\n :: Create/Switch to new hyperfine level coupling channel\n - Possible Next <Emit:: Linking Vars>:\n -> `.assign()`\n :: assign varialbe an actual value/number\n -> `.batch_assign()`\n :: create batch job with different\n sets of values assign to each variable.\n - Possible Next <Emit:: Compile >:\n -> `.quera()`\n :: Compile current program to QuEra job\n -> `.braket()`\n :: Compile current program to Amazon Braket job\n -> `.braket_local_simulator()`\n :: Compile current program to local simulator job\n \"\"\"\nreturn Linear(self, start, stop, duration)\n
"},{"location":"reference/bloqade/builder/waveform/#bloqade.builder.waveform.Waveform.piecewise_constant","title":"piecewise_constant","text":"piecewise_constant(durations, values)\n
Append/assign a piecewise constant waveform to the current location. The durations should have number of elements = len(values).
This function create a waveform of piecewise_constant of values[i]
with duration durations[i]
.
Parameters:
Name Type Description Defaultdurations
List[ScalarType]
The durations of each constant segment
requiredvalues
List[ScalarType]
The values of each constant segment
required NoteScalarType can be either float or str.
Examples:
>>> node = bloqade.start.rydberg.detuning.uniform\n>>> node = node.piecewise_constant(values=[0.5,1.5],durations=[0.1,3.8])\n
Possible Next:
Possible Next :
-> .location(int)
:: creating new channel to address another location(s)
Possible Next :
-> .slice()
:: slice current waveform
-> .record(str)
:: record the value of waveform at current time
Possible Next :
:: Append waveform into current channel
-> .linear()
-> .constant()
-> .ploy()
-> .apply()
-> .piecewise_linear()
-> .piecewise_constant()
-> .fn()
Possible Next :
-> .rydberg
:: Create/Switch to new rydberg level coupling channel
-> .hyperfine
:: Create/Switch to new hyperfine level coupling channel
Possible Next :
-> .assign()
:: assign varialbe an actual value/number
-> .batch_assign()
:: create batch job with different sets of values assign to each variable.
Possible Next :
-> .quera()
:: Compile current program to QuEra job
-> .braket()
:: Compile current program to Amazon Braket job
-> .braket_local_simulator()
:: Compile current program to local simulator job
src/bloqade/builder/waveform.py
def piecewise_constant(self, durations: List[ScalarType], values: List[ScalarType]):\n\"\"\"\n Append/assign a piecewise constant waveform to the current location.\n The durations should have number of elements = len(values).\n This function create a waveform of piecewise_constant of\n `values[i]` with duration `durations[i]`.\n Args:\n durations (List[ScalarType]): The durations of each constant segment\n values (List[ScalarType]): The values of each constant segment\n Note:\n ScalarType can be either float or str.\n Examples:\n - specify a piecewise constant of [0.5,1.5] with duration [0.1,3.8]\n for (spatial) uniform rydberg detuning.\n >>> node = bloqade.start.rydberg.detuning.uniform\n >>> node = node.piecewise_constant(values=[0.5,1.5],durations=[0.1,3.8])\n Possible Next:\n - Possible Next <Location>:\n -> `.location(int)`\n :: creating new channel to address another location(s)\n - Possible Next <WaveForm:: current>:\n -> `.slice()`\n :: slice current waveform\n -> `.record(str)`\n :: record the value of waveform at current time\n - Possible Next <WaveForm:: append>:\n :: Append waveform into current channel\n -> `.linear()`\n -> `.constant()`\n -> `.ploy()`\n -> `.apply()`\n -> `.piecewise_linear()`\n -> `.piecewise_constant()`\n -> `.fn()`\n - Possible Next <LevelCoupling>:\n -> `.rydberg`\n :: Create/Switch to new rydberg level coupling channel\n -> `.hyperfine`\n :: Create/Switch to new hyperfine level coupling channel\n - Possible Next <Emit:: Linking Vars>:\n -> `.assign()`\n :: assign varialbe an actual value/number\n -> `.batch_assign()`\n :: create batch job with different sets\n of values assign to each variable.\n - Possible Next <Compile>:\n -> `.quera()`\n :: Compile current program to QuEra job\n -> `.braket()`\n :: Compile current program to Amazon Braket job\n -> `.braket_local_simulator()`\n :: Compile current program to local simulator job\n \"\"\"\nbuilder = self\nif len(durations) != len(values):\nraise ValueError(\"durations and values lists must have same length.\")\nfor duration, value in zip(durations, values):\nbuilder = builder.constant(value, duration)\nreturn builder\n
"},{"location":"reference/bloqade/builder/waveform/#bloqade.builder.waveform.Waveform.piecewise_linear","title":"piecewise_linear","text":"piecewise_linear(durations, values)\n
Append/assign a piecewise linear waveform to the current location. The durations should have number of elements = len(values) - 1.
This function create a waveform by connecting values[i], values[i+1]
with linear segments.
Parameters:
Name Type Description Defaultdurations
List[ScalarType]
The durations of each linear segment
requiredvalues
List[ScalarType]
The values of each linear segment
requiredExamples:
>>> node = bloqade.start.rydberg.detuning.uniform\n>>> node = node.piecewise_linear(values=[0,1,1,0],durations=[0.1,3.8,0.1])\n
Note ScalarType can be either float or str.
Possible Next:
Possible Next :
-> .location(int)
:: creating new channel to address another location(s)
Possible Next :
-> .slice()
:: slice current waveform
-> .record(str)
:: record the value of waveform at current time
Possible Next :
:: Append waveform into current channel
-> .linear()
-> .constant()
-> .ploy()
-> .apply()
-> .piecewise_linear()
-> .piecewise_constant()
-> .fn()
Possible Next :
-> .rydberg
:: Create/Switch to new rydberg level coupling channel
-> .hyperfine
:: Create/Switch to new hyperfine level coupling channel
Possible Next :
-> .assign()
:: assign varialbe an actual value/number
-> .batch_assign()
:: create batch job with different sets of values assign to each variable.
Possible Next :
-> .quera()
:: Compile current program to QuEra job
-> .braket()
:: Compile current program to Amazon Braket job
-> .braket_local_simulator()
:: Compile current program to local simulator job
src/bloqade/builder/waveform.py
def piecewise_linear(self, durations: List[ScalarType], values: List[ScalarType]):\n\"\"\"\n Append/assign a piecewise linear waveform to the current location.\n The durations should have number of elements = len(values) - 1.\n This function create a waveform by connecting `values[i], values[i+1]`\n with linear segments.\n Args:\n durations (List[ScalarType]): The durations of each linear segment\n values (List[ScalarType]): The values of each linear segment\n Examples:\n - specify a piecewise linear of [0,1,1,0] with duration [0.1,3.8,0.1]\n for (spatial) uniform rydberg detuning.\n >>> node = bloqade.start.rydberg.detuning.uniform\n >>> node = node.piecewise_linear(values=[0,1,1,0],durations=[0.1,3.8,0.1])\n Note:\n ScalarType can be either float or str.\n Possible Next:\n - Possible Next <Location>:\n -> `.location(int)`\n :: creating new channel to address another location(s)\n - Possible Next <WaveForm:: current>:\n -> `.slice()`\n :: slice current waveform\n -> `.record(str)`\n :: record the value of waveform at current time\n - Possible Next <WaveForm:: append>:\n :: Append waveform into current channel\n -> `.linear()`\n -> `.constant()`\n -> `.ploy()`\n -> `.apply()`\n -> `.piecewise_linear()`\n -> `.piecewise_constant()`\n -> `.fn()`\n - Possible Next <LevelCoupling>:\n -> `.rydberg`\n :: Create/Switch to new rydberg level coupling channel\n -> `.hyperfine`\n :: Create/Switch to new hyperfine level coupling channel\n - Possible Next <Emit:: Linking Vars>:\n -> `.assign()`\n :: assign varialbe an actual value/number\n -> `.batch_assign()`\n :: create batch job with different sets\n of values assign to each variable.\n - Possible Next <Compile>:\n -> `.quera()`\n :: Compile current program to QuEra job\n -> `.braket()`\n :: Compile current program to Amazon Braket job\n -> `.braket_local_simulator()`\n :: Compile current program to local simulator job\n \"\"\"\nbuilder = self\nif len(durations) != len(values) - 1:\nraise ValueError(\"len(durations) must be len(values)-1.\")\nfor duration, start, stop in zip(durations, values[:-1], values[1:]):\nbuilder = builder.linear(start, stop, duration)\nreturn builder\n
"},{"location":"reference/bloqade/builder/waveform/#bloqade.builder.waveform.Waveform.poly","title":"poly","text":"poly(coeffs, duration)\n
Append/assign a waveform with polynomial profile to the current location.
with formwv(t) = coeffs[0] + coeffs[1]*t + coeffs[2]*t^2 + ... + coeffs[n]*t^n
Parameters:
Name Type Description Defaultcoeffs
ScalarType Union[float, str]
The coefficients of the polynomial
requiredduration
ScalarType Union[float, str]
The duration of the waveform
requiredExamples:
>>> node = bloqade.start.rydberg.detuning.uniform\n>>> node = node.poly(coeffs=[1,2,3],duration=0.5)\n
Possible Next:
Possible Next :
-> .location(int)
:: creating new channel to address another location(s)
Possible Next :
-> .slice()
:: slice current waveform
-> .record(str)
:: record the value of waveform at current time
Possible Next :
:: Append waveform into current channel
-> .linear()
-> .constant()
-> .ploy()
-> .apply()
-> .piecewise_linear()
-> .piecewise_constant()
-> .fn()
Possible Next :
-> .rydberg
:: Create/Switch to new rydberg level coupling channel
-> .hyperfine
:: Create/Switch to new hyperfine level coupling channel
Possible Next :
-> .assign()
:: assign varialbe an actual value/number
-> .batch_assign()
:: create batch job with different sets of values assign to each variable.
Possible Next :
-> .quera()
:: Compile current program to QuEra job
-> .braket()
:: Compile current program to Amazon Braket job
-> .braket_local_simulator()
:: Compile current program to local simulator job
src/bloqade/builder/waveform.py
def poly(self, coeffs: ScalarType, duration: ScalarType):\n\"\"\"\n Append/assign a waveform with polynomial profile to the current location.\n with form:\n wv(t) = coeffs[0] + coeffs[1]*t + coeffs[2]*t^2 + ... + coeffs[n]*t^n\n Args:\n coeffs (ScalarType Union[float, str]): The coefficients of the polynomial\n duration (ScalarType Union[float, str]): The duration of the waveform\n Examples:\n - specify a second order polynomial with duration 0.5\n for (spatial) uniform rydberg detuning\n >>> node = bloqade.start.rydberg.detuning.uniform\n >>> node = node.poly(coeffs=[1,2,3],duration=0.5)\n Possible Next:\n - Possible Next <Location>:\n -> `.location(int)`\n :: creating new channel to address another location(s)\n - Possible Next <WaveForm:: current>:\n -> `.slice()`\n :: slice current waveform\n -> `.record(str)`\n :: record the value of waveform at current time\n - Possible Next <WaveForm:: append>:\n :: Append waveform into current channel\n -> `.linear()`\n -> `.constant()`\n -> `.ploy()`\n -> `.apply()`\n -> `.piecewise_linear()`\n -> `.piecewise_constant()`\n -> `.fn()`\n - Possible Next <LevelCoupling>:\n -> `.rydberg`\n :: Create/Switch to new rydberg level coupling channel\n -> `.hyperfine`\n :: Create/Switch to new hyperfine level coupling channel\n - Possible Next <Emit:: Linking Vars>:\n -> `.assign()`\n :: assign varialbe an actual value/number\n -> `.batch_assign()`\n :: create batch job with different sets\n of values assign to each variable.\n - Possible Next <Compile>:\n -> `.quera()`\n :: Compile current program to QuEra job\n -> `.braket()`\n :: Compile current program to Amazon Braket job\n -> `.braket_local_simulator()`\n :: Compile current program to local simulator job\n \"\"\"\nreturn Poly(self, coeffs, duration)\n
"},{"location":"reference/bloqade/ir/","title":"Index","text":""},{"location":"reference/bloqade/ir/#bloqade.ir.AlignedWaveform","title":"AlignedWaveform","text":" Bases: Waveform
<padded waveform> ::= <waveform> | <waveform> <alignment> <value>\n<alignment> ::= 'left aligned' | 'right aligned'\n<value> ::= 'left value' | 'right value' | <scalar expr>\n
"},{"location":"reference/bloqade/ir/#bloqade.ir.Constant","title":"Constant","text":"Constant(value, duration)\n
Bases: Instruction
<constant> ::= 'constant' <scalar expr>\n
f(t=0:duration) = value
Parameters:
Name Type Description Defaultvalue
Scalar
the constant value
requiredduration
Scalar
the time span of the constant waveform.
required Source code insrc/bloqade/ir/control/waveform.py
def __init__(self, value, duration):\nself.value = cast(value)\nself._duration = cast(duration)\n
"},{"location":"reference/bloqade/ir/#bloqade.ir.Field","title":"Field","text":"Field node in the IR. Which contains collection(s) of Waveform
<field> ::= ('field' <spatial modulation> <padded waveform>)*\n
"},{"location":"reference/bloqade/ir/#bloqade.ir.Linear","title":"Linear","text":"Linear(start, stop, duration)\n
Bases: Instruction
<linear> ::= 'linear' <scalar expr> <scalar expr>\n
f(t=0:duration) = start + (stop-start)/duration * t
Parameters:
Name Type Description Defaultstart
Scalar
start value
requiredstop
Scalar
stop value
requiredduration
Scalar
the time span of the linear waveform.
required Source code insrc/bloqade/ir/control/waveform.py
def __init__(self, start, stop, duration):\nself.start = cast(start)\nself.stop = cast(stop)\nself._duration = cast(duration)\n
"},{"location":"reference/bloqade/ir/#bloqade.ir.Literal","title":"Literal","text":" Bases: Real
class-attribute
","text":"value: Decimal\n
Scalar Literal, which stores a decimaal value instance.
Parameters:
Name Type Description Defaultvalue
Decimal
decimal value instance
required"},{"location":"reference/bloqade/ir/#bloqade.ir.Poly","title":"Poly","text":"Poly(checkpoints, duration)\n
Bases: Instruction
<poly> ::= <scalar>+\n
f(t=0:duration) = c[0] + c[1]t + c[2]t^2 + ... + c[n-1]t^n-1 + c[n]t^n
Parameters:
Name Type Description Defaultcheckpoints
List[Scalar]
the coefficients c[] of the polynomial.
requiredduration
Scalar
the time span of the waveform.
required Source code insrc/bloqade/ir/control/waveform.py
def __init__(self, checkpoints, duration):\nself.checkpoints = cast(checkpoints)\nself._duration = cast(duration)\n
"},{"location":"reference/bloqade/ir/#bloqade.ir.Program","title":"Program","text":"Program(register, sequence)\n
Program is a dummy type that bundle register and sequence together.
Source code insrc/bloqade/ir/program.py
def __init__(\nself,\nregister: Union[\"AtomArrangement\", \"ParallelRegister\"],\nsequence: Sequence,\n):\nself._sequence = sequence\nself._register = register\n
"},{"location":"reference/bloqade/ir/#bloqade.ir.program.Program.register","title":"register property
","text":"register\n
Get the register of the program.
Returns:
Type Descriptionregister (Union[\"AtomArrangement\", \"ParallelRegister\"])
NoteIf the program is built with parallelize()
, The the register will be a ParallelRegister
. Otherwise it will be a AtomArrangement
.
property
","text":"sequence\n
Get the sequence of the program.
Returns:
Name Type DescriptionSequence
the sequence of the program. See also Sequence
.
Pulse(field_pairs)\n
Bases: PulseExpr
<pulse> ::= (<field name> <field>)+\n
Source code in src/bloqade/ir/control/pulse.py
def __init__(self, field_pairs):\nvalue = dict()\nfor k, v in field_pairs.items():\nif isinstance(v, Field):\nvalue[k] = v\nelif isinstance(v, dict):\nvalue[k] = Field(v)\nelse:\nraise TypeError(f\"Expected Field or dict, got {type(v)}\")\nself.value = value\n
"},{"location":"reference/bloqade/ir/#bloqade.ir.PythonFn","title":"PythonFn","text":"PythonFn(fn, duration)\n
Bases: Instruction
<python-fn> ::= 'python-fn' <python function def> <scalar expr>\n
Source code in src/bloqade/ir/control/waveform.py
def __init__(self, fn: Callable, duration: Any):\nself.fn = fn\nself._duration = cast(duration)\nsignature = inspect.getfullargspec(fn)\nif signature.varargs is not None:\nraise ValueError(\"Cannot have varargs\")\nif signature.varkw is not None:\nraise ValueError(\"Cannot have varkw\")\nself.parameters = list(signature.args[1:]) + list(signature.kwonlyargs)\n
"},{"location":"reference/bloqade/ir/#bloqade.ir.Record","title":"Record","text":" Bases: Waveform
<record> ::= 'record' <waveform> <var>\n
"},{"location":"reference/bloqade/ir/#bloqade.ir.Sample","title":"Sample","text":" Bases: Waveform
<sample> ::= 'sample' <waveform> <interpolation> <scalar>\n
"},{"location":"reference/bloqade/ir/#bloqade.ir.Scalar","title":"Scalar","text":"Base class for all scalar expressions.
<scalar> ::= <literal>\n| <variable>\n| <default>\n| <negative>\n| <add>\n| <mul>\n| <min>\n| <max>\n| <slice>\n| <inverval>\n<mul> ::= <scalar> '*' <scalar>\n<add> ::= <scalar> '+' <scalar>\n<min> ::= 'min' <scalar>+\n<max> ::= 'max' <scalar>+\n<slice> ::= <scalar expr> '[' <interval> ']'\n<interval> ::= <scalar expr> '..' <scalar expr>\n<real> ::= <literal> | <var>\n
"},{"location":"reference/bloqade/ir/#bloqade.ir.Sequence","title":"Sequence","text":"Sequence(seq_pairs=None)\n
Bases: SequenceExpr
Sequence of a program, which includes pulses informations.
Source code insrc/bloqade/ir/control/sequence.py
def __init__(self, seq_pairs: Dict | None = None):\nif seq_pairs is None:\nself.value = {}\nreturn\nvalue = {}\nfor level_coupling, pulse in seq_pairs.items():\nif not isinstance(level_coupling, LevelCoupling):\nraise TypeError(f\"Unexpected type {type(level_coupling)}\")\nif isinstance(pulse, PulseExpr):\nvalue[level_coupling] = pulse\nelif isinstance(pulse, dict):\nvalue[level_coupling] = Pulse(pulse)\nelse:\nraise TypeError(f\"Unexpected type {type(pulse)}\")\nself.value = value\n
"},{"location":"reference/bloqade/ir/#bloqade.ir.Variable","title":"Variable","text":" Bases: Real
Variable, which stores a variable name.
Parameters:
Name Type Description Defaultname
str
variable instance.
required"},{"location":"reference/bloqade/ir/#bloqade.ir.Waveform","title":"Waveform","text":"Waveform node in the IR.
<instruction>
<smooth>
<slice>
<apppend>
<negative>
<scale>
<add>
<record>
<sample>
<waveform> ::= <instruction>\n | <smooth>\n | <slice>\n | <append>\n | <negative>\n | <scale>\n | <add>\n | <record>\n | <sample>\n
"},{"location":"reference/bloqade/ir/#bloqade.ir.control.waveform.Waveform.plot","title":"plot","text":"plot(**assignments)\n
Plot the waveform.
Returns:
Name Type Descriptionfigure
a bokeh figure
Source code insrc/bloqade/ir/control/waveform.py
def plot(self, **assignments):\n\"\"\"Plot the waveform.\n Returns:\n figure: a bokeh figure\n \"\"\"\nduration = self.duration(**assignments)\ntimes = np.linspace(0, duration, 1001)\nvalues = [self.__call__(time, **assignments) for time in times]\nfig = figure(width=250, height=250)\nfig.line(times, values)\nreturn fig\n
"},{"location":"reference/bloqade/ir/#bloqade.ir.cast","title":"cast","text":"cast(py)\n
cast Real number (or list/tuple of Real numbers) to Scalar Literal
.
Parameters:
Name Type Description Defaultpy
Union[Real, Tuple[Real], List[Real]]
python object to cast
requiredReturns:
Type DescriptionAny
Union[Literal,Tuple[Literal],List[Literal]]
Source code insrc/bloqade/ir/scalar.py
def cast(py) -> Any:\n\"\"\"cast Real number (or list/tuple of Real numbers)\n to [`Scalar Literal`][bloqade.ir.scalar.Literal].\n Args:\n py (Union[Real,Tuple[Real],List[Real]]): python object to cast\n Returns:\n Union[Literal,Tuple[Literal],List[Literal]]\n \"\"\"\nret = trycast(py)\nif ret is None:\nraise TypeError(f\"Cannot cast {type(py)} to Scalar Literal\")\nreturn ret\n
"},{"location":"reference/bloqade/ir/#bloqade.ir.var","title":"var","text":"var(py)\n
cast string (or list/tuple of strings) to Variable
.
Parameters:
Name Type Description Defaultpy
Union[str, List[str], Tuple[str]]
a string or list/tuple of strings
requiredReturns:
Type DescriptionAny
Union[Variable, List[Variable], Tuple[Variable]]
Source code insrc/bloqade/ir/scalar.py
def var(py: Union[str, List[str]]) -> Any:\n\"\"\"cast string (or list/tuple of strings)\n to [`Variable`][bloqade.ir.scalar.Variable].\n Args:\n py (Union[str, List[str], Tuple[str]]): a string or list/tuple of strings\n Returns:\n Union[Variable, List[Variable], Tuple[Variable]]\n \"\"\"\nret = tryvar(py)\nif ret is None:\nraise TypeError(f\"Cannot cast {type(py)} to Variable\")\nreturn ret\n
"},{"location":"reference/bloqade/ir/program/","title":"Program","text":""},{"location":"reference/bloqade/ir/program/#bloqade.ir.program.Program","title":"Program","text":"Program(register, sequence)\n
Program is a dummy type that bundle register and sequence together.
Source code insrc/bloqade/ir/program.py
def __init__(\nself,\nregister: Union[\"AtomArrangement\", \"ParallelRegister\"],\nsequence: Sequence,\n):\nself._sequence = sequence\nself._register = register\n
"},{"location":"reference/bloqade/ir/program/#bloqade.ir.program.Program.register","title":"register property
","text":"register\n
Get the register of the program.
Returns:
Type Descriptionregister (Union[\"AtomArrangement\", \"ParallelRegister\"])
NoteIf the program is built with parallelize()
, The the register will be a ParallelRegister
. Otherwise it will be a AtomArrangement
.
property
","text":"sequence\n
Get the sequence of the program.
Returns:
Name Type DescriptionSequence
the sequence of the program. See also Sequence
.
Bases: Real
class-attribute
","text":"value: Decimal\n
Scalar Literal, which stores a decimaal value instance.
Parameters:
Name Type Description Defaultvalue
Decimal
decimal value instance
required"},{"location":"reference/bloqade/ir/scalar/#bloqade.ir.scalar.Scalar","title":"Scalar","text":"Base class for all scalar expressions.
<scalar> ::= <literal>\n| <variable>\n| <default>\n| <negative>\n| <add>\n| <mul>\n| <min>\n| <max>\n| <slice>\n| <inverval>\n<mul> ::= <scalar> '*' <scalar>\n<add> ::= <scalar> '+' <scalar>\n<min> ::= 'min' <scalar>+\n<max> ::= 'max' <scalar>+\n<slice> ::= <scalar expr> '[' <interval> ']'\n<interval> ::= <scalar expr> '..' <scalar expr>\n<real> ::= <literal> | <var>\n
"},{"location":"reference/bloqade/ir/scalar/#bloqade.ir.scalar.Variable","title":"Variable","text":" Bases: Real
Variable, which stores a variable name.
Parameters:
Name Type Description Defaultname
str
variable instance.
required"},{"location":"reference/bloqade/ir/scalar/#bloqade.ir.scalar.cast","title":"cast","text":"cast(py)\n
cast Real number (or list/tuple of Real numbers) to Scalar Literal
.
Parameters:
Name Type Description Defaultpy
Union[Real, Tuple[Real], List[Real]]
python object to cast
requiredReturns:
Type DescriptionAny
Union[Literal,Tuple[Literal],List[Literal]]
Source code insrc/bloqade/ir/scalar.py
def cast(py) -> Any:\n\"\"\"cast Real number (or list/tuple of Real numbers)\n to [`Scalar Literal`][bloqade.ir.scalar.Literal].\n Args:\n py (Union[Real,Tuple[Real],List[Real]]): python object to cast\n Returns:\n Union[Literal,Tuple[Literal],List[Literal]]\n \"\"\"\nret = trycast(py)\nif ret is None:\nraise TypeError(f\"Cannot cast {type(py)} to Scalar Literal\")\nreturn ret\n
"},{"location":"reference/bloqade/ir/scalar/#bloqade.ir.scalar.var","title":"var","text":"var(py)\n
cast string (or list/tuple of strings) to Variable
.
Parameters:
Name Type Description Defaultpy
Union[str, List[str], Tuple[str]]
a string or list/tuple of strings
requiredReturns:
Type DescriptionAny
Union[Variable, List[Variable], Tuple[Variable]]
Source code insrc/bloqade/ir/scalar.py
def var(py: Union[str, List[str]]) -> Any:\n\"\"\"cast string (or list/tuple of strings)\n to [`Variable`][bloqade.ir.scalar.Variable].\n Args:\n py (Union[str, List[str], Tuple[str]]): a string or list/tuple of strings\n Returns:\n Union[Variable, List[Variable], Tuple[Variable]]\n \"\"\"\nret = tryvar(py)\nif ret is None:\nraise TypeError(f\"Cannot cast {type(py)} to Variable\")\nreturn ret\n
"},{"location":"reference/bloqade/ir/control/","title":"Index","text":""},{"location":"reference/bloqade/ir/control/field/","title":"Field","text":""},{"location":"reference/bloqade/ir/control/field/#bloqade.ir.control.field.Field","title":"Field","text":"Field node in the IR. Which contains collection(s) of Waveform
<field> ::= ('field' <spatial modulation> <padded waveform>)*\n
"},{"location":"reference/bloqade/ir/control/pulse/","title":"Pulse","text":""},{"location":"reference/bloqade/ir/control/pulse/#bloqade.ir.control.pulse.Append","title":"Append","text":" Bases: PulseExpr
<append> ::= <expr>+\n
"},{"location":"reference/bloqade/ir/control/pulse/#bloqade.ir.control.pulse.Pulse","title":"Pulse","text":"Pulse(field_pairs)\n
Bases: PulseExpr
<pulse> ::= (<field name> <field>)+\n
Source code in src/bloqade/ir/control/pulse.py
def __init__(self, field_pairs):\nvalue = dict()\nfor k, v in field_pairs.items():\nif isinstance(v, Field):\nvalue[k] = v\nelif isinstance(v, dict):\nvalue[k] = Field(v)\nelse:\nraise TypeError(f\"Expected Field or dict, got {type(v)}\")\nself.value = value\n
"},{"location":"reference/bloqade/ir/control/pulse/#bloqade.ir.control.pulse.PulseExpr","title":"PulseExpr","text":"<expr> ::= <pulse>\n | <append>\n | <slice>\n | <named>\n
"},{"location":"reference/bloqade/ir/control/sequence/","title":"Sequence","text":""},{"location":"reference/bloqade/ir/control/sequence/#bloqade.ir.control.sequence.Sequence","title":"Sequence","text":"Sequence(seq_pairs=None)\n
Bases: SequenceExpr
Sequence of a program, which includes pulses informations.
Source code insrc/bloqade/ir/control/sequence.py
def __init__(self, seq_pairs: Dict | None = None):\nif seq_pairs is None:\nself.value = {}\nreturn\nvalue = {}\nfor level_coupling, pulse in seq_pairs.items():\nif not isinstance(level_coupling, LevelCoupling):\nraise TypeError(f\"Unexpected type {type(level_coupling)}\")\nif isinstance(pulse, PulseExpr):\nvalue[level_coupling] = pulse\nelif isinstance(pulse, dict):\nvalue[level_coupling] = Pulse(pulse)\nelse:\nraise TypeError(f\"Unexpected type {type(pulse)}\")\nself.value = value\n
"},{"location":"reference/bloqade/ir/control/waveform/","title":"Waveform","text":""},{"location":"reference/bloqade/ir/control/waveform/#bloqade.ir.control.waveform.Add","title":"Add","text":" Bases: Waveform
<add> ::= <waveform> '+' <waveform>\n
"},{"location":"reference/bloqade/ir/control/waveform/#bloqade.ir.control.waveform.AlignedWaveform","title":"AlignedWaveform","text":" Bases: Waveform
<padded waveform> ::= <waveform> | <waveform> <alignment> <value>\n<alignment> ::= 'left aligned' | 'right aligned'\n<value> ::= 'left value' | 'right value' | <scalar expr>\n
"},{"location":"reference/bloqade/ir/control/waveform/#bloqade.ir.control.waveform.Append","title":"Append","text":" Bases: Waveform
<append> ::= <waveform>+\n
"},{"location":"reference/bloqade/ir/control/waveform/#bloqade.ir.control.waveform.Constant","title":"Constant","text":"Constant(value, duration)\n
Bases: Instruction
<constant> ::= 'constant' <scalar expr>\n
f(t=0:duration) = value
Parameters:
Name Type Description Defaultvalue
Scalar
the constant value
requiredduration
Scalar
the time span of the constant waveform.
required Source code insrc/bloqade/ir/control/waveform.py
def __init__(self, value, duration):\nself.value = cast(value)\nself._duration = cast(duration)\n
"},{"location":"reference/bloqade/ir/control/waveform/#bloqade.ir.control.waveform.Instruction","title":"Instruction","text":" Bases: Waveform
Instruction node in the IR.
<linear>
<constant>
<poly>
<python-fn>
<instruction> ::= <linear>\n | <constant>\n | <poly>\n | <python-fn>\n
"},{"location":"reference/bloqade/ir/control/waveform/#bloqade.ir.control.waveform.Linear","title":"Linear","text":"Linear(start, stop, duration)\n
Bases: Instruction
<linear> ::= 'linear' <scalar expr> <scalar expr>\n
f(t=0:duration) = start + (stop-start)/duration * t
Parameters:
Name Type Description Defaultstart
Scalar
start value
requiredstop
Scalar
stop value
requiredduration
Scalar
the time span of the linear waveform.
required Source code insrc/bloqade/ir/control/waveform.py
def __init__(self, start, stop, duration):\nself.start = cast(start)\nself.stop = cast(stop)\nself._duration = cast(duration)\n
"},{"location":"reference/bloqade/ir/control/waveform/#bloqade.ir.control.waveform.Negative","title":"Negative","text":" Bases: Waveform
<negative> ::= '-' <waveform>\n
"},{"location":"reference/bloqade/ir/control/waveform/#bloqade.ir.control.waveform.Poly","title":"Poly","text":"Poly(checkpoints, duration)\n
Bases: Instruction
<poly> ::= <scalar>+\n
f(t=0:duration) = c[0] + c[1]t + c[2]t^2 + ... + c[n-1]t^n-1 + c[n]t^n
Parameters:
Name Type Description Defaultcheckpoints
List[Scalar]
the coefficients c[] of the polynomial.
requiredduration
Scalar
the time span of the waveform.
required Source code insrc/bloqade/ir/control/waveform.py
def __init__(self, checkpoints, duration):\nself.checkpoints = cast(checkpoints)\nself._duration = cast(duration)\n
"},{"location":"reference/bloqade/ir/control/waveform/#bloqade.ir.control.waveform.PythonFn","title":"PythonFn","text":"PythonFn(fn, duration)\n
Bases: Instruction
<python-fn> ::= 'python-fn' <python function def> <scalar expr>\n
Source code in src/bloqade/ir/control/waveform.py
def __init__(self, fn: Callable, duration: Any):\nself.fn = fn\nself._duration = cast(duration)\nsignature = inspect.getfullargspec(fn)\nif signature.varargs is not None:\nraise ValueError(\"Cannot have varargs\")\nif signature.varkw is not None:\nraise ValueError(\"Cannot have varkw\")\nself.parameters = list(signature.args[1:]) + list(signature.kwonlyargs)\n
"},{"location":"reference/bloqade/ir/control/waveform/#bloqade.ir.control.waveform.Record","title":"Record","text":" Bases: Waveform
<record> ::= 'record' <waveform> <var>\n
"},{"location":"reference/bloqade/ir/control/waveform/#bloqade.ir.control.waveform.Sample","title":"Sample","text":" Bases: Waveform
<sample> ::= 'sample' <waveform> <interpolation> <scalar>\n
"},{"location":"reference/bloqade/ir/control/waveform/#bloqade.ir.control.waveform.Scale","title":"Scale","text":"Scale(scalar, waveform)\n
Bases: Waveform
<scale> ::= <scalar expr> '*' <waveform>\n
Source code in src/bloqade/ir/control/waveform.py
def __init__(self, scalar, waveform: Waveform):\nself.scalar = cast(scalar)\nself.waveform = waveform\n
"},{"location":"reference/bloqade/ir/control/waveform/#bloqade.ir.control.waveform.Slice","title":"Slice","text":" Bases: Waveform
<slice> ::= <waveform> <scalar.interval>\n
"},{"location":"reference/bloqade/ir/control/waveform/#bloqade.ir.control.waveform.Smooth","title":"Smooth","text":" Bases: Waveform
<smooth> ::= 'smooth' <kernel> <waveform>\n
"},{"location":"reference/bloqade/ir/control/waveform/#bloqade.ir.control.waveform.Waveform","title":"Waveform","text":"Waveform node in the IR.
<instruction>
<smooth>
<slice>
<apppend>
<negative>
<scale>
<add>
<record>
<sample>
<waveform> ::= <instruction>\n | <smooth>\n | <slice>\n | <append>\n | <negative>\n | <scale>\n | <add>\n | <record>\n | <sample>\n
"},{"location":"reference/bloqade/ir/control/waveform/#bloqade.ir.control.waveform.Waveform.plot","title":"plot","text":"plot(**assignments)\n
Plot the waveform.
Returns:
Name Type Descriptionfigure
a bokeh figure
Source code insrc/bloqade/ir/control/waveform.py
def plot(self, **assignments):\n\"\"\"Plot the waveform.\n Returns:\n figure: a bokeh figure\n \"\"\"\nduration = self.duration(**assignments)\ntimes = np.linspace(0, duration, 1001)\nvalues = [self.__call__(time, **assignments) for time in times]\nfig = figure(width=250, height=250)\nfig.line(times, values)\nreturn fig\n
"},{"location":"reference/bloqade/ir/location/","title":"Index","text":""},{"location":"reference/bloqade/ir/location/#bloqade.ir.location.start","title":"start module-attribute
","text":"start = ListOfLocations()\n
Possible Next
-> start.rydberg
:: address rydberg level coupling
-> start.hyperfine
:: address hyperfine level coupling
Possible Next
-> start.add_locations(List[Tuple[int]])
:: add multiple atoms to current register
-> start.add_location(Tuple[int])
:: add atom to current register
AtomArrangement()\n
Bases: ProgramStart
src/bloqade/ir/location/base.py
def __init__(self) -> None:\nsuper().__init__(register=self)\n
"},{"location":"reference/bloqade/ir/location/#bloqade.ir.location.base.AtomArrangement.n_atoms","title":"n_atoms property
","text":"n_atoms: int\n
number of atoms in the register.
"},{"location":"reference/bloqade/ir/location/#bloqade.ir.location.base.AtomArrangement.n_dims","title":"n_dimsproperty
","text":"n_dims: int\n
number of dimensions in the register.
"},{"location":"reference/bloqade/ir/location/#bloqade.ir.location.base.AtomArrangement.add_position","title":"add_position","text":"add_position(position, filled=True)\n
add a position to existing atom arrangement.
Source code insrc/bloqade/ir/location/base.py
def add_position(\nself, position: Tuple[Any, Any], filled: bool = True\n) -> \"ListOfLocations\":\n\"\"\"add a position to existing atom arrangement.\"\"\"\nfrom .list import ListOfLocations\nlocation_list = [LocationInfo(position, filled)]\nfor location_info in self.enumerate():\nlocation_list.append(location_info)\nreturn ListOfLocations(location_list)\n
"},{"location":"reference/bloqade/ir/location/#bloqade.ir.location.base.AtomArrangement.add_positions","title":"add_positions","text":"add_positions(positions, filling=None)\n
add a list of positions to existing atom arrangement.
Source code insrc/bloqade/ir/location/base.py
def add_positions(\nself, positions: List[Tuple[Any, Any]], filling: Optional[List[bool]] = None\n) -> \"ListOfLocations\":\n\"\"\"add a list of positions to existing atom arrangement.\"\"\"\nfrom .list import ListOfLocations\nlocation_list = []\nif filling:\nfor position, filled in zip(positions, filling):\nlocation_list.append(LocationInfo(position, filled))\nelse:\nfor position in positions:\nlocation_list.append(LocationInfo(position, True))\nfor location_info in self.enumerate():\nlocation_list.append(location_info)\nreturn ListOfLocations(location_list)\n
"},{"location":"reference/bloqade/ir/location/#bloqade.ir.location.base.AtomArrangement.apply_defect_count","title":"apply_defect_count","text":"apply_defect_count(n_defects, rng=np.random.default_rng())\n
apply n_defects randomly to existing atom arrangement.
Source code insrc/bloqade/ir/location/base.py
def apply_defect_count(\nself, n_defects: int, rng: np.random.Generator = np.random.default_rng()\n) -> \"ListOfLocations\":\n\"\"\"apply n_defects randomly to existing atom arrangement.\"\"\"\nfrom .list import ListOfLocations\nlocation_list = []\nfor location_info in self.enumerate():\nlocation_list.append(location_info)\nfor _ in range(n_defects):\nidx = rng.integers(0, len(location_list))\nlocation_list[idx] = LocationInfo(\nlocation_list[idx].position,\n(False if location_list[idx].filling is SiteFilling.filled else True),\n)\nreturn ListOfLocations(location_list)\n
"},{"location":"reference/bloqade/ir/location/#bloqade.ir.location.base.AtomArrangement.apply_defect_density","title":"apply_defect_density","text":"apply_defect_density(\ndefect_probability, rng=np.random.default_rng()\n)\n
apply defect_probability randomly to existing atom arrangement.
Source code insrc/bloqade/ir/location/base.py
def apply_defect_density(\nself,\ndefect_probability: float,\nrng: np.random.Generator = np.random.default_rng(),\n) -> \"ListOfLocations\":\n\"\"\"apply defect_probability randomly to existing atom arrangement.\"\"\"\nfrom .list import ListOfLocations\np = min(1, max(0, defect_probability))\nlocation_list = []\nfor location_info in self.enumerate():\nif rng.random() < p:\nlocation_list.append(\nLocationInfo(\nlocation_info.position,\n(\nFalse\nif location_info.filling is SiteFilling.filled\nelse True\n),\n)\n)\nelse:\nlocation_list.append(location_info)\nreturn ListOfLocations(location_list=location_list)\n
"},{"location":"reference/bloqade/ir/location/#bloqade.ir.location.base.AtomArrangement.enumerate","title":"enumerate","text":"enumerate()\n
enumerate all locations in the register.
Source code insrc/bloqade/ir/location/base.py
def enumerate(self) -> Generator[LocationInfo, None, None]:\n\"\"\"enumerate all locations in the register.\"\"\"\nraise NotImplementedError\n
"},{"location":"reference/bloqade/ir/location/#bloqade.ir.location.base.AtomArrangement.figure","title":"figure","text":"figure(**assignments)\n
obtain a figure object from the atom arrangement.
Source code insrc/bloqade/ir/location/base.py
def figure(self, **assignments):\n\"\"\"obtain a figure object from the atom arrangement.\"\"\"\nxs_filled, ys_filled, labels_filled = [], [], []\nxs_vacant, ys_vacant, labels_vacant = [], [], []\nx_min = np.inf\nx_max = -np.inf\ny_min = np.inf\ny_max = -np.inf\nfor idx, location_info in enumerate(self.enumerate()):\n(x_var, y_var) = location_info.position\n(x, y) = (float(x_var(**assignments)), float(y_var(**assignments)))\nx_min = min(x, x_min)\ny_min = min(y, y_min)\nx_max = max(x, x_max)\ny_max = max(y, y_max)\nif location_info.filling is SiteFilling.filled:\nxs_filled.append(x)\nys_filled.append(y)\nlabels_filled.append(idx)\nelse:\nxs_vacant.append(x)\nys_vacant.append(y)\nlabels_vacant.append(idx)\n# Ly = y_max - y_min\n# Lx = x_max - x_min\n# scale_x = (Lx+2)/(Ly+2)\nif self.n_atoms > 0:\nlength_scale = max(y_max - y_min, x_max - x_min, 1)\nelse:\nlength_scale = 1\nsource_filled = ColumnDataSource(\ndata=dict(x=xs_filled, y=ys_filled, labels=labels_filled)\n)\nsource_vacant = ColumnDataSource(\ndata=dict(x=xs_vacant, y=ys_vacant, labels=labels_vacant)\n)\nsource_all = ColumnDataSource(\ndata=dict(\nx=xs_vacant + xs_filled,\ny=ys_vacant + ys_filled,\nlabels=labels_vacant + labels_filled,\n)\n)\nTOOLTIPS = [\n(\"(x,y)\", \"(@x, @y)\"),\n(\"index: \", \"@labels\"),\n]\n## remove box_zoom since we don't want to change the scale\np = figure(\nwidth=400,\nheight=400,\ntools=\"hover,wheel_zoom,reset, undo, redo, pan\",\ntooltips=TOOLTIPS,\ntoolbar_location=\"above\",\n)\np.x_range = Range1d(x_min - 1, x_min + length_scale + 1)\np.y_range = Range1d(y_min - 1, y_min + length_scale + 1)\np.circle(\n\"x\", \"y\", source=source_filled, radius=0.015 * length_scale, fill_alpha=1\n)\np.circle(\n\"x\",\n\"y\",\nsource=source_vacant,\nradius=0.015 * length_scale,\nfill_alpha=0.25,\ncolor=\"grey\",\nline_width=0.2 * length_scale,\n)\ncr = p.circle(\n\"x\",\n\"y\",\nsource=source_all,\nradius=0, # in the same unit as the data\nfill_alpha=0,\nline_width=0.15 * length_scale,\nvisible=True, # display by default\n)\n# adding rydberg radis input\n# bind sources:\nBrad_input = NumericInput(\nvalue=0, low=0, title=\"Bloqade radius (um):\", mode=\"float\"\n)\n# js link toggle btn\ntoggle_button = Button(label=\"Toggle\")\ntoggle_button.js_on_event(\n\"button_click\",\nCustomJS(args=dict(cr=cr), code=\"\"\"cr.visible = !cr.visible;\"\"\"),\n)\n# js link radius\nBrad_input.js_link(\"value\", cr.glyph, \"radius\")\nreturn p, row(Brad_input, toggle_button)\n
"},{"location":"reference/bloqade/ir/location/#bloqade.ir.location.base.AtomArrangement.scale","title":"scale","text":"scale(scale)\n
scale the atom arrangement with a given factor
Source code insrc/bloqade/ir/location/base.py
def scale(self, scale: float | Scalar) -> \"ListOfLocations\":\n\"\"\"scale the atom arrangement with a given factor\"\"\"\nfrom .list import ListOfLocations\nscale = cast(scale)\nlocation_list = []\nfor location_info in self.enumerate():\nx, y = location_info.position\nnew_position = (scale * x, scale * y)\nlocation_list.append(\nLocationInfo(new_position, bool(location_info.filling.value))\n)\nreturn ListOfLocations(location_list)\n
"},{"location":"reference/bloqade/ir/location/#bloqade.ir.location.base.AtomArrangement.show","title":"show","text":"show(**assignments)\n
show the register.
Source code insrc/bloqade/ir/location/base.py
def show(self, **assignments) -> None:\n\"\"\"show the register.\"\"\"\nshow(column(*self.figure(**assignments)))\n
"},{"location":"reference/bloqade/ir/location/#bloqade.ir.location.Chain","title":"Chain","text":"Chain(L, lattice_spacing=1.0)\n
Bases: BoundedBravais
Chain lattice.
Parameters:
Name Type Description DefaultL
int
number of sites in the chain
requiredlattice_spacing
Scalar, Real
lattice spacing. Defaults to 1.0.
1.0
.
to see possible next step in auto-prompt supported setting (IPython, IDE ...)src/bloqade/ir/location/bravais.py
def __init__(self, L: int, lattice_spacing: Any = 1.0):\nsuper().__init__(L, lattice_spacing=lattice_spacing)\n
"},{"location":"reference/bloqade/ir/location/#bloqade.ir.location.Honeycomb","title":"Honeycomb","text":"Honeycomb(L, lattice_spacing=1.0)\n
Bases: BoundedBravais
Honeycomb lattice.
Parameters:
Name Type Description DefaultL
int
number of sites in linear direction. n_atoms = L * L * 2.
requiredlattice_spacing
Scalar, Real
lattice spacing. Defaults to 1.0.
1.0
.
to see possible next step in auto-prompt supported setting (IPython, IDE ...)src/bloqade/ir/location/bravais.py
def __init__(self, L: int, lattice_spacing: Any = 1.0):\nsuper().__init__(L, L, lattice_spacing=lattice_spacing)\n
"},{"location":"reference/bloqade/ir/location/#bloqade.ir.location.Kagome","title":"Kagome","text":"Kagome(L, lattice_spacing=1.0)\n
Bases: BoundedBravais
Kagome lattice.
Parameters:
Name Type Description DefaultL
int
number of sites in linear direction. n_atoms = L * L.
requiredlattice_spacing
Scalar, Real
lattice spacing. Defaults to 1.0.
1.0
.
to see possible next step in auto-prompt supported setting (IPython, IDE ...)src/bloqade/ir/location/bravais.py
def __init__(self, L: int, lattice_spacing: Any = 1.0):\nsuper().__init__(L, L, lattice_spacing=lattice_spacing)\n
"},{"location":"reference/bloqade/ir/location/#bloqade.ir.location.Lieb","title":"Lieb","text":"Lieb(L, lattice_spacing=1.0)\n
Bases: BoundedBravais
Lieb lattice.
Parameters:
Name Type Description DefaultL
int
number of sites in linear direction. n_atoms = L * L.
requiredlattice_spacing
Scalar, Real
lattice spacing. Defaults to 1.0.
1.0
.
to see possible next step in auto-prompt supported setting (IPython, IDE ...)src/bloqade/ir/location/bravais.py
def __init__(self, L: int, lattice_spacing: Any = 1.0):\nsuper().__init__(L, L, lattice_spacing=lattice_spacing)\n
"},{"location":"reference/bloqade/ir/location/#bloqade.ir.location.Rectangular","title":"Rectangular","text":"Rectangular(\nwidth,\nheight,\nlattice_spacing_x=1.0,\nlattice_spacing_y=None,\n)\n
Bases: BoundedBravais
Rectangular lattice.
Parameters:
Name Type Description Defaultwidth
int
number of sites in x direction.
requiredheight
int
number of sites in y direction.
requiredlattice_spacing_x
Scalar, Real
lattice spacing. Defaults to 1.0.
1.0
lattice_spacing_y
Scalar, Real
lattice spacing in y direction. optional.
None
.
to see possible next step in auto-prompt supported setting (IPython, IDE ...)src/bloqade/ir/location/bravais.py
def __init__(\nself,\nwidth: int,\nheight: int,\nlattice_spacing_x: Any = 1.0,\nlattice_spacing_y: Optional[Any] = None,\n):\nif lattice_spacing_y is None:\nself.ratio = cast(1.0) / cast(lattice_spacing_x)\nelse:\nself.ratio = cast(lattice_spacing_y) / cast(lattice_spacing_x)\nsuper().__init__(width, height, lattice_spacing=lattice_spacing_x)\n
"},{"location":"reference/bloqade/ir/location/#bloqade.ir.location.Square","title":"Square","text":"Square(L, lattice_spacing=1.0)\n
Bases: BoundedBravais
Square lattice.
Parameters:
Name Type Description DefaultL
int
number of sites in linear direction. n_atoms = L * L.
requiredlattice_spacing
Scalar, Real
lattice spacing. Defaults to 1.0.
1.0
.
to see possible next step in auto-prompt supported setting (IPython, IDE ...)src/bloqade/ir/location/bravais.py
def __init__(self, L: int, lattice_spacing: Any = 1.0):\nsuper().__init__(L, L, lattice_spacing=lattice_spacing)\n
"},{"location":"reference/bloqade/ir/location/#bloqade.ir.location.Triangular","title":"Triangular","text":"Triangular(L, lattice_spacing=1.0)\n
Bases: BoundedBravais
Triangular lattice.
Parameters:
Name Type Description DefaultL
int
number of sites in linear direction. n_atoms = L * L.
requiredlattice_spacing
Scalar, Real
lattice spacing. Defaults to 1.0.
1.0
.
to see possible next step in auto-prompt supported setting (IPython, IDE ...)src/bloqade/ir/location/bravais.py
def __init__(self, L: int, lattice_spacing: Any = 1.0):\nsuper().__init__(L, L, lattice_spacing=lattice_spacing)\n
"},{"location":"reference/bloqade/ir/location/base/","title":"Base","text":""},{"location":"reference/bloqade/ir/location/base/#bloqade.ir.location.base.AtomArrangement","title":"AtomArrangement","text":"AtomArrangement()\n
Bases: ProgramStart
src/bloqade/ir/location/base.py
def __init__(self) -> None:\nsuper().__init__(register=self)\n
"},{"location":"reference/bloqade/ir/location/base/#bloqade.ir.location.base.AtomArrangement.n_atoms","title":"n_atoms property
","text":"n_atoms: int\n
number of atoms in the register.
"},{"location":"reference/bloqade/ir/location/base/#bloqade.ir.location.base.AtomArrangement.n_dims","title":"n_dimsproperty
","text":"n_dims: int\n
number of dimensions in the register.
"},{"location":"reference/bloqade/ir/location/base/#bloqade.ir.location.base.AtomArrangement.add_position","title":"add_position","text":"add_position(position, filled=True)\n
add a position to existing atom arrangement.
Source code insrc/bloqade/ir/location/base.py
def add_position(\nself, position: Tuple[Any, Any], filled: bool = True\n) -> \"ListOfLocations\":\n\"\"\"add a position to existing atom arrangement.\"\"\"\nfrom .list import ListOfLocations\nlocation_list = [LocationInfo(position, filled)]\nfor location_info in self.enumerate():\nlocation_list.append(location_info)\nreturn ListOfLocations(location_list)\n
"},{"location":"reference/bloqade/ir/location/base/#bloqade.ir.location.base.AtomArrangement.add_positions","title":"add_positions","text":"add_positions(positions, filling=None)\n
add a list of positions to existing atom arrangement.
Source code insrc/bloqade/ir/location/base.py
def add_positions(\nself, positions: List[Tuple[Any, Any]], filling: Optional[List[bool]] = None\n) -> \"ListOfLocations\":\n\"\"\"add a list of positions to existing atom arrangement.\"\"\"\nfrom .list import ListOfLocations\nlocation_list = []\nif filling:\nfor position, filled in zip(positions, filling):\nlocation_list.append(LocationInfo(position, filled))\nelse:\nfor position in positions:\nlocation_list.append(LocationInfo(position, True))\nfor location_info in self.enumerate():\nlocation_list.append(location_info)\nreturn ListOfLocations(location_list)\n
"},{"location":"reference/bloqade/ir/location/base/#bloqade.ir.location.base.AtomArrangement.apply_defect_count","title":"apply_defect_count","text":"apply_defect_count(n_defects, rng=np.random.default_rng())\n
apply n_defects randomly to existing atom arrangement.
Source code insrc/bloqade/ir/location/base.py
def apply_defect_count(\nself, n_defects: int, rng: np.random.Generator = np.random.default_rng()\n) -> \"ListOfLocations\":\n\"\"\"apply n_defects randomly to existing atom arrangement.\"\"\"\nfrom .list import ListOfLocations\nlocation_list = []\nfor location_info in self.enumerate():\nlocation_list.append(location_info)\nfor _ in range(n_defects):\nidx = rng.integers(0, len(location_list))\nlocation_list[idx] = LocationInfo(\nlocation_list[idx].position,\n(False if location_list[idx].filling is SiteFilling.filled else True),\n)\nreturn ListOfLocations(location_list)\n
"},{"location":"reference/bloqade/ir/location/base/#bloqade.ir.location.base.AtomArrangement.apply_defect_density","title":"apply_defect_density","text":"apply_defect_density(\ndefect_probability, rng=np.random.default_rng()\n)\n
apply defect_probability randomly to existing atom arrangement.
Source code insrc/bloqade/ir/location/base.py
def apply_defect_density(\nself,\ndefect_probability: float,\nrng: np.random.Generator = np.random.default_rng(),\n) -> \"ListOfLocations\":\n\"\"\"apply defect_probability randomly to existing atom arrangement.\"\"\"\nfrom .list import ListOfLocations\np = min(1, max(0, defect_probability))\nlocation_list = []\nfor location_info in self.enumerate():\nif rng.random() < p:\nlocation_list.append(\nLocationInfo(\nlocation_info.position,\n(\nFalse\nif location_info.filling is SiteFilling.filled\nelse True\n),\n)\n)\nelse:\nlocation_list.append(location_info)\nreturn ListOfLocations(location_list=location_list)\n
"},{"location":"reference/bloqade/ir/location/base/#bloqade.ir.location.base.AtomArrangement.enumerate","title":"enumerate","text":"enumerate()\n
enumerate all locations in the register.
Source code insrc/bloqade/ir/location/base.py
def enumerate(self) -> Generator[LocationInfo, None, None]:\n\"\"\"enumerate all locations in the register.\"\"\"\nraise NotImplementedError\n
"},{"location":"reference/bloqade/ir/location/base/#bloqade.ir.location.base.AtomArrangement.figure","title":"figure","text":"figure(**assignments)\n
obtain a figure object from the atom arrangement.
Source code insrc/bloqade/ir/location/base.py
def figure(self, **assignments):\n\"\"\"obtain a figure object from the atom arrangement.\"\"\"\nxs_filled, ys_filled, labels_filled = [], [], []\nxs_vacant, ys_vacant, labels_vacant = [], [], []\nx_min = np.inf\nx_max = -np.inf\ny_min = np.inf\ny_max = -np.inf\nfor idx, location_info in enumerate(self.enumerate()):\n(x_var, y_var) = location_info.position\n(x, y) = (float(x_var(**assignments)), float(y_var(**assignments)))\nx_min = min(x, x_min)\ny_min = min(y, y_min)\nx_max = max(x, x_max)\ny_max = max(y, y_max)\nif location_info.filling is SiteFilling.filled:\nxs_filled.append(x)\nys_filled.append(y)\nlabels_filled.append(idx)\nelse:\nxs_vacant.append(x)\nys_vacant.append(y)\nlabels_vacant.append(idx)\n# Ly = y_max - y_min\n# Lx = x_max - x_min\n# scale_x = (Lx+2)/(Ly+2)\nif self.n_atoms > 0:\nlength_scale = max(y_max - y_min, x_max - x_min, 1)\nelse:\nlength_scale = 1\nsource_filled = ColumnDataSource(\ndata=dict(x=xs_filled, y=ys_filled, labels=labels_filled)\n)\nsource_vacant = ColumnDataSource(\ndata=dict(x=xs_vacant, y=ys_vacant, labels=labels_vacant)\n)\nsource_all = ColumnDataSource(\ndata=dict(\nx=xs_vacant + xs_filled,\ny=ys_vacant + ys_filled,\nlabels=labels_vacant + labels_filled,\n)\n)\nTOOLTIPS = [\n(\"(x,y)\", \"(@x, @y)\"),\n(\"index: \", \"@labels\"),\n]\n## remove box_zoom since we don't want to change the scale\np = figure(\nwidth=400,\nheight=400,\ntools=\"hover,wheel_zoom,reset, undo, redo, pan\",\ntooltips=TOOLTIPS,\ntoolbar_location=\"above\",\n)\np.x_range = Range1d(x_min - 1, x_min + length_scale + 1)\np.y_range = Range1d(y_min - 1, y_min + length_scale + 1)\np.circle(\n\"x\", \"y\", source=source_filled, radius=0.015 * length_scale, fill_alpha=1\n)\np.circle(\n\"x\",\n\"y\",\nsource=source_vacant,\nradius=0.015 * length_scale,\nfill_alpha=0.25,\ncolor=\"grey\",\nline_width=0.2 * length_scale,\n)\ncr = p.circle(\n\"x\",\n\"y\",\nsource=source_all,\nradius=0, # in the same unit as the data\nfill_alpha=0,\nline_width=0.15 * length_scale,\nvisible=True, # display by default\n)\n# adding rydberg radis input\n# bind sources:\nBrad_input = NumericInput(\nvalue=0, low=0, title=\"Bloqade radius (um):\", mode=\"float\"\n)\n# js link toggle btn\ntoggle_button = Button(label=\"Toggle\")\ntoggle_button.js_on_event(\n\"button_click\",\nCustomJS(args=dict(cr=cr), code=\"\"\"cr.visible = !cr.visible;\"\"\"),\n)\n# js link radius\nBrad_input.js_link(\"value\", cr.glyph, \"radius\")\nreturn p, row(Brad_input, toggle_button)\n
"},{"location":"reference/bloqade/ir/location/base/#bloqade.ir.location.base.AtomArrangement.scale","title":"scale","text":"scale(scale)\n
scale the atom arrangement with a given factor
Source code insrc/bloqade/ir/location/base.py
def scale(self, scale: float | Scalar) -> \"ListOfLocations\":\n\"\"\"scale the atom arrangement with a given factor\"\"\"\nfrom .list import ListOfLocations\nscale = cast(scale)\nlocation_list = []\nfor location_info in self.enumerate():\nx, y = location_info.position\nnew_position = (scale * x, scale * y)\nlocation_list.append(\nLocationInfo(new_position, bool(location_info.filling.value))\n)\nreturn ListOfLocations(location_list)\n
"},{"location":"reference/bloqade/ir/location/base/#bloqade.ir.location.base.AtomArrangement.show","title":"show","text":"show(**assignments)\n
show the register.
Source code insrc/bloqade/ir/location/base.py
def show(self, **assignments) -> None:\n\"\"\"show the register.\"\"\"\nshow(column(*self.figure(**assignments)))\n
"},{"location":"reference/bloqade/ir/location/base/#bloqade.ir.location.base.ParallelRegister","title":"ParallelRegister","text":"ParallelRegister(register, cluster_spacing)\n
Bases: ProgramStart
Parallel Register
Source code insrc/bloqade/ir/location/base.py
def __init__(self, register: AtomArrangement, cluster_spacing: Any):\nif register.n_atoms > 0:\n# calculate bounding box\n# of this register\nlocation_iter = register.enumerate()\n(x, y) = next(location_iter).position\nx_min = x\nx_max = x\ny_min = y\ny_max = y\nfor location_info in location_iter:\n(x, y) = location_info.position\nx_min = x.min(x_min)\nx_max = x.max(x_max)\ny_min = y.min(y_min)\ny_max = y.max(y_max)\nshift_x = (x_max - x_min) + cluster_spacing\nshift_y = (y_max - y_min) + cluster_spacing\nregister_locations = [\nlist(location_info.position) for location_info in register.enumerate()\n]\nregister_filling = [\nlocation_info.filling.value for location_info in register.enumerate()\n]\nshift_vectors = [[shift_x, cast(0)], [cast(0), shift_y]]\nelse:\nraise ValueError(\"No locations to parallelize.\")\nself.register_locations = register_locations\nself.register_filling = register_filling\nself.shift_vectors = shift_vectors\nsuper().__init__(register=self)\n
"},{"location":"reference/bloqade/ir/location/bravais/","title":"Bravais","text":""},{"location":"reference/bloqade/ir/location/bravais/#bloqade.ir.location.bravais.BoundedBravais","title":"BoundedBravais","text":"BoundedBravais(*shape, lattice_spacing=1.0)\n
Bases: AtomArrangement
Base classe for Bravais lattices AtomArrangement
.
Square
Chain
Honeycomb
Triangular
Lieb
Kagome
Rectangular
src/bloqade/ir/location/bravais.py
def __init__(self, *shape: int, lattice_spacing: Any = 1.0):\nsuper().__init__()\nself.shape = shape\nself.lattice_spacing = cast(lattice_spacing)\nself.__n_atoms = None\nself.__n_dims = None\n
"},{"location":"reference/bloqade/ir/location/bravais/#bloqade.ir.location.bravais.BoundedBravais.n_atoms","title":"n_atoms property
","text":"n_atoms\n
number of atoms
Returns:
Name Type Descriptionint
number of atoms in the lattice
"},{"location":"reference/bloqade/ir/location/bravais/#bloqade.ir.location.bravais.BoundedBravais.n_dims","title":"n_dimsproperty
","text":"n_dims\n
dimension of the lattice
Returns:
Name Type Descriptionint
dimension of the lattice
"},{"location":"reference/bloqade/ir/location/bravais/#bloqade.ir.location.bravais.BoundedBravais.coordinates","title":"coordinates","text":"coordinates(index)\n
calculate the coordinates of a cell in the lattice given the cell index.
Source code insrc/bloqade/ir/location/bravais.py
def coordinates(self, index: List[int]) -> NDArray:\n\"\"\"calculate the coordinates of a cell in the lattice\n given the cell index.\n \"\"\"\n# damn! this is like stone age broadcasting\nvectors = np.array(self.cell_vectors())\nindex = np.array(index)\npos = np.sum(vectors.T * index, axis=1)\nreturn pos + np.array(self.cell_atoms())\n
"},{"location":"reference/bloqade/ir/location/bravais/#bloqade.ir.location.bravais.BoundedBravais.scale","title":"scale","text":"scale(factor)\n
Scale the current location with a factor.
(x,y) -> factor*(x,y)
Parameters:
Name Type Description Defaultfactor
float | Scalar
scale factor
requiredReturns:
Name Type DescriptionBoundedBravais
BoundedBravais
The lattice with the scaled locations
Source code insrc/bloqade/ir/location/bravais.py
def scale(self, factor: float | Scalar) -> \"BoundedBravais\":\n\"\"\"Scale the current location with a factor.\n (x,y) -> factor*(x,y)\n Args:\n factor (float | Scalar): scale factor\n Returns:\n BoundedBravais: The lattice with the scaled locations\n \"\"\"\nfactor = cast(factor)\nobj = self.__new__(type(self))\nfor f in fields(self):\nif f.name == \"lattice_spacing\":\nobj.lattice_spacing = factor * self.lattice_spacing\nelse:\nsetattr(obj, f.name, getattr(self, f.name))\nreturn obj\n
"},{"location":"reference/bloqade/ir/location/bravais/#bloqade.ir.location.bravais.Chain","title":"Chain","text":"Chain(L, lattice_spacing=1.0)\n
Bases: BoundedBravais
Chain lattice.
Parameters:
Name Type Description DefaultL
int
number of sites in the chain
requiredlattice_spacing
Scalar, Real
lattice spacing. Defaults to 1.0.
1.0
.
to see possible next step in auto-prompt supported setting (IPython, IDE ...)src/bloqade/ir/location/bravais.py
def __init__(self, L: int, lattice_spacing: Any = 1.0):\nsuper().__init__(L, lattice_spacing=lattice_spacing)\n
"},{"location":"reference/bloqade/ir/location/bravais/#bloqade.ir.location.bravais.Honeycomb","title":"Honeycomb","text":"Honeycomb(L, lattice_spacing=1.0)\n
Bases: BoundedBravais
Honeycomb lattice.
Parameters:
Name Type Description DefaultL
int
number of sites in linear direction. n_atoms = L * L * 2.
requiredlattice_spacing
Scalar, Real
lattice spacing. Defaults to 1.0.
1.0
.
to see possible next step in auto-prompt supported setting (IPython, IDE ...)src/bloqade/ir/location/bravais.py
def __init__(self, L: int, lattice_spacing: Any = 1.0):\nsuper().__init__(L, L, lattice_spacing=lattice_spacing)\n
"},{"location":"reference/bloqade/ir/location/bravais/#bloqade.ir.location.bravais.Kagome","title":"Kagome","text":"Kagome(L, lattice_spacing=1.0)\n
Bases: BoundedBravais
Kagome lattice.
Parameters:
Name Type Description DefaultL
int
number of sites in linear direction. n_atoms = L * L.
requiredlattice_spacing
Scalar, Real
lattice spacing. Defaults to 1.0.
1.0
.
to see possible next step in auto-prompt supported setting (IPython, IDE ...)src/bloqade/ir/location/bravais.py
def __init__(self, L: int, lattice_spacing: Any = 1.0):\nsuper().__init__(L, L, lattice_spacing=lattice_spacing)\n
"},{"location":"reference/bloqade/ir/location/bravais/#bloqade.ir.location.bravais.Lieb","title":"Lieb","text":"Lieb(L, lattice_spacing=1.0)\n
Bases: BoundedBravais
Lieb lattice.
Parameters:
Name Type Description DefaultL
int
number of sites in linear direction. n_atoms = L * L.
requiredlattice_spacing
Scalar, Real
lattice spacing. Defaults to 1.0.
1.0
.
to see possible next step in auto-prompt supported setting (IPython, IDE ...)src/bloqade/ir/location/bravais.py
def __init__(self, L: int, lattice_spacing: Any = 1.0):\nsuper().__init__(L, L, lattice_spacing=lattice_spacing)\n
"},{"location":"reference/bloqade/ir/location/bravais/#bloqade.ir.location.bravais.Rectangular","title":"Rectangular","text":"Rectangular(\nwidth,\nheight,\nlattice_spacing_x=1.0,\nlattice_spacing_y=None,\n)\n
Bases: BoundedBravais
Rectangular lattice.
Parameters:
Name Type Description Defaultwidth
int
number of sites in x direction.
requiredheight
int
number of sites in y direction.
requiredlattice_spacing_x
Scalar, Real
lattice spacing. Defaults to 1.0.
1.0
lattice_spacing_y
Scalar, Real
lattice spacing in y direction. optional.
None
.
to see possible next step in auto-prompt supported setting (IPython, IDE ...)src/bloqade/ir/location/bravais.py
def __init__(\nself,\nwidth: int,\nheight: int,\nlattice_spacing_x: Any = 1.0,\nlattice_spacing_y: Optional[Any] = None,\n):\nif lattice_spacing_y is None:\nself.ratio = cast(1.0) / cast(lattice_spacing_x)\nelse:\nself.ratio = cast(lattice_spacing_y) / cast(lattice_spacing_x)\nsuper().__init__(width, height, lattice_spacing=lattice_spacing_x)\n
"},{"location":"reference/bloqade/ir/location/bravais/#bloqade.ir.location.bravais.Square","title":"Square","text":"Square(L, lattice_spacing=1.0)\n
Bases: BoundedBravais
Square lattice.
Parameters:
Name Type Description DefaultL
int
number of sites in linear direction. n_atoms = L * L.
requiredlattice_spacing
Scalar, Real
lattice spacing. Defaults to 1.0.
1.0
.
to see possible next step in auto-prompt supported setting (IPython, IDE ...)src/bloqade/ir/location/bravais.py
def __init__(self, L: int, lattice_spacing: Any = 1.0):\nsuper().__init__(L, L, lattice_spacing=lattice_spacing)\n
"},{"location":"reference/bloqade/ir/location/bravais/#bloqade.ir.location.bravais.Triangular","title":"Triangular","text":"Triangular(L, lattice_spacing=1.0)\n
Bases: BoundedBravais
Triangular lattice.
Parameters:
Name Type Description DefaultL
int
number of sites in linear direction. n_atoms = L * L.
requiredlattice_spacing
Scalar, Real
lattice spacing. Defaults to 1.0.
1.0
.
to see possible next step in auto-prompt supported setting (IPython, IDE ...)src/bloqade/ir/location/bravais.py
def __init__(self, L: int, lattice_spacing: Any = 1.0):\nsuper().__init__(L, L, lattice_spacing=lattice_spacing)\n
"},{"location":"reference/bloqade/ir/location/list/","title":"List","text":""},{"location":"reference/bloqade/ir/location/list/#bloqade.ir.location.list.start","title":"start module-attribute
","text":"start = ListOfLocations()\n
Possible Next
-> start.rydberg
:: address rydberg level coupling
-> start.hyperfine
:: address hyperfine level coupling
Possible Next
-> start.add_locations(List[Tuple[int]])
:: add multiple atoms to current register
-> start.add_location(Tuple[int])
:: add atom to current register
Bases: BaseModel
export_as_probabilities()\n
converts from shot results to probabilities
Returns:
Name Type DescriptionTaskProbabilities
TaskProbabilities
The task results as probabilties
Source code insrc/bloqade/ir/location/quera_task_result.py
def export_as_probabilities(self) -> TaskProbabilities:\n\"\"\"converts from shot results to probabilities\n Returns:\n TaskProbabilities: The task results as probabilties\n \"\"\"\ncounts = dict()\nnshots = len(self.shot_outputs)\nfor shot_result in self.shot_outputs:\npre_sequence_str = \"\".join(str(bit) for bit in shot_result.pre_sequence)\npost_sequence_str = \"\".join(str(bit) for bit in shot_result.post_sequence)\nconfiguration = (pre_sequence_str, post_sequence_str)\n# iterative average\ncurrent_count = counts.get(configuration, 0)\ncounts[configuration] = current_count + 1\nprobabilities = [(config, count / nshots) for config, count in counts.items()]\nreturn TaskProbabilities(probabilities=probabilities)\n
"},{"location":"reference/bloqade/submission/","title":"Index","text":""},{"location":"reference/bloqade/submission/base/","title":"Base","text":""},{"location":"reference/bloqade/submission/braket/","title":"Braket","text":""},{"location":"reference/bloqade/submission/capabilities/","title":"Capabilities","text":""},{"location":"reference/bloqade/submission/mock/","title":"Mock","text":""},{"location":"reference/bloqade/submission/quera/","title":"Quera","text":""},{"location":"reference/bloqade/submission/ir/","title":"Index","text":""},{"location":"reference/bloqade/submission/ir/braket/","title":"Braket","text":""},{"location":"reference/bloqade/submission/ir/capabilities/","title":"Capabilities","text":""},{"location":"reference/bloqade/submission/ir/parallel/","title":"Parallel","text":""},{"location":"reference/bloqade/submission/ir/parallel/#bloqade.submission.ir.parallel.ClusterLocationInfo","title":"ClusterLocationInfo","text":" Bases: BaseModel
Class that stores the mapping of batched jobs.
Parameters:
Name Type Description Defaultcluster_index
int
the index of the cluster a site belongs to
requiredglobal_location_index
int
the index of the site in the multplexed system
requiredcluster_location_index
int
the index of the site in the original system
required"},{"location":"reference/bloqade/submission/ir/task_results/","title":"Task results","text":""},{"location":"reference/bloqade/submission/ir/task_results/#bloqade.submission.ir.task_results.QuEraTaskResults","title":"QuEraTaskResults","text":" Bases: BaseModel
export_as_probabilities()\n
converts from shot results to probabilities
Returns:
Name Type DescriptionTaskProbabilities
TaskProbabilities
The task results as probabilties
Source code insrc/bloqade/submission/ir/task_results.py
def export_as_probabilities(self) -> TaskProbabilities:\n\"\"\"converts from shot results to probabilities\n Returns:\n TaskProbabilities: The task results as probabilties\n \"\"\"\ncounts = dict()\nnshots = len(self.shot_outputs)\nfor shot_result in self.shot_outputs:\npre_sequence_str = \"\".join(str(bit) for bit in shot_result.pre_sequence)\npost_sequence_str = \"\".join(str(bit) for bit in shot_result.post_sequence)\nconfiguration = (pre_sequence_str, post_sequence_str)\n# iterative average\ncurrent_count = counts.get(configuration, 0)\ncounts[configuration] = current_count + 1\nprobabilities = [(config, count / nshots) for config, count in counts.items()]\nreturn TaskProbabilities(probabilities=probabilities)\n
"},{"location":"reference/bloqade/submission/ir/task_specification/","title":"Task specification","text":""},{"location":"reference/bloqade/submission/quera_api_client/","title":"Index","text":""},{"location":"reference/bloqade/submission/quera_api_client/api/","title":"Api","text":""},{"location":"reference/bloqade/submission/quera_api_client/api/#bloqade.submission.quera_api_client.api.ApiRequest","title":"ApiRequest","text":"ApiRequest(\napi_hostname, qpu_id, api_stage=\"v0\", proxy=None\n)\n
Class that defines base methods for API requests.
@param qpu_id: The QPU ID, for example qpu1-mock
. @param api_stage: Specify which version of the API to call from this object. @param proxy: Optional, the hostname for running the API via some proxy endpoint.
src/bloqade/submission/quera_api_client/api.py
def __init__(\nself,\napi_hostname: str,\nqpu_id: str,\napi_stage=\"v0\",\nproxy: Optional[str] = None,\n):\n\"\"\"\n Create an instance of `ApiRequest`.\n @param api_hostname: hostname of the API instance.\n @param qpu_id: The QPU ID, for example `qpu1-mock`.\n @param api_stage: Specify which version of the API to call from this object.\n @param proxy: Optional, the hostname for running the API via some proxy\n endpoint.\n \"\"\"\nif proxy is None:\nself.hostname = None\nself.aws_host = api_hostname\nuri_with_version = api_hostname + f\"/{api_stage}\"\nelse:\nself.hostname = api_hostname\nself.aws_host = proxy\nuri_with_version = proxy + f\"/{api_stage}\"\nself.base_url = \"https://\" + uri_with_version\nself.qpu_id = qpu_id\nself.logger = logging.getLogger(self.__class__.__name__)\n
"},{"location":"reference/bloqade/submission/quera_api_client/api/#bloqade.submission.quera_api_client.api.AwsApiRequest","title":"AwsApiRequest","text":"AwsApiRequest(\napi_hostname,\nqpu_id,\napi_stage=\"v0\",\nproxy=None,\nregion=\"us-east-1\",\naccess_key=None,\nsecret_key=None,\nsession_token=None,\nsession_expires=3600,\nrole_arn=None,\nrole_session_name=\"awsrequest\",\nprofile=None,\n)\n
Bases: ApiRequest
@param qpu_id: The QPU ID, for example qpu1-mock
. @param api_stage: Specify which version of the API to call from this object. @param proxy: Optional, the hostname for running the API via some proxy endpoint. @param region: AWS region, default value: \"us-east-1\" @param access_key: Optional, AWS account access key @param secret_key: Optional, AWS account secret key @param session_token: Optional, AWS session token @param session_expires: int, time before current tokens expire, default value 3600 @param role_arn: Optional, AWS role ARN @param role_session_name: AWS role session name, defualy value: 'awsrequest', @param profile: Optional, AWS profile to use credentials for.
src/bloqade/submission/quera_api_client/api.py
def __init__(\nself,\napi_hostname: str,\nqpu_id: str,\napi_stage=\"v0\",\nproxy: Optional[str] = None,\n# Sigv4Request arguments\nregion: str = \"us-east-1\",\naccess_key: Optional[str] = None,\nsecret_key: Optional[str] = None,\nsession_token: Optional[str] = None,\nsession_expires: int = 3600,\nrole_arn: Optional[str] = None,\nrole_session_name: str = \"awsrequest\",\nprofile: Optional[str] = None,\n):\n\"\"\"\n Create an instance of `AwsApiRequest`.\n @param api_hostname: hostname of the API instance.\n @param qpu_id: The QPU ID, for example `qpu1-mock`.\n @param api_stage: Specify which version of the API to call from this object.\n @param proxy: Optional, the hostname for running the API via some proxy\n endpoint.\n @param region: AWS region, default value: \"us-east-1\"\n @param access_key: Optional, AWS account access key\n @param secret_key: Optional, AWS account secret key\n @param session_token: Optional, AWS session token\n @param session_expires: int, time before current tokens expire, default value\n 3600\n @param role_arn: Optional, AWS role ARN\n @param role_session_name: AWS role session name, defualy value: 'awsrequest',\n @param profile: Optional, AWS profile to use credentials for.\n \"\"\"\nsuper().__init__(api_hostname, qpu_id, api_stage=api_stage, proxy=proxy)\nself.request = Sigv4Request(\nregion=region,\naccess_key=access_key,\nsecret_key=secret_key,\nsession_token=session_token,\nsession_expires=session_expires,\nrole_arn=role_arn,\nrole_session_name=role_session_name,\nprofile=profile,\n)\n
"},{"location":"reference/bloqade/submission/quera_api_client/api/#bloqade.submission.quera_api_client.api.QueueApi","title":"QueueApi","text":"QueueApi(\napi_hostname,\nqpu_id,\napi_stage=\"v0\",\nproxy=None,\n**request_sigv4_kwargs\n)\n
Simple interface to the QCS task API.
Example (replace URIs, QPU ID with correct values):
task_json = { ... \"nshots\": 10, ... \"lattice\": { ... \"sites\":[[0,0]], ... \"filling\":[1], ... }, ... \"effective_hamiltonian\": { ... \"rydberg\": { ... \"rabi_frequency_amplitude\":{ ... \"global\": { ... \"times\":[0.0, 0.1e-6, 3.9e-6, 4.0e-6], ... \"values\":[0.0, 15.0e6, 15.0e6, 0.0], ... } ... }, ... \"rabi_frequency_phase\": { ... \"global\": { ... \"times\":[0.0, 4.0e-6], ... \"values\":[0.0, 0.0], ... } ... }, ... \"detuning\":{ ... \"global\": { ... \"times\":[0.0, 4.0e-6], ... \"values\":[0.0, 0.0], ... } ... } ... } ... } ... } To Use this class with API-Gateway: api_hostname = \"XXX.execute-api.us-east-1.amazonaws.com\" vpce_uri = \"vpce-XXX-XXX.execute-api.us-east-1.vpce.amazonaws.com\" api = QueueApi(api_hostname, \"qpu1-mock\", proxy=vpce_uri) print(api.get_capabilities())
@param qpu_id: The QPU ID, for example qpu1-mock
. @param api_stage: Specify which version of the API to call from this object. @param proxy: Optional, the hostname for running the API via some proxy endpoint.
request_sigv4_kwargs:
@param region: AWS region, default value: \"us-east-1\" @param access_key: Optional, AWS account access key @param secret_key: Optional, AWS account secret key @param session_token: Optional, AWS session token @param session_expires: int, time before current tokens expire, default value 3600 @param role_arn: Optional, AWS role ARN @param role_session_name: AWS role session name, defualy value: 'awsrequest', @param profile: Optional, AWS profile to use credentials for.
Source code insrc/bloqade/submission/quera_api_client/api.py
def __init__(\nself,\napi_hostname: str,\nqpu_id: str,\napi_stage=\"v0\",\nproxy: Optional[str] = None,\n**request_sigv4_kwargs,\n):\n\"\"\"\n Create an instance of `QueueApi`.\n @param api_hostname: hostname of the API instance.\n @param qpu_id: The QPU ID, for example `qpu1-mock`.\n @param api_stage: Specify which version of the API to call from this object.\n @param proxy: Optional, the hostname for running the API via some proxy\n endpoint.\n request_sigv4_kwargs:\n @param region: AWS region, default value: \"us-east-1\"\n @param access_key: Optional, AWS account access key\n @param secret_key: Optional, AWS account secret key\n @param session_token: Optional, AWS session token\n @param session_expires: int, time before current tokens expire, default value\n 3600\n @param role_arn: Optional, AWS role ARN\n @param role_session_name: AWS role session name, defualy value: 'awsrequest',\n @param profile: Optional, AWS profile to use credentials for.\n \"\"\"\nself.api_http_request = AwsApiRequest(\napi_hostname,\nqpu_id,\napi_stage=api_stage,\nproxy=proxy,\n**request_sigv4_kwargs,\n)\nself.logger = logging.getLogger(self.__class__.__name__)\n
"},{"location":"reference/bloqade/submission/quera_api_client/api/#bloqade.submission.quera_api_client.api.QueueApi.get_capabilities","title":"get_capabilities","text":"get_capabilities()\n
Request the QPU capabilities from the task API. @return: dictionary containing different fields for capabilities.
Source code insrc/bloqade/submission/quera_api_client/api.py
def get_capabilities(self) -> Dict:\n\"\"\"\n Request the QPU capabilities from the task API.\n @return: dictionary containing different fields for capabilities.\n \"\"\"\nresult = self.api_http_request.get(\"capabilities\")\nmatch result.status_code:\ncase 200:\nmessage = \"Successfully fetched capabilities.\"\nself.logger.error(message)\ncase 404:\nmessage = f\"QPU {self.api_http_request.qpu_id} not found.\"\nself.logger.error(message)\nraise QueueApi.NotFound(message)\ncase 403:\nmessage = \"QPU return authentication error, check AWS credentials.\"\nself.logger.error(message)\nraise QueueApi.AuthenticationError(message)\ncase _:\nmessage = f\"QPU returned unhandled status {result.status_code}.\"\nself.logger.error(message)\nraise QueueApi.QueueApiError(message)\nreturn ApiRequest._result_as_json(result)\n
"},{"location":"reference/bloqade/submission/quera_api_client/api/#bloqade.submission.quera_api_client.api.QueueApi.get_task_results","title":"get_task_results","text":"get_task_results(task_id)\n
Return task results as given by API. @return: Parsed JSON of the task results. @param task_id: Task ID.
Source code insrc/bloqade/submission/quera_api_client/api.py
def get_task_results(self, task_id: Union[str, uuid.UUID]) -> Dict:\n\"\"\"\n Return task results as given by API.\n @return: Parsed JSON of the task results.\n @param task_id: Task ID.\n \"\"\"\nqueue_status = self.get_task_status_in_queue(task_id)\n# TODO: Revisit this mapping when the queue API is\n# has task result fetching build into the API\nmatch queue_status: # overwrite the\ncase \"Created\" | \"Enqueued\" | \"Accepted\":\nreturn {\"task_status\": \"Created\", \"shot_outputs\": []}\ncase \"Executing\":\nreturn {\"task_status\": \"Running\", \"shot_outputs\": []}\ncase \"Failed\" | \"Cancelled\":\nreturn {\"task_status\": queue_status, \"shot_outputs\": []}\ncase \"Unaccepted\":\nraise QueueApi.ValidationError(\nf\"Task: {task_id} has validation error, \"\n\"unable to fetch error message.\"\n)\ncase \"Completed\" | \"Partial\":\npass\ncase _:\nraise QueueApi.QueueApiError(\nf\"Undocumented queue status: {queue_status}\"\n)\nresult = self.api_http_request.get(\"task\", str(task_id), \"results\")\nmatch result.status_code:\ncase 200:\nmessage = f\"Successfully fetch task results for task_id {task_id}\"\nself.logger.debug(message)\ncase 400:\nmessage = QueueApi.bad_request\nself.logger.debug(message)\nraise QueueApi.InvalidRequestError(message)\ncase 404:\nmessage = QueueApi.qpu_or_task_not_found\nself.logger.debug(message)\nraise QueueApi.NotFound(message)\ncase 403:\nmessage = \"QPU return authentication error, check AWS credentials.\"\nself.logger.error(message)\nraise QueueApi.AuthenticationError(message)\ncase _:\nmessage = f\"QPU returned unhandled status {result.status_code}.\"\nself.logger.error(message)\nraise QueueApi.QueueApiError(message)\nreturn ApiRequest._result_as_json(result)\n
"},{"location":"reference/bloqade/submission/quera_api_client/api/#bloqade.submission.quera_api_client.api.QueueApi.get_task_status_in_queue","title":"get_task_status_in_queue","text":"get_task_status_in_queue(task_id)\n
Request task status in a queue for a given task. @param task_id: Task ID. @return: Parsed JSON of the task status.
Source code insrc/bloqade/submission/quera_api_client/api.py
def get_task_status_in_queue(self, task_id: Union[str, uuid.UUID]) -> str:\n\"\"\"\n Request task status in a queue for a given task.\n @param task_id: Task ID.\n @return: Parsed JSON of the task status.\n \"\"\"\nresult = self.api_http_request.get(\"queue\", \"task\", str(task_id))\nmatch result.status_code:\ncase 200:\nmessage = \"Successfully checked queue.\"\nself.logger.debug(message)\ncase 400:\nmessage = (\n\"The request is invalid. This may indicate an error when parsing a \"\n\"parameter.\"\n)\nself.logger.error(message)\nraise QueueApi.InvalidRequestError(message)\ncase 404:\nmessage = (\nf\"QPU {self.api_http_request.qpu_id} or task {task_id} not found.\"\n)\nself.logger.error(message)\nraise QueueApi.NotFound(message)\ncase _:\nmessage = f\"QPU returned unhandled status {result.status_code}.\"\nself.logger.error(message)\nraise QueueApi.QueueApiError(message)\nresult_json = ApiRequest._result_as_json(result)\nreturn result_json[\"status\"]\n
"},{"location":"reference/bloqade/submission/quera_api_client/api/#bloqade.submission.quera_api_client.api.QueueApi.get_task_summary","title":"get_task_summary","text":"get_task_summary(task_id)\n
Request the task summary for a given task. The summary contains the status of the current task. @param task_id: Task ID. @return: Parsed JSON of the task summary. @see: TaskSummary
in https://github.com/QuEra-QCS/QCS-API/blob/master/qcs-api/openapi.yaml
src/bloqade/submission/quera_api_client/api.py
def get_task_summary(self, task_id: Union[str, uuid.UUID]) -> Dict:\n\"\"\"\n Request the task summary for a given task. The summary contains the status of\n the current task.\n @param task_id: Task ID.\n @return: Parsed JSON of the task summary.\n @see: `TaskSummary` in https://github.com/QuEra-QCS/QCS-API/blob/master/qcs-api/openapi.yaml\n \"\"\"\nif self.get_task_status_in_queue(task_id) != \"Completed\":\nraise QueueApi.QueueApiError(\n\"Task is not completed, can't fetch task summary.\"\n)\nresult = self.api_http_request.get(\"task\", str(task_id))\nmatch result.status_code:\ncase 200:\nmessage = \"Successfully checked task summary.\"\nself.logger.warning(message)\ncase 404:\nmessage = (\nf\"QPU {self.api_http_request.qpu_id} or task {task_id} not found.\"\n)\nself.logger.error(message)\nraise QueueApi.NotFound(message)\ncase 403:\nmessage = \"QPU return authentication error, check AWS credentials.\"\nself.logger.error(message)\nraise QueueApi.AuthenticationError(message)\ncase _:\nmessage = f\"QPU returned unhandled status {result.status_code}.\"\nself.logger.error(message)\nraise QueueApi.QueueApiError(message)\nreturn ApiRequest._result_as_json(result)\n
"},{"location":"reference/bloqade/submission/quera_api_client/api/#bloqade.submission.quera_api_client.api.QueueApi.is_task_stopped","title":"is_task_stopped","text":"is_task_stopped(task_id)\n
Check whether a task is stopped (because it is completed, failed, or cancelled). @param task_id: @return: True
if task is stopped.
src/bloqade/submission/quera_api_client/api.py
def is_task_stopped(self, task_id: Union[str, uuid.UUID]) -> bool:\n\"\"\"\n Check whether a task is stopped (because it is completed, failed, or cancelled).\n @param task_id:\n @return: `True` if task is stopped.\n \"\"\"\nreturn self.get_task_status_in_queue(task_id) in (\n\"Completed\",\n\"Failed\",\n\"Cancelled\",\n)\n
"},{"location":"reference/bloqade/submission/quera_api_client/api/#bloqade.submission.quera_api_client.api.QueueApi.post_task","title":"post_task","text":"post_task(task_json)\n
Submit a task to the QPU via the task API. @param content: Task specification as a JSON string or dictionary.
Source code insrc/bloqade/submission/quera_api_client/api.py
def post_task(self, task_json: Union[str, dict]) -> str:\n\"\"\"\n Submit a task to the QPU via the task API.\n @param content: Task specification as a JSON string or dictionary.\n \"\"\"\nresult = self.api_http_request.post(\"queue\", \"task\", content=task_json)\nmatch result.status_code:\ncase 201:\nmessage = \"Successfully posted task.\"\nself.logger.warning(message)\ncase 404:\nmessage = f\"QPU {self.api_http_request.qpu_id} not found.\"\nself.logger.error(message)\nraise QueueApi.NotFound(message)\ncase 400:\nmessage = (\n\"The request is invalid. This may indicate an error when parsing \"\n\"a parameter.\"\n)\nself.logger.error(message)\nraise QueueApi.InvalidRequestError(message)\ncase 403:\nmessage = \"QPU return authentication error, check AWS credentials.\"\nself.logger.error(message)\nraise QueueApi.AuthenticationError(message)\ncase _:\nmessage = f\"QPU returned unhandled status {result.status_code}.\"\nself.logger.error(message)\nraise QueueApi.QueueApiError(message)\nresult_json = ApiRequest._result_as_json(result)\ntry:\ntask_id = result_json[\"task_id\"]\nself.logger.info(\nf\"QPU {self.api_http_request.qpu_id} accepted \"\nf\"task with task id {task_id}.\"\n)\nreturn task_id\nexcept KeyError:\nraise QueueApi.InvalidResponseError('Response did not contain \"task_id\".')\n
"},{"location":"reference/bloqade/submission/quera_api_client/aws_login/","title":"Aws login","text":""},{"location":"reference/bloqade/submission/quera_api_client/aws_login/#bloqade.submission.quera_api_client.aws_login.sso_login","title":"sso_login","text":"sso_login(profile=None)\n
checks if aws has log-in, and performs attempt of sso login if not. by default profile should be set as env variable AWS_PROFILE
, but can be specified as a parameter.
src/bloqade/submission/quera_api_client/aws_login.py
def sso_login(profile: Optional[str] = None):\n\"\"\"\n checks if aws has log-in, and performs attempt of sso login if not.\n by default profile should be set as env variable `AWS_PROFILE`,\n but can be specified as a parameter.\n \"\"\"\nif profile is not None:\nos.environ[\"AWS_PROFILE\"] = profile\ncode = os.system(\"aws sts get-caller-identity \")\nif code != 0:\nprint(\"login rsp code is \" + str(code) + \". attempting to sso login:\")\nos.system(\"aws sso login\")\n
"},{"location":"reference/bloqade/task/","title":"Index","text":""},{"location":"reference/bloqade/task/#bloqade.task.HardwareBatchTask","title":"HardwareBatchTask","text":" Bases: CloudBatchTask[HardwareTask, HardwareBatchResult]
A compiled batch-tasks that can be submitted to run on quantum hardware with specified backend.
"},{"location":"reference/bloqade/task/base/","title":"Base","text":""},{"location":"reference/bloqade/task/braket_simulator/","title":"Braket simulator","text":""},{"location":"reference/bloqade/task/braket_simulator/#bloqade.task.braket_simulator.BraketEmulatorBatchTask","title":"BraketEmulatorBatchTask","text":" Bases: JSONInterface
, BatchTask[BraketEmulatorTask, BraketEmulatorBatchResult]
A compiled batch-tasks that can be submitted to run on Amazon Braket's local simulator.
"},{"location":"reference/bloqade/task/braket_simulator/#bloqade.task.braket_simulator.BraketEmulatorBatchTask.submit","title":"submit","text":"submit(\nmultiprocessing=False,\nmax_workers=None,\nprogress_bar=False,\n**kwargs\n)\n
Submit the batch tasks to run on Amazon Braket's local simulator.
Parameters:
Name Type Description Defaultmultiprocessing
bool
Running with multiprocess. Defaults to False.
False
max_workers
Optional[int]
. Defaults to None. None
progress_bar
bool
Display progess bar. Defaults to False.
False
Returns:
Type DescriptionBraketEmulatorBatchResult
BraketEmulatorBatchResult
Source code insrc/bloqade/task/braket_simulator.py
def submit(\nself,\nmultiprocessing: bool = False,\nmax_workers: Optional[int] = None,\nprogress_bar: bool = False,\n**kwargs,\n) -> BraketEmulatorBatchResult:\n\"\"\"Submit the batch tasks to run on Amazon Braket's local simulator.\n Args:\n multiprocessing (bool, optional):\n Running with multiprocess. Defaults to False.\n max_workers (Optional[int], optional):\n <TODO>. Defaults to None.\n progress_bar (bool, optional):\n Display progess bar. Defaults to False.\n Returns:\n BraketEmulatorBatchResult\n \"\"\"\nif multiprocessing:\nfutures = OrderedDict()\nwith ProcessPoolExecutor(max_workers=max_workers) as executor:\nfor task_number, task in self.tasks.items():\nfutures[task_number] = executor.submit(task.submit, **kwargs)\nif progress_bar:\niterator = tqdm.tqdm(futures.items())\nelse:\niterator = futures.items()\ntask_results = OrderedDict()\nfor task_number, future in iterator:\ntask_results[task_number] = future.result()\nelse:\nif progress_bar:\niterator = tqdm.tqdm(self.tasks.items())\nelse:\niterator = self.tasks.items()\ntask_results = OrderedDict()\nfor task_number, task in iterator:\ntask_results[task_number] = task.submit(**kwargs)\nreturn BraketEmulatorBatchResult(braket_emulator_task_results=task_results)\n
"},{"location":"reference/bloqade/task/cloud_base/","title":"Cloud base","text":""},{"location":"reference/bloqade/task/cloud_base/#bloqade.task.cloud_base.CloudTask","title":"CloudTask","text":" Bases: JSONInterface
, Task
property
","text":"backend: SubmissionBackend\n
The backend that is used to call the web-API.
"},{"location":"reference/bloqade/task/hardware/","title":"Hardware","text":""},{"location":"reference/bloqade/task/hardware/#bloqade.task.hardware.HardwareBatchTask","title":"HardwareBatchTask","text":" Bases: CloudBatchTask[HardwareTask, HardwareBatchResult]
A compiled batch-tasks that can be submitted to run on quantum hardware with specified backend.
"},{"location":"reference/bloqade/task/report/","title":"Report","text":""},{"location":"reference/bloqade/visualization/","title":"Index","text":""},{"location":"tree/builder/","title":"Builder workflow:","text":"graph TD\n\n ProgramStart(ProgramStart)\n\n Coupling[\"[Coupling]\n Rydberg , Hyperfine\"]\n\n Detuning[Detuning]\n Rabi[Rabi]\n\n Amplitude[Amplitude]\n Phase[Phase]\n\n SpaceModulation(SpaceModulation)\n Waveform{Waveform}\n\n Codegen([\"[Compile]\n quera()\n mock()\n braket()\n braket_local_simulator()\"])\n\n Submit(\"[Submission]\n submit()\")\n\n ProgramStart --> Coupling;\n Coupling --> Detuning;\n Coupling --> Rabi;\n\n Rabi --> Amplitude;\n Rabi --> Phase;\n\n Detuning --> SpaceModulation;\n Amplitude --> SpaceModulation;\n Phase --> SpaceModulation;\n\n SpaceModulation --> Waveform;\n\n Waveform --> Coupling;\n Waveform --> Codegen;\n Codegen --> Submit;
"}]}
\ No newline at end of file
diff --git a/dev/sitemap.xml b/dev/sitemap.xml
new file mode 100644
index 0000000000..be4ce2ab58
--- /dev/null
+++ b/dev/sitemap.xml
@@ -0,0 +1,298 @@
+
+graph TD
+
+ ProgramStart(ProgramStart)
+
+ Coupling["[Coupling]
+ Rydberg , Hyperfine"]
+
+ Detuning[Detuning]
+ Rabi[Rabi]
+
+ Amplitude[Amplitude]
+ Phase[Phase]
+
+ SpaceModulation(SpaceModulation)
+ Waveform{Waveform}
+
+ Codegen(["[Compile]
+ quera()
+ mock()
+ braket()
+ braket_local_simulator()"])
+
+ Submit("[Submission]
+ submit()")
+
+ ProgramStart --> Coupling;
+ Coupling --> Detuning;
+ Coupling --> Rabi;
+
+ Rabi --> Amplitude;
+ Rabi --> Phase;
+
+ Detuning --> SpaceModulation;
+ Amplitude --> SpaceModulation;
+ Phase --> SpaceModulation;
+
+ SpaceModulation --> Waveform;
+
+ Waveform --> Coupling;
+ Waveform --> Codegen;
+ Codegen --> Submit;