ryugyosoft commited on
Commit
accfd57
·
verified ·
1 Parent(s): 420ac6d

onw 1.4.6: ~30% faster answers on Windows - the server starts at normal priority and runs above normal while generating (below normal put it on the low-power cores)

Browse files
Files changed (5) hide show
  1. CHANGELOG.md +6 -0
  2. CHANGELOG_en.md +6 -0
  3. onw/__init__.py +1 -1
  4. onw/app.py +2 -2
  5. onw/server.py +23 -2
CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@
5
  日付は日本時間です。各版は Hugging Face の `ryugyosoft/onw` にタグ(`v0.4.2` 以降)付きで残っています。
6
  onw ウィンドウは、新しい版があるとこのファイルから変更点を表示します(`## v…` の見出しで区切っています)。
7
 
 
 
 
 
 
 
8
  ## v1.4.5 (2026-10-06)
9
  - 初回のコンパイルが約 3 分短く:Qwen3.5 系の NF4 版の 4・64 トークン用グラフは、NPUW の「繰り返しをまとめる」方式ではコンパイル
10
  できず、毎回失敗してから別の方式に切り替えていました。最初から別の方式でコンパイルします(Panther Lake の Ornith-1.5-9B(NF4)で
 
5
  日付は日本時間です。各版は Hugging Face の `ryugyosoft/onw` にタグ(`v0.4.2` 以降)付きで残っています。
6
  onw ウィンドウは、新しい版があるとこのファイルから変更点を表示します(`## v…` の見出しで区切っています)。
7
 
8
+ ## v1.4.6 (2026-10-06)
9
+ - **Windows で回答が約 3 割速く(Lunar Lake の Qwen3.5-9B(NF4)で約 12 → 16 tok/s、Panther Lake の Ornith-1.5-9B(NF4)で 12.3〜15.4 → 16.1〜19.9 tok/s)**:onw のウィンドウはサーバーを優先度「通常以下」で
10
+ 起動しており、Windows は回答も省電力コア・低いクロックで動かしていました。サーバーは「通常」で起動し、回答を作っている間だけ
11
+ 「通常以上」にします。回答中に使う CPU は 1〜2 コア分なので、ほかのアプリへの影響は小さいです(`ONW_PRIORITY=normal` で回答中も
12
+ 「通常」、`off` で変えない)。
13
+
14
  ## v1.4.5 (2026-10-06)
15
  - 初回のコンパイルが約 3 分短く:Qwen3.5 系の NF4 版の 4・64 トークン用グラフは、NPUW の「繰り返しをまとめる」方式ではコンパイル
16
  できず、毎回失敗してから別の方式に切り替えていました。最初から別の方式でコンパイルします(Panther Lake の Ornith-1.5-9B(NF4)で
CHANGELOG_en.md CHANGED
@@ -4,6 +4,12 @@
4
 
5
  Dates are JST. Every version is on Hugging Face `ryugyosoft/onw`, tagged from `v0.4.2` on.
6
 
 
 
 
 
 
 
7
  ## v1.4.5 (2026-10-06)
8
  - First compile ~3 minutes shorter: the 4- and 64-token graphs of the NF4 Qwen3.5 builds cannot be compiled with NPUW's
9
  repeated-block folding, and every first load tried that, failed, then switched. They now take the other way at once
 
4
 
5
  Dates are JST. Every version is on Hugging Face `ryugyosoft/onw`, tagged from `v0.4.2` on.
6
 
7
+ ## v1.4.6 (2026-10-06)
8
+ - **Answers ~30% faster on Windows (Qwen3.5-9B NF4 on Lunar Lake: ~12 -> 16 tok/s; Ornith-1.5-9B NF4 on Panther Lake: 12.3-15.4 -> 16.1-19.9 tok/s)**: the onw window started the server below
9
+ normal priority, and Windows then ran the answers on the low-power cores at low clocks. The server now starts at normal
10
+ priority and runs above normal only while it generates; that takes one or two cores, so other apps hardly notice
11
+ (`ONW_PRIORITY=normal` keeps it normal while generating, `off` leaves it alone).
12
+
13
  ## v1.4.5 (2026-10-06)
14
  - First compile ~3 minutes shorter: the 4- and 64-token graphs of the NF4 Qwen3.5 builds cannot be compiled with NPUW's
15
  repeated-block folding, and every first load tried that, failed, then switched. They now take the other way at once
onw/__init__.py CHANGED
@@ -2,4 +2,4 @@
2
 
3
  A small engine that runs LLMs entirely on the Intel NPU: static segment graphs + host-managed state.
4
  """
5
- __version__ = "1.4.5"
 
2
 
3
  A small engine that runs LLMs entirely on the Intel NPU: static segment graphs + host-managed state.
4
  """
5
+ __version__ = "1.4.6"
onw/app.py CHANGED
@@ -677,8 +677,8 @@ def _start_server(cfg):
677
  if cfg.get("big_blocks") != "on": # (64-token blocks would stay in memory beside them)
678
  env["ONW_S64"] = "0"
679
  log = open(os.path.join(config_dir(), "server.log"), "w", encoding="utf8")
680
- kw = {"creationflags": subprocess.CREATE_NO_WINDOW | subprocess.CREATE_NEW_PROCESS_GROUP
681
- | subprocess.BELOW_NORMAL_PRIORITY_CLASS} if os.name == "nt" else {"start_new_session": True}
682
  p = subprocess.Popen(args, cwd=models_dir(cfg), stdout=log, stderr=subprocess.STDOUT, env=env, **kw)
683
  log.close()
684
  created = None
 
677
  if cfg.get("big_blocks") != "on": # (64-token blocks would stay in memory beside them)
678
  env["ONW_S64"] = "0"
679
  log = open(os.path.join(config_dir(), "server.log"), "w", encoding="utf8")
680
+ # (normal priority, also while compiling: below normal put the server on the low-power cores - see server.set_priority)
681
+ kw = {"creationflags": subprocess.CREATE_NO_WINDOW | subprocess.CREATE_NEW_PROCESS_GROUP} if os.name == "nt" else {"start_new_session": True}
682
  p = subprocess.Popen(args, cwd=models_dir(cfg), stdout=log, stderr=subprocess.STDOUT, env=env, **kw)
683
  log.close()
684
  created = None
onw/server.py CHANGED
@@ -192,8 +192,12 @@ def start_generation(msgs, kw):
192
  with lock:
193
  if stop.is_set(): # the client left while this request waited for the NPU
194
  return
195
- for d in pipe.stream_chat(msgs, should_stop=stop.is_set, split_reasoning=True, **kw):
196
- q.put(d)
 
 
 
 
197
  except Exception as e: # surfaced to the client
198
  q.put(e)
199
  finally:
@@ -575,6 +579,22 @@ def recommended_sampling(arch, engine_dir=None):
575
  from onw import compat # noqa: E402,F401 (/v1/messages and /v1/responses on this app)
576
 
577
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
578
  def main(argv=None):
579
  global pipe, MODEL_ID, API_KEY, API_SAMPLING
580
  ap = argparse.ArgumentParser(prog="onw serve", description="chat UI + OpenAI-compatible API on the Intel NPU")
@@ -600,6 +620,7 @@ def main(argv=None):
600
  a.device = "CPU"
601
  from onw.chat import ChatEngine
602
  pipe = ChatEngine(a.engine, a.device, context=a.context, pld=not a.no_pld)
 
603
  MODEL_ID = a.name or os.path.basename(os.path.normpath(a.engine))
604
  v = pipe.vision
605
  info.update(model=MODEL_ID, title=MODEL_ID, devices={"lm": a.device}, fast=False, vision=bool(v),
 
192
  with lock:
193
  if stop.is_set(): # the client left while this request waited for the NPU
194
  return
195
+ set_priority(True)
196
+ try:
197
+ for d in pipe.stream_chat(msgs, should_stop=stop.is_set, split_reasoning=True, **kw):
198
+ q.put(d)
199
+ finally:
200
+ set_priority(False)
201
  except Exception as e: # surfaced to the client
202
  q.put(e)
203
  finally:
 
579
  from onw import compat # noqa: E402,F401 (/v1/messages and /v1/responses on this app)
580
 
581
 
582
+ def set_priority(busy):
583
+ """Windows: the server's priority class - normal while loading and waiting, above normal while it generates
584
+ (busy). Windows puts a below-normal process on the low-power cores at low clocks (onw 1.4.5 and earlier started
585
+ the server below normal: Lunar Lake, Qwen3.5-9B NF4 with MTP ~12 tok/s, 16 above normal); generating takes one or two
586
+ cores, so the rest of the PC hardly notices. ONW_PRIORITY: the class while generating, normal | above (default) |
587
+ off (leave it as started)."""
588
+ want = os.environ.get("ONW_PRIORITY", "above")
589
+ if os.name != "nt" or want not in ("normal", "above"):
590
+ return
591
+ import ctypes
592
+ k32 = ctypes.WinDLL("kernel32")
593
+ k32.GetCurrentProcess.restype = ctypes.c_void_p
594
+ k32.SetPriorityClass.argtypes = [ctypes.c_void_p, ctypes.c_uint32]
595
+ k32.SetPriorityClass(k32.GetCurrentProcess(), 0x8000 if busy and want == "above" else 0x20)
596
+
597
+
598
  def main(argv=None):
599
  global pipe, MODEL_ID, API_KEY, API_SAMPLING
600
  ap = argparse.ArgumentParser(prog="onw serve", description="chat UI + OpenAI-compatible API on the Intel NPU")
 
620
  a.device = "CPU"
621
  from onw.chat import ChatEngine
622
  pipe = ChatEngine(a.engine, a.device, context=a.context, pld=not a.no_pld)
623
+ set_priority(False)
624
  MODEL_ID = a.name or os.path.basename(os.path.normpath(a.engine))
625
  v = pipe.vision
626
  info.update(model=MODEL_ID, title=MODEL_ID, devices={"lm": a.device}, fast=False, vision=bool(v),