Skip to content

TACK_LOG_COMPILES: a line per new variant, naming what made it new (#325) - #516

Open
berkgeveci wants to merge 1 commit into
Kitware:mainfrom
berkgeveci:core/compile-log-325
Open

berkgeveci wants to merge 1 commit into
Kitware:mainfrom
berkgeveci:core/compile-log-325

Conversation

@berkgeveci

@berkgeveci berkgeveci commented Dec 5, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #325 (v1: the named key parts and the compile log; see below for what is left out).

With TACK_LOG_COMPILES=1, every call that makes a new kernel variant writes one line to stderr:

tack: compiled kernel=scale (pipeline.py:7) device=cpu outcome=built variants=2 frontend_ms=0.0 passes_ms=0.3 backend_ms=12.2 disk_ms=0.9 changed="a.shape[1] (baked): 32 -> 64; out.shape[1] (baked): 32 -> 64"

What

  • variant_key_parts, beside kernel_variant_key, names each position of the real key. It covers the parameters' types and kinds, the vector widths, and each template's class, class constants, arrays (type and rank), runtime scalars, function attributes and nested classes. It also covers the baked dimensions (from ir_shape_deps) and the disjoint flag. It reads the key; it never walks the arguments again, so it cannot drift. A key part it does not know is shown by its position.
  • runtime/compile_log.py: the line compares the new variant with the last one logged for the kernel on the device. That baseline is not the last call, since calls that find their variant log nothing.
    • Outcomes: built; loaded from the disk cache (no passes, though Metal and CUDA may still compile what was stored); or failed-in-passes / failed-in-backend, with the original error kept.
    • Times: flat host times per stage.
    • Lifetimes: it keeps strings only, weakly per kernel, so no class, argument or IR is kept alive.
  • Class tokens carry their class's name and a process-local serial, so Model#1 -> Model#2 tells a class defined afresh from one of the same name. Key equality stays identity.
  • The warm fast path (_fast_resolve) is unchanged. The slow path takes timestamps only while the log is on, and the passes and build moved into _built_variant unchanged.

Not in this PR

tack.cache.capture and tack.cache.variants(), the issue's third item. The proposal's review (vault, 2026-10-31) deferred them until the log proves insufficient.

Tests

test_compile_log.py (quick):

  • a baked stride is named, while a launch length or a scalar logs nothing;
  • dtype changes;
  • a class constant, and a class defined afresh under the same name;
  • debug mode's repeat slow-path call logs nothing;
  • a warm call never reaches the log, on or off;
  • off writes nothing;
  • a failed build;
  • every position of a real key is named;
  • the log keeps no class alive;
  • two processes, where the environment switches it on and the second says loaded.

Results (CPU, M1 Max):

  • the related core files (fast path, signature property, disk cache, templates, variant cache): 129 passed;
  • the quick tier: 4161 passed, 373 skipped (this environment had no VTK);
  • ruff, SPDX, the changelog check and mkdocs build --strict are clean.

Docs

  • "See why a call compiled" in the kernel-cache guide;
  • the TACK_LOG_COMPILES row in the runtime contract's environment table;
  • the specialization design page, including a correction: a template array's sizes are not in the template key, only its rank and type;
  • CLAUDE.md.

It already found one baked size: flying edges' _points, fixed for 0.8 in #515.

This will be merged after the 0.8 release.

🤖 Generated with Claude Code

…itware#325)

variant_key_parts, beside kernel_variant_key, names each position of the real
key (parameters' types and kinds, vector widths, each template's class,
constants, arrays, runtime scalars, function attributes and nested classes,
baked dimensions, the disjoint flag). With TACK_LOG_COMPILES=1 the slow path
writes one stderr line per variant it builds or loads: the parts changed since
the kernel's last logged variant on the device, the outcome, the variant count
and the host time of the frontend, passes, backend and disk stages; a failed
build logs its stage and keeps its error. Calls that find their variant log
nothing; _fast_resolve is unchanged. Class tokens carry a name and a serial so
a class defined afresh under the same name is told apart.
@berkgeveci berkgeveci added this to the 0.9 milestone Dec 5, 2026

This branch has not been deployed

No deployments
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.

Specialization diagnostics

1 participant