Skip to content

Commit ef71c47

Browse files
committed
test(agent): observe actual CPU inference thread configuration
1 parent 58b3d3d commit ef71c47

4 files changed

Lines changed: 58 additions & 0 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"sha256": {
3+
"2026-10-07-cpu-thread-probe.json": "54a4d78c08de1425c3d4779be1aabf66c443791584431bdfd58a613eda9ce75c",
4+
"2026-10-07-cpu-thread-probe.mjs": "6552db335f8d675a54373fef7037b92b934d32b6116f7029f03131c1759c433d",
5+
"2026-10-07-cpu-thread-probe.md": "9807d51b5fde6be7a9ec8def6c3b6252b62b1bce3d4f5b0f29dd64346d700302"
6+
},
7+
"scope": "Current load observation only; no inference or prior-run certification",
8+
"build": "core1791345713/vendorb6864850e7b3"
9+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"scope": "Gemma native CPU load thread observation only; no inference; cannot retroactively certify prior runs",
3+
"errors": [],
4+
"browserVersion": "151.0.7922.34",
5+
"environment": {
6+
"crossOriginIsolated": true,
7+
"hardwareConcurrency": 10,
8+
"sharedArrayBuffer": "function"
9+
},
10+
"loads": [
11+
{
12+
"requested": {
13+
"n_threads": 4,
14+
"n_ctx": 2048,
15+
"n_gpu_layers": 0,
16+
"reasoning": false
17+
},
18+
"actualThreads": 4,
19+
"multithread": true,
20+
"loaded": true
21+
}
22+
],
23+
"note": "模型已加载,可以开始对话。",
24+
"closed": true
25+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Current CPU thread observation
2+
3+
A fresh Chromium context loaded the local Gemma candidate through the real application CPU provider. The SDK load hook recorded requested n_threads=4, n_ctx=2048, n_gpu_layers=0 and reasoning=false; after loading, getNumThreads() returned 4 and isMultithread() returned true. The page reported crossOriginIsolated=true, hardwareConcurrency=10 and SharedArrayBuffer available. No inference was requested; browser closed without page errors.
4+
5+
This rules out a missing multithread configuration for this observed load only. Prior sampling runs did not capture actual threads, so this probe cannot certify their configuration retrospectively or explain their latency. It does not test performance, output quality or physical device coverage. No production setting is changed. Further performance comparisons must capture threads and native timing in the same run and control concurrent host activity.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import {chromium} from '@playwright/test';
2+
import fs from 'node:fs/promises';
3+
const r={scope:'Gemma native CPU load thread observation only; no inference; cannot retroactively certify prior runs',errors:[]};
4+
const b=await chromium.launch({channel:'chromium'});r.browserVersion=b.version();const c=await b.newContext({serviceWorkers:'block'});
5+
await c.addInitScript(()=>{if(window===top){localStorage.setItem('agent-panel-provider','wllama');localStorage.removeItem('agent-panel-gguf-url');}});
6+
try{
7+
const p=await c.newPage();p.on('pageerror',e=>r.errors.push(e.message));
8+
await p.goto('http://127.0.0.1:5193/editor?new=docx&agent=1&locale=zh-CN');
9+
await p.waitForFunction(()=>{const e=document.querySelector('#app iframe')?.contentWindow.editor;return e?.isDocumentLoadComplete&&e?.isLoadFullApi;},null,{timeout:90000});
10+
r.environment=await p.evaluate(async()=>{
11+
const {Wllama}=await import('/assets/client-D5_UYdz1.js');const original=Wllama.prototype.loadModel;
12+
window.__loads=[];
13+
Wllama.prototype.loadModel=async function(files,options){const x={requested:{n_threads:options?.n_threads,n_ctx:options?.n_ctx,n_gpu_layers:options?.n_gpu_layers,reasoning:options?.reasoning}};window.__loads.push(x);const result=await original.call(this,files,options);x.actualThreads=this.getNumThreads();x.multithread=this.isMultithread();x.loaded=true;return result;};
14+
return {crossOriginIsolated,hardwareConcurrency:navigator.hardwareConcurrency,sharedArrayBuffer:typeof SharedArrayBuffer};});
15+
await p.evaluate(()=>window.__toggleAgentPanel());await p.locator('.agent-panel').waitFor();await p.locator('.agent-panel-settings-toggle').click();await p.locator('.agent-panel-gguf-files').setInputFiles('.scratch/node_modules/ai-models/gemma-4-E2B-it-Q4_0.gguf');await p.locator('.agent-panel-gguf-load').click();
16+
await p.waitForFunction(()=>document.querySelector('.agent-panel-note')?.textContent?.includes('模型已加载'),null,{timeout:180000});
17+
r.loads=await p.evaluate(()=>window.__loads);r.note=await p.locator('.agent-panel-note').textContent();
18+
}catch(e){r.error=String(e);}finally{await c.close();await b.close();r.closed=true;await fs.writeFile('.scratch/2026-10-07-cpu-thread-probe.json',JSON.stringify(r,null,2));console.log(JSON.stringify(r));}
19+
if(r.error)process.exitCode=1;

0 commit comments

Comments
 (0)