div18 commited on
Commit
ba5f05d
·
1 Parent(s): 5edb1ce
training/chat_utils.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Chat rendering helpers for text-only Qwen/Qwen-VL control prompts."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any, Dict, List
6
+
7
+
8
+ def render_no_think_chat(
9
+ tokenizer: Any,
10
+ messages: List[Dict[str, str]],
11
+ *,
12
+ add_generation_prompt: bool,
13
+ ) -> str:
14
+ """Render a chat prompt with Qwen thinking disabled when supported.
15
+
16
+ Qwen3-family templates expose ``enable_thinking`` as a Jinja variable.
17
+ Older templates ignore that keyword, so we fall back cleanly rather than
18
+ failing training for non-Qwen or older tokenizer builds.
19
+ """
20
+ kwargs = {
21
+ "tokenize": False,
22
+ "add_generation_prompt": add_generation_prompt,
23
+ "enable_thinking": False,
24
+ }
25
+ try:
26
+ return tokenizer.apply_chat_template(messages, **kwargs)
27
+ except TypeError as exc:
28
+ if "enable_thinking" not in str(exc):
29
+ raise
30
+ kwargs.pop("enable_thinking")
31
+ return tokenizer.apply_chat_template(messages, **kwargs)
32
+
33
+
34
+ def tokenize_text_only(tokenizer: Any, input_text: str, device: Any):
35
+ """Tokenize a rendered text prompt without invoking VL image loading.
36
+
37
+ Some Qwen-VL processors route the first positional argument to ``images``.
38
+ Passing the transcript through the explicit ``text=`` keyword keeps the
39
+ prompt on the text path and avoids PIL trying to parse chat text as an image.
40
+ """
41
+ try:
42
+ inputs = tokenizer(text=input_text, return_tensors="pt")
43
+ except ValueError as exc:
44
+ if "Incorrect image source" not in str(exc):
45
+ raise
46
+ inputs = tokenizer(text=[input_text], images=None, return_tensors="pt")
47
+ except TypeError:
48
+ inputs = tokenizer(input_text, return_tensors="pt")
49
+
50
+ return inputs.to(device)
training/launch_smoke.py CHANGED
@@ -46,9 +46,8 @@ def build_job_command() -> str:
46
  "cd /workspace/AntiAtropos\n"
47
  "\n"
48
  "echo '[bootstrap] Installing dependencies...'\n"
49
- "pip install --break-system-packages \\\n"
50
- " torch==2.10.0+cu124 torchvision==0.20.0+cu124 torchaudio==2.10.0+cu124 \\\n"
51
- " --index-url https://download.pytorch.org/whl/cu124 -q\n"
52
  "pip install --break-system-packages -r training/requirements.txt -q\n"
53
  "\n"
54
  "echo '[bootstrap] Launching training...'\n"
 
46
  "cd /workspace/AntiAtropos\n"
47
  "\n"
48
  "echo '[bootstrap] Installing dependencies...'\n"
49
+ "pip install --break-system-packages --no-deps torchvision -q\n"
50
+ "pip install --break-system-packages flash-attn --no-build-isolation -q\n"
 
51
  "pip install --break-system-packages -r training/requirements.txt -q\n"
52
  "\n"
53
  "echo '[bootstrap] Launching training...'\n"
training/requirements.txt CHANGED
@@ -2,11 +2,15 @@
2
  # Install: pip install -r training/requirements.txt
3
 
4
  # ---- Core ML ----
5
- # NOTE: torch is provided by the Docker base image (pytorch/pytorch:2.11.0).
6
  # Do NOT list it here — pip's resolver may downgrade it, breaking torchao.
7
  # torch>=2.5.0 (pre-installed in base image)
8
- # torchao is also pre-installed in the 2.11.0 base image and compatible.
9
- torchvision # required by unsloth_zoo.vision_utils
 
 
 
 
10
  transformers>=4.45.0
11
  accelerate>=0.34.0
12
  bitsandbytes>=0.43.0
 
2
  # Install: pip install -r training/requirements.txt
3
 
4
  # ---- Core ML ----
5
+ # NOTE: torch is provided by the Docker base image (pytorch/pytorch:2.10.0).
6
  # Do NOT list it here — pip's resolver may downgrade it, breaking torchao.
7
  # torch>=2.5.0 (pre-installed in base image)
8
+ # torchao is also pre-installed in the base image and compatible.
9
+ # torchvision is required by unsloth_zoo.vision_utils but MUST be installed
10
+ # separately via the PyTorch index URL (not via pip resolver) to avoid
11
+ # torch version downgrades. Install before running this file:
12
+ # pip install torch==X.Y.Z+cuNNN torchvision==A.B.C+cuNNN torchaudio==D.E.F+cuNNN \
13
+ # --index-url https://download.pytorch.org/whl/cuNNN
14
  transformers>=4.45.0
15
  accelerate>=0.34.0
16
  bitsandbytes>=0.43.0
training/run_smoke_uv.py CHANGED
@@ -37,6 +37,10 @@ subprocess.run(
37
  os.chdir(str(WORKSPACE / "AntiAtropos"))
38
 
39
  print("[bootstrap] Installing full dependencies...")
 
 
 
 
40
  subprocess.run(
41
  ["uv", "pip", "install", "-r", "training/requirements.txt", "-q"],
42
  check=True,
 
37
  os.chdir(str(WORKSPACE / "AntiAtropos"))
38
 
39
  print("[bootstrap] Installing full dependencies...")
40
+ subprocess.run(
41
+ ["uv", "pip", "install", "--no-deps", "torchvision", "-q"],
42
+ check=True,
43
+ )
44
  subprocess.run(
45
  ["uv", "pip", "install", "-r", "training/requirements.txt", "-q"],
46
  check=True,