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.
M3 sparse training currently materializes a batch × sequence × vocabulary tensor before reducing repeated token occurrences. For long sequences and a large vocabulary, this allocation dominates the sparse branch and can prevent otherwise feasible fine-tuning batches.
Pool directly into the batch × vocabulary result. Select the first maximum occurrence using detached index reductions, then gather from the original differentiable token weights. This preserves the existing first-maximum gradient convention, including positive ties, absent/special tokens and NaN propagation, while requiring storage proportional to batch × (sequence + vocabulary).
The 11 actual CPU regression cases use a genuine local BertModel and an independent token-dictionary oracle. Before this change, the two allocation checks fail and the other nine pass; after this change all 11 pass. The original import/trainer compatibility modules also pass all nine unchanged tests in both runs. Default discovery collects the same 32 items without errors; the remaining pretrained-model integration tests were collected and were not executed. No model or dataset download is needed for the executed tests.
Validated with Python 3.12.10, Torch 2.14.1+cpu and Transformers 5.18.0. Profiler bounds cover small reproducible CPU allocations; production-scale GPU memory, throughput and training quality were not benchmarked. Existing evaluation aggregation, local-negative objectives and passage MaxSim masking are unchanged.