Skip to content
Merged
Changes from all commits
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
16 changes: 16 additions & 0 deletions python/sglang/srt/model_executor/expert_location_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
logger = logging.getLogger(__name__)


_LOG_INPUT = get_bool_env_var("SGLANG_EXPERT_LOCATION_UPDATER_LOG_INPUT")


class ExpertLocationUpdater:
def __init__(self):
self._first_execution = True
Expand Down Expand Up @@ -175,6 +178,19 @@ def update_expert_weights_single_layer(
assert isinstance(old_physical_to_logical_map, list)
assert isinstance(new_physical_to_logical_map, list)

if _LOG_INPUT:
logger.info(
"update_expert_weights_single_layer "
f"{[x.shape for x in routed_experts_weights]=} "
f"{[x.shape for x in temp_buffers]=} "
f"{old_physical_to_logical_map=} "
f"{new_physical_to_logical_map=} "
f"{num_local_physical_experts=} "
f"{num_gpu_per_node=} "
f"{rank=} "
f"{world_size=} "
)
Comment on lines +182 to +192
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider using logger.debug instead of logger.info for this type of verbose debugging output controlled by a specific environment variable. This allows finer-grained control over logging levels, ensuring this detailed information is only shown when explicitly requested for debugging. Additionally, the f-string formatting with = can produce very long lines, especially for lists of shapes or maps. While convenient, explicitly formatting the output for better readability might be beneficial.

Suggested change
logger.info(
"update_expert_weights_single_layer "
f"{[x.shape for x in routed_experts_weights]=} "
f"{[x.shape for x in temp_buffers]=} "
f"{old_physical_to_logical_map=} "
f"{new_physical_to_logical_map=} "
f"{num_local_physical_experts=} "
f"{num_gpu_per_node=} "
f"{rank=} "
f"{world_size=} "
)
logger.debug(
"update_expert_weights_single_layer "
f"{[x.shape for x in routed_experts_weights]=} "
f"{[x.shape for x in temp_buffers]=} "
f"{old_physical_to_logical_map=} "
f"{new_physical_to_logical_map=} "
f"{num_local_physical_experts=} "
f"{num_gpu_per_node=} "
f"{rank=} "
f"{world_size=} "
)


output_logs = [] if debug else None

num_physical_experts = len(old_physical_to_logical_map)
Expand Down
Loading