[Model] Add support for JetBrains' Mellum v2 code generation model (#27375)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Jiminator <69131491+Jiminator@users.noreply.github.com> Co-authored-by: Alex Nails <alex.nails@radixark.ai>
This commit is contained in:
co-authored by
gemini-code-assist[bot]
Jiminator
Alex Nails
parent
7e229e2a81
commit
702bddcee8
@@ -0,0 +1,39 @@
|
||||
"""Unit tests for hybrid attention model configuration."""
|
||||
|
||||
import unittest
|
||||
from types import SimpleNamespace
|
||||
|
||||
from sglang.srt.configs.model_config import get_hybrid_layer_ids
|
||||
from sglang.test.ci.ci_register import register_cpu_ci
|
||||
from sglang.test.test_utils import CustomTestCase
|
||||
|
||||
register_cpu_ci(est_time=5, suite="base-a-test-cpu")
|
||||
|
||||
|
||||
class TestHybridLayerIds(CustomTestCase):
|
||||
def test_layer_type_architectures(self):
|
||||
config = SimpleNamespace(
|
||||
num_hidden_layers=4,
|
||||
layer_types=[
|
||||
"sliding_attention",
|
||||
"full_attention",
|
||||
"sliding_attention",
|
||||
"full_attention",
|
||||
],
|
||||
)
|
||||
|
||||
for architecture in (
|
||||
"Gemma4ForCausalLM",
|
||||
"Gemma4ForConditionalGeneration",
|
||||
"LagunaForCausalLM",
|
||||
"MellumForCausalLM",
|
||||
):
|
||||
with self.subTest(architecture=architecture):
|
||||
self.assertEqual(
|
||||
get_hybrid_layer_ids([architecture], config),
|
||||
([0, 2], [1, 3]),
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,33 @@
|
||||
"""Unit tests for the Mellum model implementation."""
|
||||
|
||||
import unittest
|
||||
|
||||
import torch
|
||||
|
||||
from sglang.srt.models.mellum import MellumForCausalLM
|
||||
from sglang.test.ci.ci_register import register_cpu_ci
|
||||
from sglang.test.test_utils import CustomTestCase
|
||||
|
||||
register_cpu_ci(est_time=5, suite="base-a-test-cpu")
|
||||
|
||||
|
||||
class TestMellumForCausalLM(CustomTestCase):
|
||||
def test_prepare_positions(self):
|
||||
model = MellumForCausalLM.__new__(MellumForCausalLM)
|
||||
positions = torch.tensor([[0, 1]], dtype=torch.int64).t()
|
||||
|
||||
model.use_fused_qk_norm_rope = False
|
||||
self.assertIs(
|
||||
model._prepare_positions(positions, torch.device("cpu")), positions
|
||||
)
|
||||
|
||||
model.use_fused_qk_norm_rope = True
|
||||
fused_positions = model._prepare_positions(positions, torch.device("cpu"))
|
||||
|
||||
self.assertEqual(fused_positions.dtype, torch.int32)
|
||||
self.assertTrue(fused_positions.is_contiguous())
|
||||
self.assertEqual(fused_positions.shape, (2,))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user