The app and setup rewrote the run config's "args" on every Load: the resource preference forced --vram-reserve-mib to 1536 (2048 with pictures, a fifth of the card on "work") whatever the file said, and a setup run (started by the Load when the context or pictures differ) dropped every option it did not choose itself, the control vector options included. - run config: "user_args" holds the options set by hand; "args_written" is the args as setup/the app last wrote them, so a hand edit of "args" is noticed and moved into user_args (strata_control/user_args.py, apps/host/server/native-user-args.mjs: the same rule) - every start (serve/server.py engine_args), every setup run (setup.carry_user_args), every host write and load and a saved tuning put the person's options over the generated ones; the same option: theirs wins - old files without args_written: setup keeps the options the old args had, the new ones lack and setup.py never names (plus the control vector group); a reserve that is not setup's own 700 - --vram-reserve-mib: any number the person set (Expert setting, user_args, the key, a value in args) is used as it is, 0 included; the safety default (1536/1024, 2048 with pictures, 20% on "work") stays for a card that drives a display or is not known to be headless; a card the probe says drives no display keeps 512 (700 with pictures); a 0.2.0-beta file where the app wrote the number itself is told from a changed one - hardware: drives_display per card (nvidia-smi display_active; the Windows adapter with a desktop resolution for AMD) - setup --vram-reserve-mib, the web settings page and `start --vram-reserve-mib` record the value as the person's - docs/TROUBLESHOOTING.md: what is kept and what the app still chooses
48 lines
2.8 KiB
JavaScript
48 lines
2.8 KiB
JavaScript
/** The engine options a person set by hand in a model's run config (strata_control/user_args.py is the same rule in Python).
|
|
* "user_args" holds them; "args_written" is the whole "args" as setup or the app last wrote it, so an option in "args" that is not in
|
|
* that copy was added or changed by hand since. Every load and every write puts the person's options over the generated ones. */
|
|
export const USER_KEY='user_args',WRITTEN_KEY='args_written';
|
|
/** Options the app or setup choose from their own answers (context, KV type, pictures, draft layer, layer split): never taken from "args" as hand edits. */
|
|
export const CHOICE_FLAGS=new Set(['--max-context','--kv','--vision','--mtp','--spec-min-p','--batch-mtp','--layer-split']);
|
|
|
|
export function groups(args){
|
|
const out=[];
|
|
for(const raw of Array.isArray(args)?args:[]){const a=String(raw);if(a.startsWith('--')||!out.length)out.push([a]);else out[out.length-1].push(a);}
|
|
return out;
|
|
}
|
|
export const flat=gs=>gs.flat();
|
|
export const flagOf=g=>g?.[0]?.startsWith('--')?g[0]:'';
|
|
/** `args` with every option the person set replaced by theirs (appended after the generated ones). */
|
|
export function merge(args,user){
|
|
const ug=groups(user),mine=new Set(ug.map(flagOf).filter(Boolean));
|
|
return flat([...groups(args).filter(g=>!mine.has(flagOf(g))),...ug]);
|
|
}
|
|
function byFlag(gs){const m=new Map();for(const g of gs){const f=flagOf(g);if(!m.has(f))m.set(f,[]);m.get(f).push(g);}return m;}
|
|
const same=(a,b)=>JSON.stringify(a??null)===JSON.stringify(b??null);
|
|
/** The person's options of a config: its user_args, with the options of "args" that differ from "args_written" on top. */
|
|
export function capture(cfg,skip=CHOICE_FLAGS){
|
|
const mine=byFlag(groups(cfg?.[USER_KEY]));
|
|
if(Array.isArray(cfg?.[WRITTEN_KEY])&&Array.isArray(cfg?.args)){
|
|
const cur=byFlag(groups(cfg.args)),was=byFlag(groups(cfg[WRITTEN_KEY]));
|
|
for(const [flag,gs] of cur)if(flag&&!skip.has(flag)&&!same(was.get(flag),gs))mine.set(flag,gs);
|
|
for(const flag of [...mine.keys()])if(was.has(flag)&&!cur.has(flag))mine.delete(flag);
|
|
}
|
|
return flat([...mine.values()].flat());
|
|
}
|
|
export function setFlag(user,flag,value){
|
|
const rest=groups(user).filter(g=>flagOf(g)!==flag);
|
|
if(value!==null&&value!==undefined)rest.push([flag,String(value)]);
|
|
return flat(rest);
|
|
}
|
|
export function flagValue(args,flag){
|
|
const list=(Array.isArray(args)?args:[]).map(String),at=list.indexOf(flag);
|
|
return at>=0&&at+1<list.length?list[at+1]:null;
|
|
}
|
|
/** `config` with the person's options merged into "args", recorded in "user_args", and "args_written" refreshed (only when the config has one). */
|
|
export function stamped(config,user){
|
|
const next={...config};
|
|
if(user.length){next.args=merge(next.args,user);next[USER_KEY]=user;}else delete next[USER_KEY];
|
|
if(WRITTEN_KEY in config)next[WRITTEN_KEY]=[...(next.args??[])];
|
|
return next;
|
|
}
|