dsh-qqbot-muu 0.1.15 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +168 -85
- package/client/qqbot-settings.js +13401 -12024
- package/config/modules.json +212 -0
- package/dist/channel-tools.js +21 -10
- package/dist/config.d.ts +14 -0
- package/dist/config.js +573 -449
- package/dist/features/contextless-store.js +247 -247
- package/dist/features/contextless-trim.js +455 -34
- package/dist/features/four-source.js +338 -336
- package/dist/features/group-join-request.js +289 -287
- package/dist/features/local-models.js +1494 -0
- package/dist/features/rotate-summarizer.js +438 -0
- package/dist/features/scenario-detect.js +321 -0
- package/dist/features/scheduler.js +8 -1
- package/dist/features/session-rotate.js +499 -0
- package/dist/features/session-title.js +199 -0
- package/dist/features/style-layer.js +501 -0
- package/dist/features/thinking-log.js +71 -69
- package/dist/gateway/bootstrap.js +1704 -1388
- package/dist/gateway/data-root.js +77 -3
- package/dist/gateway/middleware-setup.js +6 -3
- package/dist/index.js +4 -2
- package/dist/model/settings-reader.js +193 -102
- package/dist/session/session-manager.js +1730 -1587
- package/dist/shared/paths.js +128 -0
- package/dist/shared/settings-io.js +79 -0
- package/dist/transport/inbound.js +20 -1
- package/dist/transport/outbound.js +56 -4
- package/docs/RELEASE_CHECKLIST.md +24 -2
- package/dshqqbot/.qqbot-extensions/hooks/interview-panel.mjs +41 -1
- package/dshqqbot/.qqbot-extensions/inbound/00-vision.mjs +111 -0
- package/dshqqbot/.qqbot-extensions/inbound/aa-memory-recall.mjs +802 -689
- package/dshqqbot/.qqbot-extensions/inbound/ac-image-see.mjs +1 -1
- package/dshqqbot/.qqbot-extensions/inbound/az-feedback.mjs +113 -115
- package/dshqqbot/.qqbot-extensions/inbound/local-answer.mjs +689 -568
- package/dshqqbot/.qqbot-extensions/lib/.pet-form.json +1 -1
- package/dshqqbot/.qqbot-extensions/lib/draw-core.mjs +238 -7
- package/dshqqbot/.qqbot-extensions/lib/local-llm.mjs +455 -394
- package/dshqqbot/.qqbot-extensions/lib/memory-agent.mjs +930 -928
- package/dshqqbot/.qqbot-extensions/lib/memory-core.mjs +537 -537
- package/dshqqbot/.qqbot-extensions/lib/memory-db.mjs +2476 -2245
- package/dshqqbot/.qqbot-extensions/lib/memory-hippo.mjs +18 -0
- package/dshqqbot/.qqbot-extensions/lib/memory.mjs +191 -186
- package/dshqqbot/.qqbot-extensions/lib/plugin-dir.mjs +14 -4
- package/dshqqbot/.qqbot-extensions/lib/scope-util.mjs +84 -0
- package/dshqqbot/.qqbot-extensions/lib/vision.mjs +1 -1
- package/dshqqbot/.qqbot-extensions/outbound/aa-sanitize.mjs +158 -154
- package/dshqqbot/.qqbot-extensions/outbound/ac-media-fix.mjs +5 -1
- package/dshqqbot/.qqbot-extensions/outbound/memory-agent.mjs +121 -130
- package/dshqqbot/.qqbot-extensions/outbound/split-reply.mjs +18 -2
- package/dshqqbot/.qqbot-extensions/outbound/turn-memory.mjs +92 -101
- package/dshqqbot/.qqbot-extensions/tools/draw.mjs +22 -1
- package/dshqqbot/.qqbot-extensions/tools/memory.mjs +178 -120
- package/dshqqbot/.qqbot-extensions/tools/pet_card.mjs +3 -2
- package/dshqqbot/.qqbot-extensions/tools/storyboard.mjs +3 -1
- package/dshqqbot/.qqbot-extensions/vendor/abogus/test-abogus.mjs +128 -126
- package/package.json +119 -111
- package/scripts/__pycache__/fan-mode.cpython-311.pyc +0 -0
- package/scripts/__pycache__/memory-audit.cpython-311.pyc +0 -0
- package/scripts/__pycache__/qq-ip-sync.cpython-311.pyc +0 -0
- package/scripts/__pycache__/qq-whitelist.cpython-311.pyc +0 -0
- package/scripts/_add_maintenance_cfg.py +20 -0
- package/scripts/_bench_keeplease.sh +10 -0
- package/scripts/_dbg_purge.py +15 -0
- package/scripts/_elev.sh +6 -0
- package/scripts/_fix_all_admin.cmd +16 -0
- package/scripts/_livecheck-image.mjs +33 -0
- package/scripts/_livecheck-llm.mjs +34 -0
- package/scripts/_livecheck-tts.mjs +37 -0
- package/scripts/_patch_curve.py +88 -0
- package/scripts/_patch_fan_thermal.py +24 -0
- package/scripts/_tag_tmp.py +13 -0
- package/scripts/adb-broker-client.mjs +87 -0
- package/scripts/adb-broker.mjs +205 -0
- package/scripts/ai-mode.cmd +6 -0
- package/scripts/ai-mode.py +387 -0
- package/scripts/ai-toolkit.py +607 -0
- package/scripts/apply-fan-gpu45.py +51 -0
- package/scripts/bench-fans.py +515 -0
- package/scripts/bench-load-direct.py +63 -0
- package/scripts/boot-tasks-hidden.vbs +20 -0
- package/scripts/boot-tasks.cmd +277 -0
- package/scripts/chat-archive/__pycache__/build-sft-v4.cpython-311.pyc +0 -0
- package/scripts/chat-archive/__pycache__/build-sft.cpython-311.pyc +0 -0
- package/scripts/chat-archive/build-sft-v4.py +566 -0
- package/scripts/chat-archive/build-sft.py +390 -0
- package/scripts/chat-archive/eval-sft.py +155 -0
- package/scripts/chat-archive/extract-memory.py +143 -0
- package/scripts/chat-archive/inventory.py +182 -0
- package/scripts/chat-archive/merge-sft.py +114 -0
- package/scripts/chat-archive/qce-pull.py +217 -0
- package/scripts/chat-archive/qqheader.py +110 -0
- package/scripts/chat-archive/qqkey2.py +113 -0
- package/scripts/chat-archive/qqprobe.py +153 -0
- package/scripts/chat-archive/screen-collect.py +163 -0
- package/scripts/chat-archive/sqlcipher_probe.py +444 -0
- package/scripts/comfy_gen.py +209 -0
- package/scripts/compose-video.py +168 -0
- package/scripts/dl_models.py +45 -0
- package/scripts/draw-now.cmd +18 -0
- package/scripts/dsh-instance-guard.mjs +20 -2
- package/scripts/elev-extra.cmd +25 -0
- package/scripts/episode.py +529 -0
- package/scripts/fan-curve.py +218 -0
- package/scripts/fan-guard.cmd +8 -0
- package/scripts/fan-mode.py +380 -0
- package/scripts/fan_manual_safe.py +33 -0
- package/scripts/fan_restore_manual.py +46 -0
- package/scripts/fc_curves.py +359 -0
- package/scripts/fix-fan-and-timers.cmd +39 -0
- package/scripts/fix_admin_all.py +94 -0
- package/scripts/flows.mjs +224 -0
- package/scripts/gateway.cmd +126 -0
- package/scripts/gen-image.py +420 -0
- package/scripts/gen-video.py +186 -0
- package/scripts/git-askpass.cmd +2 -2
- package/scripts/gpu-mode.py +195 -0
- package/scripts/hw-profile.py +175 -0
- package/scripts/install-schedule.cmd +37 -0
- package/scripts/install-watch.cmd +29 -0
- package/scripts/matte-cutout.py +106 -0
- package/scripts/media-enhance.py +402 -0
- package/scripts/memory-audit.py +581 -0
- package/scripts/migrate-scope.mjs +140 -139
- package/scripts/model-registry.py +519 -0
- package/scripts/openid-audit.mjs +219 -0
- package/scripts/pull-gguf.py +127 -0
- package/scripts/purge-standby.py +151 -0
- package/scripts/qq-connect-login.py +133 -0
- package/scripts/qq-ip-sync-hidden.vbs +5 -0
- package/scripts/qq-ip-sync.py +300 -0
- package/scripts/qq-login-once.cmd +20 -0
- package/scripts/qq-login-qr.py +72 -0
- package/scripts/qq-whitelist-fix.cmd +27 -0
- package/scripts/qq-whitelist-login.cmd +26 -0
- package/scripts/qq-whitelist.cmd +12 -0
- package/scripts/qq-whitelist.py +1452 -0
- package/scripts/quality-compare.py +134 -0
- package/scripts/release-all.mjs +636 -430
- package/scripts/release-check.mjs +244 -226
- package/scripts/resume-coder.cmd +38 -0
- package/scripts/secure-room/index.html +334 -0
- package/scripts/secure-room/server.py +582 -0
- package/scripts/security-check.mjs +164 -0
- package/scripts/selftest-local-llm.mjs +20 -0
- package/scripts/selftest-local-models.mjs +754 -0
- package/scripts/selftest-rotate-style.mjs +308 -0
- package/scripts/shutdown-s5-optional.cmd +21 -0
- package/scripts/sleep-2325.cmd +75 -0
- package/scripts/start-comfyui.cmd +5 -0
- package/scripts/start-strata.cmd +17 -0
- package/scripts/start-strata.vbs +11 -0
- package/scripts/start-watch-hidden.vbs +3 -0
- package/scripts/stickers/auto-tag.mjs +161 -0
- package/scripts/storage.mjs +236 -0
- package/scripts/sync-plugin-copies.mjs +98 -23
- package/scripts/tests/test-qq-whitelist.py +192 -0
- package/scripts/train/__pycache__/train-lora.cpython-311.pyc +0 -0
- package/scripts/train/gguf-quantize.py +92 -0
- package/scripts/train/gguf-to-hf.py +112 -0
- package/scripts/train/merge-lora.py +51 -0
- package/scripts/train/probe-mirrors.sh +12 -0
- package/scripts/train/probe-mirrors2.sh +20 -0
- package/scripts/train/setup-wsl.sh +23 -0
- package/scripts/train/setup-wsl2.sh +25 -0
- package/scripts/train/setup-wsl3.sh +22 -0
- package/scripts/train/setup-wsl4.sh +22 -0
- package/scripts/train/train-lora.py +319 -0
- package/scripts/vram-free.py +104 -0
- package/scripts/wechat-full-pull.mjs +1 -1
- package/settings-host.js +1047 -12
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
"""
|
|
4
|
+
bench-fans.py - measure GPU/CPU thermals, fan speed and system noise drivers
|
|
5
|
+
while a local Qwen3.6-35B-A3B (Strata :8080) is loaded and serving.
|
|
6
|
+
|
|
7
|
+
Three phases:
|
|
8
|
+
1. idle - model resident, no requests
|
|
9
|
+
2. load - continuous serial ~200-token chat completions (back-to-back)
|
|
10
|
+
3. cooldown - no requests, watch it fall back
|
|
11
|
+
|
|
12
|
+
Data sources
|
|
13
|
+
* nvidia-smi -> util / vram / temp / fan% / power / pstate / sm clock
|
|
14
|
+
* LibreHardwareMonitor (via _lhm_stream.ps1) -> GPU fan RPM, hotspot,
|
|
15
|
+
memory-junction temp, CPU load
|
|
16
|
+
* CPU package temp -> needs LHM's ring0 driver. Without it the value is
|
|
17
|
+
None and goes into the CSV as an empty cell. Never invent it.
|
|
18
|
+
|
|
19
|
+
Output: F:/qqbot/logs/fan-bench-<ts>.csv (UTF-8-BOM, Excel friendly)
|
|
20
|
+
|
|
21
|
+
Usage:
|
|
22
|
+
python bench-fans.py
|
|
23
|
+
python bench-fans.py --idle 30 --load 60 --cooldown 30 --out x.csv
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
import argparse
|
|
27
|
+
import csv
|
|
28
|
+
import ctypes
|
|
29
|
+
import datetime as dt
|
|
30
|
+
import json
|
|
31
|
+
import os
|
|
32
|
+
import shutil
|
|
33
|
+
import subprocess
|
|
34
|
+
import threading
|
|
35
|
+
import time
|
|
36
|
+
import urllib.request
|
|
37
|
+
|
|
38
|
+
NV = r"C:\Windows\System32\nvidia-smi.exe"
|
|
39
|
+
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
40
|
+
# The long-lived LHM streamer is unstable (StackOverflowException in
|
|
41
|
+
# AssemblyResolve); this one-shot script is the proven path. We poll it.
|
|
42
|
+
LHM_ONCE = os.path.join(HERE, "_lhm_all.ps1")
|
|
43
|
+
LOG_DIR = r"F:\qqbot\logs"
|
|
44
|
+
API = "http://127.0.0.1:8080" # direct Strata; --api overrides
|
|
45
|
+
API_KEY = "" # gateway would need a bearer token
|
|
46
|
+
MODEL = "qwen3.6-35b-a3b-ud-q4_k_xl"
|
|
47
|
+
|
|
48
|
+
CSV_FIELDS = [
|
|
49
|
+
"timestamp", "phase", "elapsed_s",
|
|
50
|
+
"gpu_temp_c", "gpu_hotspot_c", "gpu_mem_junction_c",
|
|
51
|
+
"gpu_fan_pct", "gpu_fan_rpm",
|
|
52
|
+
"gpu_power_w", "gpu_power_limit_w",
|
|
53
|
+
"gpu_mem_used_mib", "gpu_mem_total_mib",
|
|
54
|
+
"gpu_util_pct", "gpu_clocks_sm_mhz", "pstate",
|
|
55
|
+
"cpu_temp_c", "cpu_load_pct",
|
|
56
|
+
"sys_mem_available_mb",
|
|
57
|
+
"mobo_fan_rpm", "fc_reading", "fc_cfg_mtime",
|
|
58
|
+
"req_tokens", "req_secs", "req_tok_per_s", "reqs_done",
|
|
59
|
+
"note",
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def now_iso():
|
|
64
|
+
return dt.datetime.now().astimezone().isoformat(timespec="milliseconds")
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def nvidia_sample():
|
|
68
|
+
q = ("timestamp,utilization.gpu,memory.used,memory.total,temperature.gpu,"
|
|
69
|
+
"fan.speed,power.draw,power.limit,pstate,clocks.sm")
|
|
70
|
+
try:
|
|
71
|
+
out = subprocess.run(
|
|
72
|
+
[NV, f"--query-gpu={q}", "--format=csv,noheader,nounits"],
|
|
73
|
+
capture_output=True, text=True, timeout=15,
|
|
74
|
+
)
|
|
75
|
+
except Exception:
|
|
76
|
+
return {}
|
|
77
|
+
lines = (out.stdout or "").strip().splitlines()
|
|
78
|
+
if not lines:
|
|
79
|
+
return {}
|
|
80
|
+
parts = [p.strip() for p in lines[0].split(",")]
|
|
81
|
+
if len(parts) < 10:
|
|
82
|
+
return {}
|
|
83
|
+
|
|
84
|
+
def num(x):
|
|
85
|
+
try:
|
|
86
|
+
return float(x)
|
|
87
|
+
except ValueError:
|
|
88
|
+
return None
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
"gpu_util_pct": num(parts[1]),
|
|
92
|
+
"gpu_mem_used_mib": num(parts[2]),
|
|
93
|
+
"gpu_mem_total_mib": num(parts[3]),
|
|
94
|
+
"gpu_temp_c": num(parts[4]),
|
|
95
|
+
"gpu_fan_pct": num(parts[5]),
|
|
96
|
+
"gpu_power_w": num(parts[6]),
|
|
97
|
+
"gpu_power_limit_w": num(parts[7]),
|
|
98
|
+
"pstate": parts[8],
|
|
99
|
+
"gpu_clocks_sm_mhz": num(parts[9]),
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
class MEMORYSTATUSEX(ctypes.Structure):
|
|
104
|
+
_fields_ = [
|
|
105
|
+
("dwLength", ctypes.c_ulong), ("dwMemoryLoad", ctypes.c_ulong),
|
|
106
|
+
("ullTotalPhys", ctypes.c_ulonglong), ("ullAvailPhys", ctypes.c_ulonglong),
|
|
107
|
+
("ullTotalPageFile", ctypes.c_ulonglong), ("ullAvailPageFile", ctypes.c_ulonglong),
|
|
108
|
+
("ullTotalVirtual", ctypes.c_ulonglong), ("ullAvailVirtual", ctypes.c_ulonglong),
|
|
109
|
+
("ullAvailExtendedVirtual", ctypes.c_ulonglong),
|
|
110
|
+
]
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def mem_available_mb():
|
|
114
|
+
st = MEMORYSTATUSEX()
|
|
115
|
+
st.dwLength = ctypes.sizeof(MEMORYSTATUSEX)
|
|
116
|
+
if ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(st)):
|
|
117
|
+
return round(st.ullAvailPhys / (1024 * 1024), 1)
|
|
118
|
+
return None
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
class LhmPoller:
|
|
122
|
+
"""Polls _lhm_all.ps1 every N seconds and parses its text output."""
|
|
123
|
+
|
|
124
|
+
def __init__(self, period=15.0):
|
|
125
|
+
self.period = period
|
|
126
|
+
self.latest = {}
|
|
127
|
+
self.lock = threading.Lock()
|
|
128
|
+
self.stop_flag = threading.Event()
|
|
129
|
+
self.ok = False
|
|
130
|
+
|
|
131
|
+
def start(self):
|
|
132
|
+
if not os.path.exists(LHM_ONCE):
|
|
133
|
+
return
|
|
134
|
+
threading.Thread(target=self._loop, daemon=True).start()
|
|
135
|
+
|
|
136
|
+
def _loop(self):
|
|
137
|
+
while not self.stop_flag.is_set():
|
|
138
|
+
try:
|
|
139
|
+
out = subprocess.run(
|
|
140
|
+
["powershell.exe", "-NoProfile", "-ExecutionPolicy", "Bypass",
|
|
141
|
+
"-File", LHM_ONCE],
|
|
142
|
+
capture_output=True, text=True, timeout=90,
|
|
143
|
+
encoding="utf-8", errors="replace",
|
|
144
|
+
).stdout or ""
|
|
145
|
+
except Exception:
|
|
146
|
+
out = ""
|
|
147
|
+
d = parse_lhm_text(out)
|
|
148
|
+
if d:
|
|
149
|
+
with self.lock:
|
|
150
|
+
self.latest = d
|
|
151
|
+
self.ok = True
|
|
152
|
+
self.stop_flag.wait(max(1.0, self.period))
|
|
153
|
+
|
|
154
|
+
def snapshot(self):
|
|
155
|
+
with self.lock:
|
|
156
|
+
return dict(self.latest)
|
|
157
|
+
|
|
158
|
+
def stop(self):
|
|
159
|
+
self.stop_flag.set()
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def parse_lhm_text(txt):
|
|
163
|
+
"""Pull GPU fan RPM / hotspot / junction / CPU total load out of _lhm_all output."""
|
|
164
|
+
import re
|
|
165
|
+
d = {}
|
|
166
|
+
for line in txt.splitlines():
|
|
167
|
+
line = line.strip()
|
|
168
|
+
m = re.match(r"^(Temperature|Fan|Control|Load|Clock) \| (.+?) = (-?[\d.]+)$", line)
|
|
169
|
+
if not m:
|
|
170
|
+
continue
|
|
171
|
+
kind, name, val = m.group(1), m.group(2), float(m.group(3))
|
|
172
|
+
if kind == "Fan" and name == "GPU Fan":
|
|
173
|
+
d["gpu_rpm"] = val
|
|
174
|
+
elif kind == "Temperature" and name == "GPU Core":
|
|
175
|
+
d["gpu_core"] = val
|
|
176
|
+
elif kind == "Temperature" and name == "GPU Hot Spot":
|
|
177
|
+
d["gpu_hot"] = val
|
|
178
|
+
elif kind == "Temperature" and name == "GPU Memory Junction":
|
|
179
|
+
d["gpu_memj"] = val
|
|
180
|
+
elif kind == "Control" and name == "GPU Fan":
|
|
181
|
+
d["gpu_fanp"] = val
|
|
182
|
+
elif kind == "Load" and name == "CPU Total":
|
|
183
|
+
d["cpu_load"] = val
|
|
184
|
+
elif kind == "Temperature" and name.startswith("Core (Tctl"):
|
|
185
|
+
d["cpu_tctl"] = None if val <= 0 else val
|
|
186
|
+
return d
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def http_json(url, payload=None, timeout=300):
|
|
190
|
+
data = None
|
|
191
|
+
headers = {}
|
|
192
|
+
if API_KEY:
|
|
193
|
+
headers["Authorization"] = f"Bearer {API_KEY}"
|
|
194
|
+
if payload is not None:
|
|
195
|
+
data = json.dumps(payload).encode("utf-8")
|
|
196
|
+
headers["Content-Type"] = "application/json"
|
|
197
|
+
req = urllib.request.Request(url, data=data, headers=headers)
|
|
198
|
+
with urllib.request.urlopen(req, timeout=timeout) as r:
|
|
199
|
+
return json.loads(r.read().decode("utf-8"))
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def wait_api(timeout=240):
|
|
203
|
+
"""Wait for the gateway to answer /v1/models at all."""
|
|
204
|
+
t0 = time.time()
|
|
205
|
+
while time.time() - t0 < timeout:
|
|
206
|
+
try:
|
|
207
|
+
j = http_json(f"{API}/v1/models", timeout=8)
|
|
208
|
+
return j
|
|
209
|
+
except Exception:
|
|
210
|
+
time.sleep(3)
|
|
211
|
+
return None
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
PROMPT = ("请用中文写一段关于深海热泉生态的科普介绍,大约两百个字,"
|
|
215
|
+
"句子连贯,不要分点,不要提前结束。")
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
def one_request(max_tokens=120):
|
|
219
|
+
payload = {
|
|
220
|
+
"model": MODEL,
|
|
221
|
+
"messages": [{"role": "user", "content": PROMPT}],
|
|
222
|
+
"max_tokens": max_tokens,
|
|
223
|
+
"temperature": 0.7,
|
|
224
|
+
"stream": False,
|
|
225
|
+
"chat_template_kwargs": {"enable_thinking": False},
|
|
226
|
+
}
|
|
227
|
+
t0 = time.time()
|
|
228
|
+
try:
|
|
229
|
+
r = http_json(f"{API}/v1/chat/completions", payload, timeout=420)
|
|
230
|
+
except Exception as e:
|
|
231
|
+
return None, round(time.time() - t0, 3), None, f"ERR:{type(e).__name__}"
|
|
232
|
+
secs = time.time() - t0
|
|
233
|
+
usage = r.get("usage") or {}
|
|
234
|
+
toks = usage.get("completion_tokens")
|
|
235
|
+
if toks is None:
|
|
236
|
+
txt = ((r.get("choices") or [{}])[0].get("message") or {}).get("content", "")
|
|
237
|
+
toks = max(1, len(txt) // 2)
|
|
238
|
+
tps = round(toks / secs, 2) if secs > 0 else None
|
|
239
|
+
return toks, round(secs, 3), tps, "ok"
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
class Requester(threading.Thread):
|
|
243
|
+
"""Fires serial completions back-to-back until stopped (keeps the GPU busy)."""
|
|
244
|
+
|
|
245
|
+
def __init__(self, max_tokens, gap=0.6):
|
|
246
|
+
super().__init__(daemon=True)
|
|
247
|
+
self.max_tokens = max_tokens
|
|
248
|
+
self.gap = gap
|
|
249
|
+
self.stop_flag = threading.Event()
|
|
250
|
+
self.lock = threading.Lock()
|
|
251
|
+
self.results = [] # (tokens, secs, tps)
|
|
252
|
+
self.errors = 0
|
|
253
|
+
|
|
254
|
+
def run(self):
|
|
255
|
+
while not self.stop_flag.is_set():
|
|
256
|
+
toks, secs, tps, tag = one_request(self.max_tokens)
|
|
257
|
+
if tag == "ok":
|
|
258
|
+
with self.lock:
|
|
259
|
+
self.results.append((toks, secs, tps))
|
|
260
|
+
print(f" [load] {toks} tok / {secs}s = {tps} tok/s")
|
|
261
|
+
else:
|
|
262
|
+
self.errors += 1
|
|
263
|
+
print(f" [load] {tag}")
|
|
264
|
+
time.sleep(1.0)
|
|
265
|
+
continue
|
|
266
|
+
# small breather so the panel/GUI don't OOM and VRAM has room
|
|
267
|
+
if self.gap:
|
|
268
|
+
time.sleep(self.gap)
|
|
269
|
+
|
|
270
|
+
def drain(self):
|
|
271
|
+
with self.lock:
|
|
272
|
+
r = self.results
|
|
273
|
+
self.results = []
|
|
274
|
+
return r
|
|
275
|
+
|
|
276
|
+
def stop(self):
|
|
277
|
+
self.stop_flag.set()
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
FC_CFG = os.path.join(os.environ.get("ProgramFiles(x86)", r"C:\Program Files (x86)"),
|
|
281
|
+
"FanControl", "Configurations", "userConfig.json")
|
|
282
|
+
_cfg_state = {"mtime": None, "changes": 0, "snapshot": None}
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
def fc_cfg_mtime():
|
|
286
|
+
"""mtime of the live FanControl config; flags mid-run manual edits."""
|
|
287
|
+
try:
|
|
288
|
+
m = os.path.getmtime(FC_CFG)
|
|
289
|
+
except OSError:
|
|
290
|
+
return None
|
|
291
|
+
if _cfg_state["mtime"] is None:
|
|
292
|
+
_cfg_state["mtime"] = m
|
|
293
|
+
try:
|
|
294
|
+
dst = os.path.join(LOG_DIR, "fancontrol-config-at-bench-start.json")
|
|
295
|
+
shutil.copyfile(FC_CFG, dst)
|
|
296
|
+
_cfg_state["snapshot"] = dst
|
|
297
|
+
except OSError:
|
|
298
|
+
pass
|
|
299
|
+
elif abs(m - _cfg_state["mtime"]) > 1e-6:
|
|
300
|
+
_cfg_state["changes"] += 1
|
|
301
|
+
_cfg_state["mtime"] = m
|
|
302
|
+
print(f" [!] FanControl config changed mid-run -> rows after this "
|
|
303
|
+
f"point are contaminated (change #{_cfg_state['changes']})")
|
|
304
|
+
return round(m, 1)
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
def run(args):
|
|
308
|
+
os.makedirs(LOG_DIR, exist_ok=True)
|
|
309
|
+
out_path = args.out or os.path.join(
|
|
310
|
+
LOG_DIR, f"fan-bench-{dt.datetime.now():%Y%m%d-%H%M%S}.csv")
|
|
311
|
+
print(f"[bench] csv -> {out_path}")
|
|
312
|
+
|
|
313
|
+
lhm = LhmPoller(period=args.lhm_period)
|
|
314
|
+
lhm.start()
|
|
315
|
+
|
|
316
|
+
j = wait_api(60)
|
|
317
|
+
print(f"[bench] endpoint {'OK' if j else 'NOT REACHABLE'} ({API})")
|
|
318
|
+
if not j and not args.skip_preflight:
|
|
319
|
+
print(f"[bench] aborting: no /v1/models at {API}; pass --skip-preflight "
|
|
320
|
+
f"to sample GPU/CPU only (e.g. after the model is unloaded)")
|
|
321
|
+
return None
|
|
322
|
+
|
|
323
|
+
if args.warmup:
|
|
324
|
+
print("[bench] warmup request (may take 30-90s while the 35B loads)...")
|
|
325
|
+
toks, secs, tps, tag = one_request(args.max_tokens)
|
|
326
|
+
print(f"[bench] warmup -> {tag} {toks} tok / {secs}s = {tps} tok/s")
|
|
327
|
+
print("[bench] settling 15s before the idle baseline")
|
|
328
|
+
time.sleep(15)
|
|
329
|
+
|
|
330
|
+
rows = []
|
|
331
|
+
t_start = time.time()
|
|
332
|
+
reqs_done = 0
|
|
333
|
+
pending_reqs = []
|
|
334
|
+
|
|
335
|
+
def sample(phase, note=""):
|
|
336
|
+
row = {k: None for k in CSV_FIELDS}
|
|
337
|
+
row["timestamp"] = now_iso()
|
|
338
|
+
row["phase"] = phase
|
|
339
|
+
row["elapsed_s"] = round(time.time() - t_start, 1)
|
|
340
|
+
row.update(nvidia_sample())
|
|
341
|
+
lh = lhm.snapshot()
|
|
342
|
+
if lh:
|
|
343
|
+
row["gpu_hotspot_c"] = lh.get("gpu_hot")
|
|
344
|
+
row["gpu_mem_junction_c"] = lh.get("gpu_memj")
|
|
345
|
+
row["gpu_fan_rpm"] = lh.get("gpu_rpm")
|
|
346
|
+
row["cpu_temp_c"] = lh.get("cpu_tctl")
|
|
347
|
+
row["cpu_load_pct"] = lh.get("cpu_load")
|
|
348
|
+
if row["gpu_fan_pct"] is None:
|
|
349
|
+
row["gpu_fan_pct"] = lh.get("gpu_fanp")
|
|
350
|
+
row["sys_mem_available_mb"] = mem_available_mb()
|
|
351
|
+
row["mobo_fan_rpm"] = None # see docstring: needs elevated UIA or ring0
|
|
352
|
+
row["fc_reading"] = None
|
|
353
|
+
row["reqs_done"] = reqs_done
|
|
354
|
+
row["fc_cfg_mtime"] = fc_cfg_mtime()
|
|
355
|
+
row["note"] = note
|
|
356
|
+
rows.append(row)
|
|
357
|
+
|
|
358
|
+
print(f"[bench] phase 1: idle {args.idle}s")
|
|
359
|
+
t_end = time.time() + args.idle
|
|
360
|
+
while time.time() < t_end:
|
|
361
|
+
sample("idle")
|
|
362
|
+
time.sleep(max(0.2, args.interval - 0.25))
|
|
363
|
+
|
|
364
|
+
print(f"[bench] phase 2: load {args.load}s continuous, {args.max_tokens} tok/req")
|
|
365
|
+
rq = Requester(args.max_tokens, gap=args.gap)
|
|
366
|
+
rq.start()
|
|
367
|
+
t_end = time.time() + args.load
|
|
368
|
+
while time.time() < t_end:
|
|
369
|
+
done = rq.drain()
|
|
370
|
+
reqs_done += len(done)
|
|
371
|
+
pending_reqs = done
|
|
372
|
+
sample("load", note=(f"{len(done)}req" if done else ""))
|
|
373
|
+
if done:
|
|
374
|
+
rows[-1]["req_tokens"], rows[-1]["req_secs"], rows[-1]["req_tok_per_s"] = done[-1]
|
|
375
|
+
time.sleep(max(0.2, args.interval - 0.25))
|
|
376
|
+
rq.stop()
|
|
377
|
+
time.sleep(1.0)
|
|
378
|
+
reqs_done += len(rq.drain())
|
|
379
|
+
|
|
380
|
+
print(f"[bench] phase 3: cooldown {args.cooldown}s")
|
|
381
|
+
t_end = time.time() + args.cooldown
|
|
382
|
+
while time.time() < t_end:
|
|
383
|
+
sample("cooldown")
|
|
384
|
+
time.sleep(max(0.2, args.interval - 0.25))
|
|
385
|
+
|
|
386
|
+
lhm.stop()
|
|
387
|
+
|
|
388
|
+
with open(out_path, "w", newline="", encoding="utf-8-sig") as f:
|
|
389
|
+
w = csv.DictWriter(f, fieldnames=CSV_FIELDS, extrasaction="ignore")
|
|
390
|
+
w.writeheader()
|
|
391
|
+
for r in rows:
|
|
392
|
+
w.writerow({k: ("" if r.get(k) is None else r.get(k)) for k in CSV_FIELDS})
|
|
393
|
+
|
|
394
|
+
summarize(rows, out_path)
|
|
395
|
+
return out_path
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
def _vals(rows, phase, key):
|
|
399
|
+
out = []
|
|
400
|
+
for r in rows:
|
|
401
|
+
if r["phase"] != phase:
|
|
402
|
+
continue
|
|
403
|
+
v = r.get(key)
|
|
404
|
+
if v is None or v == "":
|
|
405
|
+
continue
|
|
406
|
+
try:
|
|
407
|
+
out.append(float(v))
|
|
408
|
+
except (TypeError, ValueError):
|
|
409
|
+
pass
|
|
410
|
+
return out
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
def _stat(vals):
|
|
414
|
+
if not vals:
|
|
415
|
+
return None
|
|
416
|
+
vals = sorted(vals)
|
|
417
|
+
n = len(vals)
|
|
418
|
+
p90 = vals[min(n - 1, int(round(0.9 * (n - 1))))]
|
|
419
|
+
return {"n": n, "mean": round(sum(vals) / n, 1),
|
|
420
|
+
"min": round(vals[0], 1), "max": round(vals[-1], 1), "p90": round(p90, 1)}
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
def summarize(rows, path):
|
|
424
|
+
print("\n" + "=" * 78)
|
|
425
|
+
print("SUMMARY")
|
|
426
|
+
print("=" * 78)
|
|
427
|
+
keys = [
|
|
428
|
+
("gpu_temp_c", "GPU temp C"), ("gpu_hotspot_c", "GPU hotspot C"),
|
|
429
|
+
("gpu_mem_junction_c", "GPU memjct C"),
|
|
430
|
+
("gpu_fan_pct", "GPU fan %"), ("gpu_fan_rpm", "GPU fan RPM"),
|
|
431
|
+
("gpu_power_w", "GPU power W"), ("gpu_util_pct", "GPU util %"),
|
|
432
|
+
("gpu_mem_used_mib", "VRAM MiB"), ("gpu_clocks_sm_mhz", "SM clock MHz"),
|
|
433
|
+
("cpu_temp_c", "CPU temp C"), ("cpu_load_pct", "CPU load %"),
|
|
434
|
+
]
|
|
435
|
+
for phase in ("idle", "load", "cooldown"):
|
|
436
|
+
print(f"\n[{phase}]")
|
|
437
|
+
for k, label in keys:
|
|
438
|
+
s = _stat(_vals(rows, phase, k))
|
|
439
|
+
if s:
|
|
440
|
+
print(f" {label:14s} mean={s['mean']:>8} max={s['max']:>8} "
|
|
441
|
+
f"min={s['min']:>8} p90={s['p90']:>8} n={s['n']}")
|
|
442
|
+
else:
|
|
443
|
+
print(f" {label:14s} n/a (no reading)")
|
|
444
|
+
|
|
445
|
+
load_rows = [r for r in rows if r["phase"] == "load"]
|
|
446
|
+
if load_rows:
|
|
447
|
+
tail = load_rows[int(len(load_rows) * 0.4):]
|
|
448
|
+
print("\n[steady state = last 60% of load]")
|
|
449
|
+
for k, label in (("gpu_temp_c", "GPU temp C"), ("gpu_fan_pct", "GPU fan %"),
|
|
450
|
+
("gpu_power_w", "GPU power W"),
|
|
451
|
+
("gpu_clocks_sm_mhz", "SM clock MHz")):
|
|
452
|
+
v = [float(r[k]) for r in tail if r.get(k) not in (None, "")]
|
|
453
|
+
if v:
|
|
454
|
+
print(f" {label:14s} mean={round(sum(v)/len(v),1)} max={round(max(v),1)}")
|
|
455
|
+
|
|
456
|
+
# fan oscillation: count sign reversals of consecutive deltas
|
|
457
|
+
fan = [float(r["gpu_fan_pct"]) for r in load_rows
|
|
458
|
+
if r.get("gpu_fan_pct") not in (None, "")]
|
|
459
|
+
osc = 0
|
|
460
|
+
prev = 0
|
|
461
|
+
for a, b in zip(fan, fan[1:]):
|
|
462
|
+
d = b - a
|
|
463
|
+
if d != 0 and prev != 0 and (d > 0) != (prev > 0):
|
|
464
|
+
osc += 1
|
|
465
|
+
if d != 0:
|
|
466
|
+
prev = d
|
|
467
|
+
if fan:
|
|
468
|
+
print(f" fan%% range {min(fan):.0f}..{max(fan):.0f} reversals={osc}")
|
|
469
|
+
|
|
470
|
+
# clock throttling: drop relative to the load median
|
|
471
|
+
clk = [float(r["gpu_clocks_sm_mhz"]) for r in load_rows
|
|
472
|
+
if r.get("gpu_clocks_sm_mhz") not in (None, "")]
|
|
473
|
+
if clk:
|
|
474
|
+
med = sorted(clk)[len(clk) // 2]
|
|
475
|
+
low = [c for c in clk if c < med * 0.9]
|
|
476
|
+
print(f" clock median {med:.0f} MHz samples <90%% of median: {len(low)}"
|
|
477
|
+
+ (f" min={min(clk):.0f}" if clk else ""))
|
|
478
|
+
|
|
479
|
+
tps = [float(r["req_tok_per_s"]) for r in rows
|
|
480
|
+
if r.get("req_tok_per_s") not in (None, "")]
|
|
481
|
+
if tps:
|
|
482
|
+
print(f"\n throughput: {len(tps)} measured reqs, mean={round(sum(tps)/len(tps),2)} tok/s, "
|
|
483
|
+
f"min={round(min(tps),2)}, max={round(max(tps),2)}")
|
|
484
|
+
print(f"\n rows={len(rows)} csv={path}")
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
def main():
|
|
488
|
+
ap = argparse.ArgumentParser()
|
|
489
|
+
ap.add_argument("--idle", type=int, default=60)
|
|
490
|
+
ap.add_argument("--load", type=int, default=180)
|
|
491
|
+
ap.add_argument("--cooldown", type=int, default=120)
|
|
492
|
+
ap.add_argument("--interval", type=float, default=2.0)
|
|
493
|
+
ap.add_argument("--lhm-period", type=float, default=12.0)
|
|
494
|
+
ap.add_argument("--max-tokens", type=int, default=120)
|
|
495
|
+
ap.add_argument("--gap", type=float, default=0.6, help="sleep between requests (s)")
|
|
496
|
+
ap.add_argument("--no-warmup", dest="warmup", action="store_false")
|
|
497
|
+
ap.add_argument("--skip-preflight", action="store_true", help="sample even if no API answers")
|
|
498
|
+
ap.add_argument("--api", default=None, help="override base url, e.g. http://127.0.0.1:8090")
|
|
499
|
+
ap.add_argument("--model", default=None)
|
|
500
|
+
ap.add_argument("--key", default=None)
|
|
501
|
+
ap.add_argument("--out", default=None)
|
|
502
|
+
args = ap.parse_args()
|
|
503
|
+
|
|
504
|
+
global API, MODEL, API_KEY
|
|
505
|
+
if args.api:
|
|
506
|
+
API = args.api.rstrip("/")
|
|
507
|
+
if args.model:
|
|
508
|
+
MODEL = args.model
|
|
509
|
+
if args.key is not None:
|
|
510
|
+
API_KEY = args.key
|
|
511
|
+
run(args)
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
if __name__ == "__main__":
|
|
515
|
+
main()
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"""直接压 Strata 8080,采样风扇/温度/功耗/显存/频率,输出 CSV。
|
|
2
|
+
|
|
3
|
+
用法: python bench-load-direct.py (默认 150 秒)
|
|
4
|
+
"""
|
|
5
|
+
import csv
|
|
6
|
+
import json
|
|
7
|
+
import subprocess
|
|
8
|
+
import sys
|
|
9
|
+
import time
|
|
10
|
+
import urllib.request
|
|
11
|
+
|
|
12
|
+
URL = "http://127.0.0.1:8080/v1/chat/completions"
|
|
13
|
+
DUR = float(sys.argv[1]) if len(sys.argv) > 1 else 150.0
|
|
14
|
+
OUT = r"F:\qqbot\logs\fan-bench-direct-%s.csv" % time.strftime("%Y%m%d-%H%M%S")
|
|
15
|
+
PROMPT = "用中文写一段关于深海鲸鱼的科普,尽量长。"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def gpu():
|
|
19
|
+
q = "fan.speed,temperature.gpu,power.draw,memory.used,utilization.gpu,clocks.sm"
|
|
20
|
+
out = subprocess.run(["nvidia-smi", "--query-gpu=" + q, "--format=csv,noheader,nounits"],
|
|
21
|
+
capture_output=True, text=True, timeout=10).stdout.strip()
|
|
22
|
+
return [x.strip() for x in out.split(",")]
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def call():
|
|
26
|
+
body = json.dumps({
|
|
27
|
+
"model": "qwen3.6-35b-a3b-ud-q4_k_xl",
|
|
28
|
+
"messages": [{"role": "user", "content": PROMPT}],
|
|
29
|
+
"max_tokens": 200,
|
|
30
|
+
"chat_template_kwargs": {"enable_thinking": False},
|
|
31
|
+
}).encode()
|
|
32
|
+
req = urllib.request.Request(URL, data=body, headers={"Content-Type": "application/json"})
|
|
33
|
+
t0 = time.time()
|
|
34
|
+
with urllib.request.urlopen(req, timeout=180) as r:
|
|
35
|
+
data = json.loads(r.read().decode())
|
|
36
|
+
ct = (data.get("usage") or {}).get("completion_tokens", 0)
|
|
37
|
+
return time.time() - t0, ct
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def main():
|
|
41
|
+
rows = []
|
|
42
|
+
t_end = time.time() + DUR
|
|
43
|
+
i = 0
|
|
44
|
+
while time.time() < t_end:
|
|
45
|
+
try:
|
|
46
|
+
ms, ct = call()
|
|
47
|
+
err = ""
|
|
48
|
+
except Exception as exc: # noqa: BLE001
|
|
49
|
+
ms, ct, err = 0.0, 0, type(exc).__name__
|
|
50
|
+
g = gpu()
|
|
51
|
+
rows.append([round(time.time(), 1), i, round(ms, 2), ct] + g + [err])
|
|
52
|
+
print(rows[-1], flush=True)
|
|
53
|
+
i += 1
|
|
54
|
+
with open(OUT, "w", newline="", encoding="utf-8") as f:
|
|
55
|
+
w = csv.writer(f)
|
|
56
|
+
w.writerow(["ts", "n", "latency_s", "completion_tokens", "fan_pct", "temp_c",
|
|
57
|
+
"power_w", "vram_mb", "util_pct", "sm_mhz", "err"])
|
|
58
|
+
w.writerows(rows)
|
|
59
|
+
print("csv ->", OUT)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
if __name__ == "__main__":
|
|
63
|
+
main()
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
' boot-tasks-hidden.vbs ���� ��ѡ���� QQBootWake ��ȫ�����ڿ�
|
|
2
|
+
'
|
|
3
|
+
' Ĭ�� QQBootWake �Ķ����� cmd /c boot-tasks.cmd���� InteractiveToken �ܣ�
|
|
4
|
+
' ����ݿ���һ������̨���ڣ������Լ��أ�������Ļ���
|
|
5
|
+
' 1) �ƻ�������Ѷ����ij� wscript.exe //nologo "F:\qqbot\scripts\boot-tasks-hidden.vbs"
|
|
6
|
+
' 2) �������գ���ʼ�� F:\qqbot\scripts
|
|
7
|
+
' Ч��һ����boot-tasks.cmd ���ܣ���־��д��ֻ��û�д��ڡ�
|
|
8
|
+
'
|
|
9
|
+
' ע�⣺����ļ�ֻ��"��ѡ"����װҲ���ã���ɾ boot-tasks.cmd��
|
|
10
|
+
|
|
11
|
+
Option Explicit
|
|
12
|
+
|
|
13
|
+
Dim sh, cmd
|
|
14
|
+
Set sh = CreateObject("WScript.Shell")
|
|
15
|
+
cmd = "cmd /c """ & "F:\qqbot\scripts\boot-tasks.cmd" & """"
|
|
16
|
+
|
|
17
|
+
' 0 = ���ش���, False = ����������
|
|
18
|
+
sh.Run cmd, 0, False
|
|
19
|
+
|
|
20
|
+
Set sh = Nothing
|