Skip to content

Commit c97e326

Browse files
committed
Removed num_syndromes_per_round
Signed-off-by: Chuck Ketcham <[email protected]>
1 parent 7eae5b2 commit c97e326

File tree

11 files changed

+12
-50
lines changed

11 files changed

+12
-50
lines changed

libs/qec/include/cudaq/qec/realtime/decoding_config.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ struct decoder_config {
118118
std::string type;
119119
uint64_t block_size = 0;
120120
uint64_t syndrome_size = 0;
121-
uint64_t num_syndromes_per_round = 0;
122121
std::vector<std::int64_t> H_sparse;
123122
std::vector<std::int64_t> O_sparse;
124123
std::optional<std::vector<std::int64_t>> D_sparse;

libs/qec/lib/realtime/config.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,6 @@ struct MappingTraits<cudaq::qec::decoding::config::decoder_config> {
349349
io.mapRequired("type", config.type);
350350
io.mapRequired("block_size", config.block_size);
351351
io.mapRequired("syndrome_size", config.syndrome_size);
352-
io.mapRequired("num_syndromes_per_round", config.num_syndromes_per_round);
353352
io.mapRequired("H_sparse", config.H_sparse);
354353
io.mapRequired("O_sparse", config.O_sparse);
355354
io.mapOptional("D_sparse", config.D_sparse);
@@ -425,18 +424,6 @@ struct MappingTraits<cudaq::qec::decoding::config::decoder_config> {
425424
INIT_AND_MAP_DECODER_CUSTOM_ARGS(
426425
cudaq::qec::decoding::config::sliding_window_config);
427426
}
428-
429-
// Validate that the number of syndromes per round is less than or equal to
430-
// the syndrome size and >= 0.
431-
if (config.num_syndromes_per_round < 0 ||
432-
config.num_syndromes_per_round > config.syndrome_size) {
433-
throw std::runtime_error(
434-
"num_syndromes_per_round (" +
435-
std::to_string(config.num_syndromes_per_round) +
436-
") is not greater than 0 and less than or equal to syndrome_size (" +
437-
std::to_string(config.syndrome_size) + ") for decoder " +
438-
std::to_string(config.id));
439-
}
440427
}
441428
};
442429

