Skip to content

Commit 6c96ed9

Browse files
committed
format code
1 parent e741f25 commit 6c96ed9

9 files changed

Lines changed: 16 additions & 18 deletions

File tree

lmdeploy/pytorch/backends/dlinfer/apply_rotary_emb.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Copyright (c) OpenMMLab. All rights reserved.
22
from torch import Tensor
33

4-
from lmdeploy.pytorch.kernels.dlinfer import (apply_rotary_pos_emb,
5-
apply_rotary_pos_emb_interleaved)
4+
from lmdeploy.pytorch.kernels.dlinfer import apply_rotary_pos_emb, apply_rotary_pos_emb_interleaved
65

76
from ..apply_rotary_emb import ApplyRotaryEmbBuilder, ApplyRotaryEmbImpl
87

lmdeploy/pytorch/backends/dlinfer/ascend/op_backend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def update_step_context(cls, step_context):
223223
cu_seqlens_q_cpu, kv_seqlens_cpu = None, None
224224
else:
225225
cu_seqlens_q_cpu, kv_seqlens_cpu = _get_cpu_attention_metadata(cu_seqlens_q, kv_seqlens)
226-
226+
227227
if not step_context.is_decoding:
228228
is_prefill_no_cache = (
229229
False if is_sparse_attention else torch.equal(

lmdeploy/pytorch/backends/dlinfer/nsa.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ def _forward_index(
9090
) -> Tensor:
9191
if meta.kv_start_indices is None:
9292
raise RuntimeError(
93-
"Ascend NSA metadata is missing kv_start_indices")
93+
'Ascend NSA metadata is missing kv_start_indices')
9494
if meta.cu_seqlen_q is None:
95-
raise RuntimeError("Ascend NSA metadata is missing cu_seqlen_q")
95+
raise RuntimeError('Ascend NSA metadata is missing cu_seqlen_q')
9696

9797
k = k.unsqueeze(-2)
9898
fill_kv_cache(
@@ -120,8 +120,8 @@ def _forward_index(
120120
)
121121
if indices.dim() != 3 or indices.size(1) != 1:
122122
raise RuntimeError(
123-
"Ascend Lightning Indexer returned an unexpected shape: "
124-
f"{tuple(indices.shape)}")
123+
'Ascend Lightning Indexer returned an unexpected shape: '
124+
f'{tuple(indices.shape)}')
125125
return indices.squeeze(1)
126126

127127
def forward(

lmdeploy/pytorch/configurations/glm_moe_dsa.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ def condition(cls, hf_config):
1919
def build(cls, hf_config, model_path: str | None = None, **kwargs):
2020
"""build."""
2121
is_draft_model = kwargs.get('is_draft_model', False)
22-
2322
quantization_config = getattr(hf_config, 'quantization_config', None)
2423
is_lmdeploy_patched_fp8 = (quantization_config is not None
2524
and quantization_config.get('quant_method') == 'fp8'

lmdeploy/pytorch/kernels/dlinfer/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
# Copyright (c) OpenMMLab. All rights reserved.
22
from ..default import multinomial_sampling, per_channel_quant
3-
from .apply_rotary_pos_emb import (apply_rotary_pos_emb,
4-
apply_rotary_pos_emb_interleaved)
3+
from .apply_rotary_pos_emb import apply_rotary_pos_emb, apply_rotary_pos_emb_interleaved
54
from .awq_kernels import awq_linear
65
from .fill_kv_cache import fill_kv_cache
76
from .flash_attention import flash_attention_fwd
87
from .fused_moe import DlinferMoECommType, DlinferMoeMetadata, fused_moe, fused_moe_w8a8
9-
from .linear import linear
108
from .lightning_indexer import lightning_indexer
9+
from .linear import linear
1110
from .moe_gating_topk_softmax import moe_gating_topk_softmax
1211
from .pagedattention import paged_attention_fwd
1312
from .rms_norm import rms_norm

lmdeploy/pytorch/kernels/dlinfer/flash_attention.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def flash_attention_fwd(
2121
logit_softcapping: float = None,
2222
causal: bool = True,
2323
):
24-
actual_seq_lengths_cpu = (q_start_loc + q_seqlens).cpu()
24+
actual_seq_lengths_cpu = (q_start_loc + q_seqlens).cpu()
2525
return ext_ops.prefill_attention(
2626
query_states,
2727
key_states,

lmdeploy/pytorch/kernels/dlinfer/sparse_attention.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Copyright (c) OpenMMLab. All rights reserved.
22
import dlinfer.ops as ext_ops
3-
import torch
43
from torch import Tensor
54

65

@@ -19,13 +18,13 @@ def sparse_attention_fwd(
1918
"""Run Ascend sparse MLA attention over split noPE and RoPE caches."""
2019
if query.size(-1) <= value_head_size:
2120
raise ValueError(
22-
"sparse MLA query must contain both latent and RoPE dimensions")
21+
'sparse MLA query must contain both latent and RoPE dimensions')
2322
if sparse_indices.dim() == 2:
2423
sparse_indices = sparse_indices.unsqueeze(1)
2524
if sparse_indices.dim() != 3 or sparse_indices.size(1) != 1:
2625
raise ValueError(
27-
f"sparse indices must have shape [tokens, 1, topk], got "
28-
f"{tuple(sparse_indices.shape)}")
26+
f'sparse indices must have shape [tokens, 1, topk], got '
27+
f'{tuple(sparse_indices.shape)}')
2928

3029
q_nope = query[..., :value_head_size].contiguous()
3130
q_rope = query[..., value_head_size:].contiguous()

lmdeploy/pytorch/models/deepseek_v2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,8 @@ def get_input_embeddings(self):
11961196
return self.model.get_input_embeddings()
11971197

11981198
def _map_modelslim_param_name(self, name: str, params_dict: dict[str, nn.Parameter]) -> str | None:
1199-
"""Map ModelSlim checkpoint auxiliary tensors to lmdeploy parameters."""
1199+
"""Map ModelSlim checkpoint auxiliary tensors to lmdeploy
1200+
parameters."""
12001201
quantization_config = self.quantization_config or {}
12011202
if quantization_config.get('quant_method') != 'modelslim':
12021203
return name

lmdeploy/pytorch/nn/linear/w8a8.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ def __init__(self,
172172
'input_scale', torch.nn.Parameter(torch.empty((1, ), dtype=self.dtype, device=device),
173173
requires_grad=False))
174174
self.register_parameter(
175-
'input_offset', torch.nn.Parameter(torch.empty((1, ), dtype=torch.int8, device=device), requires_grad=False))
175+
'input_offset',
176+
torch.nn.Parameter(torch.empty((1, ), dtype=torch.int8, device=device), requires_grad=False))
176177
self.register_parameter(
177178
'deq_scale', torch.nn.Parameter(torch.empty((out_features, ), dtype=torch.float32, device=device),
178179
requires_grad=False))

0 commit comments

Comments
 (0)