You need to sign in or sign up before continuing.
Unverified Commit e074e76b authored by Shi Shuai's avatar Shi Shuai Committed by GitHub
Browse files

docs: Add offline engine launch example and documentation (#3771)

parent 4592afc2
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
"- Non-streaming asynchronous generation\n", "- Non-streaming asynchronous generation\n",
"- Streaming asynchronous generation\n", "- Streaming asynchronous generation\n",
"\n", "\n",
"****To launch the offline engine, `__main__` condition is necessary in your own script because we use \"spawn\" to create subprocesses, for more details please refer to [launch_engine](https://github.com/sgl-project/sglang/blob/main/examples/runtime/engine/launch_engine.py).****\n",
"\n",
"Additionally, you can easily build a custom server on top of the SGLang offline engine. A detailed example working in a python script can be found in [custom_server](https://github.com/sgl-project/sglang/blob/main/examples/runtime/engine/custom_server.py)." "Additionally, you can easily build a custom server on top of the SGLang offline engine. A detailed example working in a python script can be found in [custom_server](https://github.com/sgl-project/sglang/blob/main/examples/runtime/engine/custom_server.py)."
] ]
}, },
...@@ -45,7 +47,6 @@ ...@@ -45,7 +47,6 @@
"if is_in_ci():\n", "if is_in_ci():\n",
" import patch\n", " import patch\n",
"\n", "\n",
"\n",
"llm = sgl.Engine(model_path=\"meta-llama/Meta-Llama-3.1-8B-Instruct\")" "llm = sgl.Engine(model_path=\"meta-llama/Meta-Llama-3.1-8B-Instruct\")"
] ]
}, },
......
"""
This example demonstrates how to launch the offline engine.
"""
import sglang as sgl
def main():
llm = sgl.Engine(model_path="meta-llama/Meta-Llama-3.1-8B-Instruct")
llm.generate("What is the capital of France?")
llm.shutdown()
# The __main__ condition is necessary here because we use "spawn" to create subprocesses
# Spawn starts a fresh program every time, if there is no __main__, it will run into infinite loop to keep spawning processes from sgl.Engine
if __name__ == "__main__":
main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment