Skip to content

Commit de9427a

Browse files
committed
Fix MLX cache lint
1 parent 1bfe78c commit de9427a

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

backends/mlx/llm/cache.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,13 @@ def resolve_hf_cache_layout(config):
4343

4444
if layer_types is None:
4545
if getattr(text_config, "sliding_window", None) is not None:
46-
layer_types = ["sliding_attention" for _ in range(text_config.num_hidden_layers)]
46+
layer_types = [
47+
"sliding_attention" for _ in range(text_config.num_hidden_layers)
48+
]
4749
else:
48-
layer_types = ["full_attention" for _ in range(text_config.num_hidden_layers)]
50+
layer_types = [
51+
"full_attention" for _ in range(text_config.num_hidden_layers)
52+
]
4953
else:
5054
layer_types = list(layer_types)
5155

@@ -54,13 +58,20 @@ def resolve_hf_cache_layout(config):
5458

5559
if hasattr(text_config, "global_head_dim"):
5660
head_dims = [
57-
text_config.global_head_dim if layer_type == "full_attention" else text_config.head_dim
61+
(
62+
text_config.global_head_dim
63+
if layer_type == "full_attention"
64+
else text_config.head_dim
65+
)
5866
for layer_type in layer_types
5967
]
6068
num_heads = [
61-
text_config.num_global_key_value_heads
62-
if layer_type == "full_attention" and getattr(text_config, "attention_k_eq_v", False)
63-
else text_config.num_key_value_heads
69+
(
70+
text_config.num_global_key_value_heads
71+
if layer_type == "full_attention"
72+
and getattr(text_config, "attention_k_eq_v", False)
73+
else text_config.num_key_value_heads
74+
)
6475
for layer_type in layer_types
6576
]
6677
else:

0 commit comments

Comments
 (0)