huggingface / huggingface/diffusers

Public `embeddings.py` helpers raise `ValueError` with default arguments

Aperta
#14,366 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub
bug models
Lingua principale
Python
Stelle
34.5k
Fork
7.3k
Merge medio
3g 3h
PR unite (30g)
91

Descrizione

### 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

```python
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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start in src/diffusers/models/embeddings.py by reading the four public helpers and their output_type deprecation blocks, then inspect deprecate() in utils/deprecation_utils.py. Check the listed in-tree callers and existing embedding tests, if present. Done means default calls no longer raise unexpectedly, the intended public behavior is explicit, and regression coverage verifies the affected helpers.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
numpy, python, pytorch
Ambito
backend, machine-learning
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Tranquilla
Chiarezza
Specificata chiaramente
Idoneità per principianti
72/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.