huggingface / huggingface/diffusers

Error in loading flux fp8 model with local transformer_flux.py file

オープン
#9,667 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
bug stale
主要言語
Python
スター
34.5k
フォーク
7.3k
平均マージ
3日 3時間
マージ済み PR(30日)
91

説明

### Describe the bug

Unable to use flux fp8 model from `Kijai/flux-fp8` while having transformer_flux.py file in local. I have modified the scripts to remove any import error. I put some print statements in single_model_file.py to check why it is not loading the model.

### Reproduction

The below code works fine.

single_model_file.py
```
def _get_single_file_loadable_mapping_class(cls):
print(cls)
diffusers_module = importlib.import_module(__name__.split(".")[0])

for loadable_class_str in SINGLE_FILE_LOADABLE_CLASSES:
loadable_class = getattr(diffusers_module, loadable_class_str)
print(cls, loadable_class)
print(issubclass(cls, loadable_class))
if issubclass(cls, loadable_class):
return loadable_class_str

return None
```

```
from diffusers import FluxTransformer2DModel
transformer = FluxTransformer2DModel.from_single_file(
"https://huggingface.co/Kijai/flux-fp8/blob/main/flux1-schnell-fp8-e4m3fn.safetensors",
torch_dtype=torch.bfloat16
)
```

I am getting the below output:

```


False

False

False

False

False

False

False

True
```

But while using the class from my local code:

```
from transformer_flux import FluxTransformer2DModel
FluxTransformer2DModel.__module__ = 'diffusers.models.transformers.transformer_flux'
transformer = FluxTransformer2DModel.from_single_file(
"https://huggingface.co/Kijai/flux-fp8/blob/main/flux1-schnell-fp8-e4m3fn.safetensors",
torch_dtype=torch.bfloat16
)
```

It is giving me following error:

```


False

False

False

False

False

False

False

False

Traceback (most recent call last):
File "/workspace/GarmentTransferV2/test.py", line 441, in
main(args)
File "/workspace/GarmentTransferV2/test.py", line 368, in main
transformer_garment = FluxTransformerGarment2DModel.from_single_file(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/garment/lib/python3.11/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/workspace/garment/lib/python3.11/site-packages/diffusers/loaders/single_file_model.py", line 182, in from_single_file
raise ValueError(
ValueError: FromOriginalModelMixin is currently only compatible with StableCascadeUNet, UNet2DConditionModel, AutoencoderKL, ControlNetModel, SD3Transformer2DModel, MotionAdapter, SparseControlNetModel, FluxTransformer2DModel
```

Any leads would be appreciated.

### Logs

_No response_

### System Info

- 🤗 Diffusers version: 0.30.3
- Platform: Linux-6.8.0-40-generic-x86_64-with-glibc2.35
- Running on Google Colab?: No
- Python version: 3.11.9
- PyTorch version (GPU?): 2.4.1+cu121 (True)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Huggingface_hub version: 0.25.2
- Transformers version: 4.45.2
- Accelerate version: 1.0.1
- PEFT version: not installed
- Bitsandbytes version: not installed
- Safetensors version: 0.4.5
- xFormers version: not installed
- Accelerator: NVIDIA H100 80GB HBM3, 81559 MiB
- Using GPU in script?:

### Who can help?

@DN6 @sayakpaul

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

diffusers/loaders/single_file_model.py と、single_model_file.py に示されている _get_single_file_loadable_mapping_class のロジックから始めてください。Diffusers 0.30.3 で両方の import を再現し、from_single_file で使用されるクラスの同一性を比較してください。transformer_flux.py のローカルクラスが loader によって正しく認識され、この import path をカバーする regression test があることを完了条件とします。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python, pytorch
領域
machine-learning
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。