hf_text-generation-inference/server/bloom_inference/cli.py

43 lines
947 B
Python
Raw Normal View History

2022-10-18 07:19:03 -06:00
import os
2022-10-17 06:59:00 -06:00
import typer
from pathlib import Path
from bloom_inference import server, utils
2022-10-17 06:59:00 -06:00
app = typer.Typer()
@app.command()
2022-10-18 07:19:03 -06:00
def serve(
model_name: str,
sharded: bool = False,
uds_path: Path = "/tmp/bloom-inference",
2022-10-17 06:59:00 -06:00
):
2022-10-18 07:19:03 -06:00
if sharded:
assert (
os.getenv("RANK", None) is not None
), "RANK must be set when sharded is True"
assert (
os.getenv("WORLD_SIZE", None) is not None
), "WORLD_SIZE must be set when sharded is True"
assert (
os.getenv("MASTER_ADDR", None) is not None
), "MASTER_ADDR must be set when sharded is True"
assert (
os.getenv("MASTER_PORT", None) is not None
), "MASTER_PORT must be set when sharded is True"
server.serve(model_name, sharded, uds_path)
2022-10-17 06:59:00 -06:00
@app.command()
def download_weights(
2022-10-18 07:19:03 -06:00
model_name: str,
2022-10-17 06:59:00 -06:00
):
utils.download_weights(model_name)
2022-10-17 06:59:00 -06:00
if __name__ == "__main__":
app()