[bugfix] fix Error 'ValueError: Duplicate layer name' (#5280)
### What this PR does / why we need it?
When matmul_and_reduce is enabled, the prefix attribute is required.
However, in some models, the prefix is not passed correctly, causing
errors when starting the service.
The issue of incorrect prefix passing will be fixed in vLLM in the
future.
- vLLM version: release/v0.13.0
- vLLM main:
ad32e3e19c
---------
Signed-off-by: Wang Kunpeng <1289706727@qq.com>
This commit is contained in:
@@ -36,7 +36,7 @@ from vllm.model_executor.layers.quantization.base_config import \
|
||||
from vllm.model_executor.utils import set_weight_attrs
|
||||
|
||||
from vllm_ascend.ops.linear_op import get_parallel_op, get_replicated_op
|
||||
from vllm_ascend.utils import maybe_trans_nz
|
||||
from vllm_ascend.utils import enable_sp, maybe_trans_nz
|
||||
|
||||
|
||||
class AscendUnquantizedLinearMethod(UnquantizedLinearMethod):
|
||||
@@ -219,6 +219,9 @@ class AscendRowParallelLinear(RowParallelLinear):
|
||||
and the original TP group in other modules.
|
||||
"""
|
||||
|
||||
# NOTE: Globally unique prefix identifier used in SP scenarios
|
||||
unique_prefix_idx = 0
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
input_size: int,
|
||||
@@ -234,14 +237,15 @@ class AscendRowParallelLinear(RowParallelLinear):
|
||||
return_bias: bool = True,
|
||||
disable_tp: bool = False,
|
||||
):
|
||||
compilation_config = get_current_vllm_config().compilation_config
|
||||
# TODO(shaopeng-666): Remove the visual check after the mm model reconstruction is complete.
|
||||
# TODO(MengqingCao): Remove the empty string check, after specifying the prefix in linear layers of some models in the vLLM.
|
||||
if prefix in compilation_config.static_forward_context and \
|
||||
prefix != "" and \
|
||||
"visual" not in prefix:
|
||||
raise ValueError(f"Duplicate layer name: {prefix}")
|
||||
compilation_config.static_forward_context[prefix] = self
|
||||
# TODO(kunpengW-code): Specifying the prefix in linear layers of some models in the vLLM.
|
||||
if enable_sp():
|
||||
compilation_config = get_current_vllm_config().compilation_config
|
||||
unique_prefix = prefix
|
||||
if prefix in compilation_config.static_forward_context:
|
||||
unique_prefix = f"{prefix}.unique_prefix{AscendRowParallelLinear.unique_prefix_idx}"
|
||||
AscendRowParallelLinear.unique_prefix_idx += 1
|
||||
self.unique_prefix = unique_prefix
|
||||
compilation_config.static_forward_context[unique_prefix] = self
|
||||
|
||||
self.custom_op, self.tp_rank, self.tp_size = get_parallel_op(
|
||||
disable_tp, prefix, self, "row")
|
||||
|
||||
Reference in New Issue
Block a user