Training
Full paper-vs-implementation training config is in docs/paper_spec.md Sec. 2. This document is
the practical how-to.
PCMA stages
- Stage 1 (
backend/configs/stage1.yaml): bridges the viewpoint gap (natural images → optical RS). lr=2e-5, 4 epochs (PAPER_EXPLICIT). - Stage 2 (
backend/configs/stage2.yaml): bridges the imaging-physics gap (optical → non-optical), with full optical replay. lr=5e-6, 4 epochs (PAPER_EXPLICIT).
Commands
On 2x NVIDIA A40 (primary target):
bash scripts/train_stage1.sh # MANIFEST=... IMAGES_ROOT=... to override defaults
bash scripts/train_stage2.sh
For multi-GPU with DeepSpeed ZeRO-2:
deepspeed --num_gpus=2 training/train.py --config configs/stage1.yaml \
--deepspeed configs/deepspeed_zero2.json \
--manifest data/manifests/stage1_train.jsonl --images_root data/converted
deepspeed --num_gpus=2 training/train.py --config configs/stage2.yaml \
--deepspeed configs/deepspeed_zero2.json \
--manifest data/manifests/stage2_train.jsonl --images_root data/converted
backend/training/distributed.py:get_device_strategy() auto-detects CUDA / CPU and adjusts
precision + DeepSpeed usage accordingly; backend/training/trainer.py's gradient_accumulation_steps
stands in for the paper's 8-GPU data-parallel batch size on single-device hardware.
Building a training manifest
Manifests are produced per-dataset via backend/tools/convert_dataset.py (which internally calls each
DatasetConverter.write_manifest, schema-validating as it writes):
python tools/download_dataset.py --dataset cdvqa # prints manual-download instructions
python tools/convert_dataset.py --dataset cdvqa --split train
python tools/validate_dataset.py --manifest data/manifests/cdvqa/train.jsonl --intended-use train
backend/configs/stage{1,2}.yaml's data.manifests list points at the manifests to concatenate for that
stage; backend/training/train.py --manifest currently takes a single JSONL path - concatenate multiple
manifests' lines into one file (cat data/manifests/*/train.jsonl > combined.jsonl) before
passing it, or extend MMRSDataset to accept a list (a straightforward follow-up not required
for the smoke-test-scale demonstration this repo targets).
Loss
Response-only masked cross-entropy (backend/training/loss.py), verified in backend/tests/test_loss_masking.py
to give exactly zero gradient contribution from prompt and visual-token positions.
Checkpoints
backend/training/checkpointing.py:save_checkpoint/load_checkpoint write/read a directory containing
model.pt (state dict), tokenizer/ (HF save_pretrained), earth_onevision_metadata.json
(the full EarthOneVisionConfig + step/epoch + vocab extension sizes), and optionally
optimizer.pt/scheduler.pt. Every checkpoint is labeled
earth_onevision_reproduction_checkpoint - load_checkpoint actively refuses to load anything
claiming to be an official checkpoint (none exist; docs/assumptions.md #A11).
The trainer always writes the completed run to final/ inside its output
directory. The standard paths are checkpoints/stage1/final/,
checkpoints/stage2/final/, and checkpoints/baseline-small/final/. The API
selects them after checkpoints/final/.