Skip to content

Commit f670748

Browse files
author
wanghao7
committed
fix typing.
1 parent 94d7045 commit f670748

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

lightllm/common/basemodel/triton_kernel/add_in_place.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,18 @@ def _add_in_place(
2121
x = x + y * alpha
2222
tl.store(input_ptr + offsets, x, mask=mask)
2323

24+
2425
@torch.no_grad()
2526
def add_in_place(input: torch.Tensor, other: torch.Tensor, *, alpha=1):
2627
assert input.is_contiguous(), "input tensor must be contiguous"
2728
assert other.is_contiguous(), "other tensor must be contiguous"
2829
n_elements = input.numel()
29-
grid = lambda meta: (triton.cdiv(n_elements, meta['BLOCK_SIZE']), )
30+
grid = lambda meta: (triton.cdiv(n_elements, meta["BLOCK_SIZE"]),)
3031
_add_in_place[grid](
3132
input,
3233
other,
3334
n_elements,
3435
alpha,
3536
BLOCK_SIZE=1024,
3637
)
37-
return input
38+
return input

lightllm/server/router/manager.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ def __init__(self, args, router_port, detokenization_port, metric_port):
108108
self.schedule_task = None
109109
self.overlap_event = threading.Event()
110110
return
111-
112-
113111

114112
async def wait_to_model_ready(self):
115113
# 初始化模型
@@ -322,11 +320,11 @@ async def _step(self):
322320
self.running_batch = new_batch
323321
await self._prefill_batch(self.running_batch)
324322
self._filter_runing_batch()
325-
323+
326324
# 激进调度控制
327325
if not self.args.disable_aggressive_schedule:
328326
self.has_wait_tokens = self.max_wait_tokens
329-
327+
330328
elif self.is_multinode_and_multidp:
331329
# 在多节点多 dp 的模式下,如果当前 running_batch 为None, 也需要不断的调用 decode 操作,
332330
# 因为其他节点上的dp可能存在运行的请求,所以本节点也需要调用decode,推理后端的backend会
@@ -341,11 +339,11 @@ async def _step(self):
341339
new_mini_batch = await self.get_schedule_result(self.running_batch)
342340
self.has_wait_tokens = 0
343341
if new_mini_batch is not None:
344-
342+
345343
# 激进调度控制
346344
if not self.args.disable_aggressive_schedule:
347345
self.has_wait_tokens = self.max_wait_tokens
348-
346+
349347
self.stats_tool.count_prompt_tokens(new_mini_batch)
350348
await self._prefill_batch(new_mini_batch)
351349
if not new_mini_batch.is_clear():

lightllm/utils/log_utils.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
_LOG_LEVEL = getattr(logging, _LOG_LEVEL.upper(), 0)
1515
_LOG_DIR = os.environ.get("LIGHTLLM_LOG_DIR", None)
1616

17+
1718
class NewLineFormatter(logging.Formatter):
1819
"""Adds logging prefix to newlines to align multi-line messages."""
1920

@@ -45,14 +46,14 @@ def _setup_logger():
4546
_default_handler.flush = sys.stdout.flush # type: ignore
4647
_default_handler.setLevel(_LOG_LEVEL)
4748
_root_logger.addHandler(_default_handler)
48-
49+
4950
if _default_file_handler is None and _LOG_DIR is not None:
5051
if not os.path.exists(_LOG_DIR):
5152
try:
5253
os.makedirs(_LOG_DIR)
5354
except OSError as e:
5455
_root_logger.warn(f"Error creating directory {_LOG_DIR} : {e}")
55-
_default_file_handler = logging.FileHandler(_LOG_DIR + '/default.log')
56+
_default_file_handler = logging.FileHandler(_LOG_DIR + "/default.log")
5657
_default_file_handler.setLevel(_LOG_LEVEL)
5758
_default_file_handler.setFormatter(fmt)
5859
_root_logger.addHandler(_default_file_handler)
@@ -62,6 +63,7 @@ def _setup_logger():
6263
# being propagated to the parent logger.
6364
_root_logger.propagate = False
6465

66+
6567
# The logger is initialized when the module is imported.
6668
# This is thread-safe as the module is only imported once,
6769
# guaranteed by the Python GIL.
@@ -96,7 +98,8 @@ def init_logger(name: str):
9698

9799
_log_time_mark_dict = {}
98100

99-
def log_time_ready(mark_name, time_count:int):
101+
102+
def log_time_ready(mark_name, time_count: int):
100103
"""
101104
time_count 间隔时间超过多少s调用该函数会返回True,否则返回False
102105
用于控制一些日志输出的频率
@@ -112,5 +115,3 @@ def log_time_ready(mark_name, time_count:int):
112115
return True
113116
else:
114117
return False
115-
116-

unit_tests/common/basemodel/triton_kernel/test_add_in_place.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ def test_add_in_place(dim1, dim2, alpha):
2424
output = input + other * alpha
2525
add_in_place(input, other, alpha=alpha)
2626
rlt = torch.allclose(input, output, atol=1e-5, rtol=0)
27-
assert(rlt)
27+
assert rlt
28+
2829

2930
if __name__ == "__main__":
3031
pytest.main()

0 commit comments

Comments
 (0)