modelscope / modelscope/DiffSynth-Studio

How to use torch.float8_e4m3fn and lora together?

Open
#527 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
13.1k
Forks
1.3k
Avg merge
13h 12m
Merged PRs (30d)
45

Description

Hi, I'm trying this Lora (https://huggingface.co/Remade-AI/Squish) with examples/wanvideo/wan_14b_image_to_video.py script and it works great with default dtype (bfloat16), codes like below

model_manager.load_models(
    [
        [
            "models/Wan-AI/Wan2.1-I2V-14B-480P/diffusion_pytorch_model-00001-of-00007.safetensors",
            "models/Wan-AI/Wan2.1-I2V-14B-480P/diffusion_pytorch_model-00002-of-00007.safetensors",
            "models/Wan-AI/Wan2.1-I2V-14B-480P/diffusion_pytorch_model-00003-of-00007.safetensors",
            "models/Wan-AI/Wan2.1-I2V-14B-480P/diffusion_pytorch_model-00004-of-00007.safetensors",
            "models/Wan-AI/Wan2.1-I2V-14B-480P/diffusion_pytorch_model-00005-of-00007.safetensors",
            "models/Wan-AI/Wan2.1-I2V-14B-480P/diffusion_pytorch_model-00006-of-00007.safetensors",
            "models/Wan-AI/Wan2.1-I2V-14B-480P/diffusion_pytorch_model-00007-of-00007.safetensors",
            
            
        ],
        "models/Wan-AI/Wan2.1-I2V-14B-480P/models_t5_umt5-xxl-enc-bf16.pth",
        "models/Wan-AI/Wan2.1-I2V-14B-480P/Wan2.1_VAE.pth",
    ],
    torch_dtype=torch.bfloat16 # You can set `torch_dtype=torch.float8_e4m3fn` to enable FP8 quantization.
)

However, if I just updated torch_dtype=torch.bfloat16 to torch_dtype=torch.float8_e4m3fn without touching any other codes, the lora effect is gone (but inference step can still finish without errors messages)

Kindly request some guidances here on how to use Quantization and Lora together here.

Thanks.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with examples/wanvideo/wan_14b_image_to_video.py and the model_manager.load_models call shown in the report. Reproduce the comparison between torch.bfloat16 and torch.float8_e4m3fn with the referenced LoRA, then trace how quantization and LoRA loading interact. Done means documenting or correcting the configuration so the LoRA effect remains observable under FP8.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.