Skip to content

Commit

Permalink
Fix observable predictions shape in sinter's MWPF and FussionBlossom …
Browse files Browse the repository at this point in the history
…decoder (#864)

The packed obs predictions should be of shape `(num_shots, (self.num_obs
+ 7) // 8)` instead of `(num_shots, self.num_obs)`, which results in
error `ValueError: predictions.shape[1] > actual_obs.shape[1] + 1` when
simulating codes with multiple logical observables.
  • Loading branch information
inmzhang authored Dec 4, 2024
1 parent a3e080c commit d70b206
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def decode_shots_bit_packed(
bit_packed_detection_event_data: 'np.ndarray',
) -> 'np.ndarray':
num_shots = bit_packed_detection_event_data.shape[0]
predictions = np.zeros(shape=(num_shots, self.num_obs), dtype=np.uint8)
predictions = np.zeros(shape=(num_shots, (self.num_obs + 7) // 8), dtype=np.uint8)
import fusion_blossom
for shot in range(num_shots):
dets_sparse = np.flatnonzero(np.unpackbits(bit_packed_detection_event_data[shot], count=self.num_dets, bitorder='little'))
Expand Down
2 changes: 1 addition & 1 deletion glue/sample/src/sinter/_decoding/_decoding_mwpf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def decode_shots_bit_packed(
bit_packed_detection_event_data: "np.ndarray",
) -> "np.ndarray":
num_shots = bit_packed_detection_event_data.shape[0]
predictions = np.zeros(shape=(num_shots, self.num_obs), dtype=np.uint8)
predictions = np.zeros(shape=(num_shots, (self.num_obs + 7) // 8), dtype=np.uint8)
import mwpf

for shot in range(num_shots):
Expand Down

0 comments on commit d70b206

Please sign in to comment.