Arshit Malik commited on
Commit
b5338ac
·
1 Parent(s): 204114e

fix: remove swap (not allowed), switch to DeepCoder 14B IQ2_XS — fits 128K in 16GB

Browse files
Files changed (1) hide show
  1. start.sh +16 -20
start.sh CHANGED
@@ -1,10 +1,6 @@
1
  #!/bin/bash
2
  set -e
3
 
4
- echo "[boot] Creating 10 GB swap..."
5
- fallocate -l 10G /swapfile 2>/dev/null || dd if=/dev/zero of=/swapfile bs=1M count=10240 2>/dev/null
6
- chmod 600 /swapfile && mkswap /swapfile && swapon /swapfile
7
-
8
  echo "[boot] Pulling OpenClaw state..."
9
  python3 -c "
10
  import sys, os; sys.path.insert(0, '/app')
@@ -18,6 +14,7 @@ if HF_TOKEN and DATASET_REPO:
18
  hf_hub_download(repo_id=DATASET_REPO, filename=f'openclaw/{fname}',
19
  repo_type='dataset', token=HF_TOKEN,
20
  local_dir='/root', local_dir_use_symlinks=False)
 
21
  except EntryNotFoundError: pass
22
  except Exception as e: print(f' {e}')
23
  "
@@ -43,8 +40,8 @@ cat > ~/.openclaw/openclaw.json << JSONEOF
43
  "api": "openai-chat",
44
  "models": [
45
  {
46
- "id": "deepseek-r1-70b",
47
- "name": "DeepSeek R1 Distill Llama 70B IQ2_XS",
48
  "contextWindow": 131072,
49
  "maxTokens": 8192
50
  }
@@ -54,7 +51,7 @@ cat > ~/.openclaw/openclaw.json << JSONEOF
54
  },
55
  "agents": {
56
  "defaults": {
57
- "model": {"primary": "ollama/deepseek-r1-70b"},
58
  "workspace": "/app/yt-flow"
59
  }
60
  }
@@ -67,7 +64,6 @@ git config --global user.name "YT Pipeline Bot"
67
  git config --global user.email "yt-pipe-bot@hf.space"
68
  git clone https://arshitmalik:${HF_TOKEN}@huggingface.co/spaces/arshitmalik/yt-flow /app/yt-flow 2>/dev/null || true
69
 
70
- # Backup cron
71
  cat > /tmp/backup.sh << 'CRONEOF'
72
  #!/bin/bash
73
  python3 -c "
@@ -93,7 +89,6 @@ CRONEOF
93
  chmod +x /tmp/backup.sh
94
  echo "*/15 * * * * /tmp/backup.sh" | crontab -
95
 
96
- # Temporary health server (keeps Space alive during setup)
97
  python3 -c "
98
  from http.server import HTTPServer, BaseHTTPRequestHandler
99
  class H(BaseHTTPRequestHandler):
@@ -118,36 +113,37 @@ for i in $(seq 1 30); do
118
  sleep 2
119
  done
120
 
121
- echo "[boot] Building custom 70B IQ2_XS model (~3 min)..."
122
  python3 << PYEOF
123
  import subprocess, sys, os
124
  from pathlib import Path
125
  from huggingface_hub import hf_hub_download
126
 
127
  gguf_path = hf_hub_download(
128
- repo_id="bartowski/DeepSeek-R1-Distill-Llama-70B-GGUF",
129
- filename="DeepSeek-R1-Distill-Llama-70B-IQ2_XS.gguf",
130
  local_dir="/tmp/gguf",
131
  resume_download=True,
132
  token=os.environ.get("HF_TOKEN", None)
133
  )
134
  modelfile = f"""FROM {gguf_path}
135
- TEMPLATE \"\"\"<|begin▁of▁sentence|>{{ .System }}
136
-
137
- {{ .Prompt }}<|end▁of▁sentence|>
138
- <|begin▁of▁sentence|>assistant
 
139
  \"\"\"
140
- PARAMETER stop "<|begin▁of▁sentence|>"
141
- PARAMETER stop "<|end▁of▁sentence|>"
 
142
  PARAMETER num_ctx 131072
143
  PARAMETER num_predict 8192
144
  """
