T8RIN's picture
Add Qwen3.5 9B Vision Max for ImageToolbox
a74e6a8 verified
Raw History Blame Contribute Delete
1.69 kB
import subprocess
import sys
from pathlib import Path
root = Path(__file__).resolve().parent
source = root / 'sources/vision_max'
from huggingface_hub import snapshot_download
snapshot_download(
'Qwen/Qwen3.5-9B',
revision='c202236235762e1c871ad0ccb60c8ee5ba337b9a',
local_dir=source,
allow_patterns=['*.json', '*.safetensors', '*.jinja', '*.txt', 'LICENSE'],
max_workers=2,
)
output = root / 'packages/assistant/v1/vision_max'
subprocess.run([sys.executable, str(root / 'prepare_export.py')], check=True)
steps = [
('text', [sys.executable, '-u', str(root / 'build_text.py'),
'-i', str(source), '-o', str(output), '-p', 'int4', '-e', 'cpu',
'-c', str(root / 'export-cache'), '--extra_options',
'filename=text.onnx', 'exclude_embeds=true', 'exclude_mtp=true',
'shared_embeddings=false', 'prune_lm_head=true', 'block_size=32', 'accuracy_level=4',
'int4_is_symmetric=true']),
*[(component, [sys.executable, '-u', '-c',
'from olive import run; run(' + repr(str(root / 'recipes/vision_max' / (component + '.json'))) + ')'])
for component in ['embedding', 'vision']],
('configure', [sys.executable, str(root / 'configure_package.py'), 'vision_max']),
('trim', [sys.executable, str(root / 'trim_rope.py'), 'vision_max']),
]
(root / 'logs').mkdir(exist_ok=True)
for name, command in steps:
print('Starting', name, flush=True)
with (root / 'logs' / (name + '.log')).open('w') as log:
subprocess.run(command, check=True, cwd=root, stdout=log, stderr=subprocess.STDOUT)
print('Finished', name, flush=True)
print('EXPORT_COMPLETE', flush=True)