[Diffusion] Add final-layout BF16 Host Weight Runtime artifacts (#6445)
Signed-off-by: Hongsheng Liu <liuhongsheng4@huawei.com>
This commit is contained in:
1 parent
3781214675
commit
493fc64397
13 files changed
+2949
-5
No files matched your search
@@ -0,0 +1,40 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
"""Model-owned declaration for complete final-layout tensor restoration."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
FINAL_LAYOUT_TENSOR_MODEL_CONTRACT_SCHEMA = "vllm-omni.diffusion.final-layout-tensors-v1"
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class FinalLayoutModelContract:
|
||||
"""Versioned model ABI for reconstruction from exact final-layout tensors."""
|
||||
|
||||
implementation_id: str
|
||||
version: str
|
||||
schema: str = FINAL_LAYOUT_TENSOR_MODEL_CONTRACT_SCHEMA
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
for name, value in (
|
||||
("schema", self.schema),
|
||||
("implementation_id", self.implementation_id),
|
||||
("version", self.version),
|
||||
):
|
||||
if not isinstance(value, str) or not value:
|
||||
raise ValueError(f"final-layout model contract {name} must not be empty")
|
||||
|
||||
def to_dict(self) -> dict[str, str]:
|
||||
return {
|
||||
"schema": self.schema,
|
||||
"implementation_id": self.implementation_id,
|
||||
"version": self.version,
|
||||
}
|
||||
|
||||
|
||||
__all__ = [
|
||||
"FINAL_LAYOUT_TENSOR_MODEL_CONTRACT_SCHEMA",
|
||||
"FinalLayoutModelContract",
|
||||
]
|
||||
@@ -1,4 +1,5 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
|
||||
"""MiniMax H3 packed-token audio/video DiT for vLLM-Omni.
|
||||
|
||||
vLLM tensor parallel linears and the unified attention layer provide TP and
|
||||
@@ -43,6 +44,7 @@ from vllm_omni.diffusion.layers.activation import SiluAndMul
|
||||
from vllm_omni.diffusion.layers.fused_qk_norm_rope import fused_qk_norm_rope
|
||||
from vllm_omni.diffusion.layers.norm import RMSNorm
|
||||
from vllm_omni.diffusion.layers.rope import RotaryEmbedding
|
||||
from vllm_omni.diffusion.models.host_weight_contract import FinalLayoutModelContract
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from vllm.model_executor.layers.quantization.base_config import (
|
||||
@@ -889,6 +891,15 @@ class MiniMaxH3SPGather(nn.Module):
|
||||
|
||||
|
||||
class MiniMaxH3DiTModel(nn.Module):
|
||||
# Loading is tensor-complete: constructor state plus final-layout
|
||||
# parameters and persistent buffers is sufficient to reconstruct a ready
|
||||
# inference model. The model-specific validator below checks the preserved
|
||||
# FP32 portion after a lease-backed restore commits.
|
||||
host_weight_restore_contract = FinalLayoutModelContract(
|
||||
implementation_id="minimax-h3-dit",
|
||||
version="1",
|
||||
)
|
||||
|
||||
_cache_dit_adapter_config = CacheDiTAdapterConfig(
|
||||
block_forward_patterns={"blocks": ForwardPattern.Pattern_3},
|
||||
# H3 is CFG-distilled and performs one transformer forward per step.
|
||||
@@ -1064,6 +1075,10 @@ class MiniMaxH3DiTModel(nn.Module):
|
||||
if name in MINIMAX_H3_FP32_BUFFER_NAMES and buffer.dtype != _FP32_DTYPE:
|
||||
raise ValueError(f"{name} must stay fp32 after load, got {buffer.dtype}.")
|
||||
|
||||
def validate_restored_host_weights(self) -> None:
|
||||
"""Validate mixed-precision invariants after lease-backed restore."""
|
||||
self.post_load_weights()
|
||||
|
||||
def load_weights(
|
||||
self,
|
||||
weights: Iterable[tuple[str, torch.Tensor]],
|
||||
|
||||
Reference in new issue
Block a user