Skip to content

Commit 41c54ab

Browse files
byjiang1996hebiao064BBuf
authored andcommitted
[Piecewise] Use same global graph memory pool as the main cuda graph … (sgl-project#14044)
Co-authored-by: Stefan He <[email protected]> Co-authored-by: BBuf <[email protected]>
1 parent dcbadcc commit 41c54ab

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

python/sglang/srt/distributed/device_communicators/pynccl_allocator.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ def is_symmetric_memory_enabled():
7171

7272
def set_graph_pool_id(graph_pool_id):
7373
global _graph_pool_id
74-
_graph_pool_id = graph_pool_id
74+
if _graph_pool_id is not None:
75+
_graph_pool_id = graph_pool_id
7576

7677

7778
def disable_symmetric_memory_context():

python/sglang/srt/model_executor/piecewise_cuda_graph_runner.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@
4545
from sglang.srt.layers.logits_processor import LogitsProcessorOutput
4646
from sglang.srt.layers.pooler import EmbeddingPoolerOutput
4747
from sglang.srt.layers.torchao_utils import save_gemlite_cache
48+
from sglang.srt.model_executor.cuda_graph_runner import (
49+
get_global_graph_memory_pool,
50+
set_global_graph_memory_pool,
51+
)
4852
from sglang.srt.model_executor.forward_batch_info import (
4953
CaptureHiddenMode,
5054
ForwardBatch,
@@ -143,19 +147,6 @@ def patch_model(model: torch.nn.Module, compiler: str):
143147
_to_torch(model, reverse=True, num_tokens=16)
144148

145149

146-
# Reuse this memory pool across all cuda graph runners.
147-
global_graph_memory_pool = None
148-
149-
150-
def get_global_graph_memory_pool():
151-
return global_graph_memory_pool
152-
153-
154-
def set_global_graph_memory_pool(val):
155-
global global_graph_memory_pool
156-
global_graph_memory_pool = val
157-
158-
159150
def set_torch_compile_config():
160151
import torch._dynamo.config
161152

0 commit comments

Comments
 (0)