Publish the reviewed accumulated runtime, scheduler, profile, UI, native recipes and historical maintenance evidence. Includes Qwen GPU ASR correction and shared Anna/atelier ownership. Validated with 784 local tests, Python/JSON parsing and eight JavaScript syntax checks. Live GPU acceptance and full fresh-host restore limits remain documented.
87 lines
6.1 KiB
Python
87 lines
6.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Athena host only: owned runtime adoption + GPU-less SM86/120 vision build.
|
|
No service/model stop, no production source replacement, no inference.
|
|
"""
|
|
import argparse
|
|
import hashlib
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
import shutil
|
|
import subprocess
|
|
import time
|
|
|
|
BASE=Path('/opt/athena-deck-dev/runtime')
|
|
STATE=BASE/'state'
|
|
CAND=Path('/opt/athena-deck-dev/basalt-candidate-9175e7a3211b')
|
|
ROOT=Path('/opt/athena-deck-dev/basalt-deck-activation')
|
|
DEST=STATE/'basalt-runtime'
|
|
VIEW=Path('/var/lib/deck/basalt-runtime')
|
|
BLOCK={'vpn','vpn.auth','OpenVPN-KIT','GluetunVPN'}
|
|
|
|
def digest(path):
|
|
with Path(path).open('rb') as f:return hashlib.file_digest(f,'sha256').hexdigest()
|
|
|
|
def ignored(directory,names):return [n for n in names if n in BLOCK or n in ('__pycache__','.pytest_cache')]
|
|
|
|
def chown_tree(root):
|
|
for directory,dirs,files in os.walk(root,followlinks=False):
|
|
dirs[:]=[n for n in dirs if n not in BLOCK]
|
|
os.chown(directory,65534,65534)
|
|
for name in files:
|
|
if name not in BLOCK:os.chown(Path(directory)/name,65534,65534,follow_symlinks=False)
|
|
|
|
def save(phase,**values):
|
|
path=ROOT/'preparation.json';data=json.loads(path.read_text()) if path.exists() else {}
|
|
data.update(phase=phase,updated_at=time.time(),**values);path.write_text(json.dumps(data,indent=2));print(json.dumps(dict(phase=phase,**values)),flush=True)
|
|
|
|
def main():
|
|
recipe=json.loads((ROOT/'basalt_sources.json').read_text());pin=recipe['model']
|
|
assert not DEST.exists(),'Existing managed runtime: inspect instead of repeating'
|
|
assert shutil.disk_usage(STATE).free>15*1024**3
|
|
git=['git','-c','safe.directory='+str(CAND/'source'),'-C',str(CAND/'source')]
|
|
assert subprocess.check_output(git+['rev-parse','HEAD'],text=True).strip()==recipe['code']
|
|
assert not subprocess.check_output(git+['status','--porcelain','--untracked-files=no'],text=True).strip()
|
|
info=json.loads(subprocess.check_output(['docker','inspect','athena-deck-dev'],text=True))[0]
|
|
save('copy managed public runtime; original worker stays loaded',image_before=info['Image'],started_before=info['State']['StartedAt'])
|
|
shutil.copytree(CAND/'source',DEST/'source',symlinks=True,ignore=ignored)
|
|
shutil.copytree(CAND/'venv',DEST/'venv',symlinks=True,ignore=ignored)
|
|
shutil.copytree(STATE/'strata-runtime/cuda',DEST/'cuda',symlinks=True,ignore=ignored)
|
|
# Relocate text launchers only. No candidate file is changed.
|
|
for p in (DEST/'venv/bin').iterdir():
|
|
if p.name in BLOCK or p.is_symlink() or not p.is_file():continue
|
|
with p.open('rb') as f:first=f.read(2)
|
|
if first==b'#!':
|
|
data=p.read_bytes().replace(str(CAND/'venv').encode(),str(VIEW/'venv').encode());p.write_bytes(data)
|
|
for name in ('tmp','home','cache'):(DEST/name).mkdir(exist_ok=True)
|
|
chown_tree(DEST)
|
|
source=CAND/'models'/pin['file'];ident=hashlib.sha256((pin['repo']+pin['revision']+pin['file']).encode()).hexdigest();target=STATE/'models'/ident
|
|
assert source.stat().st_size==pin['size'] and source.stat().st_uid==65534
|
|
assert source.stat().st_dev==(STATE/'models').stat().st_dev,'No cross-filesystem copy or silent slower-disk adoption'
|
|
save('verify existing whole model pack; no download or duplicate',model_id=ident)
|
|
assert digest(source)==pin['sha256']
|
|
target.mkdir(mode=0o700);os.chown(target,65534,65534);os.link(source,target/'model.basalt')
|
|
entry=dict(pin,kind='chat',downloaded_at=time.time(),state='downloaded',runtime_ready=False,upstream_hash_verified=True,runtime_metadata={})
|
|
path=target/'entry.json';path.write_text(json.dumps(entry));os.chown(path,65534,65534)
|
|
assert (target/'model.basalt').stat().st_ino==source.stat().st_ino
|
|
save('compile independent SM86/120 vision sidecar; no GPU attached',model_id=ident)
|
|
v=str(VIEW);cmake=v+'/venv/bin/cmake';nvcc=v+'/cuda/bin/nvcc';ninja=v+'/venv/bin/ninja'
|
|
configure=[cmake,'-S',v+'/source/tools/vision','-B',v+'/build-vision','-G','Ninja','-DCMAKE_BUILD_TYPE=Release','-DBUILD_TESTING=OFF','-DCMAKE_CUDA_ARCHITECTURES=86;120','-DCMAKE_CUDA_COMPILER='+nvcc,'-DCUDAToolkit_ROOT='+v+'/cuda','-DCMAKE_MAKE_PROGRAM='+ninja]
|
|
build=[cmake,'--build',v+'/build-vision','--target','basalt-vision','--parallel','1']
|
|
import shlex
|
|
script='set -e; '+shlex.join(configure)+'; '+shlex.join(build)+'; '+shlex.join([v+'/venv/bin/python','-m','pip','check'])+'; '+shlex.join([v+'/venv/bin/python','-m','serve.server','--help'])
|
|
command=['docker','run','--rm','--name','athena-basalt-vision-build','--network','none','--read-only','--cap-drop','ALL','--security-opt','no-new-privileges:true','--user','65534:65534','--cpus','1','--cpu-shares','2','--memory','3g','--memory-swap','3g','--pids-limit','256','-e','NVIDIA_VISIBLE_DEVICES=void','-e','CUDA_VISIBLE_DEVICES=','-e','HOME='+v+'/home','-e','TMPDIR='+v+'/tmp','-e','LD_LIBRARY_PATH='+v+'/cuda/lib64:'+v+'/cuda/lib','--mount','type=bind,src='+str(DEST)+',dst='+v,'--mount','type=bind,src='+str(DEST/'tmp')+',dst=/tmp','--workdir',v+'/source','--entrypoint','nice',info['Image'],'-n','19','sh','-c',script]
|
|
with (ROOT/'vision-build.log').open('w') as out:subprocess.run(command,stdout=out,stderr=subprocess.STDOUT,check=True,timeout=1200)
|
|
cache=(DEST/'build-vision/CMakeCache.txt').read_text();assert 'CMAKE_CUDA_ARCHITECTURES:UNINITIALIZED=86;120' in cache
|
|
assert (DEST/'source/bin/basalt-vision').is_file()
|
|
marker=dict(commit=recipe['code'],version=recipe['version'],cuda='13.0',architectures=[120],vision_architectures=[86,120],origin='verified-candidate-adoption-plus-separate-vision-build',python='3.12.3',binary_sha256=digest(DEST/'source/bin/basalt'),vision_sha256=digest(DEST/'source/bin/basalt-vision'),inference_performed=False)
|
|
path=DEST/'ready.json';path.write_text(json.dumps(marker,indent=2));os.chown(path,65534,65534)
|
|
after=json.loads(subprocess.check_output(['docker','inspect','athena-deck-dev'],text=True))[0]
|
|
assert after['Image']==info['Image'] and after['State']['StartedAt']==info['State']['StartedAt']
|
|
save('prepared; original production unchanged',model_id=ident,vision_architectures=[86,120],managed_runtime=str(DEST),whole_model_sha256_verified=True,shared_inode=True)
|
|
|
|
if __name__=='__main__':
|
|
parser=argparse.ArgumentParser();parser.add_argument('--go',action='store_true');args=parser.parse_args()
|
|
if not args.go:parser.error('Current Michael activation Go required')
|
|
main()
|