145
  (Path("/tmp") / "Modelfile").write_text(modelfile)
146
- subprocess.run(["ollama", "create", "deepseek-r1-70b", "-f", "/tmp/Modelfile"], check=True)
147
  Path(gguf_path).unlink()
148
  PYEOF
149
 
150
- # Kill temp health server, start OpenClaw
151
  kill $HEALTH_PID 2>/dev/null
152
  echo "[boot] Starting OpenClaw gateway..."
153
  openclaw gateway &
 
1
  #!/bin/bash
2
  set -e
3
 
 
 
 
 
4
  echo "[boot] Pulling OpenClaw state..."
5
  python3 -c "
6
  import sys, os; sys.path.insert(0, '/app')
 
14
  hf_hub_download(repo_id=DATASET_REPO, filename=f'openclaw/{fname}',
15
  repo_type='dataset', token=HF_TOKEN,
16
  local_dir='/root', local_dir_use_symlinks=False)
17
+ print(f' pulled openclaw/{fname}')
18
  except EntryNotFoundError: pass
19
  except Exception as e: print(f' {e}')
20
  "
 
40
  "api": "openai-chat",
41
  "models": [
42
  {
43
+ "id": "deepcoder-14b",
44
+ "name": "DeepCoder 14B IQ2_XS (CoT + 128K)",
45
  "contextWindow": 131072,
46
  "maxTokens": 8192
47
  }
 
51
  },
52
  "agents": {
53
  "defaults": {
54
+ "model": {"primary": "ollama/deepcoder-14b"},
55
  "workspace": "/app/yt-flow"
56
  }
57
  }
 
64
  git config --global user.email "yt-pipe-bot@hf.space"
65
  git clone https://arshitmalik:${HF_TOKEN}@huggingface.co/spaces/arshitmalik/yt-flow /app/yt-flow 2>/dev/null || true
66
 
 
67
  cat > /tmp/backup.sh << 'CRONEOF'
68
  #!/bin/bash
69
  python3 -c "
 
89
  chmod +x /tmp/backup.sh
90
  echo "*/15 * * * * /tmp/backup.sh" | crontab -
91
 
 
92
  python3 -c "
93
  from http.server import HTTPServer, BaseHTTPRequestHandler
94
  class H(BaseHTTPRequestHandler):
 
113
  sleep 2
114
  done
115
 
116
+ echo "[boot] Building DeepCoder 14B IQ2_XS model..."
117
  python3 << PYEOF
118
  import subprocess, sys, os
119
  from pathlib import Path
120
  from huggingface_hub import hf_hub_download
121
 
122
  gguf_path = hf_hub_download(
123
+ repo_id="bartowski/DeepCoder-14B-Preview-GGUF",
124
+ filename="DeepCoder-14B-Preview-IQ2_XS.gguf",
125
  local_dir="/tmp/gguf",
126
  resume_download=True,
127
  token=os.environ.get("HF_TOKEN", None)
128
  )
129
  modelfile = f"""FROM {gguf_path}
130
+ TEMPLATE \"\"\"<|im_start|>system
131
+ {{ .System }}<|im_end|>
132
+ <|im_start|>user
133
+ {{ .Prompt }}<|im_end|>
134
+ <|im_start|>assistant
135
  \"\"\"
136
+ PARAMETER stop "<|im_start|>"
137
+ PARAMETER stop "<|im_end|>"
138
+ PARAMETER temperature 0.6
139
  PARAMETER num_ctx 131072
140
  PARAMETER num_predict 8192
141
  """
142
  (Path("/tmp") / "Modelfile").write_text(modelfile)
143
+ subprocess.run(["ollama", "create", "deepcoder-14b", "-f", "/tmp/Modelfile"], check=True)
144
  Path(gguf_path).unlink()
145
  PYEOF
146
 
 
147
  kill $HEALTH_PID 2>/dev/null
148
  echo "[boot] Starting OpenClaw gateway..."
149
  openclaw gateway &