Skip to content

Fix T3 loading and runtime errors - #1

Merged
jacob-block merged 2 commits into
jacob-block:add-t3-unlearningfrom
molereddy:fix-t3-runtime
Oct 25, 2026
Merged

jacob-block merged 2 commits into
jacob-block:add-t3-unlearningfrom
molereddy:fix-t3-runtime

Conversation

@molereddy

@molereddy molereddy commented Oct 25, 2026 •

Copy link
Copy Markdown

What does this PR do?

Follow-up to locuslab#196, based on add-t3-unlearning.

Fixes four runtime issues:

  1. 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.

  2. 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.

  3. 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.

  4. 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.py passes on CPU with PyTorch 2.9.1 and Transformers 5.5.4. Four small tests cover the cases above.
  • make quality passes. The new test file also passes Ruff checks and formatting.
  • Full GPU training and benchmark sweeps were not run.

@jacob-block
jacob-block merged commit 53f71c4 into jacob-block:add-t3-unlearning Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants