Skip to content

Commit

Permalink
Support setting use_thread in the run_program for easier debuggin…
Browse files Browse the repository at this point in the history
…g. (sgl-project#1823)

Co-authored-by: Byron Hsu <byronhsu1230@gmail.com>
  • Loading branch information
liuyanyi and ByronHsu authored Oct 29, 2024
1 parent 680cad2 commit 5e6c326
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
10 changes: 9 additions & 1 deletion python/sglang/lang/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,14 @@ def run_internal(state, program, func_args, func_kwargs, sync):


def run_program(
program, backend, func_args, func_kwargs, default_sampling_para, stream, sync=False
program,
backend,
func_args,
func_kwargs,
default_sampling_para,
stream,
sync=False,
use_thread=True,
):
if hasattr(backend, "endpoint"):
backend = backend.endpoint
Expand All @@ -67,6 +74,7 @@ def run_program(
chat_template=None,
stream=stream,
num_api_spec_tokens=program.num_api_spec_tokens,
use_thread=use_thread,
)
state = ProgramState(stream_executor)

Expand Down
11 changes: 10 additions & 1 deletion python/sglang/lang/ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def run(
return_text_in_logprobs: Optional[bool] = None,
stream: bool = False,
backend=None,
use_thread: bool = True,
**kwargs,
):
from sglang.lang.interpreter import run_program
Expand Down Expand Up @@ -195,7 +196,15 @@ def run(
return_text_in_logprobs=return_text_in_logprobs,
)
backend = backend or global_config.default_backend
return run_program(self, backend, args, kwargs, default_sampling_para, stream)
return run_program(
self,
backend,
args,
kwargs,
default_sampling_para,
stream,
use_thread=use_thread,
)

def run_batch(
self,
Expand Down

0 comments on commit 5e6c326

Please sign in to comment.