[CP]: FIx some issue for glm5.2 cp v2 (#33100)
This commit is contained in:
@@ -170,6 +170,13 @@ def cal_padded_tokens(forward_batch: "ForwardBatch"):
|
|||||||
# Consistent with the padding calculation logic in ForwardBatch.prepare_mlp_sync_batch,
|
# Consistent with the padding calculation logic in ForwardBatch.prepare_mlp_sync_batch,
|
||||||
# calculate the actual token length after padding when attn_tp_size > 1 or in the MAX_LEN padding mode.
|
# calculate the actual token length after padding when attn_tp_size > 1 or in the MAX_LEN padding mode.
|
||||||
from sglang.srt.layers.cp.padding import get_cp_padding_align_size
|
from sglang.srt.layers.cp.padding import get_cp_padding_align_size
|
||||||
|
from sglang.srt.layers.cp.utils import is_cp_v2_active
|
||||||
|
|
||||||
|
# CP-v2 already pads each rank-local shard to its physical size
|
||||||
|
if is_cp_v2_active(forward_batch):
|
||||||
|
return forward_batch.attn_cp_metadata.per_rank_actual_token[
|
||||||
|
get_parallel().attn_cp_rank
|
||||||
|
]
|
||||||
|
|
||||||
global_num_tokens = forward_batch.global_num_tokens_cpu.copy()
|
global_num_tokens = forward_batch.global_num_tokens_cpu.copy()
|
||||||
sync_group_size = len(global_num_tokens)
|
sync_group_size = len(global_num_tokens)
|
||||||
|
|||||||
@@ -3218,6 +3218,11 @@ class DeepseekSparseAttnBackend(
|
|||||||
|
|
||||||
rope_positions = forward_batch.positions
|
rope_positions = forward_batch.positions
|
||||||
if dsa_use_prefill_cp(forward_batch):
|
if dsa_use_prefill_cp(forward_batch):
|
||||||
|
if is_cp_v2_active(forward_batch):
|
||||||
|
rope_positions = get_cp_strategy().shard_position_ids(
|
||||||
|
rope_positions, forward_batch
|
||||||
|
)
|
||||||
|
else:
|
||||||
rope_positions = cp_split_and_rebuild_position(
|
rope_positions = cp_split_and_rebuild_position(
|
||||||
forward_batch, rope_positions
|
forward_batch, rope_positions
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -6203,12 +6203,6 @@ class ServerArgs:
|
|||||||
hf_config = model_config.hf_config
|
hf_config = model_config.hf_config
|
||||||
model_arch = hf_config.architectures[0]
|
model_arch = hf_config.architectures[0]
|
||||||
if model_arch in CP_V2_DEFAULT_MODEL_CLASSES:
|
if model_arch in CP_V2_DEFAULT_MODEL_CLASSES:
|
||||||
if getattr(hf_config, "index_share_for_mtp_iteration", False):
|
|
||||||
# GLM 5.2 (DSA index-share MTP): CP-v2 is not ready for it
|
|
||||||
# yet, so default the env to off and keep the legacy CP path.
|
|
||||||
if not envs.SGLANG_ENABLE_CP_V2.is_set():
|
|
||||||
envs.SGLANG_ENABLE_CP_V2.set(False)
|
|
||||||
else:
|
|
||||||
is_dsa_default_model = is_deepseek_dsa(hf_config)
|
is_dsa_default_model = is_deepseek_dsa(hf_config)
|
||||||
# DSA CP-v2 currently supports only the interleave strategy.
|
# DSA CP-v2 currently supports only the interleave strategy.
|
||||||
enable_default_cp_v2 = not is_dsa_default_model or (
|
enable_default_cp_v2 = not is_dsa_default_model or (
|
||||||
|
|||||||
Reference in New Issue
Block a user