Repository navigation
Conversation
Co-authored-by: OpenAI Codex
Co-authored-by: OpenAI Codex
Keep CPU/Gloo ranks independent of visible accelerator counts and avoid physical device selection when constructing CPU training arguments. Co-authored-by: OpenAI Codex
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.
PR type
PR information
Related issue: none. Found through code analysis and reproduced with constructed CPU evaluation.
Distributed evaluation repeats dataset rows to fill its final batch.
EmbeddingTrainergathers flattened anchor/positive/negative tensors without removing those padded examples, so the built-in embedding metrics include extra queries and candidate documents. Preserve each example as a group during metric gathering, let Accelerate remove sampler padding, and immediately restore the flattened tensors. This also preserves real repeated rows and supports different negative counts without padding the entire evaluation cache to the largest group.The change covers the built-in
infonceandpairedmetrics with their default preprocessing, Transformers 4.36 or later, and no sequence parallelism. Custom preprocessing and older Transformers keep the existing path. Loss gathering is unchanged. Add a CPU distributed regression and clarify the scope in both embedding guides.Experiment results
Tested on CPU with Python 3.13, PyTorch 2.14.0 and Transformers 5.17.0 on main
bdb8741699a9cc0647d9759575e0f30cc08516f0before pushing. The failure reproduction used the original69872d1baseline; the embedding trainer was unchanged between those upstream commits.-0.11395209instead of the direct-model reference-0.11750958.tests/utils, which is discoverable from the CI runner’stestsroot. The actualtests/run.pycommand collects and passes one test, and its result is recorded asSuccessin the runner’s result table. All configured pre-commit hooks, dependency and diff checks pass.EmbeddingTrainer.evaluate/predicton two Gloo processes. It covers 3/7/8 examples, varying negative counts across ranks and batches, a genuine repeated row, both built-in metrics, repeated evaluation, flat prediction outputs, loss-only evaluation, custom preprocessing and the old-Transformers fallback. Its reference comes from independent per-example model forwards.[1, 2, 1]changes from 4 queries before the fix to the expected 3 afterward. Itsmean_poschanges from0.95677412to0.94236547, matching the single-process reference; the margin agrees within2e-8. This is an evaluation correctness experiment, not a model-quality or training benchmark. GPU/NCCL and sequence-parallel execution were not tested.The CPU worker disables the project’s NPU-specific model patches before its first Swift model import. It also uses the existing single-device-mode setting to bypass accelerator-count-based model parallelism checks, and bypasses physical
set_deviceonly while constructing CPU training arguments. Model forwards, distributed collectives and metrics remain real; the fixture explicitly checks that the trainer uses CPU and two processes. Local fault injection with one reported accelerator and forbidden physical device selection fails before this fixture adjustment and passes afterward. GPU/NPU host compatibility still awaits the updated remote CI run.AI assistance was used (OpenAI Codex) for investigation, implementation and validation.
Checklist