Skip to content

Commit 3c97d22

Browse files
committed
fixup! feat(core.utils): collapse empty ptxas_options sequence to None
1 parent acaccca commit 3c97d22

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

cuda_core/cuda/core/utils/_program_cache.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,15 @@ def _gate_identity(v):
244244
def _gate_ptxas_options(v):
245245
# ``_prepare_nvjitlink_options`` emits one ``-Xptxas=<s>`` per element, and
246246
# treats ``str`` as a single-element sequence. Canonicalize to a tuple so
247-
# ``"-v"`` / ``["-v"]`` / ``("-v",)`` all hash the same.
247+
# ``"-v"`` / ``["-v"]`` / ``("-v",)`` all hash the same. An empty sequence
248+
# emits no flags, so collapse it to ``None`` too.
248249
if v is None:
249250
return None
250251
if isinstance(v, str):
251252
return ("-Xptxas=" + v,)
252253
if isinstance(v, collections.abc.Sequence):
254+
if len(v) == 0:
255+
return None
253256
return tuple(f"-Xptxas={s}" for s in v)
254257
return v
255258

cuda_core/tests/test_program_cache.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,10 @@ def test_make_program_cache_key_ptx_driver_ignored_fields_collapse(field, a, b,
401401
pytest.param("-v", ["-v"], id="str_vs_list"),
402402
pytest.param("-v", ("-v",), id="str_vs_tuple"),
403403
pytest.param(["-v"], ("-v",), id="list_vs_tuple"),
404+
# Empty sequence emits no -Xptxas flags; must match None.
405+
pytest.param(None, [], id="none_vs_empty_list"),
406+
pytest.param(None, (), id="none_vs_empty_tuple"),
407+
pytest.param([], (), id="empty_list_vs_empty_tuple"),
404408
],
405409
)
406410
def test_make_program_cache_key_ptx_ptxas_options_canonicalized(a, b, monkeypatch):

0 commit comments

Comments
 (0)