Repository navigation
Reduce redundant framework checks during trace metadata conversion - #156
Merged
Merged
Conversation
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.
Metadata conversion repeatedly tests ordinary functions and bound methods against PyTorch tensor/parameter/module types, then discards them. In the final baseline profiles, built-in
isinstanceconsumed 12.39% of profiled MNIST time and 15.27% of profiled Transformer time.Recognize exact built-in callable types before those framework checks. Preserve
_TRAINCHECKvalues and retain the existing path for custom objects, custom metaclasses and dynamic__class__behavior. Attribute getters, warning scopes, ordering, identities, tensor contents, hashes, errors and tracing coverage stay unchanged. Changed helpers have explicit type contracts.Final matched study: five alternating fresh-process pairs on labmach CPU, three cold steps, both API and subclass model tracing active:
Every one of the ten pairs improves. Baseline
7a40649dand candidate035f7f19include the same final #154/#155/#157 changes; onlydumper.pydiffers in their 78 executed production files. These numbers supersede the initial study for this final composition. Normal API exclusions remain enabled (use_full_instr=False); this does not measure the broader flag, GPU/MPS/distributed training or selective checking.All 30 final cases (six correctness, 20 ordinary, four profile) match explicit plain-training references for initial/final model state, every loss and Python/NumPy/PyTorch RNG progression. Raw trace counts/bytes and complete API pairs agree between variants; all tracked parameters show changing data hashes. Hash algorithm/backend and call counts are unchanged. Transformer manual SGD remains intact, but existing observations do not establish gradient snapshots or pre/post observations for every manual update.
The denominator is the traced training body. Whole-process medians do not improve in these short jobs: imports, setup, writer shutdown and shared-host variation dominate. Median sampled peak RSS is 556.8→561.5 MiB for MNIST and 515.7→515.7 MiB for Transformer; full ranges and individual runs are in the report.
Validation:
test_inject_eval_loopfailure also occurs on unchanged main. Pinned hooks and configured mypy across 78 production files pass; strict new-code/test checks with installed Torch types pass. Stronger legacy dumper checking has 22 baseline versus 19 candidate errors, with none introduced.File writing is already buffered/background on this path; metadata conversion and JSON encoding remain synchronous. Final encoding is only 0.31–0.50% of these profiles. Warning setup remains a measured next target; asynchronous live-object conversion needs a separate snapshot/error contract. This PR adds no asynchronous behavior or hashing/algorithm changes.
All commits are signed. Targets
maindirectly. Production change is independent of the other PRs; the final measurements validate the composed result.