-
Fix: Adapt Llama injection policy for newer transformers versions (#7443)
发布于
2025-07-26 21:27:33 +00:00 This PR fixes an
AttributeErrorthat occurs during
deepspeed.init_inferencewhen using kernel injection
(replace_with_kernel_inject=True) with Llama models from recent
versions oftransformers.The Bug:
In newer
transformersversions (e.g.,4.53.3), configurations like
num_headsandrope_thetawere moved from direct attributes of the
LlamaAttentionmodule into a nestedconfigobject.The current DeepSpeed injection policy tries to access these attributes
from their old, direct location, causing the initialization to fail with
anAttributeError: 'LlamaAttention' object has no attribute 'num_heads'.The Solution:
This change updates the Llama injection logic to be more robust:
- It first tries to read attributes like
num_headsfrom the new
configobject location. - If that fails, it falls back to the legacy direct attribute path.
Signed-off-by: huanyuqu yc37960@um.edu.mo
下载附件
- It first tries to read attributes like