kiji-proxy icon indicating copy to clipboard operation
kiji-proxy copied to clipboard

train_tpu.py: TRAINING_SEED overrides --seed, plus multi-process gaps

Open Davidnet opened this issue 2 weeks ago • 0 comments

Found while reviewing #688. Code: model/flows/experiments/train_tpu.py, model/src/config.py and model/src/trainer.py on that branch.

1. TRAINING_SEED overrides --seed (train_tpu.py:51-53, 64-66; config.py:204) With TRAINING_SEED=7 still exported, --seed 13 trains seed 7, and run_summary.json records 7. A seed sweep becomes silently wrong. The help text implies the flag wins.

2. Multi-process gaps (data parallelism)

  • Every torchrun rank writes output_dir/label_mappings.json at the same time (train_tpu.py:87). Only rank 0 should.
  • Unverified: prediction_step returns predictions and labels on CPU (trainer.py ~320-336). In multi-process runs, evaluation_loop passes them to pad_across_processes / gather_for_metrics. Run one eval step under torchrun --nproc_per_node>1 before calling data parallelism supported.

3. Smaller items

  • [data] subsample_count in the TOML is ignored; only --num-samples counts.
  • run_german_mix.sh:16-18 and the train_tpu.py docstring are hardcoded to v4 and say "on the GPU machine".
  • lr_scheduler_kwargs={"num_cycles": …} is passed to every scheduler type (trainer.py:626), so cosine runs 3 waves and linear raises TypeError. This predates #688 and is fixed on feat/lr-schedule-cosine, which isn't in a PR yet.

4. Test gaps

  • The static-padding collator's alignment of input_ids, attention_mask and pii_labels=-100 is untested; only bucketed_length is.
  • test_trainer_accumulation.py only checks the forward signature.
  • test_tpu_data_parallel.py leaks ACCELERATE_BYPASS_DEVICE_MAP=true into the rest of the session. monkeypatch.delenv(raising=False) on an unset variable records no undo.

Davidnet avatar Nov 17 '26 02:11 Davidnet