From 5e609dab7856bef0834895db6b64ee4bc430e0d4 Mon Sep 17 00:00:00 2001 From: Oleksandr Pavlyk <21087696+oleksandr-pavlyk@users.noreply.github.com> Date: Sun, 28 Jun 2026 18:42:07 -0500 Subject: [PATCH] Respect custom bulk readers in materiality checks Move Float32BinarySource material-payload detection into the source object. Default file-backed sources still use resolved file size so missing or empty sidecars remain unavailable, but positive-count sources with custom readers are treated as material and proceed through the lazy read path. Add regression coverage for virtual bulk sources whose custom reader provides data without a local sidecar file. --- python/scripts/nvbench_compare.py | 25 ++++++++++++++--------- python/test/test_nvbench_compare.py | 31 +++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/python/scripts/nvbench_compare.py b/python/scripts/nvbench_compare.py index 5afa28a..d02f5a3 100644 --- a/python/scripts/nvbench_compare.py +++ b/python/scripts/nvbench_compare.py @@ -425,6 +425,19 @@ class Float32BinarySource: self.count, self.filename, self.json_dir, self.description, self.reader ) + def has_material_payload(self) -> bool: + if self.count <= 0: + return False + + if self.reader is not read_float32_file: + return True + + filename = resolve_binary_filename(self.json_dir, self.filename) + try: + return os.path.getsize(filename) > 0 + except OSError: + return False + @dataclass(frozen=True) class GpuTimingData: @@ -1568,15 +1581,9 @@ def has_material_bulk_source(source): if source is None: return False - if isinstance(source, Float32BinarySource): - if source.count <= 0: - return False - - filename = resolve_binary_filename(source.json_dir, source.filename) - try: - return os.path.getsize(filename) > 0 - except OSError: - return False + has_material_payload = getattr(source, "has_material_payload", None) + if callable(has_material_payload): + return has_material_payload() values = getattr(source, "values", None) return values is not None and len(values) > 0 diff --git a/python/test/test_nvbench_compare.py b/python/test/test_nvbench_compare.py index 92221fa..b2a6eac 100644 --- a/python/test/test_nvbench_compare.py +++ b/python/test/test_nvbench_compare.py @@ -1220,6 +1220,37 @@ def test_compare_gpu_timings_classifies_common_cases(tmp_path, nvbench_compare): assert missing_bulk_files.status == nvbench_compare.ComparisonStatus.FAST assert missing_bulk_files.reason.code == "clear_gap_confirmed_by_summary_cycles" + def virtual_reader(_): + return np.asarray([1.0, 1.1, 1.2, 1.3], dtype="