[ci] pin ruff version and fix lint errors (#10681)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Yaowei Zheng
2026-07-24 16:29:58 +08:00
committed by GitHub
parent 3f77101580
commit 2ebe7be611
10 changed files with 30 additions and 21 deletions

View File

@@ -198,12 +198,16 @@ def _setup_lora_tuning(
pass # already loaded via load_unsloth_peft_model in loader.py
else:
if model_args.use_unsloth:
peft_model = load_unsloth_peft_model(config, model_args, finetuning_args, is_trainable=is_trainable)
peft_model = load_unsloth_peft_model(
config, model_args, finetuning_args, is_trainable=is_trainable
)
if peft_model is not None:
model = peft_model
if not model_args.use_unsloth: # unsloth was disabled or fell back
model = PeftModel.from_pretrained(model, adapter_to_resume, is_trainable=is_trainable, **init_kwargs)
model = PeftModel.from_pretrained(
model, adapter_to_resume, is_trainable=is_trainable, **init_kwargs
)
logger.info_rank0("Loaded adapter(s): {}".format(",".join(model_args.adapter_name_or_path)))

View File

@@ -120,9 +120,7 @@ def _noisy_mean_initialization(
avg_weight = _existing_embeddings(embed_weight, num_new_tokens, token_ids).mean(dim=0, keepdim=True)
if token_ids:
noise_weight = torch.empty(
len(token_ids), embedding_dim, device=embed_weight.device, dtype=embed_weight.dtype
)
noise_weight = torch.empty(len(token_ids), embedding_dim, device=embed_weight.device, dtype=embed_weight.dtype)
noise_weight.normal_(mean=0, std=(1.0 / math.sqrt(embedding_dim)))
embed_weight[token_ids] = avg_weight + noise_weight
else:
@@ -202,8 +200,7 @@ def _description_based_initialization(
if len(valid_token_ids) == 0:
# Fallback: use mean of all existing embeddings
logger.warning_rank0(
f"Description for token '{token_str}' contains no valid tokens. "
"Using mean of existing embeddings."
f"Description for token '{token_str}' contains no valid tokens. Using mean of existing embeddings."
)
base_embedding = fallback_embedding
else: