feat(compressors): add JSONL training metrics logging with CLI controls

- Add write_training_metrics() in new compressors/training_metrics.py
  for appending epoch/step/lr/component rows as JSON Lines
- Wire --metrics-path and --log-every CLI options into train.py, passing
  them to the training loop so metrics rows are written every N steps
- Accept absolute metrics paths or paths relative to output directory
- Add quantization component to loss log alongside existing distill/contrastive
- Replace inline torch.device() with get_device() utility
- Add test_hash_training_metrics.py covering multi-row JSONL append

Infrastructure:
- Pin torch 2.7.1 + CUDA 12.8 index for Linux/Windows in pyproject.toml
- Add .justfile rsync upload recipe with .stignore exclusion
- Exclude **/__marimo__ from rsync in .stignore

Dependencies updated: numpy 2.4.5, pandas 3.0.3, black 26.5.0,
click 8.4.0, contourpy, etc.
This commit is contained in:
2026-05-17 14:18:51 +08:00
parent e8c890a69f
commit 4ea567adba
8 changed files with 864 additions and 531 deletions

View File

@@ -11,6 +11,17 @@ def train(
checkpoint_path: str = typer.Option(
"hash_checkpoint.pt", "--checkpoint", "-c", help="Checkpoint path"
),
metrics_path: str = typer.Option(
"hash_training_metrics.jsonl",
"--metrics-path",
"-m",
help="JSONL metrics path for loss curves; relative to output directory unless absolute",
),
log_every: int = typer.Option(
1,
"--log-every",
help="Write one metrics row every N global steps; <=0 disables metrics logging",
),
):
from compressors import train as train_module
@@ -19,4 +30,6 @@ def train(
batch_size=batch_size,
lr=lr,
checkpoint_path=checkpoint_path,
metrics_path=metrics_path,
log_every=log_every,
)