Skip to content

Commit d70b206

Browse files
authored
Fix observable predictions shape in sinter's MWPF and FussionBlossom 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.
1 parent a3e080c commit d70b206

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

glue/sample/src/sinter/_decoding/_decoding_fusion_blossom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def decode_shots_bit_packed(
2424
bit_packed_detection_event_data: 'np.ndarray',
2525
) -> 'np.ndarray':
2626
num_shots = bit_packed_detection_event_data.shape[0]
27-
predictions = np.zeros(shape=(num_shots, self.num_obs), dtype=np.uint8)
27+
predictions = np.zeros(shape=(num_shots, (self.num_obs + 7) // 8), dtype=np.uint8)
2828
import fusion_blossom
2929
for shot in range(num_shots):
3030
dets_sparse = np.flatnonzero(np.unpackbits(bit_packed_detection_event_data[shot], count=self.num_dets, bitorder='little'))

glue/sample/src/sinter/_decoding/_decoding_mwpf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def decode_shots_bit_packed(
3838
bit_packed_detection_event_data: "np.ndarray",
3939
) -> "np.ndarray":
4040
num_shots = bit_packed_detection_event_data.shape[0]
41-
predictions = np.zeros(shape=(num_shots, self.num_obs), dtype=np.uint8)
41+
predictions = np.zeros(shape=(num_shots, (self.num_obs + 7) // 8), dtype=np.uint8)
4242
import mwpf
4343

4444
for shot in range(num_shots):

0 commit comments

Comments
 (0)