libs/qec/lib/realtime/realtime_decoding.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,8 @@ int configure_decoders(
7676
if (decoder_config.D_sparse.has_value()) {
7777
new_decoder->set_D_sparse(*decoder_config.D_sparse);
7878
} else {
79-
// Auto-generate a hard-wired D_sparse.
80-
auto num_rounds = decoder_config.syndrome_size /
81-
decoder_config.num_syndromes_per_round;
82-
CUDAQ_INFO("Auto-generating D_sparse for decoder {} with "
83-
"num_syndromes_per_round {} and num_rounds {}",
84-
decoder_config.id, decoder_config.num_syndromes_per_round,
85-
num_rounds);
86-
std::vector<std::int64_t> D_sparse =
87-
cudaq::qec::generate_timelike_sparse_detector_matrix(
88-
decoder_config.num_syndromes_per_round, num_rounds,
89-
/*include_first_round=*/false);
90-
new_decoder->set_D_sparse(D_sparse);
79+
throw std::runtime_error(
80+
"D_sparse must be provided in decoder configuration");
9181
}
9282

9383
// Invoke a dummy decoding operation to force the decoder to be

libs/qec/python/bindings/py_decoding_config.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,6 @@ void bindDecodingConfig(py::module &mod) {
152152
.def_readwrite("type", &decoder_config::type)
153153
.def_readwrite("block_size", &decoder_config::block_size)
154154
.def_readwrite("syndrome_size", &decoder_config::syndrome_size)
155-
.def_readwrite("num_syndromes_per_round",
156-
&decoder_config::num_syndromes_per_round)
157155
.def_readwrite("H_sparse", &decoder_config::H_sparse)
158156
.def_readwrite("O_sparse", &decoder_config::O_sparse)
159157
.def_readwrite("D_sparse", &decoder_config::D_sparse)

libs/qec/python/tests/test_decoders_yaml.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ def create_test_empty_decoder_config(decoder_id):
6868
config.type = "single_error_lut"
6969
config.block_size = 20
7070
config.syndrome_size = 10
71-
config.num_syndromes_per_round = config.syndrome_size
7271

7372
# Create sparse H matrix representation from a zero matrix
7473
H = np.zeros((config.syndrome_size, config.block_size), dtype=np.uint8)
@@ -80,8 +79,7 @@ def create_test_empty_decoder_config(decoder_id):
8079

8180
# Generate timelike sparse detector matrix
8281
config.D_sparse = qec.generate_timelike_sparse_detector_matrix(
83-
config.num_syndromes_per_round, 2, include_first_round=False)
84-
82+
config.syndrome_size, 2, include_first_round=False)
8583
return config
8684

8785

@@ -219,7 +217,6 @@ def test_sliding_window_decoder():
219217
config.type = "sliding_window"
220218
config.block_size = n_cols
221219
config.syndrome_size = n_rows
222-
config.num_syndromes_per_round = n_syndromes_per_round
223220

224221
# Convert PCM to sparse representation
225222
config.H_sparse = qec.pcm_to_sparse_vec(pcm)
@@ -228,8 +225,8 @@ def test_sliding_window_decoder():
228225
O = np.zeros((2, n_cols), dtype=np.uint8)
229226
config.O_sparse = qec.pcm_to_sparse_vec(O)
230227

231-
# Reset D_sparse for sliding window (set to None to indicate it's not used)
232-
config.D_sparse = None
228+
config.D_sparse = qec.generate_timelike_sparse_detector_matrix(
229+
config.syndrome_size, 2, include_first_round=False)
233230

234231
# Sliding window config
235232
sw_config = qec.qecrt.config.sliding_window_config()

libs/qec/python/tests/test_decoding_config.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,9 @@ def test_configure_valid_multi_error_lut_decoders():
167167
dc.type = "multi_error_lut"
168168
dc.block_size = 10
169169
dc.syndrome_size = 3
170-
dc.num_syndromes_per_round = 3
171170
dc.H_sparse = [1, 2, 3, -1, 6, 7, 8, -1, -1]
171+
dc.D_sparse = qec.generate_timelike_sparse_detector_matrix(
172+
dc.syndrome_size, 2, include_first_round=False)
172173
dc.set_decoder_custom_args(nv)
173174

174175
mdc = qec.multi_decoder_config()
@@ -195,7 +196,6 @@ def test_decoder_config_yaml_roundtrip_and_custom_args():
195196
dc.type = "nv-qldpc-decoder"
196197
dc.block_size = 10
197198
dc.syndrome_size = 3
198-
dc.num_syndromes_per_round = 3
199199
dc.H_sparse = [1, 2, 3, -1, 6, 7, 8, -1, -1]
200200
dc.set_decoder_custom_args(nv)
201201

@@ -210,7 +210,6 @@ def test_decoder_config_yaml_roundtrip_and_custom_args():
210210
assert dc2.type == "nv-qldpc-decoder"
211211
assert dc2.block_size == 10
212212
assert dc2.syndrome_size == 3
213-
assert dc2.num_syndromes_per_round == 3
214213

215214
# Recover NV config from decoder_custom_args (it's already the config object)
216215
nv2 = dc2.decoder_custom_args
@@ -236,7 +235,6 @@ def test_multi_decoder_config_yaml_roundtrip():
236235
d1.type = "nv-qldpc-decoder"
237236
d1.block_size = 10
238237
d1.syndrome_size = 3
239-
d1.num_syndromes_per_round = 3
240238
d1.H_sparse = [1, 2, 3, -1, 6, 7, 8, -1, -1]
241239
d1.set_decoder_custom_args(nv)
242240

@@ -248,7 +246,6 @@ def test_multi_decoder_config_yaml_roundtrip():
248246
d2.type = "multi_error_lut"
249247
d2.block_size = 10
250248
d2.syndrome_size = 3
251-
d2.num_syndromes_per_round = 3
252249
d2.H_sparse = [1, 2, 3, -1, 6, 7, 8, -1, -1]
253250
d2.set_decoder_custom_args(lut_config)
254251

@@ -280,7 +277,6 @@ def test_configure_decoders_from_str_smoke():
280277
decoder_config.type = "nv-qldpc-decoder"
281278
decoder_config.block_size = 10
282279
decoder_config.syndrome_size = 3
283-
decoder_config.num_syndromes_per_round = 3
284280
decoder_config.H_sparse = [1, 2, 3, -1, 6, 7, 8, -1, -1]
285281
decoder_config.set_decoder_custom_args(nv)
286282
yaml_str = decoder_config.to_yaml_str()
@@ -310,8 +306,9 @@ def test_configure_valid_decoders():
310306
dc.type = "multi_error_lut"
311307
dc.block_size = 10
312308
dc.syndrome_size = 3
313-
dc.num_syndromes_per_round = 3
314309
dc.H_sparse = [1, 2, 3, -1, 6, 7, 8, -1, -1]
310+
dc.D_sparse = qec.generate_timelike_sparse_detector_matrix(
311+
dc.syndrome_size, 2, include_first_round=False)
315312
lut_config = qec.multi_error_lut_config()
316313
lut_config.lut_error_depth = 2
317314
dc.set_decoder_custom_args(lut_config)
@@ -336,7 +333,6 @@ def test_configure_invalid_decoders():
336333
decoder_config.type = "invalid-decoder"
337334
decoder_config.block_size = 10
338335
decoder_config.syndrome_size = 3
339-
decoder_config.num_syndromes_per_round = 3
340336
decoder_config.H_sparse = [1, 2, 3, -1, 6, 7, 8, -1, -1]
341337
decoder_config.set_decoder_custom_args(nv)
342338

libs/qec/unittests/realtime/app_examples/surface_code-1.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ void save_dem_to_file(const cudaq::qec::detector_error_model &dem,
4242
config.type = "multi_error_lut";
4343
config.block_size = dem.num_error_mechanisms();
4444
config.syndrome_size = dem.num_detectors();
45-
config.num_syndromes_per_round = numSyndromesPerRound;
4645
config.H_sparse = cudaq::qec::pcm_to_sparse_vec(dem.detector_error_matrix);
4746
config.O_sparse =
4847
cudaq::qec::pcm_to_sparse_vec(dem.observables_flips_matrix);

libs/qec/unittests/realtime/app_examples/surface_code-2.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ void save_dem_to_file(const cudaq::qec::detector_error_model &dem,
4141
config.type = "multi_error_lut";
4242
config.block_size = dem.num_error_mechanisms();
4343
config.syndrome_size = dem.num_detectors();
44-
config.num_syndromes_per_round = numSyndromesPerRound;
4544
config.H_sparse = cudaq::qec::pcm_to_sparse_vec(dem.detector_error_matrix);
4645
config.O_sparse =
4746
cudaq::qec::pcm_to_sparse_vec(dem.observables_flips_matrix);

libs/qec/unittests/realtime/app_examples/surface_code-3.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ create_decoder_config(uint64_t id, const cudaq::qec::detector_error_model &dem,
4040
config.type = "multi_error_lut";
4141
config.block_size = dem.num_error_mechanisms();
4242
config.syndrome_size = dem.num_detectors();
43-
config.num_syndromes_per_round = numSyndromesPerRound;
4443
config.H_sparse = cudaq::qec::pcm_to_sparse_vec(dem.detector_error_matrix);
4544
config.O_sparse = cudaq::qec::pcm_to_sparse_vec(dem.observables_flips_matrix);
4645
config.D_sparse = det_mat;

libs/qec/unittests/realtime/app_examples/surface_code_1.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ def save_dem_to_file(dem, dem_filename, numSyndromesPerRound, num_logical):
7171
config.type = "multi_error_lut"
7272
config.block_size = dem.num_error_mechanisms()
7373
config.syndrome_size = dem.num_detectors()
74-
config.num_syndromes_per_round = numSyndromesPerRound
7574
config.H_sparse = qec.pcm_to_sparse_vec(dem.detector_error_matrix)
7675
config.O_sparse = qec.pcm_to_sparse_vec(dem.observables_flips_matrix)
7776
config.D_sparse = qec.generate_timelike_sparse_detector_matrix(

0 commit comments

Comments
 (0)