Commit 72b0070
* refactor(python): replace PathFinder with ArchSpec in AtomStateData.apply_moves
Part 1 of #247. The only reason PathFinder was passed to apply_moves
was for get_endpoints(), which ArchSpec already provides directly.
This removes the unnecessary dependency and prepares for porting
AtomStateData to Rust.
Also removes duplicate get_blockaded_location call on line 136 and
the path_finder field from AtomInterpreter.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat(core): implement AtomStateData in Rust with PyO3 bindings
Part 2 of #247. Implements AtomStateData as a pure Rust type in
bloqade-lanes-bytecode-core with PyO3 bindings exposed as
bloqade.lanes.bytecode.AtomStateData.
- AtomStateData tracks qubit-to-location mappings, collisions,
lane history, and move counts as atoms move through the arch
- add_atoms, apply_moves, get_qubit, get_qubit_pairing methods
- Immutable value type with deterministic hashing
- Adds get_blockaded_location to Rust ArchSpec for CZ pair lookup
- Adds Hash derive to address types (LocationAddr, LaneAddr, etc.)
- 8 new Rust tests for the atom_state module
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* revert: restore PathFinder in AtomStateData.apply_moves
Revert the PathFinder → ArchSpec change from Part 1 since Part 3
(replacing Python AtomStateData with Rust) is deferred. The API
change is unnecessary without the migration.
Keeps the duplicate get_blockaded_location line removal as a
standalone bug fix.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(core): address review feedback on AtomStateData
- Validate CZ pair targets in get_blockaded_location — return None
if the pair points to an out-of-range location
- Use LocationAddr and LaneAddr directly as HashMap keys instead of
encoded u32/u64 values for cleaner code
- Sort qubit iteration in get_qubit_pairing for deterministic output
ordering (HashMap iteration is randomized in Rust)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor(python): use validate_field for integer inputs in PyAtomStateData
Accept i64 from Python and validate with validate_field<u32> for all
qubit IDs, move counts, and collision mappings. Gives clear error
messages ("qubit_id=-1 must be non-negative") instead of silent
overflow or opaque PyO3 conversion errors.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs: improve AtomStateData docstrings in Rust, PyO3, and type stubs
Add detailed documentation for all fields, methods, and return values
across the Rust core, PyO3 bindings, and Python .pyi stubs. Explains
bidirectional map semantics, collision behavior, move_count accumulation,
and deterministic ordering guarantees.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test(core): add comprehensive tests for AtomStateData and get_blockaded_location
Adds 16 new Rust tests to match Python test coverage:
atom_state:
- apply_moves_verifies_all_fields: checks prev_lanes, move_count, unmoved qubit
- apply_moves_collision_verifies_all_fields: checks all collision state fields
- apply_moves_skips_empty_source: lane with no qubit at source is a no-op
- apply_moves_invalid_lane_returns_none: bad bus id returns None
- apply_moves_accumulates_move_count: two sequential moves increment count
- get_qubit_empty_location: lookup at unoccupied site returns None
- get_qubit_pairing_with_pairs: verifies control/target/unpaired with CZ data
- get_qubit_pairing_invalid_zone: bad zone id returns None
- get_qubit_pairing_skips_qubits_outside_zone: filters by zone membership
- default_is_empty: Default trait produces empty state
- clone_produces_equal_state: Clone trait preserves equality
query:
- get_blockaded_location_valid: site 0 pairs with site 5
- get_blockaded_location_reverse: site 5 pairs back with site 0
- get_blockaded_location_invalid_word: out-of-range word returns None
- get_blockaded_location_invalid_site: out-of-range site returns None
Also strengthens add_atoms_succeeds to verify all field values.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(core): address review feedback — endpoint validation, hash safety, collision docs
- Validate src/dst from lane_endpoints against arch spec before
mutating state, returning None for out-of-range locations
- Add field discriminant tags and length prefixes to Hash impl to
prevent cross-field collisions in HashMap/HashSet usage
- Fix collision field docs: collisions accumulate across apply_moves
calls, only cleared by constructors/add_atoms (not per-call)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(core): remove redundant endpoint validation in apply_moves
lane_endpoints already resolves through the bus tables, so if it
returns Some the endpoints are valid by construction. The extra
check_location call was unnecessary.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(core): validate lane address in lane_endpoints
Move lane validation into lane_endpoints itself so all callers get
consistent None behavior for invalid lanes. Previously, lane_endpoints
could return valid-looking endpoints for lanes with out-of-range
word_id or site_id values because those fields were copied directly
without checking against the architecture bounds.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor(python): move HashMap validation helpers to validation.rs
Move validate_i64_key_map, validate_i64_value_map, and
validate_i64_kv_map from atom_state_python.rs into validation.rs
alongside the existing validate_field and validate_vec helpers.
Made generic over the target type T (not hardcoded to u32).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test(python): add unit tests for HashMap validation helpers
Tests for validate_i64_key_map, validate_i64_value_map, and
validate_i64_kv_map covering valid inputs, negative keys/values,
overflow, and empty maps.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9a2b655 commit 72b0070
File tree
11 files changed
+1551
-8
lines changed- crates
- bloqade-lanes-bytecode-core/src
- arch
- bloqade-lanes-bytecode-python/src
- python/bloqade/lanes
- analysis/atom
- bytecode
11 files changed
+1551
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
| 119 | + | |
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
190 | 196 | | |
191 | 197 | | |
192 | 198 | | |
| |||
230 | 236 | | |
231 | 237 | | |
232 | 238 | | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
233 | 259 | | |
234 | 260 | | |
235 | 261 | | |
| |||
276 | 302 | | |
277 | 303 | | |
278 | 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 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
279 | 354 | | |
280 | 355 | | |
281 | 356 | | |
| |||
639 | 714 | | |
640 | 715 | | |
641 | 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 | + | |
642 | 763 | | |
0 commit comments