iTheresaApocalypse commited on
Commit
a683690
·
verified ·
1 Parent(s): bab68c4

Add inference client, generic game-screen prompt, and checkpoint configs

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +8 -0
  2. README.md +251 -0
  3. gamescaling/__init__.py +32 -0
  4. gamescaling/__pycache__/__init__.cpython-310.pyc +0 -0
  5. gamescaling/__pycache__/action.cpython-310.pyc +0 -0
  6. gamescaling/__pycache__/keymaps.cpython-310.pyc +0 -0
  7. gamescaling/__pycache__/policy.cpython-310.pyc +0 -0
  8. gamescaling/__pycache__/prompt.cpython-310.pyc +0 -0
  9. gamescaling/action.py +218 -0
  10. gamescaling/keymaps.py +53 -0
  11. gamescaling/policy.py +254 -0
  12. gamescaling/prompt.py +182 -0
  13. models/0p8b_s1_1600h_gs6736/chat_template.jinja +134 -0
  14. models/0p8b_s1_1600h_gs6736/config.json +104 -0
  15. models/0p8b_s1_1600h_gs6736/generation_config.json +9 -0
  16. models/0p8b_s1_1600h_gs6736/preprocessor_config.json +21 -0
  17. models/0p8b_s1_1600h_gs6736/processor_config.json +60 -0
  18. models/0p8b_s1_1600h_gs6736/tokenizer.json +3 -0
  19. models/0p8b_s1_1600h_gs6736/tokenizer_config.json +33 -0
  20. models/0p8b_s1_1600h_gs6736/video_preprocessor_config.json +21 -0
  21. models/0p8b_s3_1600h_gs6760/chat_template.jinja +134 -0
  22. models/0p8b_s3_1600h_gs6760/config.json +104 -0
  23. models/0p8b_s3_1600h_gs6760/generation_config.json +9 -0
  24. models/0p8b_s3_1600h_gs6760/preprocessor_config.json +21 -0
  25. models/0p8b_s3_1600h_gs6760/processor_config.json +60 -0
  26. models/0p8b_s3_1600h_gs6760/tokenizer.json +3 -0
  27. models/0p8b_s3_1600h_gs6760/tokenizer_config.json +33 -0
  28. models/0p8b_s3_1600h_gs6760/video_preprocessor_config.json +21 -0
  29. models/27b_s1_1600h_gs6995/chat_template.jinja +134 -0
  30. models/27b_s1_1600h_gs6995/config.json +144 -0
  31. models/27b_s1_1600h_gs6995/generation_config.json +13 -0
  32. models/27b_s1_1600h_gs6995/model.safetensors.index.json +0 -0
  33. models/27b_s1_1600h_gs6995/preprocessor_config.json +21 -0
  34. models/27b_s1_1600h_gs6995/processor_config.json +60 -0
  35. models/27b_s1_1600h_gs6995/tokenizer.json +3 -0
  36. models/27b_s1_1600h_gs6995/tokenizer_config.json +33 -0
  37. models/27b_s1_1600h_gs6995/video_preprocessor_config.json +21 -0
  38. models/27b_s3_1600h_gs7020/chat_template.jinja +134 -0
  39. models/27b_s3_1600h_gs7020/config.json +144 -0
  40. models/27b_s3_1600h_gs7020/generation_config.json +13 -0
  41. models/27b_s3_1600h_gs7020/preprocessor_config.json +21 -0
  42. models/27b_s3_1600h_gs7020/processor_config.json +60 -0
  43. models/27b_s3_1600h_gs7020/tokenizer.json +3 -0
  44. models/27b_s3_1600h_gs7020/tokenizer_config.json +33 -0
  45. models/27b_s3_1600h_gs7020/video_preprocessor_config.json +21 -0
  46. models/2b_s1_1600h_gs6736/chat_template.jinja +134 -0
  47. models/2b_s1_1600h_gs6736/config.json +104 -0
  48. models/2b_s1_1600h_gs6736/generation_config.json +9 -0
  49. models/2b_s1_1600h_gs6736/preprocessor_config.json +21 -0
  50. models/2b_s1_1600h_gs6736/processor_config.json +60 -0
