Crate metrale_closure

Crate metrale_closure 

Source
Expand description

2026-09-26: One SHA-256 over everything a kernel target’s device code is compiled from: the transitive quoted-#include closure of its sources, the manifests, the nvcc flags, the arch string and the compiler string.

Owner: metrale-closure (shared by the kernels build script and the bench gate). Invariants:

  • A path under the canonicalised root enters the digest relative to it, so two checkouts of one commit agree; a path outside root enters as given.
  • Every file in the closure is read, and any read error returns Err; there is no partial digest.
  • A quoted include that names no file on disk is not an error: it is kept in Closure::unresolved and hashed by name, not by content.

The closure, not the resolved file set, is hashed because a leaf file can #include the common file it shadows (the qwen3.6-27b nvfp4 attn_prefill_paged_indirect.cu includes its common/ namesake), and because headers are not in layout::Layout::sources, which lists one source per module.

Not covered:

  • angle-bracket includes (only the compiler string stands for them);
  • includes found through a search path or in another staged layer: an include is resolved only against the including file’s own directory;
  • preprocessor conditionals, which are not evaluated, so an include in a dead branch is still walked;
  • host code under crates/: the gate’s excuses refuses any non-kernel path before it consults this hash;
  • anything not passed in ClosureInputs.

Modules§

layout
2026-09-26: Which files a (hardware, model, quant) kernel target is compiled from.

Structs§

Closure
2026-09-26: A computed closure: the digest, plus the includes that named no file.
ClosureInputs
2026-09-26: The inputs of one target’s hash.

Enums§

ClosureError

Constants§

CLOSURE_SCHEMA
2026-09-26: Version of the hash definition. It is the first value fed into the digest after the domain tag, so changing it changes every digest. Change it whenever what is fed into the digest changes (an input, an order, a separator), or old and new records compare equal while meaning different things.

Functions§

circuit_configs
2026-09-28: The circuit configs of hardware under root.
circuit_dirs
2026-09-28: The directories circuit_configs reads, for cargo:rerun-if-changed, so a circuit file added or removed reruns the build script too.
fusions_chain
2026-09-30: The FUSIONS.toml files hardware plans with, base first; empty when neither the class nor an ancestor declares rules. A cycle, an unreadable FUSIONS.toml or an inherits that is not a class name is an error, not a shorter list: a list that stopped early would leave an ancestor’s rules out of the hash.
hash
2026-09-26: The digest of hash_with_report, without the unresolved set.
hash_with_report
2026-09-26: Hash a target’s closure and report the quoted includes that named no file on disk.
hex_lower
2026-09-30: bytes as lower-case hex.