Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions python/sglang/srt/layers/quantization/w8a8_int8.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,8 @@ def apply(
x: torch.Tensor,
bias: Optional[torch.Tensor] = None,
) -> torch.Tensor:
from sglang.srt.layers.linear import RowParallelLinear
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider moving the import statement outside of the apply method to reduce runtime overhead. While this resolves the NameError, the import statement in a frequently called method can introduce performance overhead. If circular dependencies prevent a global import, consider importing within the class's __init__ method and storing it as an instance attribute.

class NPU_W8A8LinearMethod:
    def __init__(self):
        from sglang.srt.layers.linear import RowParallelLinear
        self.RowParallelLinear = RowParallelLinear

    def apply(self, layer, ...):
        if isinstance(layer, self.RowParallelLinear):


if isinstance(layer, RowParallelLinear):
tp_rank = get_tensor_model_parallel_rank()
return self.quant_method.apply(layer, x, bias, tp_rank)
Expand Down
Loading