shank commited on
Commit
5d0b2d4
Β·
1 Parent(s): 2005cd2

fix: empty requirements.txt, install training deps at runtime

Browse files
Files changed (2) hide show
  1. requirements.txt +3 -16
  2. training/train_grpo.py +22 -16
requirements.txt CHANGED
@@ -1,16 +1,3 @@
1
- # ── Training dependencies ──────────────────────────────────────────────────────
2
- # Fully pinned to a pre-validated compatible set.
3
- # NOTES:
4
- # - gradio is injected by HF Spaces automatically β€” do NOT add it here
5
- # - wandb is excluded: it conflicts with gradio over click versioning
6
- # (wandb>=0.18 requires click!=8.0.0,>=7.1 but gradio requires click>=8.1)
7
- # wandb is initialized at runtime by the training script if available
8
-
9
- datasets==3.0.2
10
- transformers==4.46.3
11
- accelerate==1.0.1
12
- trl==0.14.0
13
- peft==0.13.2
14
- bitsandbytes==0.43.3
15
- mergekit==0.1.4
16
- pydantic==2.10.6
 
1
+ # Training packages are installed at runtime by training/train_grpo.py
2
+ # This file is intentionally minimal to avoid pip dependency conflicts
3
+ # during HF Spaces Docker builds (gradio's pinned deps conflict with ML stack)
 
 
 
 
 
 
 
 
 
 
 
 
 
training/train_grpo.py CHANGED
@@ -37,27 +37,33 @@ parser.add_argument("--resume", type=str, default=None, help="Path to checkpoint
37
  parser.add_argument("--max_steps", type=int, default=500)
38
  args = parser.parse_args()
39
 
40
- # ── Optional dependency bootstrap (disabled by default in Spaces) ─────────────
41
- # Runtime installs with loose versions caused repeated breakages from version drift.
42
- # Keep this opt-in for fresh Colab notebooks only.
43
- if os.environ.get("FORCE_BOOTSTRAP_DEPS") == "1":
44
- os.system(
45
- f"{sys.executable} -m pip install -q "
46
- "wandb==0.18.7 datasets==3.0.2 transformers==4.46.3 "
47
- "accelerate==1.0.1 trl==0.14.0 bitsandbytes==0.43.3 peft==0.13.2"
 
 
 
 
 
 
 
 
 
 
48
  )
 
 
 
49
 
50
  # ── GPU/training imports (skipped in --test-local mode) ───────────────────────
51
  if not args.test_local:
52
- # wandb is not in requirements.txt (conflicts with gradio over click versioning)
53
- # Install it at runtime before importing
54
- try:
55
- import wandb
56
- except ImportError:
57
- os.system(f"{sys.executable} -m pip install -q 'wandb>=0.18.0'")
58
- import wandb
59
-
60
  import torch
 
61
  from datasets import Dataset
62
  from transformers import (
63
  AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, TrainerCallback
 
37
  parser.add_argument("--max_steps", type=int, default=500)
38
  args = parser.parse_args()
39
 
40
+ # ── Runtime dependency install ─────────────────────────────────────────────────
41
+ # requirements.txt is empty to avoid pip conflicts during HF Spaces Docker build.
42
+ # We install all training deps here, at runtime, after gradio is already up.
43
+ if not args.test_local:
44
+ _TRAIN_DEPS = [
45
+ "wandb==0.18.7",
46
+ "datasets==3.0.2",
47
+ "transformers==4.46.3",
48
+ "accelerate==1.0.1",
49
+ "trl==0.14.0",
50
+ "peft==0.13.2",
51
+ "bitsandbytes==0.43.3",
52
+ "mergekit==0.1.4",
53
+ "pydantic==2.10.6",
54
+ ]
55
+ print("Installing training dependencies...", flush=True)
56
+ ret = os.system(
57
+ f"{sys.executable} -m pip install -q --no-cache-dir " + " ".join(f'"{d}"' for d in _TRAIN_DEPS)
58
  )
59
+ if ret != 0:
60
+ print("WARNING: pip install returned non-zero exit. Continuing anyway...", flush=True)
61
+ print("Dependencies installed.", flush=True)
62
 
63
  # ── GPU/training imports (skipped in --test-local mode) ───────────────────────
64
  if not args.test_local:
 
 
 
 
 
 
 
 
65
  import torch
66
+ import wandb
67
  from datasets import Dataset
68
  from transformers import (
69
  AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, TrainerCallback