Support setting use_thread in the run_program for easier debugging. (#1823)
Co-authored-by: Byron Hsu <byronhsu1230@gmail.com>
This commit is contained in:
@@ -54,7 +54,14 @@ def run_internal(state, program, func_args, func_kwargs, sync):
|
|||||||
|
|
||||||
|
|
||||||
def run_program(
|
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"):
|
if hasattr(backend, "endpoint"):
|
||||||
backend = backend.endpoint
|
backend = backend.endpoint
|
||||||
@@ -67,6 +74,7 @@ def run_program(
|
|||||||
chat_template=None,
|
chat_template=None,
|
||||||
stream=stream,
|
stream=stream,
|
||||||
num_api_spec_tokens=program.num_api_spec_tokens,
|
num_api_spec_tokens=program.num_api_spec_tokens,
|
||||||
|
use_thread=use_thread,
|
||||||
)
|
)
|
||||||
state = ProgramState(stream_executor)
|
state = ProgramState(stream_executor)
|
||||||
|
|
||||||
|
|||||||
@@ -168,6 +168,7 @@ class SglFunction:
|
|||||||
return_text_in_logprobs: Optional[bool] = None,
|
return_text_in_logprobs: Optional[bool] = None,
|
||||||
stream: bool = False,
|
stream: bool = False,
|
||||||
backend=None,
|
backend=None,
|
||||||
|
use_thread: bool = True,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
):
|
):
|
||||||
from sglang.lang.interpreter import run_program
|
from sglang.lang.interpreter import run_program
|
||||||
@@ -195,7 +196,15 @@ class SglFunction:
|
|||||||
return_text_in_logprobs=return_text_in_logprobs,
|
return_text_in_logprobs=return_text_in_logprobs,
|
||||||
)
|
)
|
||||||
backend = backend or global_config.default_backend
|
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(
|
def run_batch(
|
||||||
self,
|
self,
|
||||||
|
|||||||
Reference in New Issue
Block a user