Repository navigation
Conversation
This branch has not been deployed
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.
TrainCheck repeatedly scans the full trace for every context-manager instance and pre/post call-record lookup. On a complete 573,494-event tiny-Llama trace, context indexing reduced preparation from 170.855 to 11.714 seconds while preserving the same 711 ordered context states in both the full trace and its stage trace.
This change groups context events once by function, event type, process, thread, and object ID, retaining first-row selection and strict timestamp comparisons. A second commit adds a lazy per-trace call-ID index of pre/post row positions. Duplicate assertions, exception records, missing-post behavior, and fresh returned dictionaries remain intact; unsupported IDs/dtypes keep the original filters. Nullable and unsorted context timestamps retain pandas comparison semantics.
Preparation is one paired measurement on the same Linux host with one native thread. The profiled diagnostic reached the same PyTorch-signature error in 546.50 versus 71.98 seconds. Neither large-trace inference completed: the trace was collected with PyTorch 2.16.0.dev20261012, but replay used 2.2.2. Time to that error is not a completed-inference throughput or online-checker overhead result.
Validation:
The call index assumes event row order, call IDs, and event types remain stable after initialization. Replacing the dataframe or changing its length rebuilds the index; same-size in-place edits or reordering are unsupported.
Run the portable tests with
python -m unittest tests.test_context_index tests.test_call_index; run the synthetic benchmark withpython -m tools.benchmarks.trace_pandas_indexes --output measurements.json.Engineering hardening
Typed context-index keys, state, timestamps at the supported boundary, and the reusable benchmark's inputs/results (
336fc1b), with signed parent-update commits. All 32 context/call differential tests and benchmark smoke checks pass; pinned hooks and stronger Mypy 1.9 checking of the benchmark pass. One narrowly documentedAnycomparison boundary remains for legacy pandas scalar semantics; values are not coerced or errors suppressed.Separately composed updated production sources pass 140 affected Linux regression tests, whole-source Mypy (77 files), Ruff, and isort. Whole-source Black still reports three unchanged legacy files, down from six in the original base; changed-file hooks pass. Strict checks are scoped and do not establish repository-wide strict typing. Historical performance numbers above retain their original measured revisions; this hardening pass does not re-estimate them.