Conversation
jlarson4
reviewed
Oct 1, 2026
Collaborator
|
Looks great @yuanwuyuan9, thank you for getting to those comments so swiftly! I will merge as soon as it passes CI |
jlarson4
approved these changes
Oct 1, 2026
Author
Collaborator
|
Excellent, thanks for resolving this conflicts @yuanwuyuan9 |
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.
Description
compute_head_results()currently uses layer 0 to decide whether results are cached for every layer and treats valid batchless results as stale. This can leave missing or merged results untouched, overwrite existing results, or raiseKeyErrorduring repeated calls, including throughstack_head_results().Validate each layer independently, using
has_batch_dimto distinguish valid 4D and 3D per-head results and checking the head count. Preserve valid cached tensors and recompute only invalid or missing results from cachedhook_zand the model'sW_O. Retain the existing warning when all layers are already cached. The multiplication and reduction are unchanged; no new dependencies are required.Fixes #1842
Type of change
Validation
The existing LN/RMS unit fixture covers per-layer cache states, incorrect head counts, warning behavior, preservation of cached edits, repeated calls through
stack_head_results(), and missing required activations. The new acceptance test sits next to the existing compute-head-results test and uses a separatedistilgpt2Bridge to exercise forward-produced batchless results without manual cache edits.Local validation on Linux, Python 3.12.3 and PyTorch 2.11.0+cu130, with CUDA disabled:
mypymake format,make check-format, andgit diff --checkThe final full unit run used
OMP_NUM_THREADS=1 MKL_NUM_THREADS=1. Earlier default-thread runs required retries in the GPT-2 component benchmark. With retries disabled, both the unmodified02a7f5a0baseline and the initial fix failed onblocks.11.attnwith identical reported differences; both passed with single-thread settings. The numerical root cause remains undetermined.Checklist: