Deprecate the parallel getters the context answers, and ratchet them shut (#40342)
This commit is contained in:
@@ -48,6 +48,7 @@ from sglang.srt.mem_cache.multimodal_cache import (
|
||||
EmbeddingResult,
|
||||
MultiModalStaticCache,
|
||||
)
|
||||
from sglang.srt.runtime_context import get_parallel
|
||||
from sglang.srt.utils.common import safe_pickle_loads
|
||||
from sglang.test.ci.ci_register import register_cpu_ci
|
||||
from sglang.test.test_utils import CustomTestCase
|
||||
@@ -1011,10 +1012,7 @@ class TestEncoderDelivery(CustomTestCase):
|
||||
statuses[1].copy_(torch.tensor([400, 1, 0, 0]))
|
||||
|
||||
with (
|
||||
patch(
|
||||
"sglang.srt.distributed.parallel_state.get_tp_group",
|
||||
return_value=TPGroup(),
|
||||
),
|
||||
get_parallel().override(tp_group=TPGroup()),
|
||||
patch(
|
||||
"sglang.srt.disaggregation.encoder.server.torch.distributed.all_gather",
|
||||
side_effect=all_gather,
|
||||
@@ -1051,10 +1049,7 @@ class TestEncoderDelivery(CustomTestCase):
|
||||
statuses[1][2] += 1
|
||||
|
||||
with (
|
||||
patch(
|
||||
"sglang.srt.distributed.parallel_state.get_tp_group",
|
||||
return_value=TPGroup(),
|
||||
),
|
||||
get_parallel().override(tp_group=TPGroup()),
|
||||
patch(
|
||||
"sglang.srt.disaggregation.encoder.server.torch.distributed.all_gather",
|
||||
side_effect=all_gather,
|
||||
@@ -1095,10 +1090,7 @@ class TestEncoderDelivery(CustomTestCase):
|
||||
statuses[1].copy_(local_status)
|
||||
|
||||
with (
|
||||
patch(
|
||||
"sglang.srt.distributed.parallel_state.get_tp_group",
|
||||
return_value=TPGroup(),
|
||||
),
|
||||
get_parallel().override(tp_group=TPGroup()),
|
||||
patch(
|
||||
"sglang.srt.disaggregation.encoder.server.torch.distributed.all_gather",
|
||||
side_effect=all_gather,
|
||||
|
||||
@@ -9,7 +9,7 @@ import unittest
|
||||
from unittest.mock import MagicMock, call, patch
|
||||
|
||||
from sglang.srt.environ import envs
|
||||
from sglang.srt.runtime_context import get_context
|
||||
from sglang.srt.runtime_context import get_context, get_parallel
|
||||
from sglang.test.test_utils import CustomTestCase
|
||||
|
||||
|
||||
@@ -201,12 +201,12 @@ class TestRegisterToBootstrap(CustomTestCase):
|
||||
self.assertIn("10.0.0.1", url_used)
|
||||
|
||||
@patch("sglang.srt.disaggregation.common.conn.requests.put")
|
||||
# The consumer reads the group through `get_parallel()`, which reads
|
||||
# through to the canonical getter, so that is where the stub belongs.
|
||||
@patch("sglang.srt.distributed.parallel_state.get_world_group")
|
||||
def test_rust_attention_dp_replicates_complete_topology_across_hosts(
|
||||
self, mock_world_group, mock_put
|
||||
self, mock_put
|
||||
):
|
||||
# The consumer reads the group through `get_parallel()`, so the
|
||||
# stub is stated there rather than in the module the build writes.
|
||||
mock_world_group = MagicMock()
|
||||
success_resp = MagicMock()
|
||||
success_resp.status_code = 200
|
||||
mock_put.return_value = success_resp
|
||||
@@ -230,9 +230,12 @@ class TestRegisterToBootstrap(CustomTestCase):
|
||||
for dp_rank, tp_rank, host, rank_port, _ in schedulers
|
||||
]
|
||||
|
||||
mock_world_group.return_value.all_gather_object.side_effect = gather_topology
|
||||
mock_world_group.all_gather_object.side_effect = gather_topology
|
||||
|
||||
with envs.SGLANG_RUST_SERVER.override(True):
|
||||
with (
|
||||
get_parallel().override(world_group=mock_world_group),
|
||||
envs.SGLANG_RUST_SERVER.override(True),
|
||||
):
|
||||
for dp_rank, tp_rank, local_ip, _, rust_http_port in schedulers:
|
||||
manager = self._make_manager()
|
||||
manager.attn_dp_size = 2
|
||||
@@ -277,7 +280,7 @@ class TestRegisterToBootstrap(CustomTestCase):
|
||||
gather_call.args[0]["attn_dp_rank"],
|
||||
gather_call.args[0]["attn_tp_rank"],
|
||||
)
|
||||
for gather_call in mock_world_group.return_value.all_gather_object.call_args_list
|
||||
for gather_call in mock_world_group.all_gather_object.call_args_list
|
||||
],
|
||||
[(dp, tp) for dp, tp, _, _, _ in schedulers],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user