Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
698 changes: 698 additions & 0 deletions examples/timesfm3_forecasting.py

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions src/mobius/_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@
SmallThinkerGGUFCausalLMModel,
SmolLM3CausalLMModel,
SortformerDiarizationModel,
TimesFM3Config,
TimesFM3Model,
WhisperForConditionalGeneration,
XverseCausalLMModel,
)
Expand Down Expand Up @@ -1068,6 +1070,13 @@ def _detect_fallback_registration(hf_config) -> ModelRegistration | None:
),
"fastconformer_rnnt": ModelRegistration(EncDecRNNTModel, task="fastconformer-rnnt"),
"sortformer": ModelRegistration(SortformerDiarizationModel, task="diarization"),
"timesfm3": ModelRegistration(
TimesFM3Model,
task="time-series-forecasting",
config_class=TimesFM3Config,
family="timesfm",
variant="3.0",
),
"reuse": ModelRegistration(
SEMambaSpeechEnhancementModel,
task="speech-enhancement",
Expand Down
2 changes: 1 addition & 1 deletion src/mobius/integrations/transformers/_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ def build_transformers_model(
model.metadata_props["mobius.source_revision"] = revision or "unpinned"

if load_weights:
if config.block_quant_scheme is not None and hasattr(
if getattr(config, "block_quant_scheme", None) is not None and hasattr(
model_module, "build_fp8_streaming_plan"
):
if len(package) != 1:
Expand Down
25 changes: 23 additions & 2 deletions src/mobius/integrations/transformers/_config_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,14 @@ def _try_load_config_json(model_id: str, revision: str | None = None):

model_type = config_dict.get("model_type")
if not model_type:
model_type = _model_type_from_architectures(config_dict.get("architectures"))
model_type = _model_type_from_architectures(
config_dict.get("architectures")
) or _model_type_from_config_signature(config_dict)
if not model_type:
return None
logger.info(
"config.json for %s declares no model_type; inferred '%s' from architectures=%s",
"config.json for %s declares no model_type; inferred '%s' "
"from architectures=%s or its config schema",
model_id,
model_type,
config_dict.get("architectures"),
Expand All @@ -136,6 +139,24 @@ def _try_load_config_json(model_id: str, revision: str | None = None):
return _dict_to_pretrained_config(config_dict)


def _model_type_from_config_signature(config: dict) -> str | None:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems overly complicated. We can just read the google/timesfm-3.0-pytorch model name.

"""Identify non-Transformers checkpoints with an unambiguous config schema."""
transformer = config.get("transformer_config")
residual = config.get("residual_block_config")
if (
config.get("input_patch_len") is not None
and config.get("output_patch_len") is not None
and config.get("quantiles") is not None
and config.get("use_iterative_cpm_revin") is not None
and config.get("use_variate_attention") is not None
and isinstance(transformer, dict)
and isinstance(transformer.get("transformer"), dict)
and isinstance(residual, dict)
):
return "timesfm3"
return None


def _model_type_from_architectures(architectures) -> str | None:
"""Recover a HuggingFace ``model_type`` from a config's ``architectures``.

Expand Down
3 changes: 3 additions & 0 deletions src/mobius/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@
"SEMambaSpeechEnhancementModel",
"SortformerConfig",
"SortformerDiarizationModel",
"TimesFM3Config",
"TimesFM3Model",
"Qwen3TTSCodePredictorModel",
"Qwen3TTSCodecDecoderModel",
"Qwen3TTSCodecEncoderModel",
Expand Down Expand Up @@ -442,6 +444,7 @@
from mobius.models.starcoder2 import StarCoder2CausalLMModel
from mobius.models.t5 import T5EncoderModel, T5ForConditionalGeneration
from mobius.models.talkie import TalkieForCausalLM
from mobius.models.timesfm3 import TimesFM3Config, TimesFM3Model
from mobius.models.unet import (
UNet2DConditionModel,
load_unet_lora_safetensors,
Expand Down
Loading
Loading