Skip to content

Invalidate ninetoothed.build cache when inputs change#151

Merged
voltjia merged 1 commit into
masterfrom
invalidate-build-cache-on-input-change
May 8, 2026
Merged

Invalidate ninetoothed.build cache when inputs change#151
voltjia merged 1 commit into
masterfrom
invalidate-build-cache-on-input-change

Conversation

@voltjia

@voltjia voltjia commented May 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

_load_cached in ninetoothed.build previously returned the cached .so whenever it existed on disk, regardless of whether the source code, configs, or library internals had changed since it was produced. That let stale artifacts silently survive across premake, configs, or ninetoothed updates — e.g. two tests/test_aot.py::test_conv2d cases were failing with _KernelLaunchError because cached .so files from before the test_aot.py argument list grew were still being loaded.

Changes

  • Add _compute_fingerprint(premake, configs, meta_parameters, caller) that SHA-256s the premake source (with functools.partial args and keywords folded in), configs, meta_parameters, caller, and the contents of build.py and aot.py.
  • Persist the fingerprint as <kernel_name>.fingerprint alongside the other build artifacts.
  • _load_cached returns None when the fingerprint file is missing or its contents do not match.
  • Normalize configs (and meta_parameters when set) to tuples up front so pre-iterating them for the fingerprint does not exhaust generators.

Testing

Testing

pytest output:

============================= test session starts ==============================
platform linux -- Python 3.10.16, pytest-9.0.2, pluggy-1.6.0
rootdir: /home/huangjiacheng/ninetoothed
configfile: pyproject.toml
plugins: anyio-4.12.1, xdist-3.8.0, cov-7.0.0, typeguard-4.4.4
collected 213 items

tests/test_add.py .                                                      [  0%]
tests/test_addmm.py ..                                                   [  1%]
tests/test_aot.py .........                                              [  5%]
tests/test_aot_auto_tuning.py ....                                       [  7%]
tests/test_attention.py ........                                         [ 11%]
tests/test_auto_tuner.py ....                                            [ 13%]
tests/test_clone.py ....                                                 [ 15%]
tests/test_conv2d.py ....                                                [ 16%]
tests/test_data_ptr.py .                                                 [ 17%]
tests/test_debugging.py .                                                [ 17%]
tests/test_dropout.py .                                                  [ 18%]
tests/test_eval.py ........                                              [ 22%]
tests/test_expand.py .                                                   [ 22%]
tests/test_generation.py ............................................... [ 44%]
.............................                                            [ 58%]
tests/test_getitem.py ..........                                         [ 62%]
tests/test_ipynb.py .                                                    [ 63%]
tests/test_jagged.py ................                                    [ 70%]
tests/test_matmul.py ..                                                  [ 71%]
tests/test_max_pool2d.py ..                                              [ 72%]
tests/test_naming.py .......                                             [ 76%]
tests/test_pad.py ................................................       [ 98%]
tests/test_pow.py .                                                      [ 99%]
tests/test_softmax.py .                                                  [ 99%]
tests/test_unsqueeze.py .                                                [100%]

======================= 213 passed in 2781.93s (0:46:21) =======================

@voltjia voltjia merged commit 7355513 into master May 8, 2026
8 checks passed
@voltjia voltjia deleted the invalidate-build-cache-on-input-change branch May 8, 2026 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant