A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 10, 09:00 UTC
[Core] Refactor ColumnParallelLinear: remove unused parameter and optimize forward (#31939)
Signed-off-by: maang <maang_h@163.com>
maang committed
Jan 10, 2026 at 12:19 UTC
52d428295d2256cde1b4a0e781a77083679463ff
1 file changed
+4
-10
vllm/model_executor/layers/linear.py
+4
-10
@@ -411,10 +411,10 @@ class ReplicatedLinear(LinearBase):
411
assert self.quant_method is not None
412
413
output = self.quant_method.apply(self, x, bias)
414
- output_bias = self.bias if self.skip_bias_add else None
414
415
if not self.return_bias:
416
return output
417
+ output_bias = self.bias if self.skip_bias_add else None
418
return output, output_bias
419
420
def extra_repr(self) -> str:
@@ -444,8 +444,6 @@ class ColumnParallelLinear(LinearBase):
444
skip adding bias but instead return it.
445
params_dtype: Data type for the parameters.
446
quant_config: Quantization configure.
447
- output_sizes: list of output sizes packed into one output, like for QKV
448
- the list would be size 3.
447
prefix: The name of the layer in the state dict, including all parents
448
(e.g. model.layers.0.qkv_proj)
449
return_bias: If true, return bias together with outputs in forward pass.
@@ -463,7 +461,6 @@ class ColumnParallelLinear(LinearBase):
461
skip_bias_add: bool = False,
462
params_dtype: torch.dtype | None = None,
463
quant_config: QuantizationConfig | None = None,
466
- output_sizes: list[int] | None = None,
464
prefix: str = "",
465
*,
466
return_bias: bool = True,
@@ -495,9 +492,6 @@ class ColumnParallelLinear(LinearBase):
492
self._maybe_allow_fp8_block_shape_mismatch()
493
self.gather_output = gather_output
494
498
- if output_sizes is None:
499
- output_sizes = [output_size]
500
-
495
assert self.quant_method is not None
496
self.quant_method.create_weights(
497
layer=self,
@@ -614,9 +608,10 @@ class ColumnParallelLinear(LinearBase):
608
output = tensor_model_parallel_all_gather(output_parallel)
609
else:
610
output = output_parallel
617
- output_bias = self.bias if self.skip_bias_add else None
611
+
612
if not self.return_bias:
613
return output
614
+ output_bias = self.bias if self.skip_bias_add else None
615
return output, output_bias
616
617
def extra_repr(self) -> str:
@@ -1469,10 +1464,9 @@ class RowParallelLinear(LinearBase):
1464
else:
1465
output = output_parallel
1466
1472
- output_bias = self.bias if self.skip_bias_add else None
1473
-
1467
if not self.return_bias:
1468
return output
1469
+ output_bias = self.bias if self.skip_bias_add else None
1470
return output, output_bias
1471
1472
def extra_repr(self) -> str: