Skip to main content

Task: model bootstrap and parallel frontend work

This runbook gives the API a deterministic model selection order. A finished larger checkpoint is always preferred. If no checkpoint exists, the API can train the one-epoch Qwen3-0.6B baseline from a supplied manifest, then serve that checkpoint. Without a manifest, it serves the small foundation model so frontend development is not blocked.

Weight order​

The API checks these directories in order. Each trained directory is created by the trainer's epoch-end save as final/.

  1. checkpoints/final
  2. checkpoints/stage2/final
  3. checkpoints/stage1/final
  4. checkpoints/baseline-small/final
  5. Qwen/Qwen3-0.6B plus SigLIP-2 foundation weights

Set SATQUERY_CHECKPOINT to override the order. An explicit path must contain both model.pt and earth_onevision_metadata.json; invalid paths fail loudly.

Small fallback training​

Set all three variables when the API must train the small baseline before it loads the controller:

export SATQUERY_AUTO_TRAIN=1
export SATQUERY_BASELINE_MANIFEST=data/manifests/baseline_train.jsonl
export SATQUERY_BASELINE_IMAGES_ROOT=data/converted
python -m uvicorn app.backend.main:app --host 0.0.0.0 --port 8000

The first request that initializes the model runs:

python training/train.py \
--config configs/baseline.yaml \
--manifest "$SATQUERY_BASELINE_MANIFEST" \
--images_root "$SATQUERY_BASELINE_IMAGES_ROOT" \
--output-dir checkpoints/baseline-small

The API then loads checkpoints/baseline-small/final and serves requests. This is intentionally opt-in because training can take hours. Without SATQUERY_AUTO_TRAIN=1, the API serves the small foundation model immediately. The baseline uses Qwen3-0.6B, 256 vision patches, and a 2,048-token sequence limit so it fits the 48GB MPS development machine. The full PCMA configs remain unchanged for later Stage 1 and Stage 2 runs.

API status​

Use /api/model to inspect selection without loading the model:

curl http://localhost:8000/api/model

The response includes the selected name, source, checkpoint path, fallback training configuration, and the complete priority order. The frontend can use this endpoint for the header model badge. The current frontend already polls this endpoint and shows the selected model beside the API health indicator.

Parallel Zellij workflow​

Training and frontend work can proceed in parallel, but Stage 2 training must wait for the Stage 1 checkpoint. Use one Zellij session with separate tabs:

zellij -s satquery

Recommended tabs:

  1. baseline: run the one-epoch baseline or monitor its log.
  2. frontend: build and test the UI against the foundation fallback.
  3. data: convert, filter, and validate manifests.
  4. qa: run unit tests, smoke tests, and API checks.

Frontend work can proceed before training finishes. Validate the real trained checkpoint later by restarting the API and checking /api/model.

Completion criteria​

  • curl /api/model reports the expected checkpoint.
  • A baseline run produces checkpoints/baseline-small/final/model.pt.
  • /api/health and /api/analyze work after model selection.
  • Frontend tests pass against both the foundation fallback and a trained checkpoint.
  • Stage 1 and Stage 2 are prepared in parallel but trained sequentially.