[Perf][Diffusion] support Sensenova online fp8 (#7955)
Signed-off-by: Dmaner <2663515256@qq.com> Co-authored-by: Hongsheng Liu <liuhongsheng4@huawei.com>
This commit is contained in:
1 parent
2a453c5ad8
commit
79a46a4f54
6 files changed
+215
-9
No files matched your search
@@ -45,7 +45,6 @@ import pytest
|
||||
import torch
|
||||
from PIL import Image
|
||||
|
||||
from tests.e2e.accuracy.helpers import resolve_device_threshold
|
||||
from tests.helpers.mark import hardware_marks
|
||||
|
||||
_REPO_ROOT = Path(__file__).resolve().parents[3]
|
||||
@@ -85,6 +84,7 @@ class QualityTestConfig:
|
||||
guidance_scale: float | None = None
|
||||
sigmas: list[float] | None = None
|
||||
enable_cpu_offload: bool = False
|
||||
diffusion_attention_backend: str | None = None
|
||||
|
||||
def baseline_ref(self) -> str:
|
||||
return self.baseline_model or self.model or ""
|
||||
@@ -206,6 +206,21 @@ QUALITY_CONFIGS = [
|
||||
seed=142,
|
||||
num_inference_steps=20,
|
||||
),
|
||||
QualityTestConfig(
|
||||
id="fp8_sensenova_u1",
|
||||
model=os.environ.get("SENSENOVA_U1_MODEL_PATH", "SenseNova/SenseNova-U1.5-8B-MoT"),
|
||||
quantization="fp8",
|
||||
task="t2i",
|
||||
prompt="Close portrait of an elderly woman by a farmhouse window, warm natural light.",
|
||||
# Repository image-gate default, not a SenseNova-calibrated threshold.
|
||||
max_lpips=0.15,
|
||||
height=1024,
|
||||
width=1024,
|
||||
num_inference_steps=50,
|
||||
seed=42,
|
||||
negative_prompt=None,
|
||||
diffusion_attention_backend="TORCH_SDPA",
|
||||
),
|
||||
QualityTestConfig(
|
||||
id="fp8_ltx2",
|
||||
model="Lightricks/LTX-2",
|
||||
@@ -276,6 +291,15 @@ def _maybe_save_output(output_dir: Path | None, config: QualityTestConfig, label
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def _build_omni_kwargs(config: QualityTestConfig, model: str) -> dict:
|
||||
kwargs = {"model": model, "enforce_eager": True}
|
||||
if config.enable_cpu_offload:
|
||||
kwargs["enable_cpu_offload"] = True
|
||||
if config.diffusion_attention_backend is not None:
|
||||
kwargs["diffusion_attention_backend"] = config.diffusion_attention_backend
|
||||
return kwargs
|
||||
|
||||
|
||||
def _generate_image(omni, config: QualityTestConfig):
|
||||
"""Generate a single image, return (PIL.Image, peak_mem_gib)."""
|
||||
from vllm_omni.inputs.data import OmniDiffusionSamplingParams
|
||||
@@ -294,6 +318,7 @@ def _generate_image(omni, config: QualityTestConfig):
|
||||
OmniDiffusionSamplingParams(
|
||||
height=config.height,
|
||||
width=config.width,
|
||||
seed=config.seed,
|
||||
generator=generator,
|
||||
num_inference_steps=config.num_inference_steps,
|
||||
guidance_scale=config.guidance_scale,
|
||||
@@ -534,6 +559,8 @@ _OUTPUT_DIR = Path(os.environ["VLLM_OMNI_QUALITY_OUTPUT_DIR"]) if "VLLM_OMNI_QUA
|
||||
|
||||
def _quality_param(c: QualityTestConfig):
|
||||
marks = list(_marks)
|
||||
if c.id == "fp8_sensenova_u1":
|
||||
marks = hardware_marks(res={"cuda": "H200"})
|
||||
if c.id == "fp8_qwen_image":
|
||||
marks.append(
|
||||
pytest.mark.skip(reason="Qwen-Image FP8 quality gate temporarily disabled (see CI / issue tracker).")
|
||||
@@ -549,6 +576,7 @@ def _quality_param(c: QualityTestConfig):
|
||||
)
|
||||
def test_quantization_quality(config: QualityTestConfig):
|
||||
"""Validate that quantized output stays within LPIPS threshold of BF16."""
|
||||
from tests.e2e.accuracy.helpers import resolve_device_threshold
|
||||
from vllm_omni.entrypoints.omni import Omni
|
||||
|
||||
generate_fn = _generate_video if config.task == "t2v" else _generate_image
|
||||
@@ -560,9 +588,7 @@ def test_quantization_quality(config: QualityTestConfig):
|
||||
# to 0.1291 that way in build 2954). Mirrors
|
||||
# vllm_omni/quantization/tools/compare_diffusion_trajectory_similarity.py.
|
||||
# --- BF16 baseline ---
|
||||
bl_kwargs: dict = {"model": config.baseline_ref(), "enforce_eager": True}
|
||||
if config.enable_cpu_offload:
|
||||
bl_kwargs["enable_cpu_offload"] = True
|
||||
bl_kwargs = _build_omni_kwargs(config, config.baseline_ref())
|
||||
omni_bl = Omni(**bl_kwargs)
|
||||
baseline_out, bl_mem = generate_fn(omni_bl, config)
|
||||
omni_bl.shutdown()
|
||||
@@ -572,9 +598,7 @@ def test_quantization_quality(config: QualityTestConfig):
|
||||
|
||||
# --- Quantized ---
|
||||
quantization = config.quantization_ref()
|
||||
qt_kwargs: dict = {"model": config.quantized_ref(), "enforce_eager": True}
|
||||
if config.enable_cpu_offload:
|
||||
qt_kwargs["enable_cpu_offload"] = True
|
||||
qt_kwargs = _build_omni_kwargs(config, config.quantized_ref())
|
||||
if quantization is None:
|
||||
omni_qt = Omni(**qt_kwargs)
|
||||
else:
|
||||
|
||||
Reference in new issue
Block a user