Merge origin/main into codex-vae-spatial-decode-auto
Signed-off-by: Hongsheng Liu <liuhongsheng4@huawei.com>
This commit is contained in:
commit
089851e55a
244 files changed
+16669
-2175
No files matched your search
@@ -65,11 +65,10 @@ except ImportError:
|
||||
# ``model_config["guardrails"]`` is False.
|
||||
def __init__(self, *args, **kwargs):
|
||||
raise ValueError(
|
||||
f"You have disabled the safety checker for {self.__class__}. This is in violation of the "
|
||||
f"The guardrails are enabled but not functional for {self.__class__}. This is most likely due to a"
|
||||
f"missing cosmos-guardrail package. Please install cosmos-guardrail to be compliant with the "
|
||||
"[NVIDIA Open Model License Agreement]"
|
||||
"(https://www.nvidia.com/en-us/agreements/enterprise-software/nvidia-open-model-license). "
|
||||
f"Please ensure that you are compliant with the license agreement."
|
||||
f"Please install cosmos-guardrail package to enable safety checks."
|
||||
"(https://www.nvidia.com/en-us/agreements/enterprise-software/nvidia-open-model-license)."
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ import torch.nn as nn
|
||||
import torch.nn.functional as F
|
||||
from vllm.logger import init_logger
|
||||
|
||||
from vllm_omni.diffusion.layers.norm import RMSNorm as DiffusionRMSNorm
|
||||
|
||||
MINIMAX_H3_QWEN3VL_SELECTED_LM_LAYER = 50
|
||||
MINIMAX_H3_QWEN3VL_HIDDEN_DIM = 5120
|
||||
|
||||
@@ -291,18 +293,22 @@ class MiniMaxH3Qwen3VLRowParallelLinear(nn.Module):
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class MiniMaxH3Qwen3VLRMSNorm(nn.Module):
|
||||
def __init__(self, hidden_size: int, eps: float = 1e-6) -> None:
|
||||
super().__init__()
|
||||
self.weight = nn.Parameter(torch.ones(hidden_size))
|
||||
self.variance_epsilon = eps
|
||||
class MiniMaxH3Qwen3VLRMSNorm(DiffusionRMSNorm):
|
||||
"""Qwen3-VL RMSNorm using the common implementation.
|
||||
|
||||
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
|
||||
input_dtype = hidden_states.dtype
|
||||
hidden_states = hidden_states.to(torch.float32)
|
||||
variance = hidden_states.pow(2).mean(-1, keepdim=True)
|
||||
hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon)
|
||||
return self.weight * hidden_states.to(input_dtype)
|
||||
The model-specific name keeps checkpoint weight keys stable, while the
|
||||
common RMSNorm dispatches to torch_npu.npu_rms_norm on Ascend. Gamma uses
|
||||
the checkpoint/model dtype, but native fallbacks keep the RMS variance
|
||||
reduction and scaling in float32.
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
hidden_size: int,
|
||||
eps: float = 1e-6,
|
||||
dtype: torch.dtype = torch.float32,
|
||||
) -> None:
|
||||
super().__init__(hidden_size, eps=eps, dtype=dtype)
|
||||
|
||||
|
||||
def _rotate_half(x: torch.Tensor) -> torch.Tensor:
|
||||
@@ -685,8 +691,8 @@ class MiniMaxH3Qwen3VLTextAttention(nn.Module):
|
||||
dtype=dtype,
|
||||
input_is_parallel=True,
|
||||
)
|
||||
self.q_norm = MiniMaxH3Qwen3VLRMSNorm(self.head_dim, eps=config.rms_norm_eps)
|
||||
self.k_norm = MiniMaxH3Qwen3VLRMSNorm(self.head_dim, eps=config.rms_norm_eps)
|
||||
self.q_norm = MiniMaxH3Qwen3VLRMSNorm(self.head_dim, eps=config.rms_norm_eps, dtype=dtype)
|
||||
self.k_norm = MiniMaxH3Qwen3VLRMSNorm(self.head_dim, eps=config.rms_norm_eps, dtype=dtype)
|
||||
|
||||
def forward(
|
||||
self,
|
||||
@@ -760,8 +766,10 @@ class MiniMaxH3Qwen3VLTextDecoderLayer(nn.Module):
|
||||
self.hidden_size = config.hidden_size
|
||||
self.self_attn = MiniMaxH3Qwen3VLTextAttention(group, config, dtype)
|
||||
self.mlp = MiniMaxH3Qwen3VLTextMLP(group, config, dtype)
|
||||
self.input_layernorm = MiniMaxH3Qwen3VLRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
||||
self.post_attention_layernorm = MiniMaxH3Qwen3VLRMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
||||
self.input_layernorm = MiniMaxH3Qwen3VLRMSNorm(config.hidden_size, eps=config.rms_norm_eps, dtype=dtype)
|
||||
self.post_attention_layernorm = MiniMaxH3Qwen3VLRMSNorm(
|
||||
config.hidden_size, eps=config.rms_norm_eps, dtype=dtype
|
||||
)
|
||||
|
||||
def forward(
|
||||
self,
|
||||
|
||||
@@ -138,6 +138,7 @@ def format_diffusion_outputs(
|
||||
),
|
||||
"width": request.sampling_params.width,
|
||||
"height": request.sampling_params.height,
|
||||
"num_inference_steps": request.sampling_params.num_inference_steps,
|
||||
}
|
||||
|
||||
# Only the primary payload determines the response type. Some image models
|
||||
|
||||
@@ -51,8 +51,13 @@ def _iter_multimodal_image_payloads(output: OmniRequestOutput | RequestOutput) -
|
||||
if isinstance(output, OmniRequestOutput):
|
||||
if output.multimodal_output is not None:
|
||||
yield from _image_values_from_mapping_like(output.multimodal_output)
|
||||
if output.request_output is not None:
|
||||
yield from _iter_request_output_payloads(output.request_output)
|
||||
# OmniRequestOutput IS the RequestOutput now; iterate completion
|
||||
# outputs directly for multimodal payloads that the property
|
||||
# (which returns only the first match) may have missed.
|
||||
for completion in getattr(output, "outputs", []):
|
||||
mm = getattr(completion, "multimodal_output", None)
|
||||
if mm is not None:
|
||||
yield from _image_values_from_mapping_like(mm)
|
||||
else:
|
||||
yield from _iter_request_output_payloads(output)
|
||||
|
||||
|
||||
Reference in new issue
Block a user