Skip to content

LTX-2 loading fails on Hugging Face config metadata keys #30

Description

@andyelka-creator

Summary

Running LTX-2 image-to-video from the current main can fail after downloading model weights because LTXModel.from_pretrained() constructs LTXModelConfig directly from config.json.

Recent Hugging Face/Diffusers-style configs may include metadata keys such as _class_name and _diffusers_version. Those keys are not dataclass fields on LTXModelConfig, so loading aborts before generation starts.

Reproduction

Run LTX-2 with the default model repo after weights are available/downloaded:

mlx_video.ltx_2.generate \
  --prompt "Animate the image" \
  --pipeline distilled \
  --height 512 \
  --width 512 \
  --num-frames 97 \
  --image horse1.png \
  --output-path output.mp4

Actual Result

After the model snapshot is fetched and the text encoder loads, model loading fails:

Text encoder loaded successfully
✓ Text encoder loaded
TypeError: LTXModelConfig.__init__() got an unexpected keyword argument '_class_name'

Expected Result

from_pretrained() should ignore metadata keys that are not part of LTXModelConfig, matching the existing BaseModelConfig.from_dict() behavior.

Proposed Fix

Change LTXModel.from_pretrained() to build config with:

config = LTXModelConfig.from_dict(config_dict)

instead of:

config = LTXModelConfig(**config_dict)

This preserves known fields and filters unknown metadata keys.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions