zefancainlp's picture
download
raw
1.79 kB
"""Install the audited GPT-OSS output-embedding LoRA registration patch."""
import argparse
import hashlib
import importlib.metadata as metadata
from pathlib import Path
CLEAN = "9da881235f5bb8fd598c041cd1001cdba79f9c6199af23b3fb27b1241cde75f1"
PATCHED = "a5d85b9762b902a1ca32af0cefb17af4ad3c5ff563ffc2c31ce19d2d4b3f0627"
parser = argparse.ArgumentParser()
parser.add_argument("--check", action="store_true")
args = parser.parse_args()
dist = metadata.distribution("vllm")
if dist.version != "0.27.1":
raise SystemExit(f"Unsupported vLLM version: {dist.version}")
path = Path(dist.locate_file("vllm/model_executor/models/gpt_oss.py"))
source = path.read_bytes()
digest = hashlib.sha256(source).hexdigest()
if digest == PATCHED:
print("Verified GPT-OSS lm_head LoRA patch: " + digest)
elif args.check:
raise SystemExit("Missing audited lm_head LoRA patch; run scripts/setup.sh")
elif digest != CLEAN:
raise SystemExit("Unexpected GPT-OSS source hash; refusing to overwrite unknown code: " + digest)
else:
anchor = b' packed_modules_mapping = {"qkv_proj": ["q_proj", "k_proj", "v_proj"]}\n'
addition = (
b" # Register the untied output projection with vLLM's LoRA manager. The\n"
b" # strict Tinker adapter trains all 201,088 unembed rows, so silently\n"
b" # omitting this module would change both sampling and training semantics.\n"
b' embedding_modules = {"lm_head": "output_embeddings"}\n'
)
assert source.count(anchor) == 1
patched = source.replace(anchor, anchor + addition)
assert hashlib.sha256(patched).hexdigest() == PATCHED
temporary = path.with_suffix(".py.pfg-tmp")
temporary.write_bytes(patched)
temporary.replace(path)
print("Applied GPT-OSS lm_head LoRA patch: " + PATCHED)

Xet Storage Details

Size:
1.79 kB
·
Xet hash:
3ca2df5f28298cd79e9094e7075bf1a7cda7946c5d05fd367fe0af342a8db5da

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.