Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ image = pipe(prompt="a girl, qipao")
image.save("image.png")
```

For more details, please refer to our tutorials ([English](./docs/tutorial.md), [中文](./docs/tutorial_zh.md)).
For more details, please refer to our tutorials ([English](./docs/tutorial.md), [中文](./docs/tutorial_zh.md))
and the [Ascend A5 / Ascend 950 guide](./docs/ascend.md).

## Showcase

Expand Down
2 changes: 2 additions & 0 deletions diffsynth_engine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
AttnImpl,
SpargeAttentionParams,
VideoSparseAttentionParams,
QuantizationConfig,
LoraConfig,
ControlNetParams,
ControlType,
Expand Down Expand Up @@ -73,6 +74,7 @@
"AttnImpl",
"SpargeAttentionParams",
"VideoSparseAttentionParams",
"QuantizationConfig",
"LoraConfig",
"ControlNetParams",
"ControlType",
Expand Down
2 changes: 2 additions & 0 deletions diffsynth_engine/configs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
AttnImpl,
SpargeAttentionParams,
VideoSparseAttentionParams,
QuantizationConfig,
LoraConfig,
)
from .controlnet import (
Expand Down Expand Up @@ -59,6 +60,7 @@
"AttnImpl",
"SpargeAttentionParams",
"VideoSparseAttentionParams",
"QuantizationConfig",
"LoraConfig",
"ControlType",
"ControlNetParams",
Expand Down
17 changes: 17 additions & 0 deletions diffsynth_engine/configs/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class AttnImpl(Enum):
SAGE = "sage" # Sage Attention
SPARGE = "sparge" # Sparge Attention
VSA = "vsa" # Video Sparse Attention
MINDIE = "mindie" # MindIE-SD attention for Ascend NPU


@dataclass
Expand All @@ -56,12 +57,28 @@ class AttentionConfig:
attn_params: Optional[SpargeAttentionParams | VideoSparseAttentionParams] = None


@dataclass
class QuantizationConfig:
backend: Literal["auto", "native", "nunchaku", "mindie"] = "auto"
linear: Literal["none", "fp8", "int4"] = "none"
attention: Literal["none", "fp8"] = "none"

def __post_init__(self):
if self.backend not in {"auto", "native", "nunchaku", "mindie"}:
raise ValueError(f"Unsupported quantization backend: {self.backend}")
if self.linear not in {"none", "fp8", "int4"}:
raise ValueError(f"Unsupported linear quantization mode: {self.linear}")
if self.attention not in {"none", "fp8"}:
raise ValueError(f"Unsupported attention quantization mode: {self.attention}")


@dataclass
class OptimizationConfig:
use_fp8_linear: bool = False
use_fbcache: bool = False
fbcache_relative_l1_threshold: float = 0.05
use_torch_compile: bool = False
quantization: Optional[QuantizationConfig] = None


@dataclass
Expand Down
Loading