fix(pyproject): pin transformers to stable 4.x line and add HF job artifacts
Browse files- Fix invalid transformers>=5.0 constraint to >=4.41.0,<4.50.0
- Add scripts/hf_train_job.py entrypoint for HF Jobs GPU run
- Add hf_job.yaml T4-small cluster configuration
- Fingerprint-based overlap assertion already in place
- Dataset import cleanup already in place
- hf_job.yaml +22 -0
- pyproject.toml +1 -1
- scripts/hf_train_job.py +60 -38
hf_job.yaml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# HF Jobs cluster configuration for PINO 5-epoch GPU training
|
| 2 |
+
# Launches a T4-small container, clones the private pino source repo, and runs
|
| 3 |
+
# the committed training entrypoint.
|
| 4 |
+
|
| 5 |
+
name: pino-5epoch-convergence
|
| 6 |
+
cmd:
|
| 7 |
+
- bash
|
| 8 |
+
- -c
|
| 9 |
+
- |
|
| 10 |
+
set -e
|
| 11 |
+
echo "Cloning pino source repository..."
|
| 12 |
+
git clone https://user:${HF_TOKEN}@huggingface.co/mattbitzesty/pino-source /workspace/pino
|
| 13 |
+
cd /workspace/pino
|
| 14 |
+
pip install -e . --no-deps
|
| 15 |
+
pip install torch --index-url https://download.pytorch.org/whl/cu121
|
| 16 |
+
echo "Starting 5-epoch training job..."
|
| 17 |
+
python scripts/hf_train_job.py
|
| 18 |
+
flavor: t4-small
|
| 19 |
+
secrets:
|
| 20 |
+
HF_TOKEN: ${HF_TOKEN}
|
| 21 |
+
# 2 hours is generous for 5 epochs on 16k rows with a T4.
|
| 22 |
+
timeout: 7200
|
pyproject.toml
CHANGED
|
@@ -15,7 +15,7 @@ dependencies = [
|
|
| 15 |
"ugropy>=3.2",
|
| 16 |
"pydantic>=2.0",
|
| 17 |
"cma>=4.0",
|
| 18 |
-
"transformers>=
|
| 19 |
"huggingface-hub>=0.24",
|
| 20 |
]
|
| 21 |
|
|
|
|
| 15 |
"ugropy>=3.2",
|
| 16 |
"pydantic>=2.0",
|
| 17 |
"cma>=4.0",
|
| 18 |
+
"transformers>=4.41.0,<4.50.0",
|
| 19 |
"huggingface-hub>=0.24",
|
| 20 |
]
|
| 21 |
|
scripts/hf_train_job.py
CHANGED
|
@@ -1,52 +1,74 @@
|
|
| 1 |
-
#!/usr/bin/env python3
|
| 2 |
-
"""Standalone training entrypoint for Hugging Face compute jobs.
|
| 3 |
-
|
| 4 |
-
This script is designed to run from inside the cloned pino-source repository.
|
| 5 |
-
It installs dependencies and starts training from the local source code.
|
| 6 |
-
"""
|
| 7 |
from __future__ import annotations
|
| 8 |
|
| 9 |
import os
|
| 10 |
-
import subprocess
|
| 11 |
import sys
|
|
|
|
|
|
|
| 12 |
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
[sys.executable, "-m", "pip", "install", "--quiet", "--upgrade"]
|
| 18 |
-
+ [
|
| 19 |
-
"rdkit",
|
| 20 |
-
"thermo",
|
| 21 |
-
"scipy",
|
| 22 |
-
"sentence-transformers",
|
| 23 |
-
"datasets",
|
| 24 |
-
"transformers>=4.41.0,<4.50.0",
|
| 25 |
-
"accelerate",
|
| 26 |
-
"huggingface-hub",
|
| 27 |
-
"tensorboard",
|
| 28 |
-
],
|
| 29 |
-
check=True,
|
| 30 |
-
)
|
| 31 |
|
|
|
|
|
|
|
| 32 |
|
| 33 |
-
def main() -> int:
|
| 34 |
-
print("[pino-job] Installing dependencies...")
|
| 35 |
-
install_deps()
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
sys.
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
-
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
|
|
|
| 47 |
|
|
|
|
| 48 |
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from __future__ import annotations
|
| 2 |
|
| 3 |
import os
|
|
|
|
| 4 |
import sys
|
| 5 |
+
import time
|
| 6 |
+
from pathlib import Path
|
| 7 |
|
| 8 |
+
# HF Job entrypoint for the Milestone 4.16 5-epoch convergence run.
|
| 9 |
+
# This script is executed inside the HF Jobs container. It assumes the
|
| 10 |
+
# pino source tree has been cloned into /workspace/pino.
|
| 11 |
|
| 12 |
+
REPO_ROOT = Path(__file__).resolve().parents[1]
|
| 13 |
+
SRC_DIR = REPO_ROOT / "src"
|
| 14 |
+
sys.path.insert(0, str(SRC_DIR))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
+
import torch
|
| 17 |
+
from pino.train import main as train_main
|
| 18 |
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
+
def hf_train_5epoch() -> None:
|
| 21 |
+
"""Run a controlled 5-epoch training pass and push artifacts to the Hub."""
|
| 22 |
+
# Override sys.argv to match the local verification command, but point at
|
| 23 |
+
# the cloned dataset path and enable GPU if available in the container.
|
| 24 |
+
data_path = REPO_ROOT / "data" / "synthetic_dataset_v2.jsonl"
|
| 25 |
+
if not data_path.exists():
|
| 26 |
+
# Allow the dataset to be mounted elsewhere in the container.
|
| 27 |
+
data_path = Path("/data/synthetic_dataset_v2.jsonl")
|
| 28 |
|
| 29 |
+
sys.argv = [
|
| 30 |
+
"pino.train",
|
| 31 |
+
"--data", str(data_path),
|
| 32 |
+
"--epochs", "5",
|
| 33 |
+
"--batch-size", "8",
|
| 34 |
+
"--train-ratio", "0.8",
|
| 35 |
+
"--seed", "42",
|
| 36 |
+
"--workers", "0",
|
| 37 |
+
"--output-dir", str(REPO_ROOT / "models"),
|
| 38 |
+
"--log-dir", str(REPO_ROOT / "runs" / "hf_job_5epoch"),
|
| 39 |
+
]
|
| 40 |
|
| 41 |
+
print("🚀 HF Job: starting PINO 5-epoch convergence pass")
|
| 42 |
+
print(f" Device: {torch.device('cuda' if torch.cuda.is_available() else 'cpu')}")
|
| 43 |
+
print(f" Args: {' '.join(sys.argv[1:])}")
|
| 44 |
|
| 45 |
+
checkpoint_path = train_main()
|
| 46 |
|
| 47 |
+
print(f"✅ Training complete. Checkpoint: {checkpoint_path}")
|
| 48 |
+
|
| 49 |
+
# Push checkpoint to the model hub if token is present.
|
| 50 |
+
token = os.environ.get("HF_TOKEN")
|
| 51 |
+
if token and checkpoint_path:
|
| 52 |
+
from huggingface_hub import HfApi, create_repo
|
| 53 |
+
|
| 54 |
+
repo_id = "mattbitzesty/pino-pimt-checkpoint"
|
| 55 |
+
try:
|
| 56 |
+
create_repo(repo_id, private=True, token=token, exist_ok=True)
|
| 57 |
+
except Exception as exc: # noqa: BLE001
|
| 58 |
+
print(f"Repo create/exists check: {exc}")
|
| 59 |
|
| 60 |
+
api = HfApi(token=token)
|
| 61 |
+
api.upload_file(
|
| 62 |
+
path_or_fileobj=str(checkpoint_path),
|
| 63 |
+
path_in_repo="pimt_v1.pt",
|
| 64 |
+
repo_id=repo_id,
|
| 65 |
+
repo_type="model",
|
| 66 |
+
)
|
| 67 |
+
print(f"🤗 Checkpoint uploaded to https://huggingface.co/{repo_id}")
|
| 68 |
+
|
| 69 |
+
# Sleep briefly so logs flush.
|
| 70 |
+
time.sleep(5)
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
if __name__ == "__main__":
|
| 74 |
+
hf_train_5epoch()
|