Skip to content

refactor(check): layer check into selection / inputs / execution / comparison - #144

Merged
zhen8838 merged 4 commits into
tile-ai:mainfrom
zhen8838:refactor/check-surface
Aug 31, 2026
Merged

refactor(check): layer check into selection / inputs / execution / comparison#144
zhen8838 merged 4 commits into
tile-ai:mainfrom
zhen8838:refactor/check-surface

Conversation

@zhen8838

Copy link
Copy Markdown
Collaborator

Why

  • check eagerly materialized every declared weight before selecting a leaf, so checking one runnable function could allocate the union of unrelated sibling weights and fail before execution.
  • Selection, input acquisition, execution, and comparison were coupled behind overlapping flags and executable IR wrapper objects.

What

  • Split check into explicit selection, activation/weight acquisition, concrete execution, and report comparison layers.
  • Added lazy runtime resources with weak safetensors read caching and strongly memoized deterministic random draws shared across subtree views.
  • Moved semantic execution into the evaluator through a transient Reading, preserving lazy child resources and host-side orchestration.
  • Restored reports for input provenance, declared and actual dtypes, selected variants, pinned dimensions, reference norms, warnings, and matching text/JSON facts.

Contract

  • Replace --input / --ckpt with independent --inputs random|files:A,B and --weights random|ckpt:DIR axes.
  • LoadedModule is frozen data containing module, resource, and child modules; it neither owns materialized tensors nor executes functions.
  • Module.<fn> resolves to the Function / PrimFunction IR node itself, as specified by core-ir section 1.1.
  • Remove Module.forward and Module.__call__; semantic execution goes through the evaluator only.
  • evaluate accepts a LoadedModule, supports explicit function=, and takes execution placement from caller-provided device=.
  • Export evaluator.reading(loaded, device=...) as the public host-orchestration view.

Risk

  • Ten files under examples/ still use the old executable-loaded-module API. They are outside pytest and require a separate migration plan.
  • One-to-many load_group aliases and the two-level runtime twin base-class structure are intentionally unchanged.

Comment thread docs/spec/evaluator.md Outdated
Comment thread docs/spec/evaluator.md Outdated
Comment thread src/tilefoundry/cli/check.py Outdated
Comment thread src/tilefoundry/cli/check.py Outdated
Comment thread tests/dsl/test_module_decorator.py Outdated
@zhen8838
zhen8838 force-pushed the refactor/check-surface branch from f676ef5 to 273a189 Compare August 31, 2026 08:03
Comment thread src/tilefoundry/cli/check.py Outdated
Comment thread src/tilefoundry/evaluator/interpreter.py Outdated
The evaluator selected a tensor engine, a device, and a target type on the
caller's behalf. None of the three was the caller's to lose: `backend` had one
legal value and no reachable caller, the default device read the machine rather
than the inputs, and the type ladder carried a branch nobody took.

`evaluate(target, *inputs)` now asks the target which function to run and which
reading, if any, supplies its constants, then computes where the inputs already
are. A run whose inputs carry no tensor leaves the device to torch.

`check` grows `--device`, because on the command line the user could not
express one at all: both input paths build tensors on the device the selection's
Target declares.

The report drops the weight dtype column. A weight whose dtype disagrees with
its declaration is refused at first use, so the column could never differ from
what was declared; obtaining it was the only reason a resource wrapper existed.
@zhen8838
zhen8838 merged commit d686f90 into tile-ai:main Aug 31, 2026
1 check passed
@zhen8838
zhen8838 deleted the refactor/check-surface branch August 31, 2026 11:23
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