Repository navigation
Fix CPU pipeline evaluation loss normalization - #17291
Conversation
|
To use Codex here, create a Codex account and connect to github. |
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Recommended for merge based on A/B evidence showing 14 passing head checks and three expected base failures on incorrect loss normalization. Additional Windows and older-TRL coverage, plus passing macOS normalization checks, limited to the changed helper. |
CPU pipeline evaluation with TRL 1.15 divides the loss over shifted labels by the count of unshifted labels. This understates
eval_losswhenever the first token is not masked, affecting logged evaluation curves and loss-based decisions.Use the shifted target count for Zoo's CPU SFTTrainer on TRL >= 1.15, matching its fused-head evaluation. Earlier TRL releases and other trainers retain their existing normalization. Training is unchanged.
The new regression calls real
SFTTrainer.evaluate()on identical weights and data in one process and on two gloo pipeline ranks. On main10c52ed463, the three cases fail numerically:All three pass with the fix at
rtol=1e-5, with identical evaluation rows and both pipeline stages engaged. The tests setloss_type="nll"explicitly so they also exercise the preserved TRL 1.14 path.Validation on Linux CPU (torch 2.11.0, transformers 5.5.0, PEFT 0.21.2, unsloth_zoo 2026.11.3):
UNSLOTH_FORCE_CPU=1 OMP_NUM_THREADS=1 MKL_NUM_THREADS=1 python -m pytest -q \ tests/test_pp_env_eval.py \ tests/test_pp_env_cpu_chunked_ce.py \ tests/test_parallel_cp_compose_gloo.py::test_cpu_pipeline_eval_matches_one_process \ 'tests/test_pp_env_gloo.py::test_pp_env_trainer_matches_one_process[pp2]'This is separate from the router auxiliary-loss weighting in #17072 and the context-parallel reduction in #17049. No GPU, Windows, or macOS run.