Skip to content

Commit 730b8b5

Browse files
committed
fix: auto style fix by autopep8
1 parent 034142f commit 730b8b5

40 files changed

+163
-118
lines changed

.github/scripts/action_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def evaluate(models: list[str],
9494
for idx, ori_model in enumerate(models):
9595
print()
9696
print(50 * '==')
97-
print(f'Start evaluating {idx+1}/{num_model} {ori_model} ...')
97+
print(f'Start evaluating {idx + 1}/{num_model} {ori_model} ...')
9898
model = ori_model.lower()
9999

100100
lmdeploy_dir = os.path.abspath(os.environ['LMDEPLOY_DIR'])

.github/scripts/eval_chat_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
dict(role='HUMAN', begin='[INST] ', end=' [/INST]'),
134134
dict(role='BOT', begin='', end='', generate=True),
135135
],
136-
eos_token_id=2)
136+
eos_token_id=2)
137137

138138
MAX_SESSION_LEN = 2048
139139
MAX_NEW_TOKENS = 1024

autotest/interface/restful/test_restful_chat_completions_v1.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -227,14 +227,14 @@ def test_array_stopwords_streaming(self, backend, model_case):
227227
@pytest.mark.internlm2_5
228228
def test_special_words(self, backend, model_case):
229229
message = '<|im_start|>system\n当开启工具以及代码时,根据需求选择合适的工具进行调用\n' \
230-
'<|im_end|><|im_start|>system name=<|interpreter|>\n你现在已经' \
231-
'能够在一个有状态的 Jupyter 笔记本环境中运行 Python 代码。当你向 python ' \
232-
'发送含有 Python >代码的消息时,它将在该环境中执行。这个工具适用于多种场景,' \
233-
'如数据分析或处理(包括数据操作、统计分析、图表绘制),复杂的计算问题(解决数学和物理' \
234-
'难题),编程示例(理解编程概念或特性),文本处理和分析(比如文本解析和自然语言处理),' \
235-
'机器学习和数据科学(用于展示模型训练和数据可视化),以及文件操作和数据导入(处理CSV、' \
236-
'JSON等格式的文件)。<|im_end|>\n<|im_start|>user\n设 $L$ 为圆周$x^2+y^2=2x$,' \
237-
'计算曲线积分:$I=\\int_L{x\\mathrm{d}s}=$<|im_end|>\n<|im_start|>assistant'
230+
'<|im_end|><|im_start|>system name=<|interpreter|>\n你现在已经' \
231+
'能够在一个有状态的 Jupyter 笔记本环境中运行 Python 代码。当你向 python ' \
232+
'发送含有 Python >代码的消息时,它将在该环境中执行。这个工具适用于多种场景,' \
233+
'如数据分析或处理(包括数据操作、统计分析、图表绘制),复杂的计算问题(解决数学和物理' \
234+
'难题),编程示例(理解编程概念或特性),文本处理和分析(比如文本解析和自然语言处理),' \
235+
'机器学习和数据科学(用于展示模型训练和数据可视化),以及文件操作和数据导入(处理CSV、' \
236+
'JSON等格式的文件)。<|im_end|>\n<|im_start|>user\n设 $L$ 为圆周$x^2+y^2=2x$,' \
237+
'计算曲线积分:$I=\\int_L{x\\mathrm{d}s}=$<|im_end|>\n<|im_start|>assistant'
238238
api_client = APIClient(BASE_URL)
239239
model_name = api_client.available_models[0]
240240
for output in api_client.chat_completions_v1(model=model_name,

autotest/interface/restful/test_restful_generate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ def single_request(idx):
748748

749749
success_rate = success_count / 20
750750
assert success_rate == 1.0, \
751-
f'Stress test failed: success rate {success_rate*100}% < 80%'
751+
f'Stress test failed: success rate {success_rate * 100}% < 80%'
752752

753753
if success_count > 0:
754754
avg_latency = total_latency / success_count

autotest/tools/pipeline/mllm_case.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def load_video(video_path, bound=None, num_segments=32):
210210

211211
question = ''
212212
for i in range(len(imgs)):
213-
question = question + f'Frame{i+1}: {IMAGE_TOKEN}\n'
213+
question = question + f'Frame{i + 1}: {IMAGE_TOKEN}\n'
214214

215215
if lang == 'cn':
216216
question += '视频里有什么动物,它在做什么?'

lmdeploy/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def serve(model_path: str,
9595
This function has been removed. Please use alternative methods.
9696
9797
This will run the api_server in a subprocess.
98-
""" # noqa E501
98+
""" # noqa E501
9999
raise NotImplementedError("The 'serve' function is no longer available. "
100100
'This function has been deprecated and removed.')
101101

lmdeploy/cli/utils.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def get_lora_adapters(adapters: list[str]):
6161
else:
6262
for pair in adapters:
6363
assert '=' in pair, f'Multiple lora paths must in format of ' \
64-
f'xxx=yyy. But given: {pair}'
64+
f'xxx=yyy. But given: {pair}'
6565
name, path = pair.strip().split('=', 1)
6666
assert name not in output, f'Multiple lora paths with repeated lora name: {name}'
6767
output[name] = path
@@ -420,8 +420,7 @@ def calib_batchsize(parser):
420420
'--batch-size',
421421
type=int,
422422
default=1,
423-
help=\
424-
'The batch size for running the calib samples. Low GPU mem requires small batch_size. Large batch_size reduces the calibration time while costs more VRAM' # noqa
423+
help='The batch size for running the calib samples. Low GPU mem requires small batch_size. Large batch_size reduces the calibration time while costs more VRAM' # noqa
425424
)
426425

427426
@staticmethod
@@ -432,8 +431,7 @@ def calib_search_scale(parser):
432431
'--search-scale',
433432
action='store_true',
434433
default=False,
435-
help=\
436-
'Whether search scale ratio. Default to be disabled, which means only smooth quant with 0.5 ratio will be applied' # noqa
434+
help='Whether search scale ratio. Default to be disabled, which means only smooth quant with 0.5 ratio will be applied' # noqa
437435
)
438436

