Make reasoning budgets global for existing and future chat profiles
This commit is contained in:
1 parent
ad1c513f3c
commit
536d38b79e
11 files changed
+193
-125
No files matched your search
@@ -1,33 +0,0 @@
|
||||
"""Explicit, idempotent initial budget configuration for Qwen27B and Strata.
|
||||
Run with Deck stopped; runtime-only state root is an explicit argument.
|
||||
No model weights, endpoint identities or sampling settings are changed.
|
||||
"""
|
||||
import argparse,copy,json,os,tempfile
|
||||
from pathlib import Path
|
||||
import sys
|
||||
sys.path.insert(0,str(Path(__file__).resolve().parent.parent))
|
||||
from api_compat import reasoning_policy
|
||||
DEFAULT={'enabled':True,'limits':{'low':4096,'medium':8192,'high':16384}}
|
||||
def configure(rows):
|
||||
result=copy.deepcopy(rows);changed=[]
|
||||
for row in result:
|
||||
if row.get('kind')!='chat' or not (row.get('api_id','').startswith('qwen3-8-27b-') or row.get('parameters',{}).get('chat_runtime')=='strata'):continue
|
||||
# Preserve user-customized policies; apply only to legacy/disabled-empty defaults.
|
||||
current=reasoning_policy(row['parameters'].get('reasoning_budget'))
|
||||
if current!=reasoning_policy():continue
|
||||
row['parameters']['reasoning_budget']=copy.deepcopy(DEFAULT);row['revision']+=1;changed.append(row['api_id'])
|
||||
return result,changed
|
||||
if __name__=='__main__':
|
||||
p=argparse.ArgumentParser();p.add_argument('--state',type=Path,required=True);p.add_argument('--deck-stopped',action='store_true',required=True);a=p.parse_args()
|
||||
path=a.state/'profiles.json';original=path.read_text();rows,changed=configure(json.loads(original))
|
||||
if changed:
|
||||
backup=path.with_name('profiles.before-thinking-budget-20261012.json')
|
||||
if backup.exists():raise SystemExit('Backup already exists; inspect previous activation before repeating.')
|
||||
stat=path.stat();backup.write_text(original);os.chmod(backup,0o600);os.chown(backup,stat.st_uid,stat.st_gid)
|
||||
fd,tmp=tempfile.mkstemp(prefix='profiles-budget-',dir=path.parent)
|
||||
try:
|
||||
with os.fdopen(fd,'w') as f:json.dump(rows,f,ensure_ascii=False,indent=2);f.flush();os.fsync(f.fileno())
|
||||
os.chmod(tmp,stat.st_mode&0o777);os.chown(tmp,stat.st_uid,stat.st_gid);os.replace(tmp,path)
|
||||
finally:
|
||||
if os.path.exists(tmp):os.unlink(tmp)
|
||||
print(json.dumps({'activated_profiles':changed}))
|
||||
Reference in new issue
Block a user