# SPDX-License-Identifier: Apache-2.0 # Based on blazux/qwen3.8-Flash-DGX's Mamba alignment diagnosis, # Copyright 2026 blazux. Independently guarded for pinned vLLM 0bfc7a15. import ast import hashlib import importlib.util import json from pathlib import Path root = Path(importlib.util.find_spec('vllm').origin).parent edits = json.loads(Path(__file__).with_name('prefix-edits.json').read_text()) pending = [] for edit in edits: path = root / edit['file'] data = path.read_bytes() if hashlib.sha256(data).hexdigest() != edit['sha256']: raise RuntimeError(f'Unsupported source: {path}') source = data.decode() if source.count(edit['before']) != 1: raise RuntimeError(f'Ambiguous patch anchor: {path}') changed = source.replace(edit['before'], edit['after']) ast.parse(changed) pending.append((path, changed)) for path, changed in pending: path.write_text(changed) print('Applied two source-verified Mamba prefix alignment corrections')