Skip to content

Commit d48ab2d

Browse files
authored
Fix BCG circular import during server startup (#33371)
1 parent a2d1003 commit d48ab2d

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

  • python/sglang/srt/layers/cp

‎python/sglang/srt/layers/cp/bcg.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
prepare_cp_forward,
2929
)
3030
from sglang.srt.model_executor.forward_batch_info import PPProxyTensors
31-
from sglang.srt.model_executor.runner.shape_key import ShapeKey
3231

3332
if TYPE_CHECKING:
3433
from sglang.srt.model_executor.forward_batch_info import ForwardBatch
@@ -197,6 +196,12 @@ def execute_prefill_cp_bcg(
197196
**kwargs,
198197
):
199198
"""Replay a CP-local body and run the global gather/logits tail eagerly."""
199+
# Importing a runner submodule while server arguments are being resolved
200+
# executes runner/__init__.py, which imports this module through the prefill
201+
# runner. Defer the runtime-only dependency until runner initialization has
202+
# completed to keep the server-argument compatibility check acyclic.
203+
from sglang.srt.model_executor.runner.shape_key import ShapeKey
204+
200205
cp_input = runner.prefill_cp_bcg_input
201206
assert cp_input is not None
202207
model = runner.model_runner.model

0 commit comments

Comments
 (0)