Builder
Spec-shaped architecture builder.
ArchBuilder owns everything the :class:ArchSpec owns at spec scope —
the word template and the grid index space it indexes — and treats a zone
as what the spec says it is: a name, a set of coordinates for that shared
index space, and the buses that run on it.
The API is phased, and the phase order is what makes every check decidable at the call that raises it:
- Words.
add_worddefines the spec-wide template. A word is a set of grid(row, column)index pairs, so the template is independent of any zone's coordinates. Every index-space API here is(rows, columns), row-major, including thewords[...]andsites[...]selections. - Zones.
add_zonesupplies coordinates for that index space, plus which words and sites take part in transport there. The template is frozen from the first zone on, because a later word would change the occupancy and the participant set of every zone already added. - Buses. Always zone-qualified. By this point the carried-atom set of every bus is fully determined, so realizability is checked here rather than deferred to build time.
- Spec scope. Blockade radius, modes, capabilities, then
build.
See docs/superpowers/specs/2026-09-15-arch-builder-redesign-design.md
for why the previous ZoneBuilder / ArchBuilder split could not be
made consistent.
ArchBuilder
ArchBuilder(
grid_shape: tuple[int, int], word_shape: tuple[int, int]
)
Build an :class:ArchSpec from a shared word template and zones.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid_shape
|
tuple[int, int]
|
|
required |
word_shape
|
tuple[int, int]
|
|
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If either shape is not a pair of positive integers. |
Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/arch/build/v2/builder.py
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 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | |
blockade_radius
property
blockade_radius: float | None
Blockade radius (µm) applied to every zone, or None.
grid_shape
property
grid_shape: tuple[int, int]
(num_rows, num_columns) of the shared grid index space.
num_words
property
num_words: int
Words defined in the template so far.
num_zones
property
num_zones: int
Zones added so far.
sites
property
sites: _SiteQuery
Select site indices by [rows, columns] of the word shape.
Raises:
| Type | Description |
|---|---|
ValueError
|
If the template has no single row-major shape to
query against, which :meth: |
sites_per_word
property
sites_per_word: int
Total sites per word.
Read off the template once words exist, since that holds whatever
was restored; ArchSpec requires every word to have the same
count even when their shapes differ.
word_shape
property
word_shape: tuple[int, int] | None
(num_rows, num_columns) of sites in every word.
None after :meth:from_spec restored a template that no single
shape describes — see :func:_uniform_row_major_shape.
words
property
words: _WordQuery
Select word IDs by [rows, columns] of the grid index space.
add_entangling_pairs
add_entangling_pairs(
zone: str,
words_a: Sequence[int],
words_b: Sequence[int],
) -> None
Mark paired words as CZ pairs within one zone.
words_a[i] is paired with words_b[i]. Any blockade radius
previously recorded on this zone is cleared, since a manual append
means the pair list is no longer purely radius-derived.
Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/arch/build/v2/builder.py
657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 | |
add_mode
add_mode(
name: str,
zones: Sequence[str],
*,
bitstring_order: Sequence[LocationAddress] | None = None
) -> None
Add an operational mode over a subset of zones.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Mode name. |
required |
zones
|
Sequence[str]
|
Zone names active in this mode. |
required |
bitstring_order
|
Sequence[LocationAddress] | None
|
Explicit measurement bit ordering. Defaults to
every |
None
|
Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/arch/build/v2/builder.py
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 | |
add_site_bus
add_site_bus(
zone: str, src: Sequence[int], dst: Sequence[int]
) -> None
Add a site bus (intra-word movement) to one zone.
The atoms it carries are every participating word's src sites,
which is fixed once the template is frozen and the zone declares
its participants — so realizability is decided here.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
zone
|
str
|
Zone name. |
required |
src
|
Sequence[int]
|
Source site indices within the word shape. |
required |
dst
|
Sequence[int]
|
Destination site indices, parallel to |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
On mismatched or empty sequences, an out-of-range site index, or a transport no AOD can perform. |
Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/arch/build/v2/builder.py
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 | |
add_word
add_word(rows: Index, columns: Index) -> int
Add a word to the spec-wide template.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rows
|
Index
|
Grid row indices for the word's sites; must number
|
required |
columns
|
Index
|
Grid column indices; must number |
required |
Returns:
| Type | Description |
|---|---|
int
|
The new word ID. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the index count does not match |
IndexError
|
If an index falls outside |
Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/arch/build/v2/builder.py
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 | |
add_word_bus
add_word_bus(
zone: str, src: Sequence[int], dst: Sequence[int]
) -> None
Add a word bus (intra-zone movement) to one zone.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
zone
|
str
|
Zone name. |
required |
src
|
Sequence[int]
|
Source word IDs. |
required |
dst
|
Sequence[int]
|
Destination word IDs, parallel to |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
On mismatched or empty sequences, an out-of-range word ID, or a transport no AOD can perform. |
Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/arch/build/v2/builder.py
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 | |
add_zone
add_zone(
name: str,
rows: Sequence[float],
columns: Sequence[float],
*,
x_clearance: float | None,
y_clearance: float | None,
words_with_site_buses: Sequence[int] | None = None,
sites_with_word_buses: Sequence[int] | None = None
) -> int
Add a zone: coordinates for the shared index space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Zone name; must be unique. |
required |
rows
|
Sequence[float]
|
|
required |
columns
|
Sequence[float]
|
|
required |
x_clearance
|
float | None
|
Minimum x-axis distance (> 0, µm) that path
waypoints keep from every grid line. |
required |
y_clearance
|
float | None
|
Same, for the y-axis. |
required |
words_with_site_buses
|
Sequence[int] | None
|
Words eligible for site-bus transport in this zone. Defaults to every word. |
None
|
sites_with_word_buses
|
Sequence[int] | None
|
Sites carried by this zone's word buses. Defaults to every site. |
None
|
Returns:
| Type | Description |
|---|---|
int
|
The new zone ID. |
Raises:
| Type | Description |
|---|---|
ValueError
|
On a duplicate name, a coordinate count that does
not match |
IndexError
|
If a participation entry is out of range. |
Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/arch/build/v2/builder.py
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 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 | |
build
build(
*,
feed_forward: bool | None = None,
atom_reloading: bool | None = None,
blockade_radius: float | None = None,
recompute_paths: bool = False
) -> ArchSpec
Assemble the :class:ArchSpec and validate it via Rust.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
feed_forward
|
bool | None
|
Whether the device supports feed-forward. Defaults
to the value carried in by :meth: |
None
|
atom_reloading
|
bool | None
|
Whether the device supports atom reloading, with the same default. |
None
|
blockade_radius
|
float | None
|
Explicit radius (µm), overriding the value
recorded by :meth: |
None
|
recompute_paths
|
bool
|
Search every lane afresh, discarding inherited paths even for buses that predate any edit. Off by default, so neither a round-trip nor an extension silently replaces hardware-derived lane geometry. |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If no words or zones were defined, or if Rust validation fails. |
Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/arch/build/v2/builder.py
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 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 | |
connect
connect(
src: tuple[str, Sequence[int]],
dst: tuple[str, Sequence[int]],
) -> None
Add an inter-zone word bus.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src
|
tuple[str, Sequence[int]]
|
|
required |
dst
|
tuple[str, Sequence[int]]
|
|
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
On an unknown zone, mismatched or empty sequences, or a transport no AOD can perform. |
IndexError
|
If a word ID is out of range. |
Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/arch/build/v2/builder.py
609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 | |
from_spec
classmethod
from_spec(
spec: ArchSpec,
*,
x_clearance: float | None = None,
y_clearance: float | None = None
) -> ArchBuilder
Rebuild a builder from an existing :class:ArchSpec.
Every zone is replayed in phase order, so a spec that violates the builder's rules — a bus no AOD can perform, say — is rejected here rather than restored silently.
The spec's transport paths are carried over and reused verbatim by
:meth:build, per bus: appending a bus searches paths for that bus
alone and leaves every pre-existing lane exactly as it was. That
matters: the bundled architectures ship hardware-derived lane
geometry that this path search does not reproduce (no clearance
value regenerates it), and move durations — hence fidelity
estimates and the committed benchmark baselines — are read off
those segment lengths.
Clearances are not part of an ArchSpec: they are inputs to
the path search, not properties of the architecture, so a
round-trip cannot recover them. Supply them if you intend to edit
the buses, which makes the inherited paths stale and forces a
search; without them, such an edit raises rather than silently
re-routing. Passing them does not by itself discard the inherited
paths — use build(recompute_paths=True) for that.
The word template is restored verbatim, not replayed through
:meth:add_word. An ArchSpec word is an ordered list of grid
positions — it may be listed in any order, need not be a Cartesian
product, and words may differ in shape, since the only cross-word
rule is an equal site count. A site's ID is its index in that list,
so regenerating it would renumber sites and re-map every bus
endpoint and inherited lane that addresses them. When the restored
template has no single row-major shape, :attr:word_shape is
None and the sites[...] query is unavailable; use
:meth:word_sites and plain site indices instead.
Two things ArchSpec permits and this builder still refuses,
because both put two atoms in one place: a word listing the same
grid position twice, and two words sharing a position.
Specs this builder cannot represent are rejected, not
reinterpreted. ArchSpec is a more permissive format than this
builder's model, so some valid specs have no equivalent here. Each
raises ValueError naming the problem rather than being restored
as something subtly different, because the alternative is a silent
change to word numbering or routing:
- A zone bus whose endpoint spans several zones. :meth:
connectaddresses one zone per side, while aBus[ZonedWordRef]carries a zone ID per element. Rust only asks that each pair cross a zone boundary, so a bus whose source entries name two different zones is valid and unrepresentable here. This is a genuine expressiveness gap, not an oversight — an architecture that needs that shape needs a richerconnectfirst. - A zone bus with an empty endpoint, which Rust also accepts.
- Zones that disagree on grid dimensions, since the word template is spec-wide and indexes one shared index space.
- A bus with no participants — an empty
words_with_site_busesalongside site buses, or the same for word buses — which would carry no atoms.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
ArchSpec
|
The spec to rebuild. |
required |
x_clearance
|
float | None
|
Minimum x-axis waypoint clearance (µm), or
|
None
|
y_clearance
|
float | None
|
Same, for the y-axis. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the spec has no words or zones, if it uses any of the shapes listed above, or if any bus is not realizable under the builder's AOD rules. |
Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/arch/build/v2/builder.py
865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 | |
set_blockade_radius
set_blockade_radius(radius: float) -> None
Derive entangling word pairs in every zone from the radius.
The radius is a spec-scope value, but the pairs it implies are per-zone: the same radius against different coordinates yields different pairs. Every zone is scanned before any pair list is overwritten, so a layout error in a later zone cannot leave earlier zones partially updated.
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/arch/build/v2/builder.py
680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 | |
word_sites
word_sites(word_id: int) -> list[tuple[int, int]]
The (row, column) grid position of each of a word's sites.
Indexed by site ID, so this works for any template — including one
restored from a spec that word_shape cannot describe.
Source code in .venv/lib/python3.12/site-packages/bloqade/lanes/arch/build/v2/builder.py
344 345 346 347 348 349 350 | |