diff --git a/python/sglang/srt/layers/vocab_parallel_embedding.py b/python/sglang/srt/layers/vocab_parallel_embedding.py index 40d6316abf..66fee24422 100644 --- a/python/sglang/srt/layers/vocab_parallel_embedding.py +++ b/python/sglang/srt/layers/vocab_parallel_embedding.py @@ -264,10 +264,7 @@ class VocabParallelEmbedding(torch.nn.Module): self.org_vocab_size = org_num_embeddings or num_embeddings # Support the case where the vocab size is not divisible by the TP size. - if ( - _is_cpu - and pad_vocab_size(self.org_vocab_size, padding_size) % self.tp_size != 0 - ): + if pad_vocab_size(self.org_vocab_size, padding_size) % self.tp_size != 0: padding_size *= self.tp_size self.padding_size = padding_size diff --git a/test/registered/unit/dllm/test_gemma4_cuda_graph.py b/test/registered/unit/dllm/test_gemma4_cuda_graph.py index 702f0cac82..d082361b0a 100644 --- a/test/registered/unit/dllm/test_gemma4_cuda_graph.py +++ b/test/registered/unit/dllm/test_gemma4_cuda_graph.py @@ -186,7 +186,8 @@ class TestGemma4VocabularyShards(unittest.TestCase): weight = torch.randn(73, 4) probabilities = torch.randn(6, 73).softmax(dim=-1) expected = probabilities @ weight * 2.0 - for tp_size in (1, 2, 4): + # TP3 does not divide the 64-padded vocab (128), so padding scales with TP. + for tp_size in (1, 2, 3, 4): with self.subTest(tp_size=tp_size): partials = [] for rank in range(tp_size):