Skip to content
This repository was archived by the owner on Mar 21, 2026. It is now read-only.
This repository was archived by the owner on Mar 21, 2026. It is now read-only.

Converting a SD 3.5 model from PyTorch to Core ML causes ValueError #51

@justoneplanet

Description

@justoneplanet

Thank you for developing the useful tools! Let me report an issue. I have executed the following command as the README.md document.

python -m python.src.diffusionkit.tests.torch2coreml.test_mmdit --sd3-ckpt-path stabilityai/stable-diffusion-3.5-medium --model-version 2b -o ./tmp --latent-size 64

And then, the following error was unexpectedly caused.

INFO:__main__:Initializing SD3 model
INFO:__main__:Initialized.
INFO:__main__:Loading SD3 model checkpoint from ~/.cache/huggingface/hub/models--stabilityai--stable-diffusion-3.5-medium/snapshots/b940f670f0eda2d07fbb75229e779da1ad11eb80/sd3.5_medium.safetensors
INFO:diffusionkit.torch.model_io:Loading state_dict into nn.Module with  635 parameter tensors totaling 2084877376 parameters from ~/.cache/huggingface/hub/models--stabilityai--stable-diffusion-3.5-medium/snapshots/b940f670f0eda2d07fbb75229e779da1ad11eb80/sd3.5_medium.safetensors
INFO:diffusionkit.torch.model_io:Loaded state dict with 783 tensors totaling 2408206912 parameters
E
======================================================================
ERROR: setUpClass (__main__.TestSD3MMDiT)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "~/path-to/DiffusionKit/python/src/diffusionkit/tests/torch2coreml/test_mmdit.py", line 82, in setUpClass
    _load_mmdit_weights(cls.test_torch_model, TEST_SD3_CKPT_PATH)
  File "~/.pyenv/versions/3.10.11/lib/python3.10/site-packages/diffusionkit/torch/model_io.py", line 85, in _load_mmdit_weights
    raise ValueError(
ValueError: Total number of parameters in state_dict (2469663936) does not match the number of parameters in the module (2084877376)

----------------------------------------------------------------------
Ran 0 tests in 7.204s

FAILED (errors=1)

I don't think the torch/mmdit implementation is compatible with the SD 3.5. Did I execute a wrong command, or is there any solution for this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions