Skip to content

Commit

Permalink
[CQ]
Browse files Browse the repository at this point in the history
  • Loading branch information
Kye committed Feb 24, 2024
1 parent af7bd86 commit 5a5b49f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
4 changes: 2 additions & 2 deletions servers/blip2.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


def get_engine_name(rank):
return "rank{}.engine".format(rank)
return f"rank{rank}.engine"


def trt_dtype_to_torch(dtype):
Expand All @@ -20,7 +20,7 @@ def trt_dtype_to_torch(dtype):
elif dtype == trt.int32:
return torch.int32
else:
raise TypeError("%s is not supported" % dtype)
raise TypeError(f"{dtype} is not supported")


def TRTOPT(args, config):
Expand Down
10 changes: 4 additions & 6 deletions servers/cogvlm.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ async def predict(model_id: str, params: dict):
chunk = ChatCompletionResponse(
model=model_id, choices=[choice_data], object="chat.completion.chunk"
)
yield "{}".format(chunk.model_dump_json(exclude_unset=True))
yield f"{chunk.model_dump_json(exclude_unset=True)}"

previous_text = ""
for new_response in generate_stream_cogvlm(model, tokenizer, params):
Expand All @@ -238,15 +238,15 @@ async def predict(model_id: str, params: dict):
chunk = ChatCompletionResponse(
model=model_id, choices=[choice_data], object="chat.completion.chunk"
)
yield "{}".format(chunk.model_dump_json(exclude_unset=True))
yield f"{chunk.model_dump_json(exclude_unset=True)}"
choice_data = ChatCompletionResponseStreamChoice(
index=0,
delta=DeltaMessage(),
)
chunk = ChatCompletionResponse(
model=model_id, choices=[choice_data], object="chat.completion.chunk"
)
yield "{}".format(chunk.model_dump_json(exclude_unset=True))
yield f"{chunk.model_dump_json(exclude_unset=True)}"


def generate_cogvlm(
Expand Down Expand Up @@ -405,9 +405,7 @@ def generate_stream_cogvlm(
torch_type = torch.float16

print(
"========Use torch type as:{} with device:{}========\n\n".format(
torch_type, DEVICE
)
f"========Use torch type as:{torch_type} with device:{DEVICE}========\n\n"
)

if "cuda" in DEVICE:
Expand Down
6 changes: 3 additions & 3 deletions servers/qwen_tensort.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@

def get_engine_name(model, dtype, tp_size, pp_size, rank):
if pp_size == 1:
return "{}_{}_tp{}_rank{}.engine".format(model, dtype, tp_size, rank)
return "{}_{}_tp{}_pp{}_rank{}.engine".format(model, dtype, tp_size, pp_size, rank)
return f"{model}_{dtype}_tp{tp_size}_rank{rank}.engine"
return f"{model}_{dtype}_tp{tp_size}_pp{pp_size}_rank{rank}.engine"


def trt_dtype_to_torch(dtype):
Expand All @@ -42,7 +42,7 @@ def trt_dtype_to_torch(dtype):
elif dtype == trt.int32:
return torch.int32
else:
raise TypeError("%s is not supported" % dtype)
raise TypeError(f"{dtype} is not supported")


class QWenInfer(object):
Expand Down
2 changes: 1 addition & 1 deletion swarms_cloud/sky_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def execute(self, task: Task = None, cluster_name: str = None, **kwargs):
_type_: _description_
"""
if cluster_name not in self.clusters:
raise ValueError("Cluster {} does not exist".format(cluster_name))
raise ValueError(f"Cluster {cluster_name} does not exist")
try:
return sky.exec(
task=task,
Expand Down

0 comments on commit 5a5b49f

Please sign in to comment.