sanjay7676 commited on
Commit
0c4d10b
·
1 Parent(s): 57c225e

fix(hf-cpu): slim requirements.txt for Spaces; requirements-train.txt for PyTorch/TRL; suggested_hardware cpu-basic

Browse files
Files changed (5) hide show
  1. Dockerfile +3 -2
  2. README.md +13 -1
  3. requirements-train.txt +12 -0
  4. requirements.txt +7 -18
  5. setup_colab.sh +2 -1
Dockerfile CHANGED
@@ -13,8 +13,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
13
  curl \
14
  && rm -rf /var/lib/apt/lists/*
15
 
16
- COPY requirements.txt ./
17
- RUN pip install --upgrade pip && pip install -r requirements.txt
 
18
 
19
  COPY . .
20
 
 
13
  curl \
14
  && rm -rf /var/lib/apt/lists/*
15
 
16
+ COPY requirements.txt requirements-train.txt ./
17
+ RUN pip install --upgrade pip && \
18
+ pip install -r requirements.txt -r requirements-train.txt
19
 
20
  COPY . .
21
 
README.md CHANGED
@@ -9,6 +9,8 @@ sdk_version: 5.25.0
9
  python_version: 3.11
10
  app_file: app.py
11
  pinned: false
 
 
12
  ---
13
 
14
  # FORGE-v4 — Adversarial self-improvement for robust code generation
@@ -35,11 +37,18 @@ pinned: false
35
  | **Command / security cheat sheet** | [guide.md](guide.md) |
36
  | **Video / slides** | Optional. Current submission uses the mini-blog requirement via [MINI_BLOG.md](MINI_BLOG.md). |
37
 
 
 
 
 
 
 
 
38
  ### NOTE 1 — Non‑negotiable submission requirements (checklist)
39
 
40
  | # | Requirement | FORGE-v4 |
41
  | :--: | :-- | :-- |
42
- | 1 | **OpenEnv (latest):** build on the framework | **`openenv-core>=0.2.3`** in [`requirements.txt`](requirements.txt). Wrapper: [`env_openenv.py`](env_openenv.py) (`FORGEOpenEnvironment` subclasses `openenv.core.Environment`). Core loop remains [`env.py`](env.py) [`FORGEEnv`]. |
43
  | 2 | **Training:** Unsloth or TRL (or other RL stack) + **Colab** | [`train_unsloth.py`](train_unsloth.py) (Unsloth + TRL), [`train_colab.py`](train_colab.py), [`FORGE_Training_Colab.ipynb`](FORGE_Training_Colab.ipynb), Colab links in the table above. |
44
  | 3 | **Evidence of training:** loss + reward plots (real run) | Committed: [`outputs/reward_curve.png`](outputs/reward_curve.png), [`outputs/loss_curve.png`](outputs/loss_curve.png), [`outputs/pass_rate.png`](outputs/pass_rate.png), [`outputs/final_report.json`](outputs/final_report.json). |
45
  | 4 | **Writeup / video:** mini-blog on HF *or* <2 min YouTube *etc.* | **[MINI_BLOG.md](MINI_BLOG.md)** linked here; add **public YouTube or slide URL** in the table row when published. |
@@ -277,6 +286,9 @@ Deployment note: as of the latest verification, the Space URL is serving the Gra
277
 
278
  ```bash
279
  pip install -r requirements.txt
 
 
 
280
  cp .env.example .env # then edit — do not commit .env
281
  python app.py # Gradio :7860
282
  python api_server.py # OpenEnv API :8000
 
9
  python_version: 3.11
10
  app_file: app.py
11
  pinned: false
12
+ # Hint for duplicators; does not upgrade your Space by itself. CPU-friendly demo (no PyTorch in requirements.txt).
13
+ suggested_hardware: cpu-basic
14
  ---
15
 
16
  # FORGE-v4 — Adversarial self-improvement for robust code generation
 
37
  | **Command / security cheat sheet** | [guide.md](guide.md) |
38
  | **Video / slides** | Optional. Current submission uses the mini-blog requirement via [MINI_BLOG.md](MINI_BLOG.md). |
39
 
40
+ ### Hugging Face Space (CPU-only)
41
+
42
+ - This repo’s **Space README** sets **`suggested_hardware: cpu-basic`** (see [Spaces config](https://huggingface.co/docs/hub/spaces-config-reference)). **Pick CPU hardware in the Space Settings UI** if you are not on GPU.
43
+ - **`requirements.txt`** is intentionally **light** (no PyTorch / bitsandbytes) so CPU Spaces **build and start** reliably.
44
+ - For a stable demo on CPU, set Space secret **`CODE_PROVIDER_MODE=mock`** (or use **NIM** / **OpenRouter** keys so the router never loads local `custom_hf`). Loading **`Qwen2.5-Coder-1.5B` + LoRA** on free CPU is likely to **OOM or time out**.
45
+ - Full training stack: install **[`requirements-train.txt`](requirements-train.txt)** on **Colab** or locally (see Quickstart).
46
+
47
  ### NOTE 1 — Non‑negotiable submission requirements (checklist)
48
 
49
  | # | Requirement | FORGE-v4 |
50
  | :--: | :-- | :-- |
51
+ | 1 | **OpenEnv (latest):** build on the framework | **`openenv-core>=0.2.3`** in [`requirements.txt`](requirements.txt). Training extras in [`requirements-train.txt`](requirements-train.txt). Wrapper: [`env_openenv.py`](env_openenv.py). Core: [`env.py`](env.py). |
52
  | 2 | **Training:** Unsloth or TRL (or other RL stack) + **Colab** | [`train_unsloth.py`](train_unsloth.py) (Unsloth + TRL), [`train_colab.py`](train_colab.py), [`FORGE_Training_Colab.ipynb`](FORGE_Training_Colab.ipynb), Colab links in the table above. |
53
  | 3 | **Evidence of training:** loss + reward plots (real run) | Committed: [`outputs/reward_curve.png`](outputs/reward_curve.png), [`outputs/loss_curve.png`](outputs/loss_curve.png), [`outputs/pass_rate.png`](outputs/pass_rate.png), [`outputs/final_report.json`](outputs/final_report.json). |
54
  | 4 | **Writeup / video:** mini-blog on HF *or* <2 min YouTube *etc.* | **[MINI_BLOG.md](MINI_BLOG.md)** linked here; add **public YouTube or slide URL** in the table row when published. |
 
286
 
287
  ```bash
288
  pip install -r requirements.txt
289
+ # GPU / training / HF custom local weights (skip on HF CPU Space):
290
+ pip install -r requirements-train.txt
291
+
292
  cp .env.example .env # then edit — do not commit .env
293
  python app.py # Gradio :7860
294
  python api_server.py # OpenEnv API :8000
requirements-train.txt ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GPU / Colab / full Docker image — install on top of requirements.txt
2
+ # Not used on Hugging Face CPU Spaces (use CODE_PROVIDER_MODE=mock there).
3
+
4
+ torch>=2.3.0
5
+ transformers>=4.41.0
6
+ trl>=0.9.4
7
+ peft>=0.11.1
8
+ datasets>=2.19.0
9
+ accelerate>=0.30.0
10
+ bitsandbytes>=0.43.1
11
+
12
+ # Unsloth: install in Colab per CUDA — https://github.com/unslothai/unsloth
requirements.txt CHANGED
@@ -1,11 +1,11 @@
1
- # FORGE-v4: Adversarial Code Generation Environment
2
- # Finalized requirements for CLI, Colab, and Hugging Face Spaces.
3
 
4
  # OpenEnv (official framework — Meta / HF ecosystem)
5
- # Needs websockets>=15.1; use Gradio >=5.18 (see README Space sdk_version) so HF Space resolves deps.
6
  openenv-core>=0.2.3
7
 
8
- # Core Dependencies
9
  tqdm>=4.66.0
10
  numpy>=1.26.0
11
  pandas>=2.2.0
@@ -13,22 +13,11 @@ matplotlib>=3.8.0
13
  PyYAML>=6.0.1
14
  requests>=2.32.0
15
  python-dotenv>=1.0.1
16
- # HF Spaces also installs gradio[oauth]==sdk_version from README YAML — keep in sync with sdk_version.
 
17
  gradio>=5.18.0,<6
18
 
19
- # API / Serving — Gradio 5.25+ requires fastapi>=0.115.2 (<1.0)
20
  fastapi>=0.115.2,<1.0
21
  uvicorn>=0.30.0
22
  pydantic>=2.7.0
23
-
24
- # RL Training Layer (Unsloth + TRL)
25
- torch>=2.3.0
26
- transformers>=4.41.0
27
- trl>=0.9.4
28
- peft>=0.11.1
29
- datasets>=2.19.0
30
- accelerate>=0.30.0
31
- bitsandbytes>=0.43.1
32
-
33
- # Note: unsloth requires specific installation based on CUDA version.
34
- # See: https://github.com/unslothai/unsloth
 
1
+ # FORGE-v4 default install (Hugging Face CPU Spaces, Gradio demo, API).
2
+ # For training / local_model / HF custom weights, also install: pip install -r requirements-train.txt
3
 
4
  # OpenEnv (official framework — Meta / HF ecosystem)
5
+ # Needs websockets>=15.1; use Gradio >=5.18 (see README Space sdk_version).
6
  openenv-core>=0.2.3
7
 
8
+ # Core
9
  tqdm>=4.66.0
10
  numpy>=1.26.0
11
  pandas>=2.2.0
 
13
  PyYAML>=6.0.1
14
  requests>=2.32.0
15
  python-dotenv>=1.0.1
16
+
17
+ # HF Spaces installs gradio[oauth]==sdk_version from README YAML — keep sdk_version in sync.
18
  gradio>=5.18.0,<6
19
 
20
+ # API — Gradio 5.x needs fastapi>=0.115.2
21
  fastapi>=0.115.2,<1.0
22
  uvicorn>=0.30.0
23
  pydantic>=2.7.0
 
 
 
 
 
 
 
 
 
 
 
 
setup_colab.sh CHANGED
@@ -9,8 +9,9 @@ echo "------------------------------------------------------------"
9
  echo "[*] Updating pip..."
10
  python -m pip install --upgrade pip
11
 
12
- echo "[*] Installing core requirements..."
13
  pip install -r requirements.txt
 
14
 
15
  echo "[*] Installing Unsloth (Colab Optimized)..."
16
  # Using the specific Unsloth Colab installation command
 
9
  echo "[*] Updating pip..."
10
  python -m pip install --upgrade pip
11
 
12
+ echo "[*] Installing core + training requirements..."
13
  pip install -r requirements.txt
14
+ pip install -r requirements-train.txt
15
 
16
  echo "[*] Installing Unsloth (Colab Optimized)..."
17
  # Using the specific Unsloth Colab installation command