Repository navigation
Fix T3 loading and runtime errors - #1
Merged
jacob-block merged 2 commits intoOct 25, 2026
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.
What does this PR do?
Follow-up to locuslab#196, based on
add-t3-unlearning.Fixes four runtime issues:
T3 fails to initialize with Transformers 5.5.4. The wrapper calls
_autoset_attn_implementation, which was removed. This PR removes that call; the base model already selects its attention implementation when it loads.Cached generation can use the wrong token count. The running count uses the model's precision. In bfloat16, adding one to 256 rounds back to 256, so the count stops increasing and the classifier receives the wrong mean. This PR uses integer counts and float32 hidden-state sums, then casts the mean back to the model's precision.
Training crashes when both batches have no valid target tokens. If all retain and forget labels are ignored, the loss is a constant zero with no connection to the classifier. Backpropagation then fails. This PR builds the zero loss from the classifier outputs, so backpropagation succeeds with zero gradients.
A saved checkpoint still needs the original base model. Loading first fetches the original model and then overwrites its weights from the checkpoint. This fails if the original directory is gone, even though the checkpoint contains the weights. This PR loads directly from the saved configuration and weights. It also fixes reading the saved config through the standard model loader with dtype overrides, and preserves saved generation settings and requested attention settings.
Tests
python tests/test_t3.pypasses on CPU with PyTorch 2.9.1 and Transformers 5.5.4. Four small tests cover the cases above.make qualitypasses. The new test file also passes Ruff checks and formatting.