Skip to content

Support Wan2.2 S2V Quantization#1924

Merged
XuehaoSun merged 9 commits into
mainfrom
changwangss-patch-1
Jun 18, 2026
Merged

Support Wan2.2 S2V Quantization#1924
XuehaoSun merged 9 commits into
mainfrom
changwangss-patch-1

Conversation

@changwangss

@changwangss changwangss commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Description

  1. Fixed tokenizer save crash in export paths
  • Issue: exporter called tokenizer.save_pretrained(...) even when tokenizer was a string placeholder ("Placeholder"), causing: AttributeError: 'str' object has no attribute 'save_pretrained'
  • Fix: added guard in FP8/NVFP exporters to save only when tokenizer has save_pretrained; otherwise skip with a log message.
  1. Fixed model path access in is_mllm_model
  • Issue: code assumed every model object had name_or_path, but WanModel_S2V does not, causing:
  • AttributeError: 'WanModel_S2V' object has no attribute 'name_or_path'
  • Fix: added safe fallback chain (_name_or_path → name_or_path → fallback key) and robust cache-key handling.
  File "/usr/local/lib/python3.12/dist-packages/neural_compressor/torch/algorithms/autoround/autoround.py", line 216, in convert
    rounder = AutoRound(
              ^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/auto_round/autoround.py", line 165, in __new__
    return AutoRoundCompatible(**local_args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/auto_round/compressors/entry.py", line 586, in __new__
    if is_mllm_model(model, platform=platform):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/auto_round/utils/model.py", line 954, in is_mllm_model
    model_path = model_or_path if isinstance(model_or_path, str) else model_or_path.name_or_path
                                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/diffusers/models/modeling_utils.py", line 274, in __getattr__
    return super().__getattr__(name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/torch/nn/modules/module.py", line 1965, in __getattr__
    raise AttributeError(
AttributeError: 'WanModel_S2V' object has no attribute 'name_or_path'

Wan2.2 S2V tokenizer is not from transformers tokenizer, INC pass 'Placeholder' for tokenizer,

  File "/mnt/disk1/wangchang/sd/neural-compressor/examples/pytorch/diffusion_model/diffusers/wan/auto-round/auto_round
/compressors/base.py", line 1580, in quantize_and_save
    model, folders = self.save_quantized(output_dir, inplace=inplace, return_folders=True, **kwargs)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/disk1/wangchang/sd/neural-compressor/examples/pytorch/diffusion_model/diffusers/wan/auto-round/auto_round
/compressors/mllm_mixin.py", line 122, in save_quantized
    compressed_model = super().save_quantized(
                       ^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/disk1/wangchang/sd/neural-compressor/examples/pytorch/diffusion_model/diffusers/wan/auto-round/auto_round
/compressors/base.py", line 1428, in save_quantized
    compressed_model = format.save_quantized(
                       ^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/disk1/wangchang/sd/neural-compressor/examples/pytorch/diffusion_model/diffusers/wan/auto-round/auto_round
/formats.py", line 1262, in save_quantized
    return self.backend.save_quantized(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/disk1/wangchang/sd/neural-compressor/examples/pytorch/diffusion_model/diffusers/wan/auto-round/auto_round
/formats.py", line 1293, in save_quantized
    return export_func(
           ^^^^^^^^^^^^
  File "/mnt/disk1/wangchang/sd/neural-compressor/examples/pytorch/diffusion_model/diffusers/wan/auto-round/auto_round
/export/export_to_autoround/export_to_fp8.py", line 284, in save_quantized_as_autoround
    tokenizer.save_pretrained(output_dir)
    ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'save_pretrained'

@changwangss changwangss requested review from n1ck-guo and yiliu30 June 15, 2026 12:14
@chensuyue

Copy link
Copy Markdown
Contributor

/azp run Unit-Test-CUDA-AutoRound

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: changwangss <chang1.wang@intel.com>
@changwangss changwangss changed the title Get correct model path for Wan2.2 S2V Support Wan2.2 S2V Quantization Jun 15, 2026
changwangss and others added 2 commits June 15, 2026 16:35
Signed-off-by: changwangss <chang1.wang@intel.com>
@chensuyue

Copy link
Copy Markdown
Contributor

/azp run Unit-Test-CUDA-AutoRound

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Comment thread auto_round/utils/model.py Outdated
@n1ck-guo

Copy link
Copy Markdown
Contributor

LGTM

@chensuyue chensuyue added this to the 0.14.0 milestone Jun 16, 2026

@yiliu30 yiliu30 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with heng's comments; others lgtm.

Signed-off-by: changwangss <chang1.wang@intel.com>
Signed-off-by: changwangss <chang1.wang@intel.com>
@changwangss

Copy link
Copy Markdown
Contributor Author

Good point, thanks. I’ve extracted the path resolution into get_model_name_or_path and updated is_mllm_model to use it consistently. This makes the code cleaner and avoids duplicated fallback logic. @n1ck-guo @yiliu30

@changwangss

Copy link
Copy Markdown
Contributor Author

CI update: Unit-Test-AutoRound parts 3/4/5 failed during Env Setup (tests did not start).

part3: exited with code 137 (likely runner resource/OOM kill)
part5: exited with code 137 (likely runner resource/OOM kill)
part4: exited with code 1 during setup
Given failures happened before UT execution and two jobs show 137, this looks infrastructure/setup-related rather than a code regression in this PR.
Could we please rerun these jobs? @XuehaoSun @chensuyue

@changwangss

Copy link
Copy Markdown
Contributor Author

/azp run Unit-Test-AutoRound

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@chensuyue

Copy link
Copy Markdown
Contributor

/azp run Unit-Test-CUDA-AutoRound

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@changwangss

Copy link
Copy Markdown
Contributor Author

/azp run Unit-Test-CUDA-AutoRound

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@chensuyue

Copy link
Copy Markdown
Contributor

/azp run Unit-Test-CUDA-AutoRound

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@XuehaoSun XuehaoSun merged commit ca37879 into main Jun 18, 2026
33 of 35 checks passed
@XuehaoSun XuehaoSun deleted the changwangss-patch-1 branch June 18, 2026 05:20
tokenizer.save_pretrained(output_dir)
else:
print(f"Skip tokenizer save, tokenizer={tokenizer}")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why prinit

@changwangss changwangss Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for wan s2v, there is no tokenizer, https://huggingface.co/Wan-AI/Wan2.2-S2V-14B. general, if the tokenizer is not from transformers, it doesn't attribute the "save_pretrained".
Add a reminder to distinguish it from the standard process.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, why not use logger here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, makes sense to use logger here. I'll update it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants