refactor(check): layer check into selection / inputs / execution / comparison - #144
Merged
Merged
Conversation
zhen8838
commented
Aug 31, 2026
zhen8838
force-pushed
the
refactor/check-surface
branch
from
August 31, 2026 08:03
f676ef5 to
273a189
Compare
zhen8838
commented
Aug 31, 2026
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
checkeagerly 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.What
checkinto explicit selection, activation/weight acquisition, concrete execution, and report comparison layers.Reading, preserving lazy child resources and host-side orchestration.Contract
--input/--ckptwith independent--inputs random|files:A,Band--weights random|ckpt:DIRaxes.LoadedModuleis frozen data containingmodule,resource, and childmodules; it neither owns materialized tensors nor executes functions.Module.<fn>resolves to theFunction/PrimFunctionIR node itself, as specified by core-ir section 1.1.Module.forwardandModule.__call__; semantic execution goes through the evaluator only.evaluateaccepts aLoadedModule, supports explicitfunction=, and takes execution placement from caller-provideddevice=.evaluator.reading(loaded, device=...)as the public host-orchestration view.Risk
examples/still use the old executable-loaded-module API. They are outside pytest and require a separate migration plan.load_groupaliases and the two-level runtime twin base-class structure are intentionally unchanged.