ryugyosoft commited on
Commit
a5e56de
·
verified ·
1 Parent(s): ae0bbff

onwx' (onwx-dash) 1.1.0: 2-PC runs Nemotron 3.5 Bolt 74B-A9B, the model on the main PC only (streamed to the helper), faster 2-PC prompts and generation, 2-PC Linux only (part 4)

Browse files
Files changed (7) hide show
  1. README.md +21 -26
  2. README_en.md +37 -43
  3. onwx/halo.py +38 -4
  4. onwx/i18n.json +8 -0
  5. onwx/manager.py +2 -0
  6. onwx/tp.py +99 -19
  7. onwx/web/manage.html +11 -5
README.md CHANGED
@@ -163,38 +163,33 @@ curl -fsSL https://huggingface.co/ryugyosoft/onwx-dash/resolve/main/install.sh |
163
  - **API からモデルを切り替える**(設定 → サーバーと API):既定でオン。`/v1/models` にこのパソコンのモデルが全部出て(文脈長 `context_length`、最大出力 `max_output_tokens` つき)、リクエストの `model` に別のモデルの ID を指定すると、今のモデルを閉じてそれを読み込みます(10〜20 秒ほど)
164
  - 文脈の長さ、API キー、LAN からの接続、生成の既定値などは onwx と同じです
165
 
166
- ## 2 台で動かす(2-PC、1.0 から)
167
 
168
- 2 台の PC を USB4(Thunderbolt)のケーブル(または速い LAN)でつなぎ、1 つのモデルを半分ずつ持って動かします。それぞれの PC が GPU に置く重みは半分(Qwen3.6 35B-A3B の IQ4_XS で約 10 GB)になるので、1 台ではメモリが足りない PC 2 台でも動かせます。「メイン PC」はいつもどおりアプリ(サーバー、チャット、API)を動かし、「補助 PC」はエンジンだけを動かしてメイン PC に付いていきます。答えは 1 台で動かしたときとほぼ同じです(足し算の順序が変わるので、まったく同じとは限りません)。
169
 
170
- 速さ(Ryzen AI 9 HX 370 と HX 470 のミニ PC を USB4 で直結。表の下 3 行は Qwen3.6 35B-A3B UD-IQ4_XS):
171
 
172
- | | 1 台(HX 470) | 2 台 |
173
  |---|---|---|
174
- | Qwen3.8 27B(UD-Q4_K_XL)の生成 | 4.2 トークン/秒 | 6.1 トークン/秒(約 1.5 倍) |
175
- | Qwen3.8 27B のプロンプトの読み込み(2K トークン) | 185 トークン/秒 | 124 トークン/秒 |
176
- | 生成(MTP の下書きなし) | 24.8 トークン/秒 | 29.5 トークン/秒(約 1.2 倍) |
177
- | 生成(MTP の下書きあり、英語) | 28.1 トークン/秒 | 30.5 トークン/秒 |
178
- | プロンプトの読み込み(2K トークン) | 535〜679 トークン/秒 | 400〜470 トークン/秒 |
179
-
180
- 重みの大きい密なモデル(27B)ほど生成が速くなります(読むメモリが半分になるため)。プロンプトの読み込みは 2 台の間のやり取りが多いぶん遅くなります。主な利点はメモリが半分で済むことです。
181
-
182
- 1. **ケーブルと IP**:2 台を USB4 のケーブルでつなぎ、USB4 のネットワークアダプターに同じサブネットの固定 IP を付けます(例:192.168.2.1 と 192.168.2.2)
183
- - Windows(管理者の PowerShell。アダプター名は `Get-NetAdapter` で確認):
184
- ```powershell
185
- New-NetIPAddress -InterfaceAlias "USB4(TM) P2P Network Adapter" -IPAddress 192.168.2.1 -PrefixLength 24
186
- ```
187
- - Linux(`thunderbolt0` が出ないときは `sudo modprobe thunderbolt_net`):
188
- ```bash
189
- sudo nmcli con add type ethernet ifname thunderbolt0 con-name usb4 ipv4.method manual ipv4.addresses 192.168.2.2/24
190
- sudo nmcli con up usb4
191
- ```
192
- 2. **同じモデル**:両方の PC に同じ GGUF ファイル(同じモデル・同じ量子化)と、同じ版の onwx-dash を入れます
193
  3. **設定 → 2 台で動かす**:両方の PC でオンにし、役割(メイン PC / 補助 PC)を選びます。「待ち受ける PC」と「待ち受ける PC の IP アドレス」(ポート 50120)は両方の PC で同じ値にします
194
- - 片方が待ち受け、もう片方がつなぎに行きます。Windows のファイアウォールは新しいネットワークアダプターへの接続を止めることが多いので、Linux の PC か、接続を許可した PC を待ち受けにしてください(Windows で待ち受けるときは、TCP 50120 の受信を許可します)
195
- 4. **補助 PC を先に開始**:補助 PC の「サーバー」の画面かトレイのメニューで「補助を開始」(コマンドなら `.venv\Scripts\python -m onwx tp-helper`、Linux は `.venv/bin/python -m onwx tp-helper`。`--model` `--ip` `--port` `--listen` / `--connect` で設定を上書き)。メイン PC でモデルを読み込むと、つながってから読み込みます(補助 PC はメイン PC が読み込みを始めてから 10 分以内に開始しても間に合います)。補助はメイン PC がモデルを閉じるとまた待つ状態に戻ります
196
 
197
- 制限:使えるモデルは Qwen3.6 35B-A3B と Qwen3.8 27B(GGUF)です。GPU だけで動かし、NPU の手伝い、画像、別ファイルの下書きモデル(DFlash2)はこのモードでは使えません(Qwen3.6 のモデル内蔵の MTP の下書きは使えます)。プロンプトの読み込みは両方の PC で行います。モデルが合わないときやつながらないときは、メイン PC の画面に「2-PC: …」で理由が出ます。
198
 
199
  ## アンインストール
200
 
 
163
  - **API からモデルを切り替える**(設定 → サーバーと API):既定でオン。`/v1/models` にこのパソコンのモデルが全部出て(文脈長 `context_length`、最大出力 `max_output_tokens` つき)、リクエストの `model` に別のモデルの ID を指定すると、今のモデルを閉じてそれを読み込みます(10〜20 秒ほど)
164
  - 文脈の長さ、API キー、LAN からの接続、生成の既定値などは onwx と同じです
165
 
166
+ ## 2 台で動かす(2-PC、1.0 から。1.1 から Linux 専用)
167
 
168
+ 2 台の PC を USB4(Thunderbolt)のケーブルでつなぎ、1 つのモデルを半分ずつ持って動かします。それぞれの PC が GPU に置く重みは約半分になるので、1 台ではメモリが足りないモデルも動きます(Nemotron 3.5 Bolt 74B-A9B は 22 GB の GGUF で、各 PC に約 11 GB)。生成もプロンプトの読み込みも 1 台より速くなります。「メイン PC」はいつもどおりアプリ(サーバー、チャット、API)を動かし、「補助 PC」はエンジンだけを動かしてメイン PC に付いていきます。**モデルはメイン PC にあれば動きます**:読み込みのたびに、メイン PC が補助 PC の分(モデルの約半分)を USB4 で送ります(設定で、補助 PC に置いた同じ GGUF から読み込むこともできます)。答えは 1 台で動かしたときとほぼ同じです(足し算の順序が変わるので、まったく同じとは限りません)。
169
 
170
+ 速さ(Ryzen AI 9 HX 370 の 32 GB と HX 470 の 64 GB のミニ PC を USB4 で直結、Ubuntu 26.04。1 台は HX 470 か HX 370 の単体):
171
 
172
+ | | 1 台 | 2 台 |
173
  |---|---|---|
174
+ | Nemotron 3.5 Bolt 74B-A9B の生成 | 13.8 トークン/秒 | 21.8 トークン/秒(約 1.55 倍) |
175
+ | Nemotron 3.5 Bolt のプロンプトの読み込み(2K / 8K トークン) | 247 / 266 トークン/秒 | 339 / 408 トークン/秒 |
176
+ | Qwen3.8 27B(UD-Q4_K_XL)の生成 | 4.3 トークン/秒 | 7.7 トークン/秒(約 1.75 倍) |
177
+ | Qwen3.8 27B のプロンプトの読み込み(2K トークン) | 174 トークン/秒 | 273 トークン/秒 |
178
+ | Qwen3.6 35B-A3B(UD-IQ4_XS)の生成(MTP の下書きなし / あり) | 24.8 / 30.5 トークン/秒 | 35.9 / 42〜43 トークン/秒 |
179
+ | Qwen3.6 35B-A3B のプロンプトの読み込み(4K / 8K トーク��) | 1105 / 1129 トークン/秒 | 1380 / 1436〜1509 トークン/秒 |
180
+
181
+ (Nemotron の 1 台は 64 GB の HX 470。32 GB の PC 1 台には載りません)
182
+
183
+ 1. **ケーブルと IP**:2 台を USB4 のケーブルでつなぎ、USB4 のネットワークアダプターに同じサブネットの固定 IP を付けます(例:192.168.2.1 と 192.168.2.2。`thunderbolt0` が出ないときは `sudo modprobe thunderbolt_net`):
184
+ ```bash
185
+ sudo nmcli con add type ethernet ifname thunderbolt0 con-name usb4 ipv4.method manual ipv4.addresses 192.168.2.2/24 802-3-ethernet.mtu 9000
186
+ sudo nmcli con up usb4
187
+ ```
188
+ 2. **アプリ**:両方の PC に同じ版の onwx-dash を入れます。モデル(GGUF)はメイン PC にだけあれば十分です
 
 
 
 
189
  3. **設定 → 2 台で動かす**:両方の PC でオンにし、役割(メイン PC / 補助 PC)を選びます。「待ち受ける PC」と「待ち受ける PC の IP アドレス」(ポート 50120)は両方の PC で同じ値にします
