Skip to content

Commit 9f8f4e2

Browse files
committed
additional test updates
Signed-off-by: Ben Howe <[email protected]>
1 parent 2bdb2f8 commit 9f8f4e2

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

libs/qec/python/tests/test_decoding_config.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,26 @@
1414

1515
# nv_qldpc_decoder_config tests
1616

17+
18+
def is_nv_qldpc_decoder_available():
19+
"""
20+
Helper function to check if the NV-QLDPC decoder is available.
21+
"""
22+
try:
23+
# First check to sure a GPU is available.
24+
result = subprocess.run(["nvidia-smi"], capture_output=True, timeout=2)
25+
if result.returncode != 0:
26+
return False
27+
# Now make sure that the NV-QLDPC decoder is available.
28+
H_list = [[1, 0, 0, 1, 0, 1, 1], [0, 1, 0, 1, 1, 0, 1],
29+
[0, 0, 1, 0, 1, 1, 1]]
30+
H_np = np.array(H_list, dtype=np.uint8)
31+
nv_dec_gpu_and_cpu = qec.get_decoder("nv-qldpc-decoder", H_np)
32+
return True
33+
except Exception as e:
34+
return False
35+
36+
1737
FIELDS = {
1838
"use_sparsity": (bool, True, False),
1939
"error_rate": (float, 1e-3, 5e-2),
@@ -284,6 +304,9 @@ def test_configure_decoders_from_str_smoke():
284304
decoder_config.H_sparse = [1, 2, 3, -1, 6, 7, 8, -1, -1]
285305
decoder_config.set_decoder_custom_args(nv)
286306
yaml_str = decoder_config.to_yaml_str()
307+
# Do not instantiate the decoder if it is not available.
308+
if not is_nv_qldpc_decoder_available():
309+
return
287310
status = qec.configure_decoders_from_str(yaml_str)
288311
assert isinstance(status, int)
289312
qec.finalize_decoders()

0 commit comments

Comments
 (0)