Support dumping rid for correlation across passes in dump comparator (#19372)
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
from dataclasses import fields
|
||||
|
||||
from sglang.srt.debug_utils.comparator.tensor_comparison.types import (
|
||||
DiffInfo,
|
||||
TensorComparisonInfo,
|
||||
@@ -56,7 +54,7 @@ def print_comparison(info: TensorComparisonInfo, diff_threshold: float) -> None:
|
||||
|
||||
|
||||
def _print_stats_comparison(baseline: TensorStats, target: TensorStats) -> None:
|
||||
stat_names = [f.name for f in fields(TensorStats)]
|
||||
stat_names = list(TensorStats.model_fields.keys())
|
||||
for stat_name in stat_names:
|
||||
value_baseline = getattr(baseline, stat_name)
|
||||
value_target = getattr(target, stat_name)
|
||||
|
||||
@@ -1165,11 +1165,15 @@ class _SGLangPlugin(_FrameworkPlugin):
|
||||
if isinstance(value, self.ForwardBatch):
|
||||
if skip_forward_batch:
|
||||
return {}
|
||||
return {
|
||||
result = {
|
||||
"input_ids": value.input_ids,
|
||||
"seq_lens": value.seq_lens,
|
||||
"positions": value.positions,
|
||||
"req_pool_indices": value.req_pool_indices,
|
||||
}
|
||||
if value.rids is not None:
|
||||
result["rids"] = value.rids
|
||||
return result
|
||||
if isinstance(value, self.PPProxyTensors):
|
||||
return {k: v for k, v in value.tensors.items()}
|
||||
|
||||
@@ -1181,7 +1185,9 @@ class _SGLangPlugin(_FrameworkPlugin):
|
||||
return None
|
||||
|
||||
def core_fields(self) -> frozenset[str]:
|
||||
return frozenset({"input_ids", "positions", "seq_lens"})
|
||||
return frozenset(
|
||||
{"input_ids", "positions", "seq_lens", "req_pool_indices", "rids"}
|
||||
)
|
||||
|
||||
|
||||
class _MegatronPlugin(_FrameworkPlugin):
|
||||
|
||||
@@ -373,6 +373,9 @@ class ForwardBatch(ForwardBatchDeepSeekMHAMixin):
|
||||
# For hidden states before normal
|
||||
return_hidden_states_before_norm: bool = False
|
||||
|
||||
# For dumper: request IDs for cross-step sequence tracking
|
||||
rids: Optional[List[str]] = None
|
||||
|
||||
@classmethod
|
||||
def init_new(
|
||||
cls,
|
||||
@@ -417,6 +420,7 @@ class ForwardBatch(ForwardBatchDeepSeekMHAMixin):
|
||||
tbo_split_seq_index=batch.tbo_split_seq_index,
|
||||
dimensions=batch.dimensions,
|
||||
return_hidden_states_before_norm=batch.return_hidden_states_before_norm,
|
||||
rids=[req.rid for req in batch.reqs],
|
||||
)
|
||||
device = model_runner.device
|
||||
|
||||
|
||||
Reference in New Issue
Block a user