上传文件至 /

This commit is contained in:
2026-07-14 01:20:51 +08:00
parent 60745be0e2
commit 7a0702692c
2 changed files with 43 additions and 0 deletions

19
patch.py Normal file
View File

@@ -0,0 +1,19 @@
path = '/usr/local/lib/python3.12/dist-packages/transformers/tokenization_utils_base.py'
with open(path, 'r') as f:
content = f.read()
old = (' self.SPECIAL_TOKENS_ATTRIBUTES = self.SPECIAL_TOKENS_ATTRIBUTES'
' + list(special_tokens.keys())')
new = (' # PATCH: some models have extra_special_tokens as list instead of dict\n'
' if isinstance(special_tokens, list):\n'
' special_tokens = {t: t for t in special_tokens}\n'
' self.SPECIAL_TOKENS_ATTRIBUTES = self.SPECIAL_TOKENS_ATTRIBUTES'
' + list(special_tokens.keys())')
if old in content:
content = content.replace(old, new)
with open(path, 'w') as f:
f.write(content)
print('Patch applied successfully')
else:
print('WARNING: pattern not found')

24
patch_triton.py Normal file
View File

@@ -0,0 +1,24 @@
path = '/usr/local/lib/python3.12/dist-packages/vllm/v1/attention/backends/triton_attn.py'
with open(path, 'r') as f:
content = f.read()
old = ''' def validate_head_size(cls, head_size: int) -> None:
# Triton Attention supports any head size above 32
if head_size < 32:
raise ValueError(
f"Head size {head_size} is not supported by TritonAttention."
f"Head sizes need to be larger or equal 32 for this backend. "
"Set VLLM_ATTENTION_BACKEND=FLEX_ATTENTION to use "
"FlexAttention backend which supports all head sizes.")'''
new = ''' def validate_head_size(cls, head_size: int) -> None:
# PATCH: allow all head sizes (Triton compiles at runtime)
return'''
if old in content:
content = content.replace(old, new)
with open(path, 'w') as f:
f.write(content)
print('patch_triton: validate_head_size bypassed successfully')
else:
print('patch_triton: WARNING - pattern not found, patch skipped')