.gitattributes CHANGED
@@ -33,3 +33,11 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ models/0p8b_s1_1600h_gs6736/tokenizer.json filter=lfs diff=lfs merge=lfs -text
37
+ models/0p8b_s3_1600h_gs6760/tokenizer.json filter=lfs diff=lfs merge=lfs -text
38
+ models/27b_s1_1600h_gs6995/tokenizer.json filter=lfs diff=lfs merge=lfs -text
39
+ models/27b_s3_1600h_gs7020/tokenizer.json filter=lfs diff=lfs merge=lfs -text
40
+ models/2b_s1_1600h_gs6736/tokenizer.json filter=lfs diff=lfs merge=lfs -text
41
+ models/2b_s3_1600h_gs6760/tokenizer.json filter=lfs diff=lfs merge=lfs -text
42
+ models/9b_s1_1600h_gs6736/tokenizer.json filter=lfs diff=lfs merge=lfs -text
43
+ models/9b_s3_1600h_gs6760/tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,251 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GameScaling 推理模板
2
+
3
+ 用 GameScaling checkpoint 玩游戏、或把它当 baseline 所需的全部**推理侧**代码:系统提示词
4
+ 规范、多轮消息构造、vLLM 请求参数、动作反解,以及论文三个 benchmark(ViZDoom、
5
+ OmniGameArena、GameWorld)的接入。不含任何训练代码。
6
+
7
+ ```
8
+ gamescaling/ 核心包,只依赖 requests + Pillow
9
+ prompt.py 系统提示词。默认是 TRAINING_SYSTEM_PROMPT(不写游戏名)
10
+ policy.py 多轮客户端:历史窗口、图像编码、请求体
11
+ action.py 动作格式与反解(200 ms chunk -> 6 x 33 ms 键鼠)
12
+ keymaps.py 训练词表 <-> 浏览器/Playwright 键名
13
+ models/ 8 个 Qwen3.5 checkpoint,各自带 chat_template.jinja
14
+ scripts/serve_vllm.sh 起 OpenAI 兼容服务
15
+ tests/test_core.py 离线单测(不需要 GPU)
16
+ ```
17
+
18
+ 默认推理是一帧游戏画面:`TRAINING_SYSTEM_PROMPT` 里没有游戏名,user 文本固定为
19
+ `current game screen`。checkpoint 与起服务目录:
20
+
21
+ | 目录 | 规模 |
22
+ |---|---|
23
+ | `models/0p8b_s1_1600h_gs6736` | 0.8B,stage 1 |
24
+ | `models/0p8b_s3_1600h_gs6760` | 0.8B,stage 3 |
25
+ | `models/2b_s1_1600h_gs6736` | 2B,stage 1 |
26
+ | `models/2b_s3_1600h_gs6760` | 2B,stage 3 |
27
+ | `models/9b_s1_1600h_gs6736` | 9B,stage 1 |
28
+ | `models/9b_s3_1600h_gs6760` | 9B,stage 3 |
29
+ | `models/27b_s1_1600h_gs6995` | 27B,stage 1 |
30
+ | `models/27b_s3_1600h_gs7020` | 27B,stage 3 |
31
+
32
+ `27b_s3` 的权重按约 30GB 切成多片,并带 `model.safetensors.index.json`。请用该 checkpoint
33
+ 目录里的 `chat_template.jinja`,不要换成原版 Qwen 模板。
34
+
35
+ ## 1. 部署模型
36
+
37
+ ```bash
38
+ pip install "vllm>=0.17" # checkpoint 是 Qwen3.5 架构;测试版本 0.17.0
39
+ bash scripts/serve_vllm.sh /path/to/checkpoint 8000 # 单卡即可跑 0.8B-9B
40
+ ```
41
+
42
+ 脚本以 `--served-model-name gamescaling` 起服务,本仓库所有客户端默认连
43
+ `http://127.0.0.1:8000/v1`、模型名 `gamescaling`。请使用 checkpoint 目录里自带的
44
+ `chat_template.jinja`(vLLM 默认就会用),**不要**换成原版 Qwen 模板:自带模板会把没有
45
+ 思维链的历史轮渲染成 `<think>\n\n</think>\n\n<|action_start|>...`,与训练样本逐 token 一致。
46
+
47
+ ## 2. 最小用法
48
+
49
+ ```python
50
+ from PIL import Image
51
+ from gamescaling import TRAINING_SYSTEM_PROMPT, GameScalingPolicy, PolicyConfig
52
+
53
+ # 默认:系统提示词不写游戏名,输入就是一帧游戏画面。画面按原尺寸送入,不预填 <think>。
54
+ policy = GameScalingPolicy(TRAINING_SYSTEM_PROMPT, PolicyConfig())
55
+ policy.reset() # 每局开始调用
56
+ decision = policy.act(Image.open("frame.png")) # 一次调用 = 一个 200 ms 决策
57
+ a = decision.action
58
+ a.mouse # (X, Y, Z):本 chunk 鼠标位移(千分比屏幕)+ 滚轮
59
+ a.steps # 6 组,每组是这 33 ms 内按住的键
60
+ a.parsed # False = 无法解析,按 no-op 执行
61
+ ```
62
+
63
+ 之后把 `a` 交给你的执行器:6 个 33 ms 子步,每步按住该组的键(相邻两组都有的键保持按住,
64
+ 不重新按下);鼠标位移 `X/1000*屏宽`、`Y/1000*屏高` 在 200 ms 内分摊或一次性下发均可,
65
+ 三个集成各自的做法见下文。
66
+
67
+ 要写上游戏名和规则时,用 `build_system_prompt(游戏名, rules=..., key_bindings=...)`,客户端仍用
68
+ `PolicyConfig()`。论文三张表用 `PolicyConfig.preset("omnigamearena" | "vizdoom" | "gameworld")`。
69
+ `preset("omnigamearena")` 会把画面缩到 854×480,并预填 `<think>`,此时系统提示词要
70
+ `reasoning=True`。
71
+
72
+ ## 3. 系统提示词规范
73
+
74
+ 所有 benchmark 用同一骨架,顺序固定(`gamescaling/prompt.py`):
75
+
76
+ 1. **开场白**:游戏专家 + 游戏名 + "规划接下来 200ms、6 步、每步 33ms" 的契约;
77
+ 2. `**Game Rules**`:游戏是什么、怎么计分;
78
+ 3. **操作说明**:本游戏用到的键,**必须写成训练词表**(见 §4);
79
+ 4. `**Task Instruction**`:仅 GameWorld(一个游戏有多个任务);
80
+ 5. `**Output Format**`:模型据此决定输出格式;
81
+ 6. `**Explanation**` + `**Key Naming Rules**`。
82
+
83
+ 两种版式只在第 3 节和分隔符上不同:
84
+
85
+ - `build_system_prompt(...)`:键位列表版(`**Common Keys in <game>**` + `- W -> Move
86
+ forward`),ViZDoom、OmniGameArena 和**接入新游戏**都用它;鼠标控制视角的游戏加
87
+ `mouse_aim=True`。
88
+ - `build_gameworld_system_prompt(...)`:自由段落版(`**Role and Controls**`),用于
89
+ GameWorld 那种自带文字说明的游戏;浏览器键名用 `translate_controls` 转成训练词表
90
+ (`ArrowLeft` -> `Left`,`a/d` -> `A/D`,`1-9:` -> `one-nine:`)。
91
+
92
+ `Output Format` 有两种,**必须与客户端是否 prefill `<think>` 保持一致**:
93
+
94
+ | `reasoning` | 客户端 | 模型输出 |
95
+ |---|---|---|
96
+ | `True` | `think_prefill=True`,assistant 以 `<think>` 开头续写 | 自己决定想不想、想多久,���后闭合 `</think>` 输出动作 |
97
+ | `False` | 不 prefill | 直接输出 `<|action_start|>...<|action_end|>` |
98
+
99
+ 提示词请原样拷贝,不要改写:checkpoint 是按这段 Output Format 的精确文本来决定输出标签的。
100
+ 每轮 user 消息的文本固定为 `current game screen`,后接当前帧。
101
+
102
+ 多轮消息(`policy.py`):
103
+
104
+ ```
105
+ system 系统提示词
106
+ user "current game screen" + 第 t-k 帧 ┐ 最近 history_len 轮
107
+ assistant 第 t-k 轮执行的动作(默认不带思维链) ┘
108
+ ...
109
+ user "current game screen" + 当前帧
110
+ assistant "<think>"(仅 think_prefill 时,continue_final_message=True)
111
+ ```
112
+
113
+ 历史轮只放动作(`history_think=0`,论文口径)。解析失败的轮在历史里存成显式 no-op
114
+ `<|action_start|>0 0 0 ; ; ; ; ; ; <|action_end|>`,而不是模型的原始坏输出。
115
+
116
+ ## 4. 动作格式与反解
117
+
118
+ ```
119
+ <|action_start|>X Y Z ; g1 ; g2 ; g3 ; g4 ; g5 ; g6<|action_end|>
120
+ ```
121
+
122
+ - `X Y`:整个 200 ms 的鼠标位移,千分比屏幕(`X = Σdx / 屏宽 × 1000`),截断到 ±1000;
123
+ X>0 向右,Y>0 向下。
124
+ - `Z`:滚轮格数,截断到 ±5,Z>0 向上。
125
+ - `g1..g6`:六个 33 ms 子步,每组列出这段时间内**按住**的键,最多 4 个;空组 = 全部松开,
126
+ 但 `;` 要保留。
127
+ - `<|action_start|>` / `<|action_end|>` 是 special token,请求里必须带
128
+ `skip_special_tokens: false`(`build_request` 已设置),否则服务端会把标签吃掉
129
+ (`parse_action` 对裸 `X Y Z ; ...` 也能兜底)。
130
+ - 动作**只从最后一个 `</think>` 之后**读取:会思考的模型常在思维链里复述格式,从全文搜会执行
131
+ 那段引用。`<think>` 没闭合 = 生成被截断,按 no-op 处理(`Action.truncated=True`)。
132
+
133
+ 训练词表(74 个,大小写敏感,`gamescaling.action.KEY_VOCAB`):
134
+
135
+ | 类别 | token |
136
+ |---|---|
137
+ | 字母 | `A`..`Z` |
138
+ | 数字行 | `zero` `one` .. `nine` |
139
+ | F1-F12 | `One` `Two` .. `Twelve`(**首字母大写** = F 键) |
140
+ | 鼠标键 | `LB` `RB` `MB` |
141
+ | 方向 | `Up` `Down` `Left` `Right` |
142
+ | 其他 | `Shift` `Ctrl` `Alt` `Tab` `Caps` `Esc` `Space` `Enter` `Back` `Delete` `Insert` `Home` `End` `Pause` `Equal` `Minus` `Period` `Slash` `Quote` |
143
+
144
+ 不在词表里的 token 被丢弃(记在 `Action.dropped`)。`keymaps.TO_PLAYWRIGHT` 给出到浏览器
145
+ 键名的映射。
146
+
147
+ ## 5. 三个 benchmark
148
+
149
+ 三者都是**暂停时钟(pdq)**:模型思考时游戏冻结,只在执行 chunk 时前进。论文所有主表都是这个
150
+ 口径;不同时钟之间的分数不可比。
151
+
152
+ ### 5.1 ViZDoom(自包含)
153
+
154
+ ```bash
155
+ pip install -r requirements.txt vizdoom==1.2.4
156
+ python -m integrations.vizdoom.run --maps battle1 battle2 defend_the_center defend_the_line \
157
+ --episodes 10 --out runs/vizdoom
158
+ ```
159
+
160
+ 四张图、每图 10 局、每局最多 350 个 chunk(= 2100 tic 的地图超时)。一个 33 ms 子步 = 一个
161
+ tic(35 tic/s),每个子步单独 `make_action(vec, 1)`。鼠标按 Doom 的投影换算成转向角
162
+ (`atan((X/1000) / focal)`,即把屏幕上偏移 X 处的目标转到准星;focal 为实测值),转角在
163
+ 6 个 tic 上均分;HUD 开。计分:battle 图数击杀,defend 图击杀减死亡;`overall` 是四图均值的均值。
164
+ 场景文件来源见 `integrations/vizdoom/scenarios/PROVENANCE.md`。
165
+
166
+ ### 5.2 OmniGameArena
167
+
168
+ 在 [OmniGameArena](https://github.com/mxlin043/OmniGameArena)(测于 `f3a4057`)里注册
169
+ agent kind `gamescaling`:
170
+
171
+ ```bash
172
+ bash integrations/omnigamearena/install.sh /path/to/OmniGameArena
173
+ export PYTHONPATH=$PWD:$PWD/integrations/omnigamearena:$PYTHONPATH
174
+ cd /path/to/OmniGameArena
175
+ # 按 OmniGameArena README 启动 UE5(默认端口 12345)
176
+ python scripts/run_benchmark.py --config configs/gamescaling/monster_shoot.yaml
177
+ ```
178
+
179
+ 补丁只做两件事:在 `factory.py` 注册 `gamescaling`;把 `runner.py` 对 `tkinter`
180
+ 的导入改成只在 `--live` 时加载(无显示器的服务器上原版会直接 ImportError)。
181
+
182
+ 七个 solo 游戏配置在 `configs/gamescaling/`:pdq、每局 300 步(`scene_escape`、
183
+ `cue_chase` 为 500)、3 局、温度 1.0、自由思考、历史 5 帧只留动作、画面缩到 854x480。
184
+ 论文的计分约定:`solo_craft` 分数为 `min(V/50, 1)`(V 为 UE 返回的原始点数),其余游戏直接用
185
+ benchmark 分数;OVERALL 是七个游戏的均值。
186
+
187
+ 两个实际部署时的注意点:
188
+
189
+ - **一张 GPU 只跑一个 UE5 实例。** 动作按墙钟 6×33 ms 执行,多个实例抢一张卡的渲染时,按住
190
+ 前进 0.2 s 几乎不动,分数会大幅下降且不报错。
191
+ - `solo_craft` 的后续 episode 请换一个新的 UE5 进程;复用实例时第 2、3 局会立即结束并复报
192
+ 第 1 局分数。
193
+
194
+ ### 5.3 GameWorld
195
+
196
+ 在 [GameWorld](https://github.com/gameworld-project/gameworld)(测于 `e236a39`)里注册模型
197
+ id `gamescaling`:
198
+
199
+ ```bash
200
+ bash integrations/gameworld/install.sh /path/to/gameworld
201
+ export PYTHONPATH=$PWD:$PYTHONPATH
202
+ cd /path/to/gameworld
203
+ # 上游仓库只带 2 个游戏;完整游戏库的游戏在该库的 benchmark/ 子目录下
204
+ git clone --depth 1 https://github.com/gameworld-dev/gameworld-games.git /tmp/gameworld-games
205
+ rm -rf games/benchmark && mv /tmp/gameworld-games/benchmark games/benchmark
206
+ pip install -r requirements.txt && python -m playwright install --with-deps chromium
207
+ python main.py --config 01_2048+01_01+gamescaling --headless
208
+ python run_suite.py --suite <your_suite.yaml> # 批量:suite 里 model 写 gamescaling
209
+ ```
210
+
211
+ 补丁新增一种 `key_timeline` 动作:六个 33 ms 槽位的按住键(跨窗口保持),加一次鼠标移动和
212
+ 滚轮。鼠标是千分比屏幕空间里的虚拟光标,从中心出发、每个 chunk 移动 (X, Y) 并截断到屏幕内。
213
+ 系统提示词走 `gamescaling_template.j2`(自由段落版),控制说明经 `translate_controls`
214
+ 转成训练词表。
215
+
216
+ 口径(`catalog/models/gamescaling.yaml`):历史 5 轮(截图 + 动作)、截图缩放到高 480
217
+ (PNG、Lanczos)、不 prefill `<think>`、`max_tokens=4096`、温度 1.0、停在
218
+ `<|action_end|>`、宽松解析。`wasd_remap`:只在某游戏 WASD 非法而方向键合法时,把模型输出
219
+ 的 WASD 映射成方向键(模型主要在 PC 游戏上训练,习惯用 WASD 移动)。环境变量
220
+ `GAMESCALING_ENDPOINT` 可覆盖服务地址,`GAMESCALING_THINK=1` 可打开 think prefill(非论文口径)。
221
+
222
+ ## 6. 接入新游戏
223
+
224
+ 1. 用 `build_system_prompt` 写提示词:游戏名、规则、`key_bindings` 用训练词表;鼠标控视角
225
+ 时加 `mouse_aim=True`;`reasoning` 与 `think_prefill` 一致。
226
+ 2. 每 200 ms(或暂停时钟下每次决策)截一帧,调用 `policy.act(frame)`。
227
+ 3. 按 §4 执行 `Action`:6 个 33 ms 子步的按住键 + 鼠标位移 + 滚轮。
228
+ 4. 新游戏沿用默认客户端(原尺寸画面、不预填 `<think>`、`TRAINING_SYSTEM_PROMPT` 或
229
+ 你自己的 `build_system_prompt`)。要对齐论文某一张表时,再改用
230
+ `PolicyConfig.preset("omnigamearena" | "vizdoom" | "gameworld")`。
231
+
232
+ ## 7. 与论文评测代码的差异
233
+
234
+ 发布代码与论文内部评测代码逐项对拍过:三个 benchmark 的全部系统提示词逐字节相同
235
+ (ViZDoom 4 图、OmniGameArena 12 游戏 44 个 prompt、GameWorld 170 个任务),历史 trace
236
+ 中各 4000 条左右的模型回复反解结果完全相同。以下几处有意改动只在边缘情况下有区别:
237
+
238
+ - OmniGameArena 的动作只从最后一个 `</think>` 之后读取(内部代码搜全文,思维链里复述格式时
239
+ 会误执行那段引用)。
240
+ - GameWorld 中解析失败的轮在历史里存为显式 no-op(内部代码存原始输出)。
241
+ - GameWorld 槽位时长用 200/6 = 33.33 ms(内部为 33.0 ms)。
242
+ - ViZDoom 历史轮保存动作原文(内部去掉首尾空白),episode 种子用 `crc32`(内部用 Python
243
+ `hash`,跨进程不稳定)。
244
+ - OmniGameArena 的 `map_wait` 用上游默认 3 s。内部评测等 60 s,但前 3 s 之后世界是冻结的,
245
+ 所以两者进入第一步时的游戏时间一致。
246
+
247
+ ## 8. 测试
248
+
249
+ ```bash
250
+ python tests/test_core.py # 或 python -m pytest tests/;离线:提示词、请求体、动作反解,不需要 GPU / 服务
251
+ ```
gamescaling/__init__.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Inference-side contract of the GameScaling checkpoints: prompt, client, action decoding."""
2
+
3
+ from .action import (
4
+ ACTION_END,
5
+ ACTION_START,
6
+ CHUNK_MS,
7
+ CHUNK_STEPS,
8
+ KEY_VOCAB,
9
+ NOOP_ACTION_TEXT,
10
+ STEP_MS,
11
+ Action,
12
+ parse_action,
13
+ split_reasoning,
14
+ )
15
+ from .policy import Decision, GameScalingPolicy, PolicyConfig, build_request, encode_image, finalize
16
+ from .prompt import (
17
+ TRAINING_SYSTEM_PROMPT,
18
+ USER_TURN_TEXT,
19
+ build_gameworld_system_prompt,
20
+ build_system_prompt,
21
+ translate_controls,
22
+ )
23
+
24
+ __version__ = "0.1.0"
25
+
26
+ __all__ = [
27
+ "ACTION_END", "ACTION_START", "CHUNK_MS", "CHUNK_STEPS", "KEY_VOCAB", "NOOP_ACTION_TEXT",
28
+ "STEP_MS", "Action", "parse_action", "split_reasoning",
29
+ "Decision", "GameScalingPolicy", "PolicyConfig", "build_request", "encode_image", "finalize",
30
+ "TRAINING_SYSTEM_PROMPT", "USER_TURN_TEXT", "build_gameworld_system_prompt",
31
+ "build_system_prompt", "translate_controls",
32
+ ]
gamescaling/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (999 Bytes). View file
 
gamescaling/__pycache__/action.cpython-310.pyc ADDED
Binary file (8.99 kB). View file
 
gamescaling/__pycache__/keymaps.cpython-310.pyc ADDED
Binary file (2.38 kB). View file
 
gamescaling/__pycache__/policy.cpython-310.pyc ADDED
Binary file (9.62 kB). View file
 
gamescaling/__pycache__/prompt.cpython-310.pyc ADDED
Binary file (9.3 kB). View file
 
gamescaling/action.py ADDED
@@ -0,0 +1,218 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """The GameScaling action format: parse model text into one 200 ms keyboard/mouse chunk.
2
+
3
+ Every turn the model emits exactly one chunk:
4
+
5
+ <|action_start|>X Y Z ; g1 ; g2 ; g3 ; g4 ; g5 ; g6<|action_end|>
6
+
7
+ - ``X Y`` is the mouse displacement over the whole 200 ms, in per-mille of the
8
+ screen (``X = sum(dx) / width * 1000``, clamped to +-1000; X>0 right, Y>0 down).
9
+ - ``Z`` is the scroll amount in wheel clicks (clamped to +-5; Z>0 up).
10
+ - ``g1..g6`` are six 33 ms substeps. Each group lists the keys/buttons that are
11
+ held during that substep (at most 4). A key present in consecutive groups is
12
+ held continuously; an empty group releases everything.
13
+
14
+ Reasoning models may prefix the chunk with ``<think>...</think>``. The action is
15
+ always read from the text *after* the last ``</think>``: thinking models quote
16
+ the format back at themselves ("the format is <|action_start|>X Y Z ; ..."), and
17
+ reading the whole reply would execute the quote.
18
+ """
19
+
20
+ from __future__ import annotations
21
+
22
+ import re
23
+ from dataclasses import dataclass, field
24
+
25
+ ACTION_START = "<|action_start|>"
26
+ ACTION_END = "<|action_end|>"
27
+ ACTION_END_TOKEN_ID = 151670
28
+ THINK_OPEN = "<think>"
29
+ THINK_CLOSE = "</think>"
30
+
31
+ CHUNK_MS = 200.0
32
+ CHUNK_STEPS = 6
33
+ STEP_MS = CHUNK_MS / CHUNK_STEPS
34
+ MAX_KEYS_PER_STEP = 4
35
+ MOUSE_LIMIT = 1000.0
36
+ SCROLL_LIMIT = 5.0
37
+
38
+ NOOP_ACTION_TEXT = f"{ACTION_START}0 0 0 ; ; ; ; ; ; {ACTION_END}"
39
+
40
+ # The 74-token vocabulary the model was trained on. Case matters:
41
+ # `one`..`nine` are number-row keys, `One`..`Twelve` are F1..F12.
42
+ LETTER_KEYS = tuple("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
43
+ DIGIT_KEYS = ("zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine")
44
+ FUNCTION_KEYS = ("One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight",
45
+ "Nine", "Ten", "Eleven", "Twelve")
46
+ MOUSE_BUTTON_KEYS = ("LB", "RB", "MB")
47
+ ARROW_KEYS = ("Up", "Down", "Left", "Right")
48
+ SPECIAL_KEYS = ("Shift", "Ctrl", "Alt", "Tab", "Caps", "Esc", "Space", "Enter", "Back",
49
+ "Delete", "Insert", "Home", "End", "Pause")
50
+ PUNCTUATION_KEYS = ("Equal", "Minus", "Period", "Slash", "Quote")
51
+ KEY_VOCAB: frozenset[str] = frozenset(
52
+ LETTER_KEYS + DIGIT_KEYS + FUNCTION_KEYS + MOUSE_BUTTON_KEYS + ARROW_KEYS
53
+ + SPECIAL_KEYS + PUNCTUATION_KEYS
54
+ )
55
+
56
+ # `}` instead of `>` is a closing-bracket typo some models make.
57
+ _TAG_RE = re.compile(r"<\|action_start\|[>}](.*?)<\|action_end\|[>}]", re.DOTALL)
58
+ _BARE_RE = re.compile(r"^\s*-?\d")
59
+ # Lenient fallbacks (see `parse_action(lenient=True)`).
60
+ _WRAPPED_INT_RE = re.compile(
61
+ r"<\|action(?:_start)?\|>\s*(-?\d+)\s+(-?\d+)\s+(-?\d+)(.*?)<\|action(?:_end)?\|>",
62
+ re.DOTALL,
63
+ )
64
+ _SKELETON_RE = re.compile(r"[^\n;<]*(?:;[^\n;<]*){5,}")
65
+ _BARE_INT_RE = re.compile(r"(-?\d+)\s+(-?\d+)\s+(-?\d+)\s*(;[^\n<]*)", re.DOTALL)
66
+ _INT_RE = re.compile(r"^-?\d+$")
67
+
68
+
69
+ def split_reasoning(text: str) -> tuple[str, str, bool]:
70
+ """``text`` -> (reasoning, text after the reasoning, reasoning was closed).
71
+
72
+ An unclosed ``<think>`` means generation ended before any action existed
73
+ (the token budget ran out, or a stop string matched inside the reasoning),
74
+ so the tail is empty.
75
+ """
76
+ text = text or ""
77
+ if THINK_CLOSE in text:
78
+ head, _, tail = text.rpartition(THINK_CLOSE)
79
+ return head.split(THINK_OPEN)[-1].strip(), tail, True
80
+ if THINK_OPEN in text:
81
+ return text.split(THINK_OPEN)[-1].strip(), "", False
82
+ return "", text, True
83
+
84
+
85
+ @dataclass
86
+ class Action:
87
+ """One parsed 200 ms chunk. Unparseable text is a no-op with ``parsed=False``."""
88
+
89
+ mouse: tuple[float, float, float] = (0.0, 0.0, 0.0)
90
+ steps: list[list[str]] = field(default_factory=lambda: [[] for _ in range(CHUNK_STEPS)])
91
+ parsed: bool = False
92
+ truncated: bool = False
93
+ body: str = ""
94
+ dropped: list[str] = field(default_factory=list)
95
+
96
+ @property
97
+ def history_text(self) -> str:
98
+ """What this turn looks like as an assistant message in the next prompt.
99
+
100
+ Always a well-formed chunk: an unparseable turn is stored as an explicit
101
+ no-op, because putting the model's own failure into context teaches it
102
+ to repeat the failure.
103
+ """
104
+ if not self.parsed:
105
+ return NOOP_ACTION_TEXT
106
+ return f"{ACTION_START}{self.body}{ACTION_END}"
107
+
108
+ @property
109
+ def is_noop(self) -> bool:
110
+ return not any(self.steps) and self.mouse == (0.0, 0.0, 0.0)
111
+
112
+ @property
113
+ def pressed(self) -> set[str]:
114
+ return {k for group in self.steps for k in group}
115
+
116
+ def to_text(self) -> str:
117
+ x, y, z = (int(round(v)) for v in self.mouse)
118
+ groups = " ; ".join(" ".join(g) for g in self.steps)
119
+ return f"{ACTION_START}{x} {y} {z} ; {groups}{ACTION_END}"
120
+
121
+
122
+ def _build(nums: list[float], groups: list[str], body: str) -> Action:
123
+ x = max(-MOUSE_LIMIT, min(MOUSE_LIMIT, nums[0]))
124
+ y = max(-MOUSE_LIMIT, min(MOUSE_LIMIT, nums[1]))
125
+ z = max(-SCROLL_LIMIT, min(SCROLL_LIMIT, nums[2]))
126
+ steps: list[list[str]] = []
127
+ dropped: list[str] = []
128
+ for group in groups[:CHUNK_STEPS]:
129
+ keys = []
130
+ for tok in group.split():
131
+ (keys if tok in KEY_VOCAB else dropped).append(tok)
132
+ steps.append(keys[:MAX_KEYS_PER_STEP])
133
+ while len(steps) < CHUNK_STEPS:
134
+ steps.append([])
135
+ return Action(mouse=(x, y, z), steps=steps, parsed=True, body=body, dropped=dropped)
136
+
137
+
138
+ def _parse_strict(tail: str) -> Action:
139
+ m = _TAG_RE.search(tail)
140
+ if m:
141
+ body = m.group(1)
142
+ elif _BARE_RE.match(tail) and ";" in tail:
143
+ # Tags are special tokens; a server that strips them returns a bare body.
144
+ body = tail.strip()
145
+ else:
146
+ return Action()
147
+ parts = [seg.strip() for seg in body.split(";")]
148
+ if not parts or not parts[0]:
149
+ return Action()
150
+ nums: list[float] = []
151
+ for tok in parts[0].split()[:3]:
152
+ try:
153
+ nums.append(float(tok))
154
+ except ValueError:
155
+ return Action()
156
+ if len(nums) < 3:
157
+ return Action()
158
+ return _build(nums, parts[1:], body)
159
+
160
+
161
+ def _parse_lenient(text: str) -> Action:
162
+ """GameWorld's recovery for malformed replies (see `parse_action`)."""
163
+ text = text.replace(THINK_OPEN, " ").replace(THINK_CLOSE, " ")
164
+ m = _WRAPPED_INT_RE.search(text)
165
+ if m:
166
+ nums = [float(m.group(i)) for i in (1, 2, 3)]
167
+ key_part = m.group(4).strip()
168
+ body = text[m.start():m.end()]
169
+ body = body[body.find(">") + 1:body.rfind("<")]
170
+ else:
171
+ skel = None
172
+ for sm in _SKELETON_RE.finditer(text):
173
+ skel = sm.group(0)
174
+ if skel is None:
175
+ bm = _BARE_INT_RE.search(text)
176
+ if not bm:
177
+ return Action()
178
+ nums = [float(bm.group(i)) for i in (1, 2, 3)]
179
+ key_part = bm.group(4).strip()
180
+ body = bm.group(0)
181
+ else:
182
+ head = skel.partition(";")[0]
183
+ head_tokens = head.split()
184
+ if head_tokens and len(head_tokens) <= 3 and all(_INT_RE.match(t) for t in head_tokens):
185
+ nums = [float(t) for t in head_tokens] + [0.0, 0.0, 0.0]
186
+ key_part = skel[len(head):]
187
+ else:
188
+ nums = [0.0, 0.0, 0.0]
189
+ key_part = skel
190
+ body = skel
191
+ segments = key_part.split(";") if key_part else []
192
+ if segments and segments[0].strip() == "":
193
+ segments = segments[1:]
194
+ return _build(nums[:3], segments, body.strip())
195
+
196
+
197
+ def parse_action(text: str, *, lenient: bool = False) -> Action:
198
+ """Raw model reply -> :class:`Action`. Never raises; failures are no-ops.
199
+
200
+ ``lenient=False`` (OmniGameArena / ViZDoom protocol): only a chunk after the
201
+ last ``</think>`` counts, either tagged or as a bare ``X Y Z ; ...`` body.
202
+
203
+ ``lenient=True`` (GameWorld protocol): additionally recover shapes a
204
+ well-trained checkpoint rarely emits -- an action inside an unclosed
205
+ ``<think>``, a 2-number mouse prefix, a keys-only skeleton -- by locating the
206
+ ``;``-separated six-group skeleton anywhere in the reply.
207
+ """
208
+ _, tail, closed = split_reasoning(text)
209
+ if closed:
210
+ action = _parse_strict(tail)
211
+ if action.parsed or not lenient:
212
+ return action
213
+ elif not lenient:
214
+ return Action(truncated=True)
215
+ action = _parse_lenient(text or "")
216
+ if not closed and not action.parsed:
217
+ action.truncated = True
218
+ return action
gamescaling/keymaps.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Training key vocabulary -> the key names of common input backends.
2
+
3
+ Mouse buttons (`LB` / `RB` / `MB`) are not keyboard keys; every table below
4
+ leaves them out and backends handle them through `MOUSE_BUTTONS`.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from .action import LETTER_KEYS
10
+
11
+ MOUSE_BUTTONS: dict[str, str] = {"LB": "left", "RB": "right", "MB": "middle"}
12
+
13
+ # Unreal Engine 5 FKey names (OmniGameArena RemoteInput). Left variants are
14
+ # used for the L/R-merged modifier tokens.
15
+ TO_UE5: dict[str, str] = {
16
+ **{c: c for c in LETTER_KEYS},
17
+ "zero": "Zero", "one": "One", "two": "Two", "three": "Three", "four": "Four",
18
+ "five": "Five", "six": "Six", "seven": "Seven", "eight": "Eight", "nine": "Nine",
19
+ "One": "F1", "Two": "F2", "Three": "F3", "Four": "F4", "Five": "F5", "Six": "F6",
20
+ "Seven": "F7", "Eight": "F8", "Nine": "F9", "Ten": "F10", "Eleven": "F11",
21
+ "Twelve": "F12",
22
+ "Shift": "LeftShift", "Ctrl": "LeftControl", "Alt": "LeftAlt", "Tab": "Tab",
23
+ "Caps": "CapsLock", "Esc": "Escape", "Space": "SpaceBar", "Enter": "Enter",
24
+ "Back": "BackSpace", "Delete": "Delete", "Insert": "Insert", "Home": "Home",
25
+ "End": "End", "Pause": "Pause",
26
+ "Up": "Up", "Down": "Down", "Left": "Left", "Right": "Right",
27
+ "Equal": "Equals", "Minus": "Hyphen", "Period": "Period", "Slash": "Slash",
28
+ "Quote": "Apostrophe",
29
+ }
30
+
31
+ # Playwright `page.keyboard` names (GameWorld). Letters are lower case because
32
+ # GameWorld's legal-key lists are written that way.
33
+ TO_PLAYWRIGHT: dict[str, str] = {
34
+ **{c: c.lower() for c in LETTER_KEYS},
35
+ "zero": "0", "one": "1", "two": "2", "three": "3", "four": "4",
36
+ "five": "5", "six": "6", "seven": "7", "eight": "8", "nine": "9",
37
+ "One": "F1", "Two": "F2", "Three": "F3", "Four": "F4", "Five": "F5", "Six": "F6",
38
+ "Seven": "F7", "Eight": "F8", "Nine": "F9", "Ten": "F10", "Eleven": "F11",
39
+ "Twelve": "F12",
40
+ "Shift": "Shift", "Ctrl": "Control", "Alt": "Alt", "Tab": "Tab", "Caps": "CapsLock",
41
+ "Esc": "Escape", "Space": "Space", "Enter": "Enter", "Back": "Backspace",
42
+ "Delete": "Delete", "Insert": "Insert", "Home": "Home", "End": "End", "Pause": "Pause",
43
+ "Up": "ArrowUp", "Down": "ArrowDown", "Left": "ArrowLeft", "Right": "ArrowRight",
44
+ "Equal": "Equal", "Minus": "Minus", "Period": "Period", "Slash": "Slash",
45
+ "Quote": "Quote",
46
+ }
47
+
48
+ # Playwright name -> training token, for rewriting a game's documented controls
49
+ # into the vocabulary the model emits.
50
+ PLAYWRIGHT_TO_TOKEN: dict[str, str] = {
51
+ "ArrowLeft": "Left", "ArrowRight": "Right", "ArrowUp": "Up", "ArrowDown": "Down",
52
+ "Escape": "Esc", "CapsLock": "Caps", "Control": "Ctrl", "Backspace": "Back",
53
+ }
gamescaling/policy.py ADDED
@@ -0,0 +1,254 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Multi-turn policy client for a GameScaling checkpoint served by vLLM.
2
+
3
+ One call to :meth:`GameScalingPolicy.act` is one 200 ms decision:
4
+
5
+ system the game's system prompt (see `gamescaling.prompt`)
6
+ user, assistant one pair per past decision: "current game screen" + frame,
7
+ ... then the action the model took (its reasoning is dropped
8
+ unless `history_think` asks to keep it)
9
+ user "current game screen" + the current frame
10
+ assistant optionally prefilled with "<think>"; the model continues
11
+
12
+ The checkpoint's own chat template renders a past assistant turn without
13
+ reasoning as `<think>\\n\\n</think>\\n\\n<|action_start|>...`, exactly as in
14
+ training, so the client only ever sends the action string.
15
+ """
16
+
17
+ from __future__ import annotations
18
+
19
+ import base64
20
+ import io
21
+ import logging
22
+ import re
23
+ import time
24
+ from collections import deque
25
+ from dataclasses import dataclass, field, replace
26
+ from typing import Any, NamedTuple
27
+
28
+ import requests
29
+ from PIL import Image
30
+
31
+ from .action import (
32
+ ACTION_END,
33
+ ACTION_END_TOKEN_ID,
34
+ ACTION_START,
35
+ THINK_OPEN,
36
+ Action,
37
+ parse_action,
38
+ split_reasoning,
39
+ )
40
+ from .prompt import USER_TURN_TEXT
41
+
42
+ logger = logging.getLogger(__name__)
43
+
44
+ _RESAMPLE = {"bilinear": Image.BILINEAR, "lanczos": Image.LANCZOS, "bicubic": Image.BICUBIC}
45
+
46
+
47
+ @dataclass
48
+ class PolicyConfig:
49
+ base_url: str = "http://127.0.0.1:8000/v1"
50
+ model: str = "gamescaling"
51
+ api_key: str = "EMPTY"
52
+ # Past decisions kept in context (one frame + one action each).
53
+ history_len: int = 5
54
+ # How many of the most recent past turns keep their <think> text; -1 = all.
55
+ history_think: int = 0
56
+ # Frame sent to the model. None keeps the given game screen as-is.
57
+ # An exact (w, h), or image_height, is only for a benchmark preset.
58
+ image_size: tuple[int, int] | None = None
59
+ image_height: int | None = None
60
+ image_format: str = "jpeg" # jpeg | png
61
+ jpeg_quality: int = 90
62
+ resample: str = "bilinear"
63
+ # Prefill "<think>" so the model reasons freely and closes it itself.
64
+ # Off by default: the generic prompt asks for an action string. Turn it on
65
+ # only together with a system prompt built with reasoning=True.
66
+ think_prefill: bool = False
67
+ temperature: float = 1.0
68
+ max_tokens: int = 2048
69
+ stop: list[str] = field(default_factory=lambda: [ACTION_END])
70
+ stop_token_ids: list[int] = field(default_factory=list)
71
+ include_stop_str_in_output: bool = False
72
+ lenient_parse: bool = False
73
+ timeout: float = 120.0
74
+
75
+ @classmethod
76
+ def preset(cls, benchmark: str, **overrides: Any) -> "PolicyConfig":
77
+ """Paper-benchmark clients. The default constructor is not one of these.
78
+
79
+ Default ``PolicyConfig()`` sends the given game frame unchanged and does
80
+ not prefill ``<think>``. Use a preset only when reproducing a paper table.
81
+ """
82
+ presets = {
83
+ "omnigamearena": cls(image_size=(854, 480), think_prefill=True),
84
+ # Free-form reasoning without a stop string: a model that quotes the
85
+ # format inside <think> would otherwise be cut off mid-thought.
86
+ "vizdoom": cls(image_size=(854, 480), think_prefill=True, stop=[]),
87
+ "gameworld": cls(
88
+ image_size=None, image_height=480, image_format="png", resample="lanczos",
89
+ think_prefill=False, max_tokens=4096, stop=[ACTION_END],
90
+ stop_token_ids=[ACTION_END_TOKEN_ID], include_stop_str_in_output=True,
91
+ lenient_parse=True,
92
+ ),
93
+ }
94
+ if benchmark not in presets:
95
+ raise ValueError(f"unknown benchmark {benchmark!r}; known: {sorted(presets)}")
96
+ return replace(presets[benchmark], **overrides)
97
+
98
+
99
+ class Turn(NamedTuple):
100
+ image_url: str
101
+ reasoning: str
102
+ action_text: str
103
+
104
+
105
+ @dataclass
106
+ class Decision:
107
+ """The outcome of one :meth:`GameScalingPolicy.act` call."""
108
+
109
+ action: Action
110
+ text: str
111
+ reasoning: str
112
+ latency_ms: float
113
+ finish_reason: str | None = None
114
+ completion_tokens: int | None = None
115
+ error: str | None = None
116
+
117
+
118
+ def encode_image(image: Image.Image, cfg: PolicyConfig) -> str:
119
+ """Resize + encode a frame into the data URL the request carries."""
120
+ img = image
121
+ if cfg.image_size is not None and img.size != tuple(cfg.image_size):
122
+ img = img.resize(tuple(cfg.image_size), _RESAMPLE[cfg.resample])
123
+ elif cfg.image_height and img.height != cfg.image_height:
124
+ width = max(1, round(img.width * cfg.image_height / img.height))
125
+ img = img.resize((width, cfg.image_height), _RESAMPLE[cfg.resample])
126
+ buf = io.BytesIO()
127
+ if cfg.image_format == "png":
128
+ img.convert("RGB").save(buf, format="PNG")
129
+ mime = "image/png"
130
+ else:
131
+ img.convert("RGB").save(buf, format="JPEG", quality=cfg.jpeg_quality)
132
+ mime = "image/jpeg"
133
+ return f"data:{mime};base64," + base64.b64encode(buf.getvalue()).decode("ascii")
134
+
135
+
136
+ def user_turn(image_url: str) -> dict:
137
+ return {"role": "user", "content": [
138
+ {"type": "text", "text": USER_TURN_TEXT},
139
+ {"type": "image_url", "image_url": {"url": image_url}},
140
+ ]}
141
+
142
+
143
+ def assistant_turn(action_text: str, reasoning: str = "") -> dict:
144
+ if reasoning:
145
+ action_text = f"{THINK_OPEN}\n{reasoning.strip()}\n</think>\n\n{action_text}"
146
+ return {"role": "assistant", "content": action_text}
147
+
148
+
149
+ def build_request(messages: list[dict], cfg: PolicyConfig) -> dict:
150
+ """OpenAI-compatible /chat/completions body with the vLLM extensions we rely on."""
151
+ body: dict[str, Any] = {
152
+ "model": cfg.model,
153
+ "messages": list(messages),
154
+ "temperature": cfg.temperature,
155
+ "max_tokens": cfg.max_tokens,
156
+ # The action tags are special tokens; keep them in the decoded text.
157
+ "skip_special_tokens": False,
158
+ }
159
+ if cfg.stop:
160
+ body["stop"] = list(cfg.stop)
161
+ if cfg.stop_token_ids:
162
+ body["stop_token_ids"] = list(cfg.stop_token_ids)
163
+ if cfg.include_stop_str_in_output:
164
+ body["include_stop_str_in_output"] = True
165
+ if cfg.think_prefill:
166
+ body["messages"].append({"role": "assistant", "content": THINK_OPEN})
167
+ body["continue_final_message"] = True
168
+ body["add_generation_prompt"] = False
169
+ return body
170
+
171
+
172
+ def finalize(text: str, finish_reason: str | None, cfg: PolicyConfig) -> str:
173
+ """Undo what the request itself did to the reply.
174
+
175
+ The prefill is not part of the returned text, and a stop string is removed
176
+ from it. Both are restored so the reply parses the same way as training data.
177
+ """
178
+ text = text or ""
179
+ if cfg.think_prefill and not text.lstrip().startswith(THINK_OPEN):
180
+ text = THINK_OPEN + text
181
+ _, tail, closed = split_reasoning(text)
182
+ if closed and ACTION_START not in tail:
183
+ bare = tail.strip()
184
+ if re.match(r"^-?\d", bare) and ";" in bare:
185
+ text = text[: len(text) - len(tail)] + ACTION_START + bare
186
+ if (finish_reason == "stop" and ACTION_START in text
187
+ and ACTION_END not in text[text.rfind(ACTION_START):]):
188
+ text += ACTION_END
189
+ return text
190
+
191
+
192
+ class GameScalingPolicy:
193
+ """Stateful client: call :meth:`reset` at episode start, :meth:`act` per 200 ms."""
194
+
195
+ def __init__(self, system_prompt: str, config: PolicyConfig | None = None):
196
+ self.system_prompt = system_prompt
197
+ self.cfg = config or PolicyConfig()
198
+ self._history: deque[Turn] = deque()
199
+ self._session = requests.Session()
200
+
201
+ @property
202
+ def base_url(self) -> str:
203
+ return self.cfg.base_url.rstrip("/")
204
+
205
+ def reset(self) -> None:
206
+ self._history.clear()
207
+
208
+ def health_check(self) -> bool:
209
+ try:
210
+ r = self._session.get(f"{self.base_url}/models", timeout=10,
211
+ headers={"Authorization": f"Bearer {self.cfg.api_key}"})
212
+ return r.status_code < 400
213
+ except requests.RequestException:
214
+ return False
215
+
216
+ def messages(self, image_url: str) -> list[dict]:
217
+ out: list[dict] = [{"role": "system", "content": self.system_prompt}] if self.system_prompt else []
218
+ n = len(self._history)
219
+ for i, turn in enumerate(self._history):
220
+ out.append(user_turn(turn.image_url))
221
+ age = n - i
222
+ keep = self.cfg.history_think < 0 or age <= self.cfg.history_think
223
+ out.append(assistant_turn(turn.action_text, turn.reasoning if keep else ""))
224
+ out.append(user_turn(image_url))
225
+ return out
226
+
227
+ def act(self, image: Image.Image) -> Decision:
228
+ url = encode_image(image, self.cfg)
229
+ body = build_request(self.messages(url), self.cfg)
230
+ t0 = time.perf_counter()
231
+ text, finish, tokens, error = "", None, None, None
232
+ try:
233
+ r = self._session.post(f"{self.base_url}/chat/completions", json=body,
234
+ timeout=self.cfg.timeout,
235
+ headers={"Authorization": f"Bearer {self.cfg.api_key}"})
236
+ if r.status_code >= 400:
237
+ raise requests.HTTPError(f"HTTP {r.status_code}: {r.text[:500]}")
238
+ payload = r.json()
239
+ choice = (payload.get("choices") or [{}])[0]
240
+ text = (choice.get("message") or {}).get("content") or ""
241
+ finish = choice.get("finish_reason")
242
+ tokens = (payload.get("usage") or {}).get("completion_tokens")
243
+ except (requests.RequestException, ValueError, KeyError) as exc:
244
+ error = str(exc)
245
+ logger.error("policy request failed: %s", exc)
246
+ latency_ms = (time.perf_counter() - t0) * 1000
247
+ text = finalize(text, finish, self.cfg) if not error else ""
248
+ action = parse_action(text, lenient=self.cfg.lenient_parse)
249
+ reasoning, _, closed = split_reasoning(text)
250
+ self._history.append(Turn(url, reasoning if closed else "", action.history_text))
251
+ while len(self._history) > self.cfg.history_len:
252
+ self._history.popleft()
253
+ return Decision(action=action, text=text, reasoning=reasoning, latency_ms=latency_ms,
254
+ finish_reason=finish, completion_tokens=tokens, error=error)
gamescaling/prompt.py ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """System prompts for GameScaling checkpoints.
2
+
3
+ All three benchmarks in the paper use the same skeleton, in this order:
4
+
5
+ 1. opening: gaming expert, the game's name, the 200 ms / 6 x 33 ms contract;
6
+ 2. ``**Game Rules**``: what the game is and how it is scored;
7
+ 3. controls: the keys this game uses, written in the training vocabulary;
8
+ 4. ``**Task Instruction**`` (GameWorld only: one game has several tasks);
9
+ 5. ``**Output Format**``: plain, or the empty-think / think+action variant when
10
+ the client lets the model reason;
11
+ 6. ``**Explanation**`` + ``**Key Naming Rules**``.
12
+
13
+ Only the wording of the controls section and the separators differ between the
14
+ two layouts below. Copy the strings, do not paraphrase them: the checkpoints key
15
+ their output tag off the exact Output Format section.
16
+ """
17
+
18
+ from __future__ import annotations
19
+
20
+ import re
21
+ from collections.abc import Iterable
22
+
23
+ from .keymaps import PLAYWRIGHT_TO_TOKEN
24
+
25
+ OPENING = (
26
+ "You are a gaming expert, and you are currently playing {name}. You are "
27
+ "proficient in keyboard and mouse operations. You understand game mechanics "
28
+ "and combat pacing, can quickly extract key information from the current "
29
+ "screen, and can think and make precise decisions at critical moments. Based "
30
+ "on the current screen, plan the next 200ms of actions, consisting of 6 steps "
31
+ "spaced 33ms apart. Each step lasts 33ms, until the next step begins. If the "
32
+ "current situation continues the previous strategy, output the action "
33
+ "directly. Think only when the situation changes significantly, the previous "
34
+ "analysis is no longer valid, or a new objective appears."
35
+ )
36
+
37
+ OUTPUT_FORMAT_PLAIN = (
38
+ "<|action_start|>X Y Z ; k1 k2 k3 ; k4 k5 ; k6 ; k7 ; k8 ; k9 k10<|action_end|>"
39
+ )
40
+ OUTPUT_FORMAT_THINK = (
41
+ "**Action only (usual)**\n"
42
+ "<think></think><|action_start|>X Y Z ; k1 k2 k3 ; k4 k5 ; k6 ; k7 ; k8 ; k9 k10"
43
+ "<|action_end|>\n"
44
+ "**Thinking + action (when necessary)**\n"
45
+ "<think>reasoning</think><|action_start|>X Y Z ; k1 k2 k3 ; k4 k5 ; k6 ; k7 ; k8 ; k9 k10"
46
+ "<|action_end|>"
47
+ )
48
+
49
+ TAIL = (
50
+ "**Explanation**\n"
51
+ "1. **Mouse Movement**: First, specify the relative displacement X, Y (X>0 means "
52
+ "move right, Y>0 means move down) and scroll amount Z (Z>0 means scroll up).\n"
53
+ "2. **Key Sequence**: Then list 6 groups of keys; within each group, keys are "
54
+ "separated by spaces, and groups are separated by semicolons.\n"
55
+ "- Each group can contain up to 4 keys.\n"
56
+ "- If a group has no keys, leave it empty but keep the `;`.\n"
57
+ "3. Only output a plain string that conforms to the above format — no line breaks "
58
+ "and no quotation marks.\n"
59
+ "**Key Naming Rules**\n"
60
+ "- Number keys `0-9`: use lowercase English words, e.g., `zero` for `0`, `one` for `1`, "
61
+ "... `nine` for `9`.\n"
62
+ "- Function keys `F1-F12`: use capitalized English words, e.g., `One` represents `F1`, "
63
+ "`Two` represents `F2`, and so on.\n"
64
+ "- Mouse buttons: use `LB`, `RB`, `MB` for the left, right, and middle mouse button.\n"
65
+ "- Letters: use the uppercase letter, e.g., `A`, `D`, `W`, `S`.\n"
66
+ "- Arrow keys: use `Up`, `Down`, `Left`, `Right`.\n"
67
+ "- Modifier/special keys: `Shift`, `Ctrl`, `Alt`, `Tab`, `Caps`, `Esc`, `Space`, "
68
+ "`Enter`, `Back` (backspace), `Delete`, `Insert`, `Home`, `End`, `Pause`."
69
+ )
70
+
71
+ MOUSE_AIM_LINE = "- Mouse X Y -> aim / rotate the camera (X>0 right, Y>0 down)"
72
+ _MOUSE_BUTTON_ALIASES = {"LMB": "LB", "RMB": "RB", "MMB": "MB"}
73
+
74
+ # Default inference prompt: no game name, no rules. The user turn is one game
75
+ # frame labeled "current game screen". Named games use `build_system_prompt`.
76
+ TRAINING_SYSTEM_PROMPT = '''You are an experienced PC game player, proficient in keyboard and mouse operations. Based on the current game screen and the corresponding historical trajectory, plan the next 200ms of actions, consisting of 6 steps. Each step is spaced 33ms apart. Every step lasts 33ms from its start time until the next step begins.
77
+ **Output Format**
78
+ <|action_start|>X Y Z ; k1 k2 k3 ; k4 k5 ; k6 ; k7 ; k8 ; k9 k10<|action_end|>
79
+ **Explanation**
80
+ 1. **Mouse Movement**: First, specify the relative displacement X, Y (X>0 means move right, Y>0
81
+ means move down) and scroll amount Z (Z>0 means scroll up).
82
+ 2. **Key Sequence**: Then list 6 groups of keys; within each group, keys are separated by spaces,
83
+ and groups are separated by semicolons.
84
+ - Each group can contain up to 4 keys.
85
+ - If a group has no keys, leave it empty but keep the `;`.
86
+ 3. Only output a plain string that conforms to the above format — no line breaks and no quotation marks.
87
+ **Key Naming Rules**
88
+ - Number keys `1-9`: use lowercase English words, e.g., `one` represents the `1` key on the keyboard.
89
+ - Function keys `F1-F12`: use capitalized English words, e.g., `One` represents `F1`, `Two` represents `F2`, and so on.
90
+ - Other keys (letters, Shift, Tab, Space, etc.): use the real keyboard name with an initial capital letter, e.g., `A`, `D`, `Shift`, `Space`, etc.'''
91
+
92
+ USER_TURN_TEXT = "current game screen"
93
+
94
+
95
+ def _output_format(reasoning: bool) -> str:
96
+ return OUTPUT_FORMAT_THINK if reasoning else OUTPUT_FORMAT_PLAIN
97
+
98
+
99
+ def build_system_prompt(
100
+ game_name: str,
101
+ *,
102
+ rules: str | None = None,
103
+ key_bindings: Iterable[tuple[str, str]] | dict[str, str] | None = None,
104
+ mouse_aim: bool = True,
105
+ reasoning: bool = False,
106
+ ) -> str:
107
+ """Key-list layout for a named game (ViZDoom, OmniGameArena, or a new game).
108
+
109
+ ``key_bindings`` maps training tokens to what they do, e.g.
110
+ ``{"W": "Move forward", "LB": "Fire"}``; ``LMB``/``RMB``/``MMB`` are accepted
111
+ as aliases of ``LB``/``RB``/``MB``. ``mouse_aim`` adds the camera line for
112
+ games that are steered with the mouse. ``reasoning`` must match whether the
113
+ client prefills ``<think>`` (see ``PolicyConfig.think_prefill``).
114
+ """
115
+ parts = [OPENING.format(name=game_name)]
116
+ if rules and rules.strip():
117
+ parts.append("**Game Rules**\n" + rules.strip())
118
+ items = key_bindings.items() if isinstance(key_bindings, dict) else (key_bindings or ())
119
+ common = [f"- {_MOUSE_BUTTON_ALIASES.get(k, k)} -> {v}" for k, v in items]
120
+ if mouse_aim:
121
+ common.append(MOUSE_AIM_LINE)
122
+ if common:
123
+ parts.append(f"**Common Keys in {game_name}**\n" + "\n".join(common))
124
+ parts.append("**Output Format**\n" + _output_format(reasoning))
125
+ parts.append(TAIL)
126
+ return "\n".join(parts)
127
+
128
+
129
+ def build_gameworld_system_prompt(
130
+ game_name: str | None,
131
+ *,
132
+ rules: str | None = None,
133
+ controls: str | None = None,
134
+ task: str | None = None,
135
+ reasoning: bool = False,
136
+ ) -> str:
137
+ """Free-text layout (GameWorld): rules, role/controls and task as paragraphs.
138
+
139
+ ``controls`` must already use training key names; see
140
+ :func:`translate_controls`.
141
+ """
142
+ opening = OPENING if game_name else OPENING.replace(", and you are currently playing {name}", "")
143
+ out = opening.format(name=game_name) + "\n"
144
+ if rules:
145
+ out += "\n**Game Rules**\n" + rules + "\n"
146
+ if controls:
147
+ out += "\n**Role and Controls**\n" + controls + "\n"
148
+ if task:
149
+ out += "\n**Task Instruction**\n" + task + "\n"
150
+ out += "\n**Output Format**\n" + _output_format(reasoning) + "\n" + TAIL
151
+ return out.strip()
152
+
153
+
154
+ _PW_TO_TOKEN = PLAYWRIGHT_TO_TOKEN
155
+ _PW_KEY_RE = re.compile(r"\b(" + "|".join(map(re.escape, _PW_TO_TOKEN)) + r")\b")
156
+ _DIGIT_WORD = {"0": "zero", "1": "one", "2": "two", "3": "three", "4": "four",
157
+ "5": "five", "6": "six", "7": "seven", "8": "eight", "9": "nine"}
158
+ _COMBO_SLASH_RE = re.compile(r"(?<![A-Za-z0-9])([A-Za-z])\s*/\s*([A-Za-z])(?![A-Za-z0-9])")
159
+ _COMBO_PLUS_RE = re.compile(r"(?<![A-Za-z0-9])([A-Za-z])\s*\+\s*([A-Za-z])(?![A-Za-z0-9])")
160
+ _LIST_LETTER_RE = re.compile(r"(?m)^(\s*-\s*)([a-z])(?=\s*[:/+])")
161
+ _COLON_LETTER_RE = re.compile(r"(?<![A-Za-z0-9])([a-z])(?=\s*:)")
162
+ _DIGIT_RANGE_RE = re.compile(r"(?<![A-Za-z0-9])(\d)\s*-\s*(\d)(?=\s*:)")
163
+ _LIST_DIGIT_RE = re.compile(r"(?m)^(\s*-\s*)(\d)(?=\s*[:/])")
164
+
165
+
166
+ def translate_controls(text: str | None) -> str:
167
+ """Rewrite a controls paragraph from browser key names into training tokens.
168
+
169
+ ``ArrowLeft`` -> ``Left``, ``Escape`` -> ``Esc``, ...; single letters become
170
+ upper case and digits become words, but only where they stand as keys
171
+ (``a/d``, ``w + a``, ``- r:``, ``1-9:``) so prose is left alone.
172
+ """
173
+ if not text:
174
+ return ""
175
+ out = _PW_KEY_RE.sub(lambda m: _PW_TO_TOKEN[m.group(1)], str(text))
176
+ out = _DIGIT_RANGE_RE.sub(lambda m: f"{_DIGIT_WORD[m.group(1)]}-{_DIGIT_WORD[m.group(2)]}", out)
177
+ out = _LIST_DIGIT_RE.sub(lambda m: m.group(1) + _DIGIT_WORD[m.group(2)], out)
178
+ out = _COMBO_SLASH_RE.sub(lambda m: f"{m.group(1).upper()}/{m.group(2).upper()}", out)
179
+ out = _COMBO_PLUS_RE.sub(lambda m: f"{m.group(1).upper()} + {m.group(2).upper()}", out)
180
+ out = _LIST_LETTER_RE.sub(lambda m: m.group(1) + m.group(2).upper(), out)
181
+ out = _COLON_LETTER_RE.sub(lambda m: m.group(1).upper(), out)
182
+ return out
models/0p8b_s1_1600h_gs6736/chat_template.jinja ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- set image_count = namespace(value=0) %}
2
+ {%- set video_count = namespace(value=0) %}
3
+ {%- macro render_content(content, do_vision_count, is_system_content=false) %}
4
+ {%- if content is string %}
5
+ {{- content }}
6
+ {%- elif content is iterable and content is not mapping %}
7
+ {%- for item in content %}
8
+ {%- if 'image' in item or 'image_url' in item or item.type == 'image' %}
9
+ {%- if is_system_content %}
10
+ {{- raise_exception('System message cannot contain images.') }}
11
+ {%- endif %}
12
+ {%- if do_vision_count %}
13
+ {%- set image_count.value = image_count.value + 1 %}
14
+ {%- endif %}
15
+ {%- if add_vision_id %}
16
+ {{- 'Picture ' ~ image_count.value ~ ': ' }}
17
+ {%- endif %}
18
+ {{- '<|vision_start|><|image_pad|><|vision_end|>' }}
19
+ {%- elif 'video' in item or item.type == 'video' %}
20
+ {%- if is_system_content %}
21
+ {{- raise_exception('System message cannot contain videos.') }}
22
+ {%- endif %}
23
+ {%- if do_vision_count %}
24
+ {%- set video_count.value = video_count.value + 1 %}
25
+ {%- endif %}
26
+ {%- if add_vision_id %}
27
+ {{- 'Video ' ~ video_count.value ~ ': ' }}
28
+ {%- endif %}
29
+ {{- '<|vision_start|><|video_pad|><|vision_end|>' }}
30
+ {%- elif 'text' in item %}
31
+ {{- item.text }}
32
+ {%- else %}
33
+ {{- raise_exception('Unexpected item type in content.') }}
34
+ {%- endif %}
35
+ {%- endfor %}
36
+ {%- elif content is none or content is undefined %}
37
+ {{- '' }}
38
+ {%- else %}
39
+ {{- raise_exception('Unexpected content type.') }}
40
+ {%- endif %}
41
+ {%- endmacro %}
42
+ {#- ICLR27-GameScaling CPT permissive template:
43
+ - 去掉原 Qwen3.5 模板对 "user query" 的强制断言(逐轮套模板会遇到无 user 的单轮)。
44
+ - 去掉 assistant 轮的 <think> 注入(该注入依赖全局 last_query_index, 会使
45
+ "逐轮拼接 != 整体" 从而破坏 MultiTurnSFTDataset.sanity_check 与 loss 掩码对齐)。
46
+ - 去掉原模板的 `{%- if not messages %}` 空判断: 本管线把 messages 以 numpy object-array
47
+ 传入, `not <ndarray>` 会触发 "truth value of an array ... is ambiguous"。 #}
48
+ {%- if tools and tools is iterable and tools is not mapping %}
49
+ {{- '<|im_start|>system\n' }}
50
+ {{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
51
+ {%- for tool in tools %}
52
+ {{- "\n" }}
53
+ {{- tool | tojson }}
54
+ {%- endfor %}
55
+ {{- "\n</tools>" }}
56
+ {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
57
+ {%- if messages[0].role == 'system' %}
58
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
59
+ {%- if content %}
60
+ {{- '\n\n' + content }}
61
+ {%- endif %}
62
+ {%- endif %}
63
+ {{- '<|im_end|>\n' }}
64
+ {%- else %}
65
+ {%- if messages[0].role == 'system' %}
66
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
67
+ {{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}
68
+ {%- endif %}
69
+ {%- endif %}
70
+ {%- for message in messages %}
71
+ {%- set content = render_content(message.content, true)|trim %}
72
+ {%- if message.role == "system" %}
73
+ {%- if not loop.first %}
74
+ {{- raise_exception('System message must be at the beginning.') }}
75
+ {%- endif %}
76
+ {%- elif message.role == "user" %}
77
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
78
+ {%- elif message.role == "assistant" %}
79
+ {#- ICLR27 think 处理(逐轮、常量、不依赖跨轮 index => 不破坏 sanity_check 与 loss 掩码):
80
+ - 若该轮本身已带 <think>(如 zebra_cot 推理数据): 原样保留其真实思维链, 不再注入,
81
+ 避免拼成"空 think + 真 think"的双块(那会破坏 Qwen 原生"恰好一个 think 块"结构)。
82
+ - 否则(VPT/游戏/普通 VL 等无 think 的轮): 注入 Qwen 原生"空 think"块 <think>\n\n</think>\n\n,
83
+ 训练无 think GT 只保结构, ���模型仍会输出 <think>...</think>, 不破坏原生思考通路;
84
+ inference 端由生成提示(下方 add_generation_prompt, 不注入)自由填充思考内容。 #}
85
+ {%- if '<think>' in content or '</think>' in content %}
86
+ {{- '<|im_start|>' + message.role + '\n' + content }}
87
+ {%- else %}
88
+ {{- '<|im_start|>' + message.role + '\n' + '<think>\n\n</think>\n\n' + content }}
89
+ {%- endif %}
90
+ {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
91
+ {%- for tool_call in message.tool_calls %}
92
+ {%- if tool_call.function is defined %}
93
+ {%- set tool_call = tool_call.function %}
94
+ {%- endif %}
95
+ {%- if loop.first %}
96
+ {%- if content|trim %}
97
+ {{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
98
+ {%- else %}
99
+ {{- '<tool_call>\n<function=' + tool_call.name + '>\n' }}
100
+ {%- endif %}
101
+ {%- else %}
102
+ {{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
103
+ {%- endif %}
104
+ {%- if tool_call.arguments is defined %}
105
+ {%- for args_name, args_value in tool_call.arguments|items %}
106
+ {{- '<parameter=' + args_name + '>\n' }}
107
+ {%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}
108
+ {{- args_value }}
109
+ {{- '\n</parameter>\n' }}
110
+ {%- endfor %}
111
+ {%- endif %}
112
+ {{- '</function>\n</tool_call>' }}
113
+ {%- endfor %}
114
+ {%- endif %}
115
+ {{- '<|im_end|>\n' }}
116
+ {%- elif message.role == "tool" %}
117
+ {%- if loop.previtem and loop.previtem.role != "tool" %}
118
+ {{- '<|im_start|>user' }}
119
+ {%- endif %}
120
+ {{- '\n<tool_response>\n' }}
121
+ {{- content }}
122
+ {{- '\n</tool_response>' }}
123
+ {%- if not loop.last and loop.nextitem.role != "tool" %}
124
+ {{- '<|im_end|>\n' }}
125
+ {%- elif loop.last %}
126
+ {{- '<|im_end|>\n' }}
127
+ {%- endif %}
128
+ {%- else %}
129
+ {{- raise_exception('Unexpected message role.') }}
130
+ {%- endif %}
131
+ {%- endfor %}
132
+ {%- if add_generation_prompt %}
133
+ {{- '<|im_start|>assistant\n' }}
134
+ {%- endif %}
models/0p8b_s1_1600h_gs6736/config.json ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen3_5ForConditionalGeneration"
4
+ ],
5
+ "bos_token_id": null,
6
+ "dtype": "bfloat16",
7
+ "eos_token_id": 248046,
8
+ "image_token_id": 248056,
9
+ "model_type": "qwen3_5",
10
+ "pad_token_id": 248044,
11
+ "text_config": {
12
+ "attention_bias": false,
13
+ "attention_dropout": 0.0,
14
+ "attn_output_gate": true,
15
+ "bos_token_id": null,
16
+ "dtype": "bfloat16",
17
+ "eos_token_id": 248044,
18
+ "full_attention_interval": 4,
19
+ "head_dim": 256,
20
+ "hidden_act": "silu",
21
+ "hidden_size": 1024,
22
+ "initializer_range": 0.02,
23
+ "intermediate_size": 3584,
24
+ "layer_types": [
25
+ "linear_attention",
26
+ "linear_attention",
27
+ "linear_attention",
28
+ "full_attention",
29
+ "linear_attention",
30
+ "linear_attention",
31
+ "linear_attention",
32
+ "full_attention",
33
+ "linear_attention",
34
+ "linear_attention",
35
+ "linear_attention",
36
+ "full_attention",
37
+ "linear_attention",
38
+ "linear_attention",
39
+ "linear_attention",
40
+ "full_attention",
41
+ "linear_attention",
42
+ "linear_attention",
43
+ "linear_attention",
44
+ "full_attention",
45
+ "linear_attention",
46
+ "linear_attention",
47
+ "linear_attention",
48
+ "full_attention"
49
+ ],
50
+ "linear_conv_kernel_dim": 4,
51
+ "linear_key_head_dim": 128,
52
+ "linear_num_key_heads": 16,
53
+ "linear_num_value_heads": 16,
54
+ "linear_value_head_dim": 128,
55
+ "mamba_ssm_dtype": "float32",
56
+ "max_position_embeddings": 262144,
57
+ "mlp_only_layers": [],
58
+ "model_type": "qwen3_5_text",
59
+ "mtp_num_hidden_layers": 1,
60
+ "mtp_use_dedicated_embeddings": false,
61
+ "num_attention_heads": 8,
62
+ "num_hidden_layers": 24,
63
+ "num_key_value_heads": 2,
64
+ "pad_token_id": null,
65
+ "partial_rotary_factor": 0.25,
66
+ "rms_norm_eps": 1e-06,
67
+ "rope_parameters": {
68
+ "mrope_interleaved": true,
69
+ "mrope_section": [
70
+ 11,
71
+ 11,
72
+ 10
73
+ ],
74
+ "partial_rotary_factor": 0.25,
75
+ "rope_theta": 10000000,
76
+ "rope_type": "default"
77
+ },
78
+ "tie_word_embeddings": true,
79
+ "use_cache": true,
80
+ "vocab_size": 248320
81
+ },
82
+ "tie_word_embeddings": true,
83
+ "transformers_version": "5.14.1",
84
+ "video_token_id": 248057,
85
+ "vision_config": {
86
+ "deepstack_visual_indexes": [],
87
+ "depth": 12,
88
+ "dtype": "bfloat16",
89
+ "hidden_act": "gelu_pytorch_tanh",
90
+ "hidden_size": 768,
91
+ "in_channels": 3,
92
+ "initializer_range": 0.02,
93
+ "intermediate_size": 3072,
94
+ "model_type": "qwen3_5_vision",
95
+ "num_heads": 12,
96
+ "num_position_embeddings": 2304,
97
+ "out_hidden_size": 1024,
98
+ "patch_size": 16,
99
+ "spatial_merge_size": 2,
100
+ "temporal_patch_size": 2
101
+ },
102
+ "vision_end_token_id": 248054,
103
+ "vision_start_token_id": 248053
104
+ }
models/0p8b_s1_1600h_gs6736/generation_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "eos_token_id": 248046,
4
+ "output_attentions": false,
5
+ "output_hidden_states": false,
6
+ "pad_token_id": 248044,
7
+ "transformers_version": "5.14.1",
8
+ "use_cache": true
9
+ }
models/0p8b_s1_1600h_gs6736/preprocessor_config.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "size": {
3
+ "longest_edge": 16777216,
4
+ "shortest_edge": 65536
5
+ },
6
+ "patch_size": 16,
7
+ "temporal_patch_size": 2,
8
+ "merge_size": 2,
9
+ "image_mean": [
10
+ 0.5,
11
+ 0.5,
12
+ 0.5
13
+ ],
14
+ "image_std": [
15
+ 0.5,
16
+ 0.5,
17
+ 0.5
18
+ ],
19
+ "processor_class": "Qwen3VLProcessor",
20
+ "image_processor_type": "Qwen2VLImageProcessorFast"
21
+ }
models/0p8b_s1_1600h_gs6736/processor_config.json ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "image_processor": {
3
+ "do_convert_rgb": true,
4
+ "do_normalize": true,
5
+ "do_rescale": true,
6
+ "do_resize": true,
7
+ "image_mean": [
8
+ 0.5,
9
+ 0.5,
10
+ 0.5
11
+ ],
12
+ "image_processor_type": "Qwen2VLImageProcessor",
13
+ "image_std": [
14
+ 0.5,
15
+ 0.5,
16
+ 0.5
17
+ ],
18
+ "merge_size": 2,
19
+ "patch_size": 16,
20
+ "resample": 3,
21
+ "rescale_factor": 0.00392156862745098,
22
+ "size": {
23
+ "longest_edge": 16777216,
24
+ "shortest_edge": 65536
25
+ },
26
+ "temporal_patch_size": 2
27
+ },
28
+ "processor_class": "Qwen3VLProcessor",
29
+ "video_processor": {
30
+ "do_convert_rgb": true,
31
+ "do_normalize": true,
32
+ "do_rescale": true,
33
+ "do_resize": true,
34
+ "do_sample_frames": true,
35
+ "fps": 2,
36
+ "image_mean": [
37
+ 0.5,
38
+ 0.5,
39
+ 0.5
40
+ ],
41
+ "image_std": [
42
+ 0.5,
43
+ 0.5,
44
+ 0.5
45
+ ],
46
+ "max_frames": 768,
47
+ "merge_size": 2,
48
+ "min_frames": 4,
49
+ "patch_size": 16,
50
+ "resample": 3,
51
+ "rescale_factor": 0.00392156862745098,
52
+ "return_metadata": false,
53
+ "size": {
54
+ "longest_edge": 25165824,
55
+ "shortest_edge": 4096
56
+ },
57
+ "temporal_patch_size": 2,
58
+ "video_processor_type": "Qwen3VLVideoProcessor"
59
+ }
60
+ }
models/0p8b_s1_1600h_gs6736/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:06b9509352d2af50381ab2247e083b80d32d5c0aba91c272ca9ff729b6a0e523
3
+ size 19989325
models/0p8b_s1_1600h_gs6736/tokenizer_config.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "audio_bos_token": "<|audio_start|>",
4
+ "audio_eos_token": "<|audio_end|>",
5
+ "audio_token": "<|audio_pad|>",
6
+ "backend": "tokenizers",
7
+ "bos_token": null,
8
+ "clean_up_tokenization_spaces": false,
9
+ "eos_token": "<|im_end|>",
10
+ "errors": "replace",
11
+ "image_token": "<|image_pad|>",
12
+ "is_local": true,
13
+ "local_files_only": false,
14
+ "model_max_length": 262144,
15
+ "model_specific_special_tokens": {
16
+ "audio_bos_token": "<|audio_start|>",
17
+ "audio_eos_token": "<|audio_end|>",
18
+ "audio_token": "<|audio_pad|>",
19
+ "image_token": "<|image_pad|>",
20
+ "video_token": "<|video_pad|>",
21
+ "vision_bos_token": "<|vision_start|>",
22
+ "vision_eos_token": "<|vision_end|>"
23
+ },
24
+ "pad_token": "<|endoftext|>",
25
+ "pretokenize_regex": "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?[\\p{L}\\p{M}]+|\\p{N}| ?[^\\s\\p{L}\\p{M}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+",
26
+ "processor_class": "Qwen3VLProcessor",
27
+ "split_special_tokens": false,
28
+ "tokenizer_class": "Qwen2Tokenizer",
29
+ "unk_token": null,
30
+ "video_token": "<|video_pad|>",
31
+ "vision_bos_token": "<|vision_start|>",
32
+ "vision_eos_token": "<|vision_end|>"
33
+ }
models/0p8b_s1_1600h_gs6736/video_preprocessor_config.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "size": {
3
+ "longest_edge": 25165824,
4
+ "shortest_edge": 4096
5
+ },
6
+ "patch_size": 16,
7
+ "temporal_patch_size": 2,
8
+ "merge_size": 2,
9
+ "image_mean": [
10
+ 0.5,
11
+ 0.5,
12
+ 0.5
13
+ ],
14
+ "image_std": [
15
+ 0.5,
16
+ 0.5,
17
+ 0.5
18
+ ],
19
+ "processor_class": "Qwen3VLProcessor",
20
+ "video_processor_type": "Qwen3VLVideoProcessor"
21
+ }
models/0p8b_s3_1600h_gs6760/chat_template.jinja ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- set image_count = namespace(value=0) %}
2
+ {%- set video_count = namespace(value=0) %}
3
+ {%- macro render_content(content, do_vision_count, is_system_content=false) %}
4
+ {%- if content is string %}
5
+ {{- content }}
6
+ {%- elif content is iterable and content is not mapping %}
7
+ {%- for item in content %}
8
+ {%- if 'image' in item or 'image_url' in item or item.type == 'image' %}
9
+ {%- if is_system_content %}
10
+ {{- raise_exception('System message cannot contain images.') }}
11
+ {%- endif %}
12
+ {%- if do_vision_count %}
13
+ {%- set image_count.value = image_count.value + 1 %}
14
+ {%- endif %}
15
+ {%- if add_vision_id %}
16
+ {{- 'Picture ' ~ image_count.value ~ ': ' }}
17
+ {%- endif %}
18
+ {{- '<|vision_start|><|image_pad|><|vision_end|>' }}
19
+ {%- elif 'video' in item or item.type == 'video' %}
20
+ {%- if is_system_content %}
21
+ {{- raise_exception('System message cannot contain videos.') }}
22
+ {%- endif %}
23
+ {%- if do_vision_count %}
24
+ {%- set video_count.value = video_count.value + 1 %}
25
+ {%- endif %}
26
+ {%- if add_vision_id %}
27
+ {{- 'Video ' ~ video_count.value ~ ': ' }}
28
+ {%- endif %}
29
+ {{- '<|vision_start|><|video_pad|><|vision_end|>' }}
30
+ {%- elif 'text' in item %}
31
+ {{- item.text }}
32
+ {%- else %}
33
+ {{- raise_exception('Unexpected item type in content.') }}
34
+ {%- endif %}
35
+ {%- endfor %}
36
+ {%- elif content is none or content is undefined %}
37
+ {{- '' }}
38
+ {%- else %}
39
+ {{- raise_exception('Unexpected content type.') }}
40
+ {%- endif %}
41
+ {%- endmacro %}
42
+ {#- ICLR27-GameScaling CPT permissive template:
43
+ - 去掉原 Qwen3.5 模板对 "user query" 的强制断言(逐轮套模板会遇到无 user 的单轮)。
44
+ - 去掉 assistant 轮的 <think> 注入(该注入依赖全局 last_query_index, 会使
45
+ "逐轮拼接 != 整体" 从而破坏 MultiTurnSFTDataset.sanity_check 与 loss 掩码对齐)。
46
+ - 去掉原模板的 `{%- if not messages %}` 空判断: 本管线把 messages 以 numpy object-array
47
+ 传入, `not <ndarray>` 会触发 "truth value of an array ... is ambiguous"。 #}
48
+ {%- if tools and tools is iterable and tools is not mapping %}
49
+ {{- '<|im_start|>system\n' }}
50
+ {{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
51
+ {%- for tool in tools %}
52
+ {{- "\n" }}
53
+ {{- tool | tojson }}
54
+ {%- endfor %}
55
+ {{- "\n</tools>" }}
56
+ {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
57
+ {%- if messages[0].role == 'system' %}
58
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
59
+ {%- if content %}
60
+ {{- '\n\n' + content }}
61
+ {%- endif %}
62
+ {%- endif %}
63
+ {{- '<|im_end|>\n' }}
64
+ {%- else %}
65
+ {%- if messages[0].role == 'system' %}
66
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
67
+ {{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}
68
+ {%- endif %}
69
+ {%- endif %}
70
+ {%- for message in messages %}
71
+ {%- set content = render_content(message.content, true)|trim %}
72
+ {%- if message.role == "system" %}
73
+ {%- if not loop.first %}
74
+ {{- raise_exception('System message must be at the beginning.') }}
75
+ {%- endif %}
76
+ {%- elif message.role == "user" %}
77
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
78
+ {%- elif message.role == "assistant" %}
79
+ {#- ICLR27 think 处理(逐轮、常量、不依赖跨轮 index => 不破坏 sanity_check 与 loss 掩码):
80
+ - 若该轮本身已带 <think>(如 zebra_cot 推理数据): 原样保留其真实思维链, 不再注入,
81
+ 避免拼成"空 think + 真 think"的双块(那会破坏 Qwen 原生"恰好一个 think 块"结构)。
82
+ - 否则(VPT/游戏/普通 VL 等无 think 的轮): 注入 Qwen 原生"空 think"块 <think>\n\n</think>\n\n,
83
+ 训练无 think GT 只保结构, ���模型仍会输出 <think>...</think>, 不破坏原生思考通路;
84
+ inference 端由生成提示(下方 add_generation_prompt, 不注入)自由填充思考内容。 #}
85
+ {%- if '<think>' in content or '</think>' in content %}
86
+ {{- '<|im_start|>' + message.role + '\n' + content }}
87
+ {%- else %}
88
+ {{- '<|im_start|>' + message.role + '\n' + '<think>\n\n</think>\n\n' + content }}
89
+ {%- endif %}
90
+ {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
91
+ {%- for tool_call in message.tool_calls %}
92
+ {%- if tool_call.function is defined %}
93
+ {%- set tool_call = tool_call.function %}
94
+ {%- endif %}
95
+ {%- if loop.first %}
96
+ {%- if content|trim %}
97
+ {{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
98
+ {%- else %}
99
+ {{- '<tool_call>\n<function=' + tool_call.name + '>\n' }}
100
+ {%- endif %}
101
+ {%- else %}
102
+ {{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
103
+ {%- endif %}
104
+ {%- if tool_call.arguments is defined %}
105
+ {%- for args_name, args_value in tool_call.arguments|items %}
106
+ {{- '<parameter=' + args_name + '>\n' }}
107
+ {%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}
108
+ {{- args_value }}
109
+ {{- '\n</parameter>\n' }}
110
+ {%- endfor %}
111
+ {%- endif %}
112
+ {{- '</function>\n</tool_call>' }}
113
+ {%- endfor %}
114
+ {%- endif %}
115
+ {{- '<|im_end|>\n' }}
116
+ {%- elif message.role == "tool" %}
117
+ {%- if loop.previtem and loop.previtem.role != "tool" %}
118
+ {{- '<|im_start|>user' }}
119
+ {%- endif %}
120
+ {{- '\n<tool_response>\n' }}
121
+ {{- content }}
122
+ {{- '\n</tool_response>' }}
123
+ {%- if not loop.last and loop.nextitem.role != "tool" %}
124
+ {{- '<|im_end|>\n' }}
125
+ {%- elif loop.last %}
126
+ {{- '<|im_end|>\n' }}
127
+ {%- endif %}
128
+ {%- else %}
129
+ {{- raise_exception('Unexpected message role.') }}
130
+ {%- endif %}
131
+ {%- endfor %}
132
+ {%- if add_generation_prompt %}
133
+ {{- '<|im_start|>assistant\n' }}
134
+ {%- endif %}
models/0p8b_s3_1600h_gs6760/config.json ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen3_5ForConditionalGeneration"
4
+ ],
5
+ "bos_token_id": null,
6
+ "dtype": "bfloat16",
7
+ "eos_token_id": 248046,
8
+ "image_token_id": 248056,
9
+ "model_type": "qwen3_5",
10
+ "pad_token_id": 248044,
11
+ "text_config": {
12
+ "attention_bias": false,
13
+ "attention_dropout": 0.0,
14
+ "attn_output_gate": true,
15
+ "bos_token_id": null,
16
+ "dtype": "bfloat16",
17
+ "eos_token_id": 248044,
18
+ "full_attention_interval": 4,
19
+ "head_dim": 256,
20
+ "hidden_act": "silu",
21
+ "hidden_size": 1024,
22
+ "initializer_range": 0.02,
23
+ "intermediate_size": 3584,
24
+ "layer_types": [
25
+ "linear_attention",
26
+ "linear_attention",
27
+ "linear_attention",
28
+ "full_attention",
29
+ "linear_attention",
30
+ "linear_attention",
31
+ "linear_attention",
32
+ "full_attention",
33
+ "linear_attention",
34
+ "linear_attention",
35
+ "linear_attention",
36
+ "full_attention",
37
+ "linear_attention",
38
+ "linear_attention",
39
+ "linear_attention",
40
+ "full_attention",
41
+ "linear_attention",
42
+ "linear_attention",
43
+ "linear_attention",
44
+ "full_attention",
45
+ "linear_attention",
46
+ "linear_attention",
47
+ "linear_attention",
48
+ "full_attention"
49
+ ],
50
+ "linear_conv_kernel_dim": 4,
51
+ "linear_key_head_dim": 128,
52
+ "linear_num_key_heads": 16,
53
+ "linear_num_value_heads": 16,
54
+ "linear_value_head_dim": 128,
55
+ "mamba_ssm_dtype": "float32",
56
+ "max_position_embeddings": 262144,
57
+ "mlp_only_layers": [],
58
+ "model_type": "qwen3_5_text",
59
+ "mtp_num_hidden_layers": 1,
60
+ "mtp_use_dedicated_embeddings": false,
61
+ "num_attention_heads": 8,
62
+ "num_hidden_layers": 24,
63
+ "num_key_value_heads": 2,
64
+ "pad_token_id": null,
65
+ "partial_rotary_factor": 0.25,
66
+ "rms_norm_eps": 1e-06,
67
+ "rope_parameters": {
68
+ "mrope_interleaved": true,
69
+ "mrope_section": [
70
+ 11,
71
+ 11,
72
+ 10
73
+ ],
74
+ "partial_rotary_factor": 0.25,
75
+ "rope_theta": 10000000,
76
+ "rope_type": "default"
77
+ },
78
+ "tie_word_embeddings": true,
79
+ "use_cache": true,
80
+ "vocab_size": 248320
81
+ },
82
+ "tie_word_embeddings": true,
83
+ "transformers_version": "5.14.1",
84
+ "video_token_id": 248057,
85
+ "vision_config": {
86
+ "deepstack_visual_indexes": [],
87
+ "depth": 12,
88
+ "dtype": "bfloat16",
89
+ "hidden_act": "gelu_pytorch_tanh",
90
+ "hidden_size": 768,
91
+ "in_channels": 3,
92
+ "initializer_range": 0.02,
93
+ "intermediate_size": 3072,
94
+ "model_type": "qwen3_5_vision",
95
+ "num_heads": 12,
96
+ "num_position_embeddings": 2304,
97
+ "out_hidden_size": 1024,
98
+ "patch_size": 16,
99
+ "spatial_merge_size": 2,
100
+ "temporal_patch_size": 2
101
+ },
102
+ "vision_end_token_id": 248054,
103
+ "vision_start_token_id": 248053
104
+ }
models/0p8b_s3_1600h_gs6760/generation_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "eos_token_id": 248046,
4
+ "output_attentions": false,
5
+ "output_hidden_states": false,
6
+ "pad_token_id": 248044,
7
+ "transformers_version": "5.14.1",
8
+ "use_cache": true
9
+ }
models/0p8b_s3_1600h_gs6760/preprocessor_config.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "size": {
3
+ "longest_edge": 16777216,
4
+ "shortest_edge": 65536
5
+ },
6
+ "patch_size": 16,
7
+ "temporal_patch_size": 2,
8
+ "merge_size": 2,
9
+ "image_mean": [
10
+ 0.5,
11
+ 0.5,
12
+ 0.5
13
+ ],
14
+ "image_std": [
15
+ 0.5,
16
+ 0.5,
17
+ 0.5
18
+ ],
19
+ "processor_class": "Qwen3VLProcessor",
20
+ "image_processor_type": "Qwen2VLImageProcessorFast"
21
+ }
models/0p8b_s3_1600h_gs6760/processor_config.json ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "image_processor": {
3
+ "do_convert_rgb": true,
4
+ "do_normalize": true,
5
+ "do_rescale": true,
6
+ "do_resize": true,
7
+ "image_mean": [
8
+ 0.5,
9
+ 0.5,
10
+ 0.5
11
+ ],
12
+ "image_processor_type": "Qwen2VLImageProcessor",
13
+ "image_std": [
14
+ 0.5,
15
+ 0.5,
16
+ 0.5
17
+ ],
18
+ "merge_size": 2,
19
+ "patch_size": 16,
20
+ "resample": 3,
21
+ "rescale_factor": 0.00392156862745098,
22
+ "size": {
23
+ "longest_edge": 16777216,
24
+ "shortest_edge": 65536
25
+ },
26
+ "temporal_patch_size": 2
27
+ },
28
+ "processor_class": "Qwen3VLProcessor",
29
+ "video_processor": {
30
+ "do_convert_rgb": true,
31
+ "do_normalize": true,
32
+ "do_rescale": true,
33
+ "do_resize": true,
34
+ "do_sample_frames": true,
35
+ "fps": 2,
36
+ "image_mean": [
37
+ 0.5,
38
+ 0.5,
39
+ 0.5
40
+ ],
41
+ "image_std": [
42
+ 0.5,
43
+ 0.5,
44
+ 0.5
45
+ ],
46
+ "max_frames": 768,
47
+ "merge_size": 2,
48
+ "min_frames": 4,
49
+ "patch_size": 16,
50
+ "resample": 3,
51
+ "rescale_factor": 0.00392156862745098,
52
+ "return_metadata": false,
53
+ "size": {
54
+ "longest_edge": 25165824,
55
+ "shortest_edge": 4096
56
+ },
57
+ "temporal_patch_size": 2,
58
+ "video_processor_type": "Qwen3VLVideoProcessor"
59
+ }
60
+ }
models/0p8b_s3_1600h_gs6760/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:06b9509352d2af50381ab2247e083b80d32d5c0aba91c272ca9ff729b6a0e523
3
+ size 19989325
models/0p8b_s3_1600h_gs6760/tokenizer_config.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "audio_bos_token": "<|audio_start|>",
4
+ "audio_eos_token": "<|audio_end|>",
5
+ "audio_token": "<|audio_pad|>",
6
+ "backend": "tokenizers",
7
+ "bos_token": null,
8
+ "clean_up_tokenization_spaces": false,
9
+ "eos_token": "<|im_end|>",
10
+ "errors": "replace",
11
+ "image_token": "<|image_pad|>",
12
+ "is_local": true,
13
+ "local_files_only": false,
14
+ "model_max_length": 262144,
15
+ "model_specific_special_tokens": {
16
+ "audio_bos_token": "<|audio_start|>",
17
+ "audio_eos_token": "<|audio_end|>",
18
+ "audio_token": "<|audio_pad|>",
19
+ "image_token": "<|image_pad|>",
20
+ "video_token": "<|video_pad|>",
21
+ "vision_bos_token": "<|vision_start|>",
22
+ "vision_eos_token": "<|vision_end|>"
23
+ },
24
+ "pad_token": "<|endoftext|>",
25
+ "pretokenize_regex": "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?[\\p{L}\\p{M}]+|\\p{N}| ?[^\\s\\p{L}\\p{M}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+",
26
+ "processor_class": "Qwen3VLProcessor",
27
+ "split_special_tokens": false,
28
+ "tokenizer_class": "Qwen2Tokenizer",
29
+ "unk_token": null,
30
+ "video_token": "<|video_pad|>",
31
+ "vision_bos_token": "<|vision_start|>",
32
+ "vision_eos_token": "<|vision_end|>"
33
+ }
models/0p8b_s3_1600h_gs6760/video_preprocessor_config.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "size": {
3
+ "longest_edge": 25165824,
4
+ "shortest_edge": 4096
5
+ },
6
+ "patch_size": 16,
7
+ "temporal_patch_size": 2,
8
+ "merge_size": 2,
9
+ "image_mean": [
10
+ 0.5,
11
+ 0.5,
12
+ 0.5
13
+ ],
14
+ "image_std": [
15
+ 0.5,
16
+ 0.5,
17
+ 0.5
18
+ ],
19
+ "processor_class": "Qwen3VLProcessor",
20
+ "video_processor_type": "Qwen3VLVideoProcessor"
21
+ }
models/27b_s1_1600h_gs6995/chat_template.jinja ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- set image_count = namespace(value=0) %}
2
+ {%- set video_count = namespace(value=0) %}
3
+ {%- macro render_content(content, do_vision_count, is_system_content=false) %}
4
+ {%- if content is string %}
5
+ {{- content }}
6
+ {%- elif content is iterable and content is not mapping %}
7
+ {%- for item in content %}
8
+ {%- if 'image' in item or 'image_url' in item or item.type == 'image' %}
9
+ {%- if is_system_content %}
10
+ {{- raise_exception('System message cannot contain images.') }}
11
+ {%- endif %}
12
+ {%- if do_vision_count %}
13
+ {%- set image_count.value = image_count.value + 1 %}
14
+ {%- endif %}
15
+ {%- if add_vision_id %}
16
+ {{- 'Picture ' ~ image_count.value ~ ': ' }}
17
+ {%- endif %}
18
+ {{- '<|vision_start|><|image_pad|><|vision_end|>' }}
19
+ {%- elif 'video' in item or item.type == 'video' %}
20
+ {%- if is_system_content %}
21
+ {{- raise_exception('System message cannot contain videos.') }}
22
+ {%- endif %}
23
+ {%- if do_vision_count %}
24
+ {%- set video_count.value = video_count.value + 1 %}
25
+ {%- endif %}
26
+ {%- if add_vision_id %}
27
+ {{- 'Video ' ~ video_count.value ~ ': ' }}
28
+ {%- endif %}
29
+ {{- '<|vision_start|><|video_pad|><|vision_end|>' }}
30
+ {%- elif 'text' in item %}
31
+ {{- item.text }}
32
+ {%- else %}
33
+ {{- raise_exception('Unexpected item type in content.') }}
34
+ {%- endif %}
35
+ {%- endfor %}
36
+ {%- elif content is none or content is undefined %}
37
+ {{- '' }}
38
+ {%- else %}
39
+ {{- raise_exception('Unexpected content type.') }}
40
+ {%- endif %}
41
+ {%- endmacro %}
42
+ {#- ICLR27-GameScaling CPT permissive template:
43
+ - 去掉原 Qwen3.5 模板对 "user query" 的强制断言(逐轮套模板会遇到无 user 的单轮)。
44
+ - 去掉 assistant 轮的 <think> 注入(该注入依赖全局 last_query_index, 会使
45
+ "逐轮拼接 != 整体" 从而破坏 MultiTurnSFTDataset.sanity_check 与 loss 掩码对齐)。
46
+ - 去掉原模板的 `{%- if not messages %}` 空判断: 本管线把 messages 以 numpy object-array
47
+ 传入, `not <ndarray>` 会触发 "truth value of an array ... is ambiguous"。 #}
48
+ {%- if tools and tools is iterable and tools is not mapping %}
49
+ {{- '<|im_start|>system\n' }}
50
+ {{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
51
+ {%- for tool in tools %}
52
+ {{- "\n" }}
53
+ {{- tool | tojson }}
54
+ {%- endfor %}
55
+ {{- "\n</tools>" }}
56
+ {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
57
+ {%- if messages[0].role == 'system' %}
58
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
59
+ {%- if content %}
60
+ {{- '\n\n' + content }}
61
+ {%- endif %}
62
+ {%- endif %}
63
+ {{- '<|im_end|>\n' }}
64
+ {%- else %}
65
+ {%- if messages[0].role == 'system' %}
66
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
67
+ {{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}
68
+ {%- endif %}
69
+ {%- endif %}
70
+ {%- for message in messages %}
71
+ {%- set content = render_content(message.content, true)|trim %}
72
+ {%- if message.role == "system" %}
73
+ {%- if not loop.first %}
74
+ {{- raise_exception('System message must be at the beginning.') }}
75
+ {%- endif %}
76
+ {%- elif message.role == "user" %}
77
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
78
+ {%- elif message.role == "assistant" %}
79
+ {#- ICLR27 think 处理(逐轮、常量、不依赖跨轮 index => 不破坏 sanity_check 与 loss 掩码):
80
+ - 若该轮本身已带 <think>(如 zebra_cot 推理数据): 原样保留其真实思维链, 不再注入,
81
+ 避免拼成"空 think + 真 think"的双块(那会破坏 Qwen 原生"恰好一个 think 块"结构)。
82
+ - 否则(VPT/游戏/普通 VL 等无 think 的轮): 注入 Qwen 原生"空 think"块 <think>\n\n</think>\n\n,
83
+ 训练无 think GT 只保结构, ���模型仍会输出 <think>...</think>, 不破坏原生思考通路;
84
+ inference 端由生成提示(下方 add_generation_prompt, 不注入)自由填充思考内容。 #}
85
+ {%- if '<think>' in content or '</think>' in content %}
86
+ {{- '<|im_start|>' + message.role + '\n' + content }}
87
+ {%- else %}
88
+ {{- '<|im_start|>' + message.role + '\n' + '<think>\n\n</think>\n\n' + content }}
89
+ {%- endif %}
90
+ {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
91
+ {%- for tool_call in message.tool_calls %}
92
+ {%- if tool_call.function is defined %}
93
+ {%- set tool_call = tool_call.function %}
94
+ {%- endif %}
95
+ {%- if loop.first %}
96
+ {%- if content|trim %}
97
+ {{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
98
+ {%- else %}
99
+ {{- '<tool_call>\n<function=' + tool_call.name + '>\n' }}
100
+ {%- endif %}
101
+ {%- else %}
102
+ {{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
103
+ {%- endif %}
104
+ {%- if tool_call.arguments is defined %}
105
+ {%- for args_name, args_value in tool_call.arguments|items %}
106
+ {{- '<parameter=' + args_name + '>\n' }}
107
+ {%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}
108
+ {{- args_value }}
109
+ {{- '\n</parameter>\n' }}
110
+ {%- endfor %}
111
+ {%- endif %}
112
+ {{- '</function>\n</tool_call>' }}
113
+ {%- endfor %}
114
+ {%- endif %}
115
+ {{- '<|im_end|>\n' }}
116
+ {%- elif message.role == "tool" %}
117
+ {%- if loop.previtem and loop.previtem.role != "tool" %}
118
+ {{- '<|im_start|>user' }}
119
+ {%- endif %}
120
+ {{- '\n<tool_response>\n' }}
121
+ {{- content }}
122
+ {{- '\n</tool_response>' }}
123
+ {%- if not loop.last and loop.nextitem.role != "tool" %}
124
+ {{- '<|im_end|>\n' }}
125
+ {%- elif loop.last %}
126
+ {{- '<|im_end|>\n' }}
127
+ {%- endif %}
128
+ {%- else %}
129
+ {{- raise_exception('Unexpected message role.') }}
130
+ {%- endif %}
131
+ {%- endfor %}
132
+ {%- if add_generation_prompt %}
133
+ {{- '<|im_start|>assistant\n' }}
134
+ {%- endif %}
models/27b_s1_1600h_gs6995/config.json ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen3_5ForConditionalGeneration"
4
+ ],
5
+ "bos_token_id": null,
6
+ "dtype": "bfloat16",
7
+ "eos_token_id": 248046,
8
+ "image_token_id": 248056,
9
+ "model_type": "qwen3_5",
10
+ "pad_token_id": 248044,
11
+ "text_config": {
12
+ "attention_bias": false,
13
+ "attention_dropout": 0.0,
14
+ "attn_output_gate": true,
15
+ "bos_token_id": null,
16
+ "dtype": "bfloat16",
17
+ "eos_token_id": 248044,
18
+ "full_attention_interval": 4,
19
+ "head_dim": 256,
20
+ "hidden_act": "silu",
21
+ "hidden_size": 5120,
22
+ "initializer_range": 0.02,
23
+ "intermediate_size": 17408,
24
+ "layer_types": [
25
+ "linear_attention",
26
+ "linear_attention",
27
+ "linear_attention",
28
+ "full_attention",
29
+ "linear_attention",
30
+ "linear_attention",
31
+ "linear_attention",
32
+ "full_attention",
33
+ "linear_attention",
34
+ "linear_attention",
35
+ "linear_attention",
36
+ "full_attention",
37
+ "linear_attention",
38
+ "linear_attention",
39
+ "linear_attention",
40
+ "full_attention",
41
+ "linear_attention",
42
+ "linear_attention",
43
+ "linear_attention",
44
+ "full_attention",
45
+ "linear_attention",
46
+ "linear_attention",
47
+ "linear_attention",
48
+ "full_attention",
49
+ "linear_attention",
50
+ "linear_attention",
51
+ "linear_attention",
52
+ "full_attention",
53
+ "linear_attention",
54
+ "linear_attention",
55
+ "linear_attention",
56
+ "full_attention",
57
+ "linear_attention",
58
+ "linear_attention",
59
+ "linear_attention",
60
+ "full_attention",
61
+ "linear_attention",
62
+ "linear_attention",
63
+ "linear_attention",
64
+ "full_attention",
65
+ "linear_attention",
66
+ "linear_attention",
67
+ "linear_attention",
68
+ "full_attention",
69
+ "linear_attention",
70
+ "linear_attention",
71
+ "linear_attention",
72
+ "full_attention",
73
+ "linear_attention",
74
+ "linear_attention",
75
+ "linear_attention",
76
+ "full_attention",
77
+ "linear_attention",
78
+ "linear_attention",
79
+ "linear_attention",
80
+ "full_attention",
81
+ "linear_attention",
82
+ "linear_attention",
83
+ "linear_attention",
84
+ "full_attention",
85
+ "linear_attention",
86
+ "linear_attention",
87
+ "linear_attention",
88
+ "full_attention"
89
+ ],
90
+ "linear_conv_kernel_dim": 4,
91
+ "linear_key_head_dim": 128,
92
+ "linear_num_key_heads": 16,
93
+ "linear_num_value_heads": 48,
94
+ "linear_value_head_dim": 128,
95
+ "mamba_ssm_dtype": "float32",
96
+ "max_position_embeddings": 262144,
97
+ "mlp_only_layers": [],
98
+ "model_type": "qwen3_5_text",
99
+ "mtp_num_hidden_layers": 1,
100
+ "mtp_use_dedicated_embeddings": false,
101
+ "num_attention_heads": 24,
102
+ "num_hidden_layers": 64,
103
+ "num_key_value_heads": 4,
104
+ "pad_token_id": null,
105
+ "partial_rotary_factor": 0.25,
106
+ "rms_norm_eps": 1e-06,
107
+ "rope_parameters": {
108
+ "mrope_interleaved": true,
109
+ "mrope_section": [
110
+ 11,
111
+ 11,
112
+ 10
113
+ ],
114
+ "partial_rotary_factor": 0.25,
115
+ "rope_theta": 10000000,
116
+ "rope_type": "default"
117
+ },
118
+ "tie_word_embeddings": false,
119
+ "use_cache": true,
120
+ "vocab_size": 248320
121
+ },
122
+ "tie_word_embeddings": false,
123
+ "transformers_version": "5.14.1",
124
+ "video_token_id": 248057,
125
+ "vision_config": {
126
+ "deepstack_visual_indexes": [],
127
+ "depth": 27,
128
+ "dtype": "bfloat16",
129
+ "hidden_act": "gelu_pytorch_tanh",
130
+ "hidden_size": 1152,
131
+ "in_channels": 3,
132
+ "initializer_range": 0.02,
133
+ "intermediate_size": 4304,
134
+ "model_type": "qwen3_5_vision",
135
+ "num_heads": 16,
136
+ "num_position_embeddings": 2304,
137
+ "out_hidden_size": 5120,
138
+ "patch_size": 16,
139
+ "spatial_merge_size": 2,
140
+ "temporal_patch_size": 2
141
+ },
142
+ "vision_end_token_id": 248054,
143
+ "vision_start_token_id": 248053
144
+ }
models/27b_s1_1600h_gs6995/generation_config.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 248044,
3
+ "do_sample": true,
4
+ "eos_token_id": [
5
+ 248046,
6
+ 248044
7
+ ],
8
+ "pad_token_id": 248044,
9
+ "temperature": 0.6,
10
+ "top_k": 20,
11
+ "top_p": 0.95,
12
+ "transformers_version": "5.14.1"
13
+ }
models/27b_s1_1600h_gs6995/model.safetensors.index.json ADDED
The diff for this file is too large to render. See raw diff
 
models/27b_s1_1600h_gs6995/preprocessor_config.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "size": {
3
+ "longest_edge": 16777216,
4
+ "shortest_edge": 65536
5
+ },
6
+ "patch_size": 16,
7
+ "temporal_patch_size": 2,
8
+ "merge_size": 2,
9
+ "image_mean": [
10
+ 0.5,
11
+ 0.5,
12
+ 0.5
13
+ ],
14
+ "image_std": [
15
+ 0.5,
16
+ 0.5,
17
+ 0.5
18
+ ],
19
+ "processor_class": "Qwen3VLProcessor",
20
+ "image_processor_type": "Qwen2VLImageProcessorFast"
21
+ }
models/27b_s1_1600h_gs6995/processor_config.json ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "image_processor": {
3
+ "do_convert_rgb": true,
4
+ "do_normalize": true,
5
+ "do_rescale": true,
6
+ "do_resize": true,
7
+ "image_mean": [
8
+ 0.5,
9
+ 0.5,
10
+ 0.5
11
+ ],
12
+ "image_processor_type": "Qwen2VLImageProcessor",
13
+ "image_std": [
14
+ 0.5,
15
+ 0.5,
16
+ 0.5
17
+ ],
18
+ "merge_size": 2,
19
+ "patch_size": 16,
20
+ "resample": 3,
21
+ "rescale_factor": 0.00392156862745098,
22
+ "size": {
23
+ "longest_edge": 16777216,
24
+ "shortest_edge": 65536
25
+ },
26
+ "temporal_patch_size": 2
27
+ },
28
+ "processor_class": "Qwen3VLProcessor",
29
+ "video_processor": {
30
+ "do_convert_rgb": true,
31
+ "do_normalize": true,
32
+ "do_rescale": true,
33
+ "do_resize": true,
34
+ "do_sample_frames": true,
35
+ "fps": 2,
36
+ "image_mean": [
37
+ 0.5,
38
+ 0.5,
39
+ 0.5
40
+ ],
41
+ "image_std": [
42
+ 0.5,
43
+ 0.5,
44
+ 0.5
45
+ ],
46
+ "max_frames": 768,
47
+ "merge_size": 2,
48
+ "min_frames": 4,
49
+ "patch_size": 16,
50
+ "resample": 3,
51
+ "rescale_factor": 0.00392156862745098,
52
+ "return_metadata": false,
53
+ "size": {
54
+ "longest_edge": 25165824,
55
+ "shortest_edge": 4096
56
+ },
57
+ "temporal_patch_size": 2,
58
+ "video_processor_type": "Qwen3VLVideoProcessor"
59
+ }
60
+ }
models/27b_s1_1600h_gs6995/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:06b9509352d2af50381ab2247e083b80d32d5c0aba91c272ca9ff729b6a0e523
3
+ size 19989325
models/27b_s1_1600h_gs6995/tokenizer_config.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "audio_bos_token": "<|audio_start|>",
4
+ "audio_eos_token": "<|audio_end|>",
5
+ "audio_token": "<|audio_pad|>",
6
+ "backend": "tokenizers",
7
+ "bos_token": null,
8
+ "clean_up_tokenization_spaces": false,
9
+ "eos_token": "<|im_end|>",
10
+ "errors": "replace",
11
+ "image_token": "<|image_pad|>",
12
+ "is_local": true,
13
+ "local_files_only": false,
14
+ "model_max_length": 262144,
15
+ "model_specific_special_tokens": {
16
+ "audio_bos_token": "<|audio_start|>",
17
+ "audio_eos_token": "<|audio_end|>",
18
+ "audio_token": "<|audio_pad|>",
19
+ "image_token": "<|image_pad|>",
20
+ "video_token": "<|video_pad|>",
21
+ "vision_bos_token": "<|vision_start|>",
22
+ "vision_eos_token": "<|vision_end|>"
23
+ },
24
+ "pad_token": "<|endoftext|>",
25
+ "pretokenize_regex": "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?[\\p{L}\\p{M}]+|\\p{N}| ?[^\\s\\p{L}\\p{M}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+",
26
+ "processor_class": "Qwen3VLProcessor",
27
+ "split_special_tokens": false,
28
+ "tokenizer_class": "Qwen2Tokenizer",
29
+ "unk_token": null,
30
+ "video_token": "<|video_pad|>",
31
+ "vision_bos_token": "<|vision_start|>",
32
+ "vision_eos_token": "<|vision_end|>"
33
+ }
models/27b_s1_1600h_gs6995/video_preprocessor_config.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "size": {
3
+ "longest_edge": 25165824,
4
+ "shortest_edge": 4096
5
+ },
6
+ "patch_size": 16,
7
+ "temporal_patch_size": 2,
8
+ "merge_size": 2,
9
+ "image_mean": [
10
+ 0.5,
11
+ 0.5,
12
+ 0.5
13
+ ],
14
+ "image_std": [
15
+ 0.5,
16
+ 0.5,
17
+ 0.5
18
+ ],
19
+ "processor_class": "Qwen3VLProcessor",
20
+ "video_processor_type": "Qwen3VLVideoProcessor"
21
+ }
models/27b_s3_1600h_gs7020/chat_template.jinja ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- set image_count = namespace(value=0) %}
2
+ {%- set video_count = namespace(value=0) %}
3
+ {%- macro render_content(content, do_vision_count, is_system_content=false) %}
4
+ {%- if content is string %}
5
+ {{- content }}
6
+ {%- elif content is iterable and content is not mapping %}
7
+ {%- for item in content %}
8
+ {%- if 'image' in item or 'image_url' in item or item.type == 'image' %}
9
+ {%- if is_system_content %}
10
+ {{- raise_exception('System message cannot contain images.') }}
11
+ {%- endif %}
12
+ {%- if do_vision_count %}
13
+ {%- set image_count.value = image_count.value + 1 %}
14
+ {%- endif %}
15
+ {%- if add_vision_id %}
16
+ {{- 'Picture ' ~ image_count.value ~ ': ' }}
17
+ {%- endif %}
18
+ {{- '<|vision_start|><|image_pad|><|vision_end|>' }}
19
+ {%- elif 'video' in item or item.type == 'video' %}
20
+ {%- if is_system_content %}
21
+ {{- raise_exception('System message cannot contain videos.') }}
22
+ {%- endif %}
23
+ {%- if do_vision_count %}
24
+ {%- set video_count.value = video_count.value + 1 %}
25
+ {%- endif %}
26
+ {%- if add_vision_id %}
27
+ {{- 'Video ' ~ video_count.value ~ ': ' }}
28
+ {%- endif %}
29
+ {{- '<|vision_start|><|video_pad|><|vision_end|>' }}
30
+ {%- elif 'text' in item %}
31
+ {{- item.text }}
32
+ {%- else %}
33
+ {{- raise_exception('Unexpected item type in content.') }}
34
+ {%- endif %}
35
+ {%- endfor %}
36
+ {%- elif content is none or content is undefined %}
37
+ {{- '' }}
38
+ {%- else %}
39
+ {{- raise_exception('Unexpected content type.') }}
40
+ {%- endif %}
41
+ {%- endmacro %}
42
+ {#- ICLR27-GameScaling CPT permissive template:
43
+ - 去掉原 Qwen3.5 模板对 "user query" 的强制断言(逐轮套模板会遇到无 user 的单轮)。
44
+ - 去掉 assistant 轮的 <think> 注入(该注入依赖全局 last_query_index, 会使
45
+ "逐轮拼接 != 整体" 从而破坏 MultiTurnSFTDataset.sanity_check 与 loss 掩码对齐)。
46
+ - 去掉原模板的 `{%- if not messages %}` 空判断: 本管线把 messages 以 numpy object-array
47
+ 传入, `not <ndarray>` 会触发 "truth value of an array ... is ambiguous"。 #}
48
+ {%- if tools and tools is iterable and tools is not mapping %}
49
+ {{- '<|im_start|>system\n' }}
50
+ {{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
51
+ {%- for tool in tools %}
52
+ {{- "\n" }}
53
+ {{- tool | tojson }}
54
+ {%- endfor %}
55
+ {{- "\n</tools>" }}
56
+ {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
57
+ {%- if messages[0].role == 'system' %}
58
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
59
+ {%- if content %}
60
+ {{- '\n\n' + content }}
61
+ {%- endif %}
62
+ {%- endif %}
63
+ {{- '<|im_end|>\n' }}
64
+ {%- else %}
65
+ {%- if messages[0].role == 'system' %}
66
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
67
+ {{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}
68
+ {%- endif %}
69
+ {%- endif %}
70
+ {%- for message in messages %}
71
+ {%- set content = render_content(message.content, true)|trim %}
72
+ {%- if message.role == "system" %}
73
+ {%- if not loop.first %}
74
+ {{- raise_exception('System message must be at the beginning.') }}
75
+ {%- endif %}
76
+ {%- elif message.role == "user" %}
77
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
78
+ {%- elif message.role == "assistant" %}
79
+ {#- ICLR27 think 处理(逐轮、常量、不依赖跨轮 index => 不破坏 sanity_check 与 loss 掩码):
80
+ - 若该轮本身已带 <think>(如 zebra_cot 推理数据): 原样保留其真实思维链, 不再注入,
81
+ 避免拼成"空 think + 真 think"的双块(那会破坏 Qwen 原生"恰好一个 think 块"结构)。
82
+ - 否则(VPT/游戏/普通 VL 等无 think 的轮): 注入 Qwen 原生"空 think"块 <think>\n\n</think>\n\n,
83
+ 训练无 think GT 只保结构, ���模型仍会输出 <think>...</think>, 不破坏原生思考通路;
84
+ inference 端由生成提示(下方 add_generation_prompt, 不注入)自由填充思考内容。 #}
85
+ {%- if '<think>' in content or '</think>' in content %}
86
+ {{- '<|im_start|>' + message.role + '\n' + content }}
87
+ {%- else %}
88
+ {{- '<|im_start|>' + message.role + '\n' + '<think>\n\n</think>\n\n' + content }}
89
+ {%- endif %}
90
+ {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
91
+ {%- for tool_call in message.tool_calls %}
92
+ {%- if tool_call.function is defined %}
93
+ {%- set tool_call = tool_call.function %}
94
+ {%- endif %}
95
+ {%- if loop.first %}
96
+ {%- if content|trim %}
97
+ {{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
98
+ {%- else %}
99
+ {{- '<tool_call>\n<function=' + tool_call.name + '>\n' }}
100
+ {%- endif %}
101
+ {%- else %}
102
+ {{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
103
+ {%- endif %}
104
+ {%- if tool_call.arguments is defined %}
105
+ {%- for args_name, args_value in tool_call.arguments|items %}
106
+ {{- '<parameter=' + args_name + '>\n' }}
107
+ {%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}
108
+ {{- args_value }}
109
+ {{- '\n</parameter>\n' }}
110
+ {%- endfor %}
111
+ {%- endif %}
112
+ {{- '</function>\n</tool_call>' }}
113
+ {%- endfor %}
114
+ {%- endif %}
115
+ {{- '<|im_end|>\n' }}
116
+ {%- elif message.role == "tool" %}
117
+ {%- if loop.previtem and loop.previtem.role != "tool" %}
118
+ {{- '<|im_start|>user' }}
119
+ {%- endif %}
120
+ {{- '\n<tool_response>\n' }}
121
+ {{- content }}
122
+ {{- '\n</tool_response>' }}
123
+ {%- if not loop.last and loop.nextitem.role != "tool" %}
124
+ {{- '<|im_end|>\n' }}
125
+ {%- elif loop.last %}
126
+ {{- '<|im_end|>\n' }}
127
+ {%- endif %}
128
+ {%- else %}
129
+ {{- raise_exception('Unexpected message role.') }}
130
+ {%- endif %}
131
+ {%- endfor %}
132
+ {%- if add_generation_prompt %}
133
+ {{- '<|im_start|>assistant\n' }}
134
+ {%- endif %}
models/27b_s3_1600h_gs7020/config.json ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen3_5ForConditionalGeneration"
4
+ ],
5
+ "bos_token_id": null,
6
+ "dtype": "float32",
7
+ "eos_token_id": 248046,
8
+ "image_token_id": 248056,
9
+ "model_type": "qwen3_5",
10
+ "pad_token_id": 248044,
11
+ "text_config": {
12
+ "attention_bias": false,
13
+ "attention_dropout": 0.0,
14
+ "attn_output_gate": true,
15
+ "bos_token_id": null,
16
+ "dtype": "float32",
17
+ "eos_token_id": 248044,
18
+ "full_attention_interval": 4,
19
+ "head_dim": 256,
20
+ "hidden_act": "silu",
21
+ "hidden_size": 5120,
22
+ "initializer_range": 0.02,
23
+ "intermediate_size": 17408,
24
+ "layer_types": [
25
+ "linear_attention",
26
+ "linear_attention",
27
+ "linear_attention",
28
+ "full_attention",
29
+ "linear_attention",
30
+ "linear_attention",
31
+ "linear_attention",
32
+ "full_attention",
33
+ "linear_attention",
34
+ "linear_attention",
35
+ "linear_attention",
36
+ "full_attention",
37
+ "linear_attention",
38
+ "linear_attention",
39
+ "linear_attention",
40
+ "full_attention",
41
+ "linear_attention",
42
+ "linear_attention",
43
+ "linear_attention",
44
+ "full_attention",
45
+ "linear_attention",
46
+ "linear_attention",
47
+ "linear_attention",
48
+ "full_attention",
49
+ "linear_attention",
50
+ "linear_attention",
51
+ "linear_attention",
52
+ "full_attention",
53
+ "linear_attention",
54
+ "linear_attention",
55
+ "linear_attention",
56
+ "full_attention",
57
+ "linear_attention",
58
+ "linear_attention",
59
+ "linear_attention",
60
+ "full_attention",
61
+ "linear_attention",
62
+ "linear_attention",
63
+ "linear_attention",
64
+ "full_attention",
65
+ "linear_attention",
66
+ "linear_attention",
67
+ "linear_attention",
68
+ "full_attention",
69
+ "linear_attention",
70
+ "linear_attention",
71
+ "linear_attention",
72
+ "full_attention",
73
+ "linear_attention",
74
+ "linear_attention",
75
+ "linear_attention",
76
+ "full_attention",
77
+ "linear_attention",
78
+ "linear_attention",
79
+ "linear_attention",
80
+ "full_attention",
81
+ "linear_attention",
82
+ "linear_attention",
83
+ "linear_attention",
84
+ "full_attention",
85
+ "linear_attention",
86
+ "linear_attention",
87
+ "linear_attention",
88
+ "full_attention"
89
+ ],
90
+ "linear_conv_kernel_dim": 4,
91
+ "linear_key_head_dim": 128,
92
+ "linear_num_key_heads": 16,
93
+ "linear_num_value_heads": 48,
94
+ "linear_value_head_dim": 128,
95
+ "mamba_ssm_dtype": "float32",
96
+ "max_position_embeddings": 262144,
97
+ "mlp_only_layers": [],
98
+ "model_type": "qwen3_5_text",
99
+ "mtp_num_hidden_layers": 1,
100
+ "mtp_use_dedicated_embeddings": false,
101
+ "num_attention_heads": 24,
102
+ "num_hidden_layers": 64,
103
+ "num_key_value_heads": 4,
104
+ "pad_token_id": null,
105
+ "partial_rotary_factor": 0.25,
106
+ "rms_norm_eps": 1e-06,
107
+ "rope_parameters": {
108
+ "mrope_interleaved": true,
109
+ "mrope_section": [
110
+ 11,
111
+ 11,
112
+ 10
113
+ ],
114
+ "partial_rotary_factor": 0.25,
115
+ "rope_theta": 10000000,
116
+ "rope_type": "default"
117
+ },
118
+ "tie_word_embeddings": false,
119
+ "use_cache": true,
120
+ "vocab_size": 248320
121
+ },
122
+ "tie_word_embeddings": false,
123
+ "transformers_version": "5.14.1",
124
+ "video_token_id": 248057,
125
+ "vision_config": {
126
+ "deepstack_visual_indexes": [],
127
+ "depth": 27,
128
+ "dtype": "float32",
129
+ "hidden_act": "gelu_pytorch_tanh",
130
+ "hidden_size": 1152,
131
+ "in_channels": 3,
132
+ "initializer_range": 0.02,
133
+ "intermediate_size": 4304,
134
+ "model_type": "qwen3_5_vision",
135
+ "num_heads": 16,
136
+ "num_position_embeddings": 2304,
137
+ "out_hidden_size": 5120,
138
+ "patch_size": 16,
139
+ "spatial_merge_size": 2,
140
+ "temporal_patch_size": 2
141
+ },
142
+ "vision_end_token_id": 248054,
143
+ "vision_start_token_id": 248053
144
+ }
models/27b_s3_1600h_gs7020/generation_config.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 248044,
3
+ "do_sample": true,
4
+ "eos_token_id": [
5
+ 248046,
6
+ 248044
7
+ ],
8
+ "pad_token_id": 248044,
9
+ "temperature": 0.6,
10
+ "top_k": 20,
11
+ "top_p": 0.95,
12
+ "transformers_version": "5.14.1"
13
+ }
models/27b_s3_1600h_gs7020/preprocessor_config.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "size": {
3
+ "longest_edge": 16777216,
4
+ "shortest_edge": 65536
5
+ },
6
+ "patch_size": 16,
7
+ "temporal_patch_size": 2,
8
+ "merge_size": 2,
9
+ "image_mean": [
10
+ 0.5,
11
+ 0.5,
12
+ 0.5
13
+ ],
14
+ "image_std": [
15
+ 0.5,
16
+ 0.5,
17
+ 0.5
18
+ ],
19
+ "processor_class": "Qwen3VLProcessor",
20
+ "image_processor_type": "Qwen2VLImageProcessorFast"
21
+ }
models/27b_s3_1600h_gs7020/processor_config.json ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "image_processor": {
3
+ "do_convert_rgb": true,
4
+ "do_normalize": true,
5
+ "do_rescale": true,
6
+ "do_resize": true,
7
+ "image_mean": [
8
+ 0.5,
9
+ 0.5,
10
+ 0.5
11
+ ],
12
+ "image_processor_type": "Qwen2VLImageProcessor",
13
+ "image_std": [
14
+ 0.5,
15
+ 0.5,
16
+ 0.5
17
+ ],
18
+ "merge_size": 2,
19
+ "patch_size": 16,
20
+ "resample": 3,
21
+ "rescale_factor": 0.00392156862745098,
22
+ "size": {
23
+ "longest_edge": 16777216,
24
+ "shortest_edge": 65536
25
+ },
26
+ "temporal_patch_size": 2
27
+ },
28
+ "processor_class": "Qwen3VLProcessor",
29
+ "video_processor": {
30
+ "do_convert_rgb": true,
31
+ "do_normalize": true,
32
+ "do_rescale": true,
33
+ "do_resize": true,
34
+ "do_sample_frames": true,
35
+ "fps": 2,
36
+ "image_mean": [
37
+ 0.5,
38
+ 0.5,
39
+ 0.5
40
+ ],
41
+ "image_std": [
42
+ 0.5,
43
+ 0.5,
44
+ 0.5
45
+ ],
46
+ "max_frames": 768,
47
+ "merge_size": 2,
48
+ "min_frames": 4,
49
+ "patch_size": 16,
50
+ "resample": 3,
51
+ "rescale_factor": 0.00392156862745098,
52
+ "return_metadata": false,
53
+ "size": {
54
+ "longest_edge": 25165824,
55
+ "shortest_edge": 4096
56
+ },
57
+ "temporal_patch_size": 2,
58
+ "video_processor_type": "Qwen3VLVideoProcessor"
59
+ }
60
+ }
models/27b_s3_1600h_gs7020/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:06b9509352d2af50381ab2247e083b80d32d5c0aba91c272ca9ff729b6a0e523
3
+ size 19989325
models/27b_s3_1600h_gs7020/tokenizer_config.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "audio_bos_token": "<|audio_start|>",
4
+ "audio_eos_token": "<|audio_end|>",
5
+ "audio_token": "<|audio_pad|>",
6
+ "backend": "tokenizers",
7
+ "bos_token": null,
8
+ "clean_up_tokenization_spaces": false,
9
+ "eos_token": "<|im_end|>",
10
+ "errors": "replace",
11
+ "image_token": "<|image_pad|>",
12
+ "is_local": true,
13
+ "local_files_only": false,
14
+ "model_max_length": 262144,
15
+ "model_specific_special_tokens": {
16
+ "audio_bos_token": "<|audio_start|>",
17
+ "audio_eos_token": "<|audio_end|>",
18
+ "audio_token": "<|audio_pad|>",
19
+ "image_token": "<|image_pad|>",
20
+ "video_token": "<|video_pad|>",
21
+ "vision_bos_token": "<|vision_start|>",
22
+ "vision_eos_token": "<|vision_end|>"
23
+ },
24
+ "pad_token": "<|endoftext|>",
25
+ "pretokenize_regex": "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?[\\p{L}\\p{M}]+|\\p{N}| ?[^\\s\\p{L}\\p{M}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+",
26
+ "processor_class": "Qwen3VLProcessor",
27
+ "split_special_tokens": false,
28
+ "tokenizer_class": "Qwen2Tokenizer",
29
+ "unk_token": null,
30
+ "video_token": "<|video_pad|>",
31
+ "vision_bos_token": "<|vision_start|>",
32
+ "vision_eos_token": "<|vision_end|>"
33
+ }
models/27b_s3_1600h_gs7020/video_preprocessor_config.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "size": {
3
+ "longest_edge": 25165824,
4
+ "shortest_edge": 4096
5
+ },
6
+ "patch_size": 16,
7
+ "temporal_patch_size": 2,
8
+ "merge_size": 2,
9
+ "image_mean": [
10
+ 0.5,
11
+ 0.5,
12
+ 0.5
13
+ ],
14
+ "image_std": [
15
+ 0.5,
16
+ 0.5,
17
+ 0.5
18
+ ],
19
+ "processor_class": "Qwen3VLProcessor",
20
+ "video_processor_type": "Qwen3VLVideoProcessor"
21
+ }
models/2b_s1_1600h_gs6736/chat_template.jinja ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- set image_count = namespace(value=0) %}
2
+ {%- set video_count = namespace(value=0) %}
3
+ {%- macro render_content(content, do_vision_count, is_system_content=false) %}
4
+ {%- if content is string %}
5
+ {{- content }}
6
+ {%- elif content is iterable and content is not mapping %}
7
+ {%- for item in content %}
8
+ {%- if 'image' in item or 'image_url' in item or item.type == 'image' %}
9
+ {%- if is_system_content %}
10
+ {{- raise_exception('System message cannot contain images.') }}
11
+ {%- endif %}
12
+ {%- if do_vision_count %}
13
+ {%- set image_count.value = image_count.value + 1 %}
14
+ {%- endif %}
15
+ {%- if add_vision_id %}
16
+ {{- 'Picture ' ~ image_count.value ~ ': ' }}
17
+ {%- endif %}
18
+ {{- '<|vision_start|><|image_pad|><|vision_end|>' }}
19
+ {%- elif 'video' in item or item.type == 'video' %}
20
+ {%- if is_system_content %}
21
+ {{- raise_exception('System message cannot contain videos.') }}
22
+ {%- endif %}
23
+ {%- if do_vision_count %}
24
+ {%- set video_count.value = video_count.value + 1 %}
25
+ {%- endif %}
26
+ {%- if add_vision_id %}
27
+ {{- 'Video ' ~ video_count.value ~ ': ' }}
28
+ {%- endif %}
29
+ {{- '<|vision_start|><|video_pad|><|vision_end|>' }}
30
+ {%- elif 'text' in item %}
31
+ {{- item.text }}
32
+ {%- else %}
33
+ {{- raise_exception('Unexpected item type in content.') }}
34
+ {%- endif %}
35
+ {%- endfor %}
36
+ {%- elif content is none or content is undefined %}
37
+ {{- '' }}
38
+ {%- else %}
39
+ {{- raise_exception('Unexpected content type.') }}
40
+ {%- endif %}
41
+ {%- endmacro %}
42
+ {#- ICLR27-GameScaling CPT permissive template:
43
+ - 去掉原 Qwen3.5 模板对 "user query" 的强制断言(逐轮套模板会遇到无 user 的单轮)。
44
+ - 去掉 assistant 轮的 <think> 注入(该注入依赖全局 last_query_index, 会使
45
+ "逐轮拼接 != 整体" 从而破坏 MultiTurnSFTDataset.sanity_check 与 loss 掩码对齐)。
46
+ - 去掉原模板的 `{%- if not messages %}` 空判断: 本管线把 messages 以 numpy object-array
47
+ 传入, `not <ndarray>` 会触发 "truth value of an array ... is ambiguous"。 #}
48
+ {%- if tools and tools is iterable and tools is not mapping %}
49
+ {{- '<|im_start|>system\n' }}
50
+ {{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
51
+ {%- for tool in tools %}
52
+ {{- "\n" }}
53
+ {{- tool | tojson }}
54
+ {%- endfor %}
55
+ {{- "\n</tools>" }}
56
+ {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
57
+ {%- if messages[0].role == 'system' %}
58
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
59
+ {%- if content %}
60
+ {{- '\n\n' + content }}
61
+ {%- endif %}
62
+ {%- endif %}
63
+ {{- '<|im_end|>\n' }}
64
+ {%- else %}
65
+ {%- if messages[0].role == 'system' %}
66
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
67
+ {{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}
68
+ {%- endif %}
69
+ {%- endif %}
70
+ {%- for message in messages %}
71
+ {%- set content = render_content(message.content, true)|trim %}
72
+ {%- if message.role == "system" %}
73
+ {%- if not loop.first %}
74
+ {{- raise_exception('System message must be at the beginning.') }}
75
+ {%- endif %}
76
+ {%- elif message.role == "user" %}
77
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
78
+ {%- elif message.role == "assistant" %}
79
+ {#- ICLR27 think 处理(逐轮、常量、不依赖跨轮 index => 不破坏 sanity_check 与 loss 掩码):
80
+ - 若该轮本身已带 <think>(如 zebra_cot 推理数据): 原样保留其真实思维链, 不再注入,
81
+ 避免拼成"空 think + 真 think"的双块(那会破坏 Qwen 原生"恰好一个 think 块"结构)。
82
+ - 否则(VPT/游戏/普通 VL 等无 think 的轮): 注入 Qwen 原生"空 think"块 <think>\n\n</think>\n\n,
83
+ 训练无 think GT 只保结构, ���模型仍会输出 <think>...</think>, 不破坏原生思考通路;
84
+ inference 端由生成提示(下方 add_generation_prompt, 不注入)自由填充思考内容。 #}
85
+ {%- if '<think>' in content or '</think>' in content %}
86
+ {{- '<|im_start|>' + message.role + '\n' + content }}
87
+ {%- else %}
88
+ {{- '<|im_start|>' + message.role + '\n' + '<think>\n\n</think>\n\n' + content }}
89
+ {%- endif %}
90
+ {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
91
+ {%- for tool_call in message.tool_calls %}
92
+ {%- if tool_call.function is defined %}
93
+ {%- set tool_call = tool_call.function %}
94
+ {%- endif %}
95
+ {%- if loop.first %}
96
+ {%- if content|trim %}
97
+ {{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
98
+ {%- else %}
99
+ {{- '<tool_call>\n<function=' + tool_call.name + '>\n' }}
100
+ {%- endif %}
101
+ {%- else %}
102
+ {{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
103
+ {%- endif %}
104
+ {%- if tool_call.arguments is defined %}
105
+ {%- for args_name, args_value in tool_call.arguments|items %}
106
+ {{- '<parameter=' + args_name + '>\n' }}
107
+ {%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}
108
+ {{- args_value }}
109
+ {{- '\n</parameter>\n' }}
110
+ {%- endfor %}
111
+ {%- endif %}
112
+ {{- '</function>\n</tool_call>' }}
113
+ {%- endfor %}
114
+ {%- endif %}
115
+ {{- '<|im_end|>\n' }}
116
+ {%- elif message.role == "tool" %}
117
+ {%- if loop.previtem and loop.previtem.role != "tool" %}
118
+ {{- '<|im_start|>user' }}
119
+ {%- endif %}
120
+ {{- '\n<tool_response>\n' }}
121
+ {{- content }}
122
+ {{- '\n</tool_response>' }}
123
+ {%- if not loop.last and loop.nextitem.role != "tool" %}
124
+ {{- '<|im_end|>\n' }}
125
+ {%- elif loop.last %}
126
+ {{- '<|im_end|>\n' }}
127
+ {%- endif %}
128
+ {%- else %}
129
+ {{- raise_exception('Unexpected message role.') }}
130
+ {%- endif %}
131
+ {%- endfor %}
132
+ {%- if add_generation_prompt %}
133
+ {{- '<|im_start|>assistant\n' }}
134
+ {%- endif %}
models/2b_s1_1600h_gs6736/config.json ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen3_5ForConditionalGeneration"
4
+ ],
5
+ "bos_token_id": null,
6
+ "dtype": "bfloat16",
7
+ "eos_token_id": 248046,
8
+ "image_token_id": 248056,
9
+ "model_type": "qwen3_5",
10
+ "pad_token_id": 248044,
11
+ "text_config": {
12
+ "attention_bias": false,
13
+ "attention_dropout": 0.0,
14
+ "attn_output_gate": true,
15
+ "bos_token_id": null,
16
+ "dtype": "bfloat16",
17
+ "eos_token_id": 248044,
18
+ "full_attention_interval": 4,
19
+ "head_dim": 256,
20
+ "hidden_act": "silu",
21
+ "hidden_size": 2048,
22
+ "initializer_range": 0.02,
23
+ "intermediate_size": 6144,
24
+ "layer_types": [
25
+ "linear_attention",
26
+ "linear_attention",
27
+ "linear_attention",
28
+ "full_attention",
29
+ "linear_attention",
30
+ "linear_attention",
31
+ "linear_attention",
32
+ "full_attention",
33
+ "linear_attention",
34
+ "linear_attention",
35
+ "linear_attention",
36
+ "full_attention",
37
+ "linear_attention",
38
+ "linear_attention",
39
+ "linear_attention",
40
+ "full_attention",
41
+ "linear_attention",
42
+ "linear_attention",
43
+ "linear_attention",
44
+ "full_attention",
45
+ "linear_attention",
46
+ "linear_attention",
47
+ "linear_attention",
48
+ "full_attention"
49
+ ],
50
+ "linear_conv_kernel_dim": 4,
51
+ "linear_key_head_dim": 128,
52
+ "linear_num_key_heads": 16,
53
+ "linear_num_value_heads": 16,
54
+ "linear_value_head_dim": 128,
55
+ "mamba_ssm_dtype": "float32",
56
+ "max_position_embeddings": 262144,
57
+ "mlp_only_layers": [],
58
+ "model_type": "qwen3_5_text",
59
+ "mtp_num_hidden_layers": 1,
60
+ "mtp_use_dedicated_embeddings": false,
61
+ "num_attention_heads": 8,
62
+ "num_hidden_layers": 24,
63
+ "num_key_value_heads": 2,
64
+ "pad_token_id": null,
65
+ "partial_rotary_factor": 0.25,
66
+ "rms_norm_eps": 1e-06,
67
+ "rope_parameters": {
68
+ "mrope_interleaved": true,
69
+ "mrope_section": [
70
+ 11,
71
+ 11,
72
+ 10
73
+ ],
74
+ "partial_rotary_factor": 0.25,
75
+ "rope_theta": 10000000,
76
+ "rope_type": "default"
77
+ },
78
+ "tie_word_embeddings": true,
79
+ "use_cache": true,
80
+ "vocab_size": 248320
81
+ },
82
+ "tie_word_embeddings": true,
83
+ "transformers_version": "5.14.1",
84
+ "video_token_id": 248057,
85
+ "vision_config": {
86
+ "deepstack_visual_indexes": [],
87
+ "depth": 24,
88
+ "dtype": "bfloat16",
89
+ "hidden_act": "gelu_pytorch_tanh",
90
+ "hidden_size": 1024,
91
+ "in_channels": 3,
92
+ "initializer_range": 0.02,
93
+ "intermediate_size": 4096,
94
+ "model_type": "qwen3_5_vision",
95
+ "num_heads": 16,
96
+ "num_position_embeddings": 2304,
97
+ "out_hidden_size": 2048,
98
+ "patch_size": 16,
99
+ "spatial_merge_size": 2,
100
+ "temporal_patch_size": 2
101
+ },
102
+ "vision_end_token_id": 248054,
103
+ "vision_start_token_id": 248053
104
+ }
models/2b_s1_1600h_gs6736/generation_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "eos_token_id": 248046,
4
+ "output_attentions": false,
5
+ "output_hidden_states": false,
6
+ "pad_token_id": 248044,
7
+ "transformers_version": "5.14.1",
8
+ "use_cache": true
9
+ }
models/2b_s1_1600h_gs6736/preprocessor_config.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "size": {
3
+ "longest_edge": 16777216,
4
+ "shortest_edge": 65536
5
+ },
6
+ "patch_size": 16,
7
+ "temporal_patch_size": 2,
8
+ "merge_size": 2,
9
+ "image_mean": [
10
+ 0.5,
11
+ 0.5,
12
+ 0.5
13
+ ],
14
+ "image_std": [
15
+ 0.5,
16
+ 0.5,
17
+ 0.5
18
+ ],
19
+ "processor_class": "Qwen3VLProcessor",
20
+ "image_processor_type": "Qwen2VLImageProcessorFast"
21
+ }
models/2b_s1_1600h_gs6736/processor_config.json ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "image_processor": {
3
+ "do_convert_rgb": true,
4
+ "do_normalize": true,
5
+ "do_rescale": true,
6
+ "do_resize": true,
7
+ "image_mean": [
8
+ 0.5,
9
+ 0.5,
10
+ 0.5
11
+ ],
12
+ "image_processor_type": "Qwen2VLImageProcessor",
13
+ "image_std": [
14
+ 0.5,
15
+ 0.5,
16
+ 0.5
17
+ ],
18
+ "merge_size": 2,
19
+ "patch_size": 16,
20
+ "resample": 3,
21
+ "rescale_factor": 0.00392156862745098,
22
+ "size": {
23
+ "longest_edge": 16777216,
24
+ "shortest_edge": 65536
25
+ },
26
+ "temporal_patch_size": 2
27
+ },
28
+ "processor_class": "Qwen3VLProcessor",
29
+ "video_processor": {
30
+ "do_convert_rgb": true,
31
+ "do_normalize": true,
32
+ "do_rescale": true,
33
+ "do_resize": true,
34
+ "do_sample_frames": true,
35
+ "fps": 2,
36
+ "image_mean": [
37
+ 0.5,
38
+ 0.5,
39
+ 0.5
40
+ ],
41
+ "image_std": [
42
+ 0.5,
43
+ 0.5,
44
+ 0.5
45
+ ],
46
+ "max_frames": 768,
47
+ "merge_size": 2,
48
+ "min_frames": 4,
49
+ "patch_size": 16,
50
+ "resample": 3,
51
+ "rescale_factor": 0.00392156862745098,
52
+ "return_metadata": false,
53
+ "size": {
54
+ "longest_edge": 25165824,
55
+ "shortest_edge": 4096
56
+ },
57
+ "temporal_patch_size": 2,
58
+ "video_processor_type": "Qwen3VLVideoProcessor"
59
+ }
60
+ }