fix: adjust ruff lints and small refactors

This commit is contained in:
drbh 2025-01-07 22:25:38 +00:00
parent d397748ca8
commit 78004db1e6
3 changed files with 3 additions and 4 deletions

View File

@ -660,7 +660,7 @@ class FlashLlamaForCausalLM(torch.nn.Module):
if embedding_multiplier is not None: if embedding_multiplier is not None:
self.embed_tokens.weight.data *= embedding_multiplier self.embed_tokens.weight.data *= embedding_multiplier
prefix = "lm_head" if not prefix or name != "model" else f"{prefix}.lm_head" prefix = "lm_head" if not prefix or name != "model" else f"{prefix}.{suffix}"
with no_fp8(weights): with no_fp8(weights):
self.lm_head = SpeculativeHead.load( self.lm_head = SpeculativeHead.load(

View File

@ -19,7 +19,6 @@ from typing import List, Optional, Tuple
import torch import torch
import torch.utils.checkpoint import torch.utils.checkpoint
from torch import nn from torch import nn
import math
from transformers.activations import ACT2FN from transformers.activations import ACT2FN
from text_generation_server.models.custom_modeling.vlm import ( from text_generation_server.models.custom_modeling.vlm import (

View File

@ -30,7 +30,7 @@ IDEFICS3_GLOBAL_IMG_TOKEN = "<global-img>"
# copied from: https://github.com/huggingface/transformers/blob/02ed609285c2448b3b54c31e362f2c389fa952ab/src/transformers/models/idefics3/processing_idefics3.py#L44-L60 # copied from: https://github.com/huggingface/transformers/blob/02ed609285c2448b3b54c31e362f2c389fa952ab/src/transformers/models/idefics3/processing_idefics3.py#L44-L60
def get_image_prompt_string( def _prompt_split_image(
*, *,
image_seq_len: int, image_seq_len: int,
image_rows: int, image_rows: int,
@ -97,7 +97,7 @@ def image_text_replacement(processor, image_input, config, image_id: int) -> str
((config.vision_config.image_size // config.vision_config.patch_size) ** 2) ((config.vision_config.image_size // config.vision_config.patch_size) ** 2)
/ (config.scale_factor**2) / (config.scale_factor**2)
) )
image_str = get_image_prompt_string( image_str = _prompt_split_image(
image_seq_len=image_seq_len, image_seq_len=image_seq_len,
image_rows=n_rows, image_rows=n_rows,
image_cols=n_cols, image_cols=n_cols,