190
+ 4. **補助 PC を先に開始**:補助 PC の「サーバー」の画面かトレイのメニューで「補助を開始」(コマンドなら `.venv/bin/python -m onwx tp-helper`。`--model`(GGUF のパスか `stream`)`--ip` `--port` `--listen` / `--connect` で設定を上書き)。メイン PC でモデルを読み込むと、つながってから読み込みます(補助 PC はメイン PC が読み込みを始めてから 10 分以内に開始しても間に合います)。補助はメイン PC がモデルを閉じるとまた待つ状態に戻ります
 
191
 
192
+ 制限:使えるモデルは Nemotron 3.5 Bolt 74B-A9B、Qwen3.6 35B-A3B、Qwen3.8 27B(GGUF)です。2 台とも Linux で使ってください(Windows では Windows の GPU ランタイムでやり取りが遅く、1 台より遅くなったため、1.1 から設定に出しません)。GPU だけで動かし、NPU の手伝い、画像、別ファイルの下書きモデル(DFlash2、Nemotron の LiLiCorr)はこのモードでは使えません(Qwen3.6 のモデル内蔵の MTP の下書きは使えます)。モデルが合わないときやつながらないときは、メイン PC の画面に「2-PC: …」で理由が出ます。
193
 
194
  ## アンインストール
195
 
README_en.md CHANGED
@@ -194,53 +194,47 @@ It downloads the Linux engine for the PC's GPU (about 0.65 GB, AMD TheRock's Lin
194
  model and loads that one (10-20 s)
195
  - Context length, API key, LAN access, generation defaults: as in onwx
196
 
197
- ## Two PCs (2-PC, from 1.0)
198
 
199
- Two PCs joined by a USB4 (Thunderbolt) cable (or a fast LAN) run one model together, each holding half of it: each
200
- PC keeps half of the weights on its GPU (about 10 GB for Qwen3.6 35B-A3B IQ4_XS), so two PCs that are each too small
201
- for the model can run it. The "main PC" runs the app as usual (server, chat, API); the "helper PC" runs only the engine
202
- and follows the main PC. Answers are nearly the same as on one PC (the sums run in a different order, so not always
203
- bit for bit).
 
204
 
205
- Speed (Ryzen AI 9 HX 370 + HX 470 mini PCs, USB4 cable; the last three rows Qwen3.6 35B-A3B UD-IQ4_XS):
 
206
 
207
- | | one PC (HX 470) | two PCs |
208
  |---|---|---|
209
- | Qwen3.8 27B (UD-Q4_K_XL) generation | 4.2 tokens/s | 6.1 tokens/s (about 1.5x) |
210
- | Qwen3.8 27B prompt reading (2K tokens) | 185 tokens/s | 124 tokens/s |
211
- | generation (no MTP draft) | 24.8 tokens/s | 29.5 tokens/s (about 1.2x) |
212
- | generation (MTP draft, English) | 28.1 tokens/s | 30.5 tokens/s |
213
- | prompt reading (2K tokens) | 535-679 tokens/s | 400-470 tokens/s |
214
-
215
- Generation gains most for a dense model with big weights (the 27B: each PC reads half of them); prompt reading gets
216
- slower (the PCs exchange more data there). The main gain is half the memory on each PC.
217
-
218
- 1. **Cable and IPs**: connect the two PCs with a USB4 cable and give their USB4 network adapters fixed IPs in the same
219
- subnet (for example 192.168.2.1 and 192.168.2.2)
220
- - Windows (PowerShell as administrator; `Get-NetAdapter` shows the adapter's name):
221
- ```powershell
222
- New-NetIPAddress -InterfaceAlias "USB4(TM) P2P Network Adapter" -IPAddress 192.168.2.1 -PrefixLength 24
223
- ```
224
- - Linux (no `thunderbolt0`: `sudo modprobe thunderbolt_net`):
225
- ```bash
226
- sudo nmcli con add type ethernet ifname thunderbolt0 con-name usb4 ipv4.method manual ipv4.addresses 192.168.2.2/24
227
- sudo nmcli con up usb4
228
- ```
229
- 2. **The same model**: the same GGUF file (same model, same quantization) and the same onwx-dash version on both PCs
230
- 3. **Settings → Two PCs**: turn it on on both PCs and pick each one's role (main PC / helper PC). "Listening PC" and
231
- "Listening PC's IP address" (port 50120) are the same on both PCs
232
- - One PC listens, the other connects to it. Windows' firewall often blocks connections coming in on a new network
233
- adapter, so let the Linux PC, or the PC whose firewall allows it, listen (a listening Windows PC needs inbound
234
- TCP 50120 allowed)
235
- 4. **Start the helper first**: on the helper PC press "Start helper" on the Server page or in the tray menu (or run
236
- `.venv\Scripts\python -m onwx tp-helper`, on Linux `.venv/bin/python -m onwx tp-helper`; `--model`, `--ip`,
237
- `--port`, `--listen` / `--connect` override the settings). Loading the model on the main PC then connects first and
238
- loads (the helper may also start up to 10 minutes after the main PC begins loading). When the main PC closes the
239
- model, the helper waits for the next one
240
-
241
- Limits: Qwen3.6 35B-A3B and Qwen3.8 27B (GGUF); the GPU only (no NPU help, no images and no separate DFlash2
242
- draft in this mode; Qwen3.6's built-in MTP draft works); both PCs read the prompts.
243
- A model mismatch or a failed connection shows its reason on the main PC as "2-PC: ...".
244
 
245
  ## Uninstall
246
 
 
194
  model and loads that one (10-20 s)
195
  - Context length, API key, LAN access, generation defaults: as in onwx
196
 
197
+ ## Two PCs (2-PC, from 1.0; Linux only from 1.1)
198
 
199
+ Two PCs joined by a USB4 (Thunderbolt) cable run one model together, each holding about half of it on its GPU - so a
200
+ model too big for one PC runs (Nemotron 3.5 Bolt 74B-A9B: a 22 GB GGUF, about 11 GB on each PC), and both generation
201
+ and prompt reading get faster than on one PC. The "main PC" runs the app as usual (server, chat, API); the "helper
202
+ PC" runs only the engine and follows it. **The model only has to be on the main PC**: each time it loads, the main PC
203
+ sends the helper's part (about half of the model) over USB4 (a setting lets the helper load the same GGUF from its own
204
+ disk instead). Answers are nearly the same as on one PC (the sums run in a different order, so not always identical).
205
 
206
+ Speed (a Ryzen AI 9 HX 370 32 GB and a HX 470 64 GB mini PC on a direct USB4 cable, Ubuntu 26.04; one PC = either
207
+ alone):
208
 
209
+ | | 1 PC | 2 PCs |
210
  |---|---|---|
211
+ | Nemotron 3.5 Bolt 74B-A9B generation | 13.8 tokens/s | 21.8 tokens/s (about 1.55x) |
212
+ | Nemotron 3.5 Bolt prompt reading (2K / 8K tokens) | 247 / 266 tokens/s | 339 / 408 tokens/s |
213
+ | Qwen3.8 27B (UD-Q4_K_XL) generation | 4.3 tokens/s | 7.7 tokens/s (about 1.75x) |
214
+ | Qwen3.8 27B prompt reading (2K tokens) | 174 tokens/s | 273 tokens/s |
215
+ | Qwen3.6 35B-A3B (UD-IQ4_XS) generation (without / with MTP drafts) | 24.8 / 30.5 tokens/s | 35.9 / 42-43 tokens/s |
216
+ | Qwen3.6 35B-A3B prompt reading (4K / 8K tokens) | 1105 / 1129 tokens/s | 1380 / 1436-1509 tokens/s |
217
+
218
+ (Nemotron's one PC is the 64 GB HX 470; it does not fit one 32 GB PC.)
219
+
220
+ 1. **Cable and IP**: join the PCs with a USB4 cable and give the USB4 network adapters fixed addresses in one subnet
221
+ (e.g. 192.168.2.1 and 192.168.2.2; `sudo modprobe thunderbolt_net` if `thunderbolt0` is missing):
222
+ ```bash
223
+ sudo nmcli con add type ethernet ifname thunderbolt0 con-name usb4 ipv4.method manual ipv4.addresses 192.168.2.2/24 802-3-ethernet.mtu 9000
224
+ sudo nmcli con up usb4
225
+ ```
226
+ 2. **App**: the same version of onwx-dash on both PCs. The model (GGUF) is needed on the main PC only
227
+ 3. **Settings -> Two PCs**: turn it on on both PCs and pick the role (main PC / helper PC). "Listening PC" and "the
228
+ listening PC's IP address" (port 50120) are the same on both
229
+ 4. **Start the helper first**: on the helper PC, "Start helper" on the Server page or in the tray menu (or
230
+ `.venv/bin/python -m onwx tp-helper`; `--model` (a GGUF path or `stream`) `--ip` `--port` `--listen` /
231
+ `--connect` override the settings). Loading the model on the main PC then connects first and loads (the helper may
232
+ start up to 10 minutes after the main PC began loading). When the main PC closes the model, the helper waits again
233
+
234
+ Limits: Nemotron 3.5 Bolt 74B-A9B, Qwen3.6 35B-A3B and Qwen3.8 27B (GGUF). Use Linux on both PCs (on Windows the GPU
235
+ runtime made the exchange slower than one PC, so from 1.1 the setting is not shown there). GPU only: no NPU help,
236
+ no images and no separate draft model (DFlash2, Nemotron's LiLiCorr) in this mode (Qwen3.6's built-in MTP drafts
237
+ work). When the model does not match or the PCs do not connect, the main PC shows the reason ("2-PC: ...").
 
 
 
 
 
 
 
 
238
 
239
  ## Uninstall
240
 
onwx/halo.py CHANGED
@@ -211,13 +211,15 @@ class HaloModel:
211
  # and halo_load waits for the helper PC; GPU only (no NPU help) in this mode
212
  from . import tp
213
  want_tp = os.environ.get(tp.ENV, "")
214
- self.tp = tp.engine_env(want_tp, arch)
 
215
  if self.tp:
216
  npu = False
217
  print(f"[tp] 2-PC: waiting for the helper PC ({'listening on' if os.environ['GUFO_TP_LISTEN'] == '1' else 'connecting to'} "
218
  f"{self.tp[0]}:{self.tp[1]}, up to 10 minutes)", flush=True)
219
  elif want_tp:
220
- print(f"[tp] 2-PC is for Qwen3.6-35B-A3B only: {os.path.basename(path)} runs on this PC alone", flush=True)
 
221
  # [dash] the NPU's share (ONWX_HALO_NPU_SHARE: auto / 0-100 %); a 0 % share runs on the GPU only
222
  self.npu_vars = npu_env(arch, bool(npu), os.environ.get("ONWX_HALO_NPU_SHARE", "auto"))
223
  self.npu_on = bool(self.npu_vars)
@@ -258,7 +260,8 @@ class HaloModel:
258
  d = os.path.join(folder, c[0]) if c else d
259
  # [dash] Ternary Bonsai 2 27B drafts on the 890M too since the engine verifies through int8 WMMA (Ryzen AI 9
260
  # HX 470 10-31: plain 9.8 tok/s, with 7 drafts 8.5-21.3, four prompts' mean 14.6; it was 4.9-11.9 before)
261
- draft_on = os.environ.get("ONWX_HALO_DRAFT", "") != "0"
 
262
  if draft_on and os.path.isfile(d) and hasattr(L, "halo_spec_draft"):
263
  if L.halo_spec_load(h, d.encode()) < 0:
264
  print(f"[halo] the draft model {os.path.basename(d)} did not load ({_err()}): no speculative decoding",
@@ -281,8 +284,10 @@ class HaloModel:
281
  # [dash] drafts a step at most (the engine's HALO_QSPEC_DRAFTS, default 4): the 890M's DDR5 makes every
282
  # extra verified row cost its own experts' reads - 1 measured fastest there (dash64 10-30: plain 23.8,
283
  # 1 draft 30.0 / sampled 27.7, 4 drafts 28.5 / 25.4 tok/s); Strix Halo keeps 4. A value set by the user stays.
 
 
284
  if gpu_arch() == "gfx1150":
285
- os.environ.setdefault("HALO_QSPEC_DRAFTS", "1")
286
  if L.halo_spec_load(h, b"embedded") < 0:
287
  print(f"[halo] no MTP head ({_err()}): no speculative decoding", flush=True)
288
  else:
@@ -336,6 +341,8 @@ class HaloModel:
336
  self.held = []
337
  raise
338
  self.held.extend(int(x) for x in ids)
 
 
339
  if not want_logits:
340
  return None
341
  if L.halo_logits(self.h, self._buf, self.V) < 0:
@@ -412,8 +419,35 @@ class HaloModel:
412
  em = [int(self._qout[i]) for i in range(n)]
413
  self.held.append(int(x))
414
  self.held.extend(em[:-1])
 
 
415
  return em
416
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
417
  def close(self):
418
  if getattr(self, "h", None):
419
  lib().halo_free(self.h)
 
211
  # and halo_load waits for the helper PC; GPU only (no NPU help) in this mode
212
  from . import tp
213
  want_tp = os.environ.get(tp.ENV, "")
214
+ self.tp = tp.engine_env(want_tp, arch, path)
215
+ self._tp_steps = 0
216
  if self.tp:
217
  npu = False
218
  print(f"[tp] 2-PC: waiting for the helper PC ({'listening on' if os.environ['GUFO_TP_LISTEN'] == '1' else 'connecting to'} "
219
  f"{self.tp[0]}:{self.tp[1]}, up to 10 minutes)", flush=True)
220
  elif want_tp:
221
+ print(f"[tp] 2-PC is for Qwen3.6-35B-A3B, Qwen3.8-27B and Nemotron 3.5 Bolt: {os.path.basename(path)} "
222
+ f"runs on this PC alone", flush=True)
223
  # [dash] the NPU's share (ONWX_HALO_NPU_SHARE: auto / 0-100 %); a 0 % share runs on the GPU only
224
  self.npu_vars = npu_env(arch, bool(npu), os.environ.get("ONWX_HALO_NPU_SHARE", "auto"))
225
  self.npu_on = bool(self.npu_vars)
 
260
  d = os.path.join(folder, c[0]) if c else d
261
  # [dash] Ternary Bonsai 2 27B drafts on the 890M too since the engine verifies through int8 WMMA (Ryzen AI 9
262
  # HX 470 10-31: plain 9.8 tok/s, with 7 drafts 8.5-21.3, four prompts' mean 14.6; it was 4.9-11.9 before)
263
+ # (2-PC: the engine has no draft-model verification over two PCs yet - Nemotron's LiLiCorr draft stays off)
264
+ draft_on = os.environ.get("ONWX_HALO_DRAFT", "") != "0" and not self.tp
265
  if draft_on and os.path.isfile(d) and hasattr(L, "halo_spec_draft"):
266
  if L.halo_spec_load(h, d.encode()) < 0:
267
  print(f"[halo] the draft model {os.path.basename(d)} did not load ({_err()}): no speculative decoding",
 
284
  # [dash] drafts a step at most (the engine's HALO_QSPEC_DRAFTS, default 4): the 890M's DDR5 makes every
285
  # extra verified row cost its own experts' reads - 1 measured fastest there (dash64 10-30: plain 23.8,
286
  # 1 draft 30.0 / sampled 27.7, 4 drafts 28.5 / 25.4 tok/s); Strix Halo keeps 4. A value set by the user stays.
287
+ # Linux (ryzenu / dash64u 2026-11-10, greedy, 256 tokens): 2 drafts best - 1 PC plain 24.8, d1 29.5,
288
+ # d2 30.5, d3 28.2; 2 PCs plain 35.9, d1 41.2, d2 42.1-43.1, d3 41.4 tok/s.
289
  if gpu_arch() == "gfx1150":
290
+ os.environ.setdefault("HALO_QSPEC_DRAFTS", "1" if os.name == "nt" else "2")
291
  if L.halo_spec_load(h, b"embedded") < 0:
292
  print(f"[halo] no MTP head ({_err()}): no speculative decoding", flush=True)
293
  else:
 
341
  self.held = []
342
  raise
343
  self.held.extend(int(x) for x in ids)
344
+ if self.tp and n == 1:
345
+ self._tp_tick(1)
346
  if not want_logits:
347
  return None
348
  if L.halo_logits(self.h, self._buf, self.V) < 0:
 
419
  em = [int(self._qout[i]) for i in range(n)]
420
  self.held.append(int(x))
421
  self.held.extend(em[:-1])
422
+ if self.tp:
423
+ self._tp_tick(n)
424
  return em
425
 
426
+ def _tp_tick(self, n):
427
+ """[1.x] two PCs: every 512 decoded tokens, the engine's balance advice (both PCs' compute per sum) is stored
428
+ for this model and pair (onwx/tp.py); the next load splits the work by it."""
429
+ self._tp_steps = getattr(self, "_tp_steps", 0) + n
430
+ if self._tp_steps < 512:
431
+ return
432
+ self._tp_steps = 0
433
+ L = lib()
434
+ if not hasattr(L, "halo_tp_balance"):
435
+ return
436
+ L.halo_tp_balance.restype = ctypes.c_int
437
+ L.halo_tp_balance.argtypes = [ctypes.c_void_p, ctypes.c_int, ctypes.POINTER(ctypes.c_double)]
438
+ out = (ctypes.c_double * 5)()
439
+ if L.halo_tp_balance(self.h, 1, out) != 0:
440
+ return
441
+ from . import tp
442
+ try:
443
+ if tp.balance_update(self.path, self.tp[0], out[4],
444
+ {"main_us": round(out[0], 1), "helper_us": round(out[1], 1), "sums": int(out[2]),
445
+ "loaded": round(out[3], 3)}):
446
+ print(f"[tp] work split: main {out[0]:.0f} us, helper {out[1]:.0f} us per sum at share "
447
+ f"{out[3]:.3f} -> {out[4]:.3f} from the next load", flush=True)
448
+ except OSError:
449
+ pass
450
+
451
  def close(self):
452
  if getattr(self, "h", None):
453
  lib().halo_free(self.h)
onwx/i18n.json CHANGED
@@ -447,6 +447,10 @@
447
  "2 台の PC を USB4(Thunderbolt)のケーブルでつなぎ、1 つのモデルを半分ずつ持って動かします。モデルのメモリが半分になり、生成も速くなります(Ryzen AI 9 HX のミニ PC 2 台で、Qwen3.8 27B は 1 台の約 1.5 倍、Qwen3.6 35B-A3B は約 1.2 倍。プロンプトの読み込みは 1 台より遅くなります)。使えるのは Qwen3.6 35B-A3B と Qwen3.8 27B の GGUF で、GPU だけで動かします(NPU の手伝いと画像はこのモードでは使えません)。": "Two PCs joined by a USB4 (Thunderbolt) cable run one model, each holding half of it. The model's memory is halved and generation gets faster (two Ryzen AI 9 HX mini PCs: Qwen3.8 27B about 1.5x, Qwen3.6 35B-A3B about 1.2x of one PC; prompt reading is slower than on one PC). Qwen3.6 35B-A3B and Qwen3.8 27B GGUFs, on the GPU only (no NPU help and no images in this mode).",
448
  "2 台の PC で 1 つのモデルを動かす": "Run one model on two PCs",
449
  "オンにすると、Qwen3.6 35B-A3B か Qwen3.8 27B を読み込むときにもう 1 台とつながってから読み込みます。ほかのモデルはこれまでどおり 1 台で動きます。": "When on, loading Qwen3.6 35B-A3B or Qwen3.8 27B first connects to the other PC. Other models run on one PC as before.",
 
 
 
 
450
  "この PC の役割": "This PC's role",
451
  "メイン PC(サーバー・チャット・API)": "Main PC (server, chat, API)",
452
  "補助 PC(エンジンだけ)": "Helper PC (engine only)",
@@ -475,6 +479,10 @@
475
  "補助を開始すると、読み込まれているモデル({0})を閉じます。よろしいですか?": "Starting the helper closes the loaded model ({0}). Continue?"
476
  },
477
  "zh": {
 
 
 
 
478
  "三値(2 ビット)の 9B を、全部 NPU で動かします(Qwen3.5-9B ベースの Ternary Bonsai 2。画像も読めます)。Ryzen AI Max+ 395 で生成は約 20 tok/s、プロンプトの読み込みは 2 万トークンで約 40 秒(約 500 tok/s)。文脈は最大 262144 トークン": "三值(2 位)9B,全部在 NPU 上运行(基于 Qwen3.5-9B 的 Ternary Bonsai 2,也能读图)。Ryzen AI Max+ 395 上生成约 20 tok/s,提示词读取约 500 tok/s(2 万词元约 40 秒)。上下文最多 262144 词元",
479
  "三値(2 ビット)の軽い 4B を、全部 NPU で動かします(Qwen3.5-4B ベースの Ternary Bonsai 2。画像も読めます)。Ryzen AI Max+ 395 で生成は約 30 tok/s、プロンプトの読み込みは 2 万トークンで約 34 秒(約 600 tok/s)。文脈は最大 262144 トークン": "轻量的三值(2 位)4B,全部在 NPU 上运行(基于 Qwen3.5-4B 的 Ternary Bonsai 2,也能读图)。Ryzen AI Max+ 395 上生成约 30 tok/s,提示词读取约 600 tok/s(2 万词元约 34 秒)。上下文最多 262144 词元",
480
  "API の最大出力トークン": "API 最大输出 token 数",
 
447
  "2 台の PC を USB4(Thunderbolt)のケーブルでつなぎ、1 つのモデルを半分ずつ持って動かします。モデルのメモリが半分になり、生成も速くなります(Ryzen AI 9 HX のミニ PC 2 台で、Qwen3.8 27B は 1 台の約 1.5 倍、Qwen3.6 35B-A3B は約 1.2 倍。プロンプトの読み込みは 1 台より遅くなります)。使えるのは Qwen3.6 35B-A3B と Qwen3.8 27B の GGUF で、GPU だけで動かします(NPU の手伝いと画像はこのモードでは使えません)。": "Two PCs joined by a USB4 (Thunderbolt) cable run one model, each holding half of it. The model's memory is halved and generation gets faster (two Ryzen AI 9 HX mini PCs: Qwen3.8 27B about 1.5x, Qwen3.6 35B-A3B about 1.2x of one PC; prompt reading is slower than on one PC). Qwen3.6 35B-A3B and Qwen3.8 27B GGUFs, on the GPU only (no NPU help and no images in this mode).",
448
  "2 台の PC で 1 つのモデルを動かす": "Run one model on two PCs",
449
  "オンにすると、Qwen3.6 35B-A3B か Qwen3.8 27B を読み込むときにもう 1 台とつながってから読み込みます。ほかのモデルはこれまでどおり 1 台で動きます。": "When on, loading Qwen3.6 35B-A3B or Qwen3.8 27B first connects to the other PC. Other models run on one PC as before.",
450
+ "2 台の PC を USB4(Thunderbolt)のケーブルでつなぎ、1 つのモデルを半分ずつ持って動かします。モデルのメモリが半分になり、1 台では載らないモデルも動き、生成も速くなります(Ryzen AI 9 HX のミニ PC 2 台で、Nemotron 3.5 Bolt 74B-A9B は生成が 1 台の約 1.55 倍・プロンプトの読み込みが約 1.4〜1.5 倍、Qwen3.8 27B は生成が約 1.7 倍、Qwen3.6 35B-A3B は約 1.4 倍)。モデルはメイン PC にあれば動きます。使えるのは Nemotron 3.5 Bolt、Qwen3.6 35B-A3B、Qwen3.8 27B の GGUF で、GPU だけで動かします(NPU の手伝いと画像はこのモードでは使えません)。2 台とも Linux で使ってください。": "Connect two PCs with a USB4 (Thunderbolt) cable and run one model with half of it on each. Each PC needs half the memory, models too big for one PC run, and generation gets faster (two Ryzen AI 9 HX mini PCs: Nemotron 3.5 Bolt 74B-A9B generates about 1.55x and reads prompts about 1.4-1.5x as fast as one PC, Qwen3.8 27B generates about 1.7x, Qwen3.6 35B-A3B about 1.4x). The model only has to be on the main PC. Supported: the Nemotron 3.5 Bolt, Qwen3.6 35B-A3B and Qwen3.8 27B GGUFs, on the GPU only (no NPU help and no images in this mode). Use Linux on both PCs.",
451
+ "オンにすると、Nemotron 3.5 Bolt、Qwen3.6 35B-A3B か Qwen3.8 27B を読み込むときにもう 1 台とつながってから読み込みます。ほかのモデルはこれまでどおり 1 台で動きます。": "When on, loading Nemotron 3.5 Bolt, Qwen3.6 35B-A3B or Qwen3.8 27B first connects to the other PC. Other models run on one PC as before.",
452
+ "補助 PC でも自分のモデルファイルを使う": "Let the helper PC use its own model file",
453
+ "オフ(おすすめ):補助 PC にモデルは要りません。読み込みのたびに、メイン PC が補助 PC の分(モデルの約半分)を USB4 で送ります。オン:補助 PC にもメイン PC と同じ GGUF を置き、そこから読み込みます。": "Off (recommended): the helper PC needs no model. Each time the model loads, the main PC sends the helper's part (about half of the model) over USB4. On: put the same GGUF as on the main PC on the helper PC too and load from it.",
454
  "この PC の役割": "This PC's role",
455
  "メイン PC(サーバー・チャット・API)": "Main PC (server, chat, API)",
456
  "補助 PC(エンジンだけ)": "Helper PC (engine only)",
 
479
  "補助を開始すると、読み込まれているモデル({0})を閉じます。よろしいですか?": "Starting the helper closes the loaded model ({0}). Continue?"
480
  },
481
  "zh": {
482
+ "2 台の PC を USB4(Thunderbolt)のケーブルでつなぎ、1 つのモデルを半分ずつ持って動かします。モデルのメモリが半分になり、1 台では載らないモデルも動き、生成も速くなります(Ryzen AI 9 HX のミニ PC 2 台で、Nemotron 3.5 Bolt 74B-A9B は生成が 1 台の約 1.55 倍・プロンプトの読み込みが約 1.4〜1.5 倍、Qwen3.8 27B は生成が約 1.7 倍、Qwen3.6 35B-A3B は約 1.4 倍)。モデルはメイン PC にあれば動きます。使えるのは Nemotron 3.5 Bolt、Qwen3.6 35B-A3B、Qwen3.8 27B の GGUF で、GPU だけで動かします(NPU の手伝いと画像はこのモードでは使えません)。2 台とも Linux で使ってください。": "用 USB4(Thunderbolt)线连接两台电脑,每台各持模型的一半来运行一个模型。每台所需内存减半,一台装不下的模型也能运行,生成也更快(两台 Ryzen AI 9 HX 迷你电脑:Nemotron 3.5 Bolt 74B-A9B 的生成约为一台的 1.55 倍、读取提示词约 1.4��1.5 倍,Qwen3.8 27B 生成约 1.7 倍,Qwen3.6 35B-A3B 约 1.4 倍)。模型只需放在主电脑上。可用的是 Nemotron 3.5 Bolt、Qwen3.6 35B-A3B、Qwen3.8 27B 的 GGUF,只用 GPU 运行(此模式下不能使用 NPU 协助和图片)。两台都请使用 Linux。",
483
+ "オンにすると、Nemotron 3.5 Bolt、Qwen3.6 35B-A3B か Qwen3.8 27B を読み込むときにもう 1 台とつながってから読み込みます。ほかのモデルはこれまでどおり 1 台で動きます。": "开启后,加载 Nemotron 3.5 Bolt、Qwen3.6 35B-A3B 或 Qwen3.8 27B 时会先连接另一台电脑再加载。其他模型仍在一台电脑上运行。",
484
+ "補助 PC でも自分のモデルファイルを使う": "辅助电脑也使用自己的模型文件",
485
+ "オフ(おすすめ):補助 PC にモデルは要りません。読み込みのたびに、メイン PC が補助 PC の分(モデルの約半分)を USB4 で送ります。オン:補助 PC にもメイン PC と同じ GGUF を置き、そこから読み込みます。": "关闭(推荐):辅助电脑不需要模型。每次加载时,主电脑通过 USB4 发送辅助电脑负责的部分(约模型的一半)。开启:在辅助电脑上也放与主电脑相同的 GGUF,从中加载。",
486
  "三値(2 ビット)の 9B を、全部 NPU で動かします(Qwen3.5-9B ベースの Ternary Bonsai 2。画像も読めます)。Ryzen AI Max+ 395 で生成は約 20 tok/s、プロンプトの読み込みは 2 万トークンで約 40 秒(約 500 tok/s)。文脈は最大 262144 トークン": "三值(2 位)9B,全部在 NPU 上运行(基于 Qwen3.5-9B 的 Ternary Bonsai 2,也能读图)。Ryzen AI Max+ 395 上生成约 20 tok/s,提示词读取约 500 tok/s(2 万词元约 40 秒)。上下文最多 262144 词元",
487
  "三値(2 ビット)の軽い 4B を、全部 NPU で動かします(Qwen3.5-4B ベースの Ternary Bonsai 2。画像も読めます)。Ryzen AI Max+ 395 で生成は約 30 tok/s、プロンプトの読み込みは 2 万トークンで約 34 秒(約 600 tok/s)。文脈は最大 262144 トークン": "轻量的三值(2 位)4B,全部在 NPU 上运行(基于 Qwen3.5-4B 的 Ternary Bonsai 2,也能读图)。Ryzen AI Max+ 395 上生成约 30 tok/s,提示词读取约 600 tok/s(2 万词元约 34 秒)。上下文最多 262144 词元",
488
  "API の最大出力トークン": "API 最大输出 token 数",
onwx/manager.py CHANGED
@@ -199,6 +199,8 @@ class Manager:
199
  def _tp(cfg, inst, info, status):
200
  """[1.0] two PCs (onwx/tp.py): the setting, whether the engine can, the helper process, the main PC's wait."""
201
  from . import tp
 
 
202
  try:
203
  return {"settings": tp.settings(cfg), "supported": tp.engine_supports(), "helper": tp.helper_status(),
204
  "models": [{"key": k, "title": app.model_title(k), "path": p} for k, p in inst.items()
 
199
  def _tp(cfg, inst, info, status):
200
  """[1.0] two PCs (onwx/tp.py): the setting, whether the engine can, the helper process, the main PC's wait."""
201
  from . import tp
202
+ if not tp.OS_OK: # [1.1] Linux only: no settings tab on Windows
203
+ return {}
204
  try:
205
  return {"settings": tp.settings(cfg), "supported": tp.engine_supports(), "helper": tp.helper_status(),
206
  "models": [{"key": k, "title": app.model_title(k), "path": p} for k, p in inst.items()
onwx/tp.py CHANGED
@@ -17,19 +17,27 @@ The setting "halo_tp" (the same on both PCs except "role"):
17
  listener "main" | "helper": which PC listens (Windows' firewall usually blocks connections coming in on a new
18
  network adapter: the Linux side, or the side whose firewall lets them in, should listen)
19
  streams TCP streams (4)
20
- model the helper's GGUF: a model key / file ("" = the model chosen in the app if it is a Qwen3.6-35B-A3B, else
21
- the first one found)
 
 
22
 
23
  No NPU help and no images in 2-PC mode; the GPU engine only.
24
  """
25
  import argparse, ipaddress, json, os, subprocess, sys, threading, time
26
 
27
  TP_ARCH = "qwen35moe" # (the NPU switches the helper turns off use this one)
28
- TP_ARCHS = ("qwen35moe", "qwen35") # the architectures the engine splits over two PCs (Qwen3.6-35B-A3B, Qwen3.8-27B)
29
- TP_PREFIX = ("qwen3.6-35b-a3b", "qwen3.8-27b") # their GGUF files' names (the catalog's quants)
 
 
30
  DEFAULT = {"enabled": False, "role": "main", "ip": "192.168.2.1", "port": 50120, "listener": "main", "streams": 4,
31
- "model": ""}
 
32
  ENV = "ONWX_HALO_TP" # app -> server process: "ip,port,streams,listen" (main role only)
 
 
 
33
 
34
 
35
  # ------------------------------------------------------------------ settings
@@ -54,6 +62,7 @@ def settings(cfg):
54
  except (TypeError, ValueError):
55
  pass
56
  out["model"] = str(raw.get("model") or "")
 
57
  return out
58
 
59
 
@@ -75,7 +84,7 @@ def validate(new):
75
  role = new.get("role") if new.get("role") in ("main", "helper") else "main"
76
  listener = new.get("listener") if new.get("listener") in ("main", "helper") else "main"
77
  return {"enabled": bool(new.get("enabled")), "role": role, "ip": ip, "port": port, "listener": listener,
78
- "streams": streams, "model": str(new.get("model") or "")}, None
79
 
80
 
81
  def listens(s):
@@ -92,16 +101,17 @@ def main_env(cfg):
92
  """{ONWX_HALO_TP: "ip,port,streams,listen"} for the server process when this PC is the main PC of a 2-PC pair,
93
  else {}. The server's engine (onwx.halo) turns it into GUFO_TP / GUFO_TP_LISTEN for a qwen35moe model only."""
94
  s = settings(cfg)
95
- if not (s["enabled"] and s["role"] == "main"):
96
  return {}
97
  return {ENV: f"{s['ip']},{s['port']},{s['streams']},{1 if listens(s) else 0}"}
98
 
99
 
100
- def engine_env(value, arch):
101
  """onwx.halo, before halo_load: GUFO_TP / GUFO_TP_LISTEN from ONWX_HALO_TP for a model the engine splits
102
  (arch qwen35moe); for any other model they are removed (a model switch in the same server). -> (ip, port) or
103
- None."""
104
- for k in ("GUFO_TP", "GUFO_TP_LISTEN"):
 
105
  os.environ.pop(k, None)
106
  if not value or arch not in TP_ARCHS:
107
  return None
@@ -112,9 +122,73 @@ def engine_env(value, arch):
112
  return None
113
  os.environ["GUFO_TP"] = f"0,{ip},{port},{streams}"
114
  os.environ["GUFO_TP_LISTEN"] = "1" if listen else "0"
 
 
 
115
  return ip, port
116
 
117
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  # ------------------------------------------------------------------ engine support (without loading the engine)
119
 
120
  _SUPPORT = {}
@@ -242,13 +316,16 @@ def start_helper(cfg):
242
  from .i18n import T
243
  with _LOCK:
244
  s = settings(cfg)
 
 
245
  if not s["enabled"] or s["role"] != "helper":
246
  raise ValueError(T("設定で「2 台で動かす」をオンにして、この PC の役割を「補助 PC」にしてください"))
247
  if engine_supports() is False:
248
  raise ValueError(T("この版の GPU エンジンは 2 台で動かす機能に対応していません"))
249
  if engine_supports() is None:
250
  raise ValueError(T("この PC には GPU エンジンがありません"))
251
- model = helper_model(cfg)
 
252
  if not model:
253
  raise ValueError(T("Qwen3.6-35B-A3B の GGUF がこの PC にありません(メイン PC と同じファイルを置いてください)"))
254
  stop_helper()
@@ -339,9 +416,10 @@ def helper_running():
339
  def _parse(argv, cfg):
340
  s = settings(cfg)
341
  ap = argparse.ArgumentParser(prog="onwx tp-helper",
342
- description="2-PC helper: hold the other half of a Qwen3.6-35B-A3B GGUF for the main PC "
343
  "(defaults from the app's settings, halo_tp)")
344
- ap.add_argument("--model", default=None, help="the GGUF file, or the app's model key (default: from the settings)")
 
345
  ap.add_argument("--ip", default=s["ip"], help="the listening PC's USB4 / LAN address (default %(default)s)")
346
  ap.add_argument("--port", type=int, default=s["port"], help="TCP port (default %(default)s)")
347
  ap.add_argument("--streams", type=int, default=s["streams"], help="TCP streams (default %(default)s)")
@@ -371,13 +449,14 @@ def main(argv=None):
371
  from . import app
372
  cfg = app.load_config()
373
  a = _parse(sys.argv[2:] if argv is None else argv, cfg)
374
- model = helper_model(cfg, a.model)
 
375
  if not model:
376
- say(f"[tp] error: no Qwen3.6-35B-A3B GGUF found ({a.model or 'the settings / the model folders'}); "
377
  "put the same file as on the main PC here and pass --model PATH")
378
  return 2
379
- if not tp_model(model):
380
- say(f"[tp] note: {os.path.basename(model)} is not named like a Qwen3.6-35B-A3B GGUF; the engine checks it")
381
  if not app.single_instance("tp-helper"):
382
  say("[tp] error: a 2-PC helper is already running on this PC")
383
  return 2
@@ -407,7 +486,8 @@ def main(argv=None):
407
  pass
408
  _write_pid({"pid": os.getpid(), "created": created, "ip": a.ip, "port": a.port, "listen": bool(a.listen),
409
  "model": model})
410
- say(f"[tp] onwx-dash 2-PC helper; engine {L.halo_version().decode()}; model {model}")
 
411
  how = f"listening on {a.ip}:{a.port}" if a.listen else f"connecting to {a.ip}:{a.port}"
412
  try:
413
  while True:
@@ -415,7 +495,7 @@ def main(argv=None):
415
  out = []
416
 
417
  def serve():
418
- rc = L.halo_tp_serve(model.encode(), a.ip.encode(), a.port, 1 if a.listen else 0, a.streams)
419
  # (the engine's error text is per thread: read it on the thread that made the call)
420
  out.append((rc, halo._err() if rc < 0 else ""))
421
 
 
17
  listener "main" | "helper": which PC listens (Windows' firewall usually blocks connections coming in on a new
18
  network adapter: the Linux side, or the side whose firewall lets them in, should listen)
19
  streams TCP streams (4)
20
+ own_copy [1.1] False (default): the helper needs no model file - the main PC sends the helper's part of its GGUF
21
+ over the link while the helper loads (Linux helpers). True: the helper loads its own copy (`model`)
22
+ model the helper's own GGUF (own_copy): a model key / file ("" = the model chosen in the app if it is a 2-PC
23
+ model, else the first one found)
24
 
25
  No NPU help and no images in 2-PC mode; the GPU engine only.
26
  """
27
  import argparse, ipaddress, json, os, subprocess, sys, threading, time
28
 
29
  TP_ARCH = "qwen35moe" # (the NPU switches the helper turns off use this one)
30
+ # the architectures the engine splits over two PCs (Qwen3.6-35B-A3B, Qwen3.8-27B, Nemotron 3.5 Bolt 74B-A9B - the
31
+ # last needs two PCs on 32 GB machines: about 11 GB of weights each)
32
+ TP_ARCHS = ("qwen35moe", "qwen35", "nemotron_h_moe")
33
+ TP_PREFIX = ("qwen3.6-35b-a3b", "qwen3.8-27b", "nvidia-nemotron-3.5-bolt") # their GGUF files' names
34
  DEFAULT = {"enabled": False, "role": "main", "ip": "192.168.2.1", "port": 50120, "listener": "main", "streams": 4,
35
+ "model": "", "own_copy": False}
36
+ STREAM = "stream" # tp-helper --model stream: the main PC sends the model (halo_tp_serve(""))
37
  ENV = "ONWX_HALO_TP" # app -> server process: "ip,port,streams,listen" (main role only)
38
+ # [1.1] Linux only (both PCs): Windows' GPU runtime made the exchange slower than one PC (1.0 measured), so the
39
+ # setting is hidden there and does nothing
40
+ OS_OK = os.name != "nt"
41
 
42
 
43
  # ------------------------------------------------------------------ settings
 
62
  except (TypeError, ValueError):
63
  pass
64
  out["model"] = str(raw.get("model") or "")
65
+ out["own_copy"] = bool(raw.get("own_copy", False))
66
  return out
67
 
68
 
 
84
  role = new.get("role") if new.get("role") in ("main", "helper") else "main"
85
  listener = new.get("listener") if new.get("listener") in ("main", "helper") else "main"
86
  return {"enabled": bool(new.get("enabled")), "role": role, "ip": ip, "port": port, "listener": listener,
87
+ "streams": streams, "model": str(new.get("model") or ""), "own_copy": bool(new.get("own_copy"))}, None
88
 
89
 
90
  def listens(s):
 
101
  """{ONWX_HALO_TP: "ip,port,streams,listen"} for the server process when this PC is the main PC of a 2-PC pair,
102
  else {}. The server's engine (onwx.halo) turns it into GUFO_TP / GUFO_TP_LISTEN for a qwen35moe model only."""
103
  s = settings(cfg)
104
+ if not (OS_OK and s["enabled"] and s["role"] == "main"):
105
  return {}
106
  return {ENV: f"{s['ip']},{s['port']},{s['streams']},{1 if listens(s) else 0}"}
107
 
108
 
109
+ def engine_env(value, arch, model_path=None):
110
  """onwx.halo, before halo_load: GUFO_TP / GUFO_TP_LISTEN from ONWX_HALO_TP for a model the engine splits
111
  (arch qwen35moe); for any other model they are removed (a model switch in the same server). -> (ip, port) or
112
+ None. Also GUFO_TP_SPLIT: the work split learned for this model and pair (balance_*; the engine sends it to the
113
+ helper at hello), or ONWX_HALO_TP_SPLIT when set to a number (a fixed split; "auto" / unset = learned)."""
114
+ for k in ("GUFO_TP", "GUFO_TP_LISTEN", "GUFO_TP_SPLIT"):
115
  os.environ.pop(k, None)
116
  if not value or arch not in TP_ARCHS:
117
  return None
 
122
  return None
123
  os.environ["GUFO_TP"] = f"0,{ip},{port},{streams}"
124
  os.environ["GUFO_TP_LISTEN"] = "1" if listen else "0"
125
+ split = split_for(model_path, ip)
126
+ if split is not None:
127
+ os.environ["GUFO_TP_SPLIT"] = f"{split:.3f}"
128
  return ip, port
129
 
130
 
131
+ # ------------------------------------------------------------------ uneven split (the two PCs' speeds)
132
+ # The engine splits the DeltaNet heads and the dense FFN width by GUFO_TP_SPLIT (the main PC's share, 0.5 = half and
133
+ # half). While the app decodes, halo_tp_balance measures both PCs' compute per sum and advises the share that would
134
+ # even them out; it is kept per model file and pair in <config>/tp_balance.json and used from the next load on.
135
+
136
+ def _balance_file():
137
+ from . import app
138
+ return os.path.join(app.config_dir(), "tp_balance.json")
139
+
140
+
141
+ def _balance_key(model_path, ip):
142
+ try:
143
+ size = os.path.getsize(model_path)
144
+ except OSError:
145
+ size = 0
146
+ return f"{os.path.basename(model_path)}|{size}|{ip}"
147
+
148
+
149
+ def split_for(model_path, ip):
150
+ """The share to load with: ONWX_HALO_TP_SPLIT as a number, else the learned one, else None (half and half)."""
151
+ fixed = os.environ.get("ONWX_HALO_TP_SPLIT", "auto").strip().lower()
152
+ if fixed not in ("", "auto"):
153
+ try:
154
+ v = float(fixed)
155
+ return v if 0.3 <= v <= 0.7 else None
156
+ except ValueError:
157
+ return None
158
+ if not model_path:
159
+ return None
160
+ try:
161
+ with open(_balance_file(), encoding="utf-8") as f:
162
+ v = json.load(f).get(_balance_key(model_path, ip))
163
+ return float(v["split"]) if v and 0.3 <= float(v["split"]) <= 0.7 else None
164
+ except (OSError, ValueError, TypeError, KeyError):
165
+ return None
166
+
167
+
168
+ def balance_update(model_path, ip, advice, measured):
169
+ """Store the engine's advice (when it moved by >= 0.01): the next load splits by it. -> True when stored."""
170
+ if os.environ.get("ONWX_HALO_TP_SPLIT", "auto").strip().lower() not in ("", "auto"):
171
+ return False
172
+ now = split_for(model_path, ip)
173
+ if now is not None and abs(now - advice) < 0.01:
174
+ return False
175
+ if now is None and abs(advice - 0.5) < 0.01:
176
+ return False
177
+ path = _balance_file()
178
+ try:
179
+ with open(path, encoding="utf-8") as f:
180
+ data = json.load(f)
181
+ except (OSError, ValueError):
182
+ data = {}
183
+ data[_balance_key(model_path, ip)] = {"split": round(advice, 3), "measured": measured,
184
+ "at": time.strftime("%Y-%m-%d %H:%M:%S")}
185
+ tmp = path + ".tmp"
186
+ with open(tmp, "w", encoding="utf-8") as f:
187
+ json.dump(data, f, indent=1)
188
+ os.replace(tmp, path)
189
+ return True
190
+
191
+
192
  # ------------------------------------------------------------------ engine support (without loading the engine)
193
 
194
  _SUPPORT = {}
 
316
  from .i18n import T
317
  with _LOCK:
318
  s = settings(cfg)
319
+ if not OS_OK:
320
+ raise ValueError("2-PC: Linux only")
321
  if not s["enabled"] or s["role"] != "helper":
322
  raise ValueError(T("設定で「2 台で動かす」をオンにして、この PC の役割を「補助 PC」にしてください"))
323
  if engine_supports() is False:
324
  raise ValueError(T("この版の GPU エンジンは 2 台で動かす機能に対応していません"))
325
  if engine_supports() is None:
326
  raise ValueError(T("この PC には GPU エンジンがありません"))
327
+ # [1.1] the model from the main PC unless this PC is set to use its own copy
328
+ model = helper_model(cfg) if s["own_copy"] else STREAM
329
  if not model:
330
  raise ValueError(T("Qwen3.6-35B-A3B の GGUF がこの PC にありません(メイン PC と同じファイルを置いてください)"))
331
  stop_helper()
 
416
  def _parse(argv, cfg):
417
  s = settings(cfg)
418
  ap = argparse.ArgumentParser(prog="onwx tp-helper",
419
+ description="2-PC helper: hold the other half of a 2-PC model for the main PC "
420
  "(defaults from the app's settings, halo_tp)")
421
+ ap.add_argument("--model", default=None, help="the GGUF file, the app's model key, or 'stream' (the main PC sends "
422
+ "the model; default: from the settings)")
423
  ap.add_argument("--ip", default=s["ip"], help="the listening PC's USB4 / LAN address (default %(default)s)")
424
  ap.add_argument("--port", type=int, default=s["port"], help="TCP port (default %(default)s)")
425
  ap.add_argument("--streams", type=int, default=s["streams"], help="TCP streams (default %(default)s)")
 
449
  from . import app
450
  cfg = app.load_config()
451
  a = _parse(sys.argv[2:] if argv is None else argv, cfg)
452
+ streamed = a.model == STREAM or (not a.model and not settings(cfg)["own_copy"])
453
+ model = STREAM if streamed else helper_model(cfg, a.model)
454
  if not model:
455
+ say(f"[tp] error: no 2-PC model GGUF found (Qwen3.6-35B-A3B / Qwen3.8-27B / Nemotron 3.5 Bolt; {a.model or 'the settings / the model folders'}); "
456
  "put the same file as on the main PC here and pass --model PATH")
457
  return 2
458
+ if not streamed and not tp_model(model):
459
+ say(f"[tp] note: {os.path.basename(model)} is not named like a 2-PC model GGUF; the engine checks it")
460
  if not app.single_instance("tp-helper"):
461
  say("[tp] error: a 2-PC helper is already running on this PC")
462
  return 2
 
486
  pass
487
  _write_pid({"pid": os.getpid(), "created": created, "ip": a.ip, "port": a.port, "listen": bool(a.listen),
488
  "model": model})
489
+ say(f"[tp] onwx-dash 2-PC helper; engine {L.halo_version().decode()}; model "
490
+ f"{'from the main PC (sent over the link while loading)' if streamed else model}")
491
  how = f"listening on {a.ip}:{a.port}" if a.listen else f"connecting to {a.ip}:{a.port}"
492
  try:
493
  while True:
 
495
  out = []
496
 
497
  def serve():
498
+ rc = L.halo_tp_serve(b"" if streamed else model.encode(), a.ip.encode(), a.port, 1 if a.listen else 0, a.streams)
499
  # (the engine's error text is per thread: read it on the thread that made the call)
500
  out.append((rc, halo._err() if rc < 0 else ""))
501
 
onwx/web/manage.html CHANGED
@@ -272,14 +272,15 @@
272
  <div class="card set sub" data-sub="tp">
273
  <div class="sec">2 台で動かす (2-PC)</div>
274
  <div class="banner small" id="tp-old" style="display:none">この版の GPU エンジンは 2 台で動かす機能に対応していません。両方の PC の onwx-dash を新しい版にしてください。</div>
275
- <span class="desc">2 台の PC を USB4(Thunderbolt)のケーブルでつなぎ、1 つのモデルを半分ずつ持って動かします。モデルのメモリが半分になり、生成も速くなります(Ryzen AI 9 HX のミニ PC 2 台で、Qwen3.8 27B は 1 台の約 1.5 倍、Qwen3.6 35B-A3B は約 1.2 倍。プロンプトの読み込みは 1 台より遅くなります)。使えるのは Qwen3.6 35B-A3B と Qwen3.8 27B の GGUF で、GPU だけで動かします(NPU の手伝いと画像はこのモードでは使えません)。</span>
276
- <label class="swrow"><span class="switch"><input type="checkbox" id="f-tp_enabled"><i></i></span><span>2 台の PC で 1 つのモデルを動かす<span class="desc">オンにすると、Qwen3.6 35B-A3B か Qwen3.8 27B を読み込むときにもう 1 台とつながってから読み込みます。ほかのモデルはこれまでどおり 1 台で動きます。</span></span></label>
277
  <div class="opt"><span class="k">この PC の役割</span><select id="f-tp_role" style="width:300px;max-width:100%"><option value="main">メイン PC(サーバー・チャット・API)</option><option value="helper">補助 PC(エンジンだけ)</option></select>
278
  <span class="desc">メイン PC はいつもどおりモデルを読み込みます。補助 PC は「サーバー」の画面かトレイのメニューで補助を開始し、メイン PC を待ちます。</span></div>
279
  <div class="opt"><span class="k">待ち受ける PC</span><select id="f-tp_listener" style="width:300px;max-width:100%"><option value="main">メイン PC が待ち受ける</option><option value="helper">補助 PC が待ち受ける</option></select>
280
  <span class="desc">片方が待ち受け、もう片方がつなぎに行きます。Windows のファイアウォールは新しいネットワークアダプターへの接続を止めることが多いので、Linux の PC か、接続を許可した PC を待ち受けにしてください。両方の PC で同じ値にします。</span></div>
281
  <div class="opt"><span class="k">待ち受ける PC の IP アドレス</span><input type="text" id="f-tp_ip" style="width:160px" placeholder="192.168.2.1"> <span class="small muted">ポート</span> <input type="number" id="f-tp_port" min="1" max="65535" style="width:90px"> <span class="small muted">TCP の本数</span> <input type="number" id="f-tp_streams" min="1" max="16" style="width:60px">
282
  <span class="desc">USB4 のネットワークアダプターに、同じサブネットの固定 IP を付けておきます(例:192.168.2.1 と 192.168.2.2)。ここには待ち受ける PC の IP を入れ、両方の PC で同じ値にします。</span></div>
 
283
  <div class="opt" id="row-tp_model"><span class="k">補助 PC のモデル</span><select id="f-tp_model" style="width:300px;max-width:100%"></select>
284
  <span class="desc">メイン PC と同じ GGUF ファイル(同じモデル・同じ量子化)が必要です。</span></div>
285
  <span class="desc">補助 PC を先に開始してください(メイン PC が読み込みを始めてから 10 分以内でもかまいません)。両方の PC で同じ版の onwx-dash を使ってください。プロンプトの読み込みは両方の PC で行います。</span>
@@ -492,6 +493,7 @@
492
  const html = opts.join("");
493
  if ($("f-tp_model").dataset.html !== html) { $("f-tp_model").innerHTML = html; $("f-tp_model").dataset.html = html; }
494
  $("f-tp_model").value = t.model || "";
 
495
  tpForm();
496
  }
497
  }
@@ -499,10 +501,14 @@
499
  // [1.0] two PCs: the settings sub-tab (GPU engine PCs only) and, on the helper PC, its card on the server page
500
  function tpForm() {
501
  const on = $("f-tp_enabled").checked;
502
- for (const id of ["f-tp_role", "f-tp_listener", "f-tp_ip", "f-tp_port", "f-tp_streams", "f-tp_model"]) $(id).disabled = !on;
503
- $("row-tp_model").style.display = $("f-tp_role").value === "helper" ? "" : "none";
 
 
 
504
  }
505
  $("f-tp_enabled").addEventListener("change", tpForm);
 
506
  $("f-tp_role").addEventListener("change", tpForm);
507
  const tpAddr = (listen, ip, port) => T(listen ? "{0} で待ち受け" : "{0} につなぐ", ip + ":" + port);
508
  function renderTp() {
@@ -658,7 +664,7 @@
658
  if (S.tp && S.tp.settings) // [1.0] two PCs
659
  body.halo_tp = {enabled: $("f-tp_enabled").checked, role: $("f-tp_role").value, listener: $("f-tp_listener").value,
660
  ip: $("f-tp_ip").value.trim(), port: $("f-tp_port").value, streams: $("f-tp_streams").value,
661
- model: $("f-tp_model").value};
662
  const oldLang = S.config.lang || "auto";
663
  const r = await post("settings", body);
664
  if (r.error) return;
 
272
  <div class="card set sub" data-sub="tp">
273
  <div class="sec">2 台で動かす (2-PC)</div>
274
  <div class="banner small" id="tp-old" style="display:none">この版の GPU エンジンは 2 台で動かす機能に対応していません。両方の PC の onwx-dash を新しい版にしてください。</div>
275
+ <span class="desc">2 台の PC を USB4(Thunderbolt)のケーブルでつなぎ、1 つのモデルを半分ずつ持って動かします。モデルのメモリが半分になり、1 台では載らないモデルも動き、生成も速くなります(Ryzen AI 9 HX のミニ PC 2 台で、Nemotron 3.5 Bolt 74B-A9B は生成が 1 台の約 1.55 倍・プロンプトの読み込みが約 1.4〜1.5 倍、Qwen3.8 27B は生成が約 1.7 倍、Qwen3.6 35B-A3B は約 1.4 倍)。モデルはメイン PC にあれば動きます。使えるのは Nemotron 3.5 Bolt、Qwen3.6 35B-A3B、Qwen3.8 27B の GGUF で、GPU だけで動かします(NPU の手伝いと画像はこのモードでは使えません)。2 台とも Linux で使ってください。</span>
276
+ <label class="swrow"><span class="switch"><input type="checkbox" id="f-tp_enabled"><i></i></span><span>2 台の PC で 1 つのモデルを動かす<span class="desc">オンにすると、Nemotron 3.5 Bolt、Qwen3.6 35B-A3B か Qwen3.8 27B を読み込むときにもう 1 台とつながってから読み込みます。ほかのモデルはこれまでどおり 1 台で動きます。</span></span></label>
277
  <div class="opt"><span class="k">この PC の役割</span><select id="f-tp_role" style="width:300px;max-width:100%"><option value="main">メイン PC(サーバー・チャット・API)</option><option value="helper">補助 PC(エンジンだけ)</option></select>
278
  <span class="desc">メイン PC はいつもどおりモデルを読み込みます。補助 PC は「サーバー」の画面かトレイのメニューで補助を開始し、メイン PC を待ちます。</span></div>
279
  <div class="opt"><span class="k">待ち受ける PC</span><select id="f-tp_listener" style="width:300px;max-width:100%"><option value="main">メイン PC が待ち受ける</option><option value="helper">補助 PC が待ち受ける</option></select>
280
  <span class="desc">片方が待ち受け、もう片方がつなぎに行きます。Windows のファイアウォールは新しいネットワークアダプターへの接続を止めることが多いので、Linux の PC か、接続を許可した PC を待ち受けにしてください。両方の PC で同じ値にします。</span></div>
281
  <div class="opt"><span class="k">待ち受ける PC の IP アドレス</span><input type="text" id="f-tp_ip" style="width:160px" placeholder="192.168.2.1"> <span class="small muted">ポート</span> <input type="number" id="f-tp_port" min="1" max="65535" style="width:90px"> <span class="small muted">TCP の本数</span> <input type="number" id="f-tp_streams" min="1" max="16" style="width:60px">
282
  <span class="desc">USB4 のネットワークアダプターに、同じサブネットの固定 IP を付けておきます(例:192.168.2.1 と 192.168.2.2)。ここには待ち受ける PC の IP を入れ、両方の PC で同じ値にします。</span></div>
283
+ <label class="swrow" id="row-tp_own"><span class="switch"><input type="checkbox" id="f-tp_own_copy"><i></i></span><span>補助 PC でも自分のモデルファイルを使う<span class="desc">オフ(おすすめ):補助 PC にモデルは要りません。読み込みのたびに、メイン PC が補助 PC の分(モデルの約半分)を USB4 で送ります。オン:補助 PC にもメイン PC と同じ GGUF を置き、そこから読み込みます。</span></span></label>
284
  <div class="opt" id="row-tp_model"><span class="k">補助 PC のモデル</span><select id="f-tp_model" style="width:300px;max-width:100%"></select>
285
  <span class="desc">メイン PC と同じ GGUF ファイル(同じモデル・同じ量子化)が必要です。</span></div>
286
  <span class="desc">補助 PC を先に開始してください(メイン PC が読み込みを始めてから 10 分以内でもかまいません)。両方の PC で同じ版の onwx-dash を使ってください。プロンプトの読み込みは両方の PC で行います。</span>
 
493
  const html = opts.join("");
494
  if ($("f-tp_model").dataset.html !== html) { $("f-tp_model").innerHTML = html; $("f-tp_model").dataset.html = html; }
495
  $("f-tp_model").value = t.model || "";
496
+ $("f-tp_own_copy").checked = !!t.own_copy;
497
  tpForm();
498
  }
499
  }
 
501
  // [1.0] two PCs: the settings sub-tab (GPU engine PCs only) and, on the helper PC, its card on the server page
502
  function tpForm() {
503
  const on = $("f-tp_enabled").checked;
504
+ for (const id of ["f-tp_role", "f-tp_listener", "f-tp_ip", "f-tp_port", "f-tp_streams", "f-tp_model", "f-tp_own_copy"])
505
+ $(id).disabled = !on;
506
+ const helper = $("f-tp_role").value === "helper";
507
+ $("row-tp_own").style.display = helper ? "" : "none"; // [1.1] the model from the main PC by default
508
+ $("row-tp_model").style.display = helper && $("f-tp_own_copy").checked ? "" : "none";
509
  }
510
  $("f-tp_enabled").addEventListener("change", tpForm);
511
+ $("f-tp_own_copy").addEventListener("change", tpForm);
512
  $("f-tp_role").addEventListener("change", tpForm);
513
  const tpAddr = (listen, ip, port) => T(listen ? "{0} で待ち受け" : "{0} につなぐ", ip + ":" + port);
514
  function renderTp() {
 
664
  if (S.tp && S.tp.settings) // [1.0] two PCs
665
  body.halo_tp = {enabled: $("f-tp_enabled").checked, role: $("f-tp_role").value, listener: $("f-tp_listener").value,
666
  ip: $("f-tp_ip").value.trim(), port: $("f-tp_port").value, streams: $("f-tp_streams").value,
667
+ model: $("f-tp_model").value, own_copy: $("f-tp_own_copy").checked};
668
  const oldLang = S.config.lang || "auto";
669
  const r = await post("settings", body);
670
  if (r.error) return;