From 8746b13e76b8f2db97ef5f41901b07a9ff5bfc5d Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Tue, 28 Jul 2026 05:37:55 -0700 Subject: [PATCH] Studio tests: bump the tensor-abort mtime by 1ms so the case runs on Windows (#7556) test_tensor_abort_cache_invalidated_on_binary_mtime_change bumped mtime by a single nanosecond. NTFS stores timestamps as 64-bit FILETIME values in 100ns ticks, so on Windows that bump rounds away, st_mtime_ns reads back unchanged, the cache key is identical and the stale abort is inherited, and the assertion sees True where it wants False. 1ms is still a same-second, sub-second change and is exactly representable, so the case the test exists to cover actually runs. Skip when the filesystem cannot record any sub-second change at all rather than asserting product behaviour the platform cannot exercise. Not caught before because both jobs in studio-backend-ci.yml are runs-on: ubuntu-latest, so the studio backend tests only ever run on Linux. --- studio/backend/tests/test_tp_vision_regression.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/studio/backend/tests/test_tp_vision_regression.py b/studio/backend/tests/test_tp_vision_regression.py index 1781bd70ae..239da44ed1 100644 --- a/studio/backend/tests/test_tp_vision_regression.py +++ b/studio/backend/tests/test_tp_vision_regression.py @@ -24,6 +24,8 @@ import textwrap import types as _types from pathlib import Path +import pytest + _BACKEND_DIR = str(Path(__file__).resolve().parent.parent) if _BACKEND_DIR not in sys.path: sys.path.insert(0, _BACKEND_DIR) @@ -327,14 +329,18 @@ def test_tensor_abort_cache_invalidated_on_binary_mtime_change(tmp_path): ), "a binary swapped in place (new mtime) must be re-probed" # A same-second replacement (sub-second mtime bump) must also re-probe: # second-resolution mtime would inherit the stale abort (reviewer.py P2). + # Bump by 1ms, not 1ns: NTFS stores mtime as 100ns FILETIME ticks, so a 1ns + # bump rounds away on Windows and the key never changes. sec_ns = (binp.stat().st_mtime_ns // 1_000_000_000) * 1_000_000_000 os.utime(p, ns = (sec_ns, sec_ns)) LlamaCppBackend._record_tensor_split_abort(p, "m") binp.write_text("v2") - os.utime(p, ns = (sec_ns, sec_ns + 1)) + os.utime(p, ns = (sec_ns, sec_ns + 1_000_000)) + if binp.stat().st_mtime_ns == sec_ns: + pytest.skip("filesystem cannot record a sub-second mtime change") assert ( LlamaCppBackend._tensor_split_aborts(p, "m") is False - ), "a same-second in-place swap (ns mtime bump) must be re-probed" + ), "a same-second in-place swap (sub-second mtime bump) must be re-probed" finally: for key in list(LlamaCppBackend._tensor_split_abort_keys): if key and key[0] == p: