Files
sglang/python
leavelet ce0e486327 Gate scheduler metrics on attn_cp_rank==0 too, not just attn_tp_rank==0
Under CP, attn_cp_size shards the TP group so compute_dp_attention_world_info
collapses attn_tp_size to 1 -> attn_tp_rank == 0 on EVERY CP rank. So
is_stats_logging_rank and current_scheduler_metrics_enabled were True on all
attn_cp_size ranks, making each rank log a 'Prefill batch' line and emit
scheduler-side metrics (SchedulerStats gauges, realtime token throughput) ->
summed token-throughput inflated by cp_size and duplicated per-rank logs.

Add attn_cp_rank == 0 to both gates, matching the scheduler's other single-rank
guards (scheduler.py:633/1591/1615/1631). No-op when CP is off (attn_cp_rank is
always 0). init_metrics runs after attn_cp_rank/attn_tp_rank are set
(scheduler.py:375/415 -> 433). Does NOT affect sglang:num_requests_total (a
TokenizerManager counter, one process per engine).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-28 02:07:14 +00:00
..
2026-06-10 05:54:43 +08:00