Preserve revision pins in secondary artifact loaders (#51446)
Signed-off-by: Clinton Thomas <1033162+KernelClint@users.noreply.github.com> Co-authored-by: Lucas Bourtoule <35483370+dhalf@users.noreply.github.com>
This commit is contained in:
co-authored by
Lucas Bourtoule
parent
adc1200597
commit
90fd4a333f
@@ -890,7 +890,11 @@ class ModelConfig:
|
||||
convertor_cls = MODEL_ARCH_CONFIG_CONVERTORS.get(
|
||||
self.hf_config.model_type, ModelArchConfigConvertorBase
|
||||
)
|
||||
convertor = convertor_cls(self.hf_config, self.hf_text_config)
|
||||
convertor = convertor_cls(
|
||||
self.hf_config,
|
||||
self.hf_text_config,
|
||||
revision=getattr(self, "revision", None),
|
||||
)
|
||||
return convertor.convert(
|
||||
supports_multimodal=self._supports_multimodal_for_mm_prefix()
|
||||
)
|
||||
@@ -1651,6 +1655,7 @@ class ModelConfig:
|
||||
self.hf_config_path or self.model,
|
||||
trust_remote_code=self.trust_remote_code,
|
||||
revision=self.revision,
|
||||
code_revision=self.code_revision,
|
||||
config_format=self.config_format,
|
||||
hf_token=self.hf_token,
|
||||
)
|
||||
@@ -1658,6 +1663,7 @@ class ModelConfig:
|
||||
config = try_get_generation_config(
|
||||
self.generation_config,
|
||||
trust_remote_code=self.trust_remote_code,
|
||||
code_revision=self.code_revision,
|
||||
config_format=self.config_format,
|
||||
hf_token=self.hf_token,
|
||||
)
|
||||
|
||||
@@ -779,6 +779,7 @@ class VllmConfig:
|
||||
quant_config.maybe_update_config(
|
||||
model_config.model,
|
||||
hf_config=model_config.hf_config,
|
||||
revision=model_config.revision,
|
||||
)
|
||||
return quant_config
|
||||
return None
|
||||
|
||||
@@ -621,7 +621,9 @@ def is_vllm_tensorized(tensorizer_config: "TensorizerConfig") -> bool:
|
||||
|
||||
|
||||
def serialize_extra_artifacts(
|
||||
tensorizer_args: TensorizerArgs, served_model_name: str | list[str] | None
|
||||
tensorizer_args: TensorizerArgs,
|
||||
served_model_name: str | list[str] | None,
|
||||
revision: str | None = None,
|
||||
) -> None:
|
||||
if not isinstance(served_model_name, str):
|
||||
raise ValueError(
|
||||
@@ -632,6 +634,7 @@ def serialize_extra_artifacts(
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
hf_api().snapshot_download(
|
||||
served_model_name,
|
||||
revision=revision,
|
||||
local_dir=tmpdir,
|
||||
ignore_patterns=[
|
||||
"*.pt",
|
||||
@@ -693,7 +696,11 @@ def serialize_vllm_model(
|
||||
serializer.write_module(model)
|
||||
serializer.close()
|
||||
|
||||
serialize_extra_artifacts(tensorizer_args, model_config.served_model_name)
|
||||
serialize_extra_artifacts(
|
||||
tensorizer_args,
|
||||
model_config.served_model_name,
|
||||
revision=model_config.revision,
|
||||
)
|
||||
|
||||
logger.info("Successfully serialized model to %s", str(output_file))
|
||||
return model
|
||||
|
||||
@@ -519,12 +519,17 @@ class FunAudioChatProcessingInfo(BaseProcessingInfo):
|
||||
|
||||
@cached_property
|
||||
def feature_extractor(self) -> WhisperFeatureExtractor:
|
||||
return WhisperFeatureExtractor.from_pretrained(self.model_id)
|
||||
return WhisperFeatureExtractor.from_pretrained(
|
||||
self.model_id,
|
||||
revision=self.ctx.model_config.revision,
|
||||
)
|
||||
|
||||
@cached_property
|
||||
def speech_tokenizer(self) -> TokenizersBackend:
|
||||
return TokenizersBackend.from_pretrained(
|
||||
self.model_id, subfolder="speech_tokenizer"
|
||||
self.model_id,
|
||||
subfolder="speech_tokenizer",
|
||||
revision=self.ctx.model_config.tokenizer_revision,
|
||||
)
|
||||
|
||||
def get_feature_extractor(self) -> WhisperFeatureExtractor:
|
||||
|
||||
+13
-2
@@ -210,7 +210,7 @@ def _build_mixed_prompt_embeds(
|
||||
return full_embeds, is_token_ids.tolist()
|
||||
|
||||
|
||||
_PROCESSOR_CHAT_TEMPLATES = dict[tuple[str, bool], str | None]()
|
||||
_PROCESSOR_CHAT_TEMPLATES = dict[tuple[str, str | None, str | None, bool], str | None]()
|
||||
"""
|
||||
Used in `_try_get_processor_chat_template` to avoid calling
|
||||
`cached_get_processor` again if the processor fails to be loaded.
|
||||
@@ -222,9 +222,16 @@ This is needed because `lru_cache` does not cache when an exception happens.
|
||||
def _try_get_processor_chat_template(
|
||||
tokenizer: HfTokenizer,
|
||||
*,
|
||||
revision: str | None,
|
||||
code_revision: str | None,
|
||||
trust_remote_code: bool,
|
||||
) -> str | None:
|
||||
cache_key = (tokenizer.name_or_path, trust_remote_code)
|
||||
cache_key = (
|
||||
tokenizer.name_or_path,
|
||||
revision,
|
||||
code_revision,
|
||||
trust_remote_code,
|
||||
)
|
||||
if cache_key in _PROCESSOR_CHAT_TEMPLATES:
|
||||
return _PROCESSOR_CHAT_TEMPLATES[cache_key]
|
||||
|
||||
@@ -234,6 +241,8 @@ def _try_get_processor_chat_template(
|
||||
processor = cached_get_processor(
|
||||
tokenizer.name_or_path,
|
||||
processor_cls=(PythonBackend, TokenizersBackend, ProcessorMixin),
|
||||
revision=revision,
|
||||
code_revision=code_revision,
|
||||
trust_remote_code=trust_remote_code,
|
||||
)
|
||||
if (
|
||||
@@ -271,6 +280,8 @@ def resolve_chat_template(
|
||||
if tools is None:
|
||||
chat_template = _try_get_processor_chat_template(
|
||||
tokenizer,
|
||||
revision=model_config.revision,
|
||||
code_revision=model_config.code_revision,
|
||||
trust_remote_code=model_config.trust_remote_code,
|
||||
)
|
||||
if chat_template is not None:
|
||||
|
||||
@@ -1071,6 +1071,7 @@ def try_get_generation_config(
|
||||
model: str,
|
||||
trust_remote_code: bool,
|
||||
revision: str | None = None,
|
||||
code_revision: str | None = None,
|
||||
config_format: str | ConfigFormat = "auto",
|
||||
hf_token: bool | str | None = None,
|
||||
) -> GenerationConfig | None:
|
||||
@@ -1086,6 +1087,7 @@ def try_get_generation_config(
|
||||
model,
|
||||
trust_remote_code=trust_remote_code,
|
||||
revision=revision,
|
||||
code_revision=code_revision,
|
||||
config_format=config_format,
|
||||
token=hf_token,
|
||||
)
|
||||
|
||||
@@ -24,9 +24,15 @@ logger = init_logger(__name__)
|
||||
|
||||
|
||||
class ModelArchConfigConvertorBase:
|
||||
def __init__(self, hf_config: PretrainedConfig, hf_text_config: PretrainedConfig):
|
||||
def __init__(
|
||||
self,
|
||||
hf_config: PretrainedConfig,
|
||||
hf_text_config: PretrainedConfig,
|
||||
revision: str | None = None,
|
||||
):
|
||||
self.hf_config = hf_config
|
||||
self.hf_text_config = hf_text_config
|
||||
self.revision = revision
|
||||
|
||||
def get_per_layer_hf_configs(
|
||||
self,
|
||||
@@ -122,7 +128,7 @@ class ModelArchConfigConvertorBase:
|
||||
model_path = self.hf_config.name_or_path
|
||||
if not model_path:
|
||||
return qk_rope_head_dim
|
||||
raw = get_hf_file_to_dict("config.json", model_path)
|
||||
raw = get_hf_file_to_dict("config.json", model_path, self.revision)
|
||||
if raw and "qk_rope_head_dim" in raw:
|
||||
correct = raw["qk_rope_head_dim"]
|
||||
if correct != qk_rope_head_dim:
|
||||
@@ -595,16 +601,26 @@ def _strip_mimo_v2_attention_chunk_size(
|
||||
|
||||
|
||||
class MimoV2ModelArchConfigConvertor(ModelArchConfigConvertorBase):
|
||||
def __init__(self, hf_config: PretrainedConfig, hf_text_config: PretrainedConfig):
|
||||
def __init__(
|
||||
self,
|
||||
hf_config: PretrainedConfig,
|
||||
hf_text_config: PretrainedConfig,
|
||||
revision: str | None = None,
|
||||
):
|
||||
if getattr(hf_config, "vision_config", None):
|
||||
hf_config.architectures = ["MiMoV2OmniForCausalLM"]
|
||||
super().__init__(hf_config, hf_text_config)
|
||||
super().__init__(hf_config, hf_text_config, revision)
|
||||
_strip_mimo_v2_attention_chunk_size(hf_config, hf_text_config)
|
||||
|
||||
|
||||
class MimoV2MTPModelArchConfigConvertor(ModelArchConfigConvertorBase):
|
||||
def __init__(self, hf_config: PretrainedConfig, hf_text_config: PretrainedConfig):
|
||||
super().__init__(hf_config, hf_text_config)
|
||||
def __init__(
|
||||
self,
|
||||
hf_config: PretrainedConfig,
|
||||
hf_text_config: PretrainedConfig,
|
||||
revision: str | None = None,
|
||||
):
|
||||
super().__init__(hf_config, hf_text_config, revision)
|
||||
_strip_mimo_v2_attention_chunk_size(hf_config, hf_text_config)
|
||||
|
||||
def get_num_hidden_layers(self) -> int:
|
||||
|
||||
Reference in New Issue
Block a user