439437
@staticmethod
@@ -454,8 +452,7 @@ def chat_template(parser):
454452
'--chat-template',
455453
type=str,
456454
default=None,
457-
help=\
458-
'A JSON file or string that specifies the chat template configuration. ' # noqa
455+
help='A JSON file or string that specifies the chat template configuration. ' # noqa
459456
'Please refer to https://lmdeploy.readthedocs.io/en/latest/advance/chat_template.html for the specification' # noqa
460457
)
461458

lmdeploy/lite/utils/__init__.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
from .batch_split import concat_decoder_layer_outputs, split_decoder_layer_inputs
44
from .cal_qparams import (
5-
QParams,
6-
cal_qparams_per_channel_absmax,
7-
cal_qparams_per_channel_minmax,
8-
cal_qparams_per_group_absmax,
9-
cal_qparams_per_group_minmax,
10-
cal_qparams_per_tensor_absmax,
11-
cal_qparams_per_tensor_minmax,
12-
precise_round,
5+
QParams,
6+
cal_qparams_per_channel_absmax,
7+
cal_qparams_per_channel_minmax,
8+
cal_qparams_per_group_absmax,
9+
cal_qparams_per_group_minmax,
10+
cal_qparams_per_tensor_absmax,
11+
cal_qparams_per_tensor_minmax,
12+
precise_round,
1313
)
1414
from .calib_dataloader import get_calib_loaders
1515
from .collect import bimap_name_mod, collect_target_modules, collect_target_weights

lmdeploy/messages.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -451,16 +451,16 @@ def __post_init__(self):
451451
assert self.quant_policy in (0, 4, 8), 'invalid quant_policy'
452452
assert self.device_type in ['cuda', 'ascend', 'maca', 'camb'], (f'invalid device_type: {self.device_type}')
453453
assert self.kernel_block_size >= 16 and \
454-
(self.kernel_block_size & (self.kernel_block_size - 1)) == 0, \
455-
f'kernel_block_size must be >= 16 and a power of 2, but got {self.kernel_block_size}'
454+
(self.kernel_block_size & (self.kernel_block_size - 1)) == 0, \
455+
f'kernel_block_size must be >= 16 and a power of 2, but got {self.kernel_block_size}'
456456
assert self.block_size >= self.kernel_block_size and \
457-
self.block_size % self.kernel_block_size == 0, \
458-
(f'block_size must be >= kernel_block_size and an integer multiple '
459-
f'of kernel_block_size, but got block_size {self.block_size} '
460-
f'and kernel_block_size {self.kernel_block_size}')
457+
self.block_size % self.kernel_block_size == 0, \
458+
(f'block_size must be >= kernel_block_size and an integer multiple '
459+
f'of kernel_block_size, but got block_size {self.block_size} '
460+
f'and kernel_block_size {self.kernel_block_size}')
461461
if self.quant_policy > 0 and self.device_type not in ['cuda', 'ascend']:
462462
assert False, \
463-
'kv cache quantization only works for CUDA and ASCEND.'
463+
'kv cache quantization only works for CUDA and ASCEND.'
464464
if self.device_type == 'camb' and self.block_size != 16:
465465
self.block_size = 16
466466
logger.warning('Currently, camb device requires block size to be 16, \

lmdeploy/metrics/loggers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ def log(self):
116116
f'{scheduler_stats.num_api_routed_reqs} / {scheduler_stats.num_api_waiting_reqs}, '
117117
f'Engine (running/waiting): '
118118
f'{scheduler_stats.num_running_reqs} / {scheduler_stats.num_waiting_reqs}, '
119-
f'KV cache: {scheduler_stats.gpu_cache_usage * 100 :.1f}%, ')
119+
f'KV cache: {scheduler_stats.gpu_cache_usage * 100:.1f}%, ')
120120

121121
if scheduler_stats.prefix_cache_hit_rate != 0:
122-
log_msg += f'Prefix cache hit rate: {scheduler_stats.prefix_cache_hit_rate * 100 :.1f}%, '
122+
log_msg += f'Prefix cache hit rate: {scheduler_stats.prefix_cache_hit_rate * 100:.1f}%, '
123123

124124
if spec_msg is not None:
125125
log_msg += spec_msg

0 commit comments

Comments
 (0)