Add more support for intel Gaudi accelerators (#2357)

This commit is contained in:
Qun Yang
2024-12-06 17:16:33 +08:00
committed by GitHub
parent 34b364e073
commit 37ee906f61
8 changed files with 88 additions and 14 deletions

View File

@@ -1,7 +1,13 @@
import argparse
import dataclasses
import sglang as sgl
from sglang.srt.server_args import ServerArgs
def main():
def main(
server_args: ServerArgs,
):
# Sample prompts.
prompts = [
"Hello, my name is",
@@ -13,7 +19,7 @@ def main():
sampling_params = {"temperature": 0.8, "top_p": 0.95}
# Create an LLM.
llm = sgl.Engine(model_path="meta-llama/Meta-Llama-3.1-8B-Instruct")
llm = sgl.Engine(**dataclasses.asdict(server_args))
outputs = llm.generate(prompts, sampling_params)
# Print the outputs.
@@ -25,4 +31,8 @@ def main():
# 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()
parser = argparse.ArgumentParser()
ServerArgs.add_cli_args(parser)
args = parser.parse_args()
server_args = ServerArgs.from_cli_args(args)
main(server_args)