Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Enhance Indexer and DeepseekV2AttentionMLA to support dynamic is_neox…
…_style parameter. Refactor rope parameter handling in DeepseekV2DecoderLayer for improved configuration flexibility.

Signed-off-by: Xinyuan Tong <xinyuantong.cs@gmail.com>
  • Loading branch information
JustinTong0323 committed Feb 5, 2026
commit 541c98206dac152795f753b30245e46b6c929b7d
3 changes: 2 additions & 1 deletion python/sglang/srt/layers/attention/nsa/nsa_indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def __init__(
scale_fmt: Optional[str],
block_size: int = 128,
rope_scaling: Optional[Dict[str, Any]] = None,
is_neox_style: bool = True,
prefix: str = "",
quant_config: Optional[QuantizationConfig] = None,
alt_stream: Optional[torch.cuda.Stream] = None,
Expand Down Expand Up @@ -202,7 +203,7 @@ def __init__(
max_position=max_position_embeddings,
base=rope_theta, # type: ignore
rope_scaling=rope_scaling,
is_neox_style=True,
is_neox_style=is_neox_style,
device=get_global_server_args().device,
)
self.block_size = block_size
Expand Down
17 changes: 13 additions & 4 deletions python/sglang/srt/models/deepseek_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,7 @@ def __init__(
)

if self.use_nsa:
is_neox_style = not getattr(config, "indexer_rope_interleave", True)
self.indexer = Indexer(
hidden_size=hidden_size,
index_n_heads=get_nsa_index_n_heads(config),
Expand All @@ -1162,6 +1163,7 @@ def __init__(
scale_fmt="ue8m0",
block_size=128,
rope_scaling=rope_scaling,
is_neox_style=is_neox_style,
prefix=add_prefix("indexer", prefix),
quant_config=quant_config,
layer_id=layer_id,
Expand Down Expand Up @@ -1191,13 +1193,14 @@ def __init__(
self.kv_a_layernorm = RMSNorm(self.kv_lora_rank, eps=config.rms_norm_eps)

if not skip_rope:
is_neox_style = not getattr(config, "rope_interleave", True)
self.rotary_emb = get_rope_wrapper(
qk_rope_head_dim,
rotary_dim=qk_rope_head_dim,
max_position=max_position_embeddings,
base=rope_theta,
rope_scaling=rope_scaling,
is_neox_style=False,
is_neox_style=is_neox_style,
device=get_global_server_args().device,
)

Expand Down Expand Up @@ -2227,9 +2230,15 @@ def __init__(
super().__init__()
self.hidden_size = config.hidden_size
self.config = config
rope_theta = getattr(config, "rope_theta", 10000)
rope_scaling = getattr(config, "rope_scaling", None)
max_position_embeddings = getattr(config, "max_position_embeddings", 8192)
if hasattr(config, "rope_parameters"):
rope_theta = config.rope_parameters.get("rope_theta")
assert rope_theta is not None, f"rope_theta not found in config: {config}"
rope_type = config.rope_parameters.get("rope_type")
rope_scaling = config.rope_parameters if rope_type != "default" else None
else:
rope_theta = config.rope_theta
rope_scaling = config.rope_scaling
max_position_embeddings = config.max_position_embeddings
self.speculative_algorithm = SpeculativeAlgorithm.from_string(
get_global_server_args().speculative_algorithm
)
Expand Down
Loading