Skip to content

Public embeddings.py helpers raise ValueError with default arguments #14366

Description

@4ktLuffy

Describe the bug

Four public helpers in src/diffusers/models/embeddings.py raise ValueError when called with their default arguments, on main (0.40.0.dev0).

All four default to output_type="np", and that branch calls deprecate(..., "0.33.0"/"0.34.0", ...). Since deprecate() raises once __version__ is at or past the target (utils/deprecation_utils.py), and the current version is 0.40, the default path raises before doing anything.

Reproduction

import numpy as np
from diffusers.models import embeddings as E

E.get_2d_sincos_pos_embed(embed_dim=8, grid_size=2)
E.get_2d_sincos_pos_embed_from_grid(8, np.zeros((2, 4)))
E.get_1d_sincos_pos_embed_from_grid(8, np.arange(4))
E.get_2d_rotary_pos_embed(8, (2, 2), (0, 0, 2, 2))

Each raises:

ValueError: The deprecation tuple ("output_type=='np'", '0.33.0', ...) should be removed
since diffusers' version 0.40.0.dev0 is >= 0.33.0

Expected behavior

Three things look off rather than one:

  1. The default value routes into the raising branch, so no-argument calls fail.
  2. The error text is an internal maintenance message addressed to maintainers, not to the caller.
  3. The intended guidance is never reached — deprecate() raises before it warns, so "Pass output_type='pt' to use the new version now." is never shown, and the return get_*_np(...) fallback immediately after each call is unreachable.

get_1d_sincos_pos_embed_from_grid documents the default explicitly: output_type ("str", *optional*, defaults to "np"). The other three accept output_type but do not document it at all.

Scope

Library internals are not affected. All eight in-tree call sites pass output_type="pt" (or a variable) explicitly — hunyuandit, pag_hunyuandit, controlnet_hunyuandit, transformer_omnigen, latte_transformer_3d, transformer_skyreels_v2, autoencoder_rae, deprecated/unidiffuser. This affects external callers using these public helpers directly.

Not tested: whether any downstream project relies on the "np" return path.

Related to #14365, which inventories 20 deprecate() call sites past their target version. Splitting this out per the discussion there — @Dev-X25874 is keeping that PR scoped to vq_model.py.

System Info

  • diffusers version: 0.40.0.dev0 (main, commit a8345366e)
  • Platform: macOS (Darwin 25.0.0), CPU only
  • Python version: 3.11
  • PyTorch version: 2.13.0

Who can help?

@hlky (git blame shows the deprecation blocks are yours, so you would know whether the "np" path was meant to be removed at 0.33/0.34) and @yiyixuxu

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmodels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions