engineattest

package
v0.6.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2026 License: MIT Imports: 0 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package engineattest turns "this ran on the ANE" or "this ran on the GPU" from a comment into a checked runtime assertion.

The failure mode it guards against is hollow code: a function that claims to dispatch work to an accelerator, benchmarks well, and never touches the silicon. Timing cannot catch that impostor — a no-op is fast — so the assertion reads hardware-owned evidence instead:

  • [ANE] attaches a zeroed performance-stats object to the model's request, runs the attested function, and fails unless the driver reported nonzero hardware execution time. Before trusting a zero it proves the counter can move at all by running one extra evaluation of the model (the sensitivity canary).

  • [Queue.GPU] tracks the command buffers a wrapped [metal.MTLCommandQueue] vends during the attested function and fails unless at least one completed on the GPU with a nonzero scheduling window (GPUEndTime > GPUStartTime > 0).

Basic use:

if err := engineattest.ANE(k.Model(), func() error { return k.Eval() }); err != nil {
	log.Fatalf("ANE claim did not survive: %v", err)
}

Limits, stated rather than implied: the ANE probe needs a model that reports hardware execution time. In-memory MIL models expose no hardware counters and fail the canary with [ErrUnattestable]; package-backed models can report it, but on some OS/firmware versions (observed on macOS 26.6) the driver leaves every perf counter zero for them too, and the canary likewise returns [ErrUnattestable] rather than a false verdict. The canary runs one real evaluation, which overwrites the model's output surfaces from its current inputs. The GPU probe attests that work went through the wrapped queue — code that submits real work through a different queue fails the assertion, and code that commits empty command buffers on purpose can fool it; the threat model is hollow code, not adversarial code.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL