[Diffusion] Add rank-local mmap storage for DLO
Decouple node-local checkpoint storage from the DLO AllGather transfer protocol. Compatible rank-local workers retain shared file-backed sources and stream complete blocks through bounded staging without changing request scheduling. Refs #6195 Signed-off-by: Hongsheng Liu <liuhongsheng4@huawei.com>
This commit is contained in:
1 parent
5d50bdc2ab
commit
2956af1e9d
11 files changed
+884
-216
No files matched your search
@@ -11,6 +11,7 @@ from __future__ import annotations
|
||||
import math
|
||||
from collections.abc import Iterable, Mapping
|
||||
from dataclasses import dataclass
|
||||
from functools import partial
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
import torch
|
||||
@@ -350,6 +351,18 @@ class MiniMaxH3Attention(nn.Module):
|
||||
prefix=f"{prefix}.qkv_proj",
|
||||
return_bias=True,
|
||||
)
|
||||
if quant_config is None:
|
||||
# The checkpoint interleaves Q/K/V by query group, while vLLM's
|
||||
# fused QKV linear consumes contiguous Q, then K, then V rows. The
|
||||
# regular loader performs this conversion before weight_loader().
|
||||
# DLO mmap applies the same adapter while packing one bounded host
|
||||
# staging block; the raw file-backed master remains node-shared.
|
||||
self.qkv_proj.weight.mmap_weight_transform = partial(
|
||||
_reorder_grouped_qkv_to_qkv,
|
||||
num_query_groups=arch.num_attention_heads,
|
||||
heads_per_group=1,
|
||||
head_dim=arch.attention_head_dim,
|
||||
)
|
||||
self.num_heads = self.qkv_proj.num_heads
|
||||
self.num_kv_heads = self.qkv_proj.num_kv_heads
|
||||
self.rot_dim = 6 * arch.rope_inv_freq_len
|
||||
|
||||
@@ -532,13 +532,10 @@ class MiniMaxH3Pipeline(
|
||||
encoder_block_attrs={"text_encoder": ("vision.blocks", "text_model.layers")},
|
||||
on_demand_component_paths=frozenset({"text_encoder", "video_vae", "audio_vae"}),
|
||||
)
|
||||
# H3's regular loader performs checkpoint-layout conversions (grouped QKV
|
||||
# and fused MLP). Keep it on that path until mmap can run the same loader
|
||||
# callbacks for every affected parameter.
|
||||
_supports_mmap_loading: ClassVar[bool] = False
|
||||
# TODO(offload): Re-enable after the generic rank-local mmap path can run
|
||||
# this model's grouped-QKV reorder and fused-MLP packing before TP sharding.
|
||||
# Do not bypass the regular loader until that equivalence is tested.
|
||||
# TP1 DLO mmap applies the grouped-QKV adapter while packing each block.
|
||||
# The fused MLP checkpoint is already gate-then-up, matching its TP1
|
||||
# runtime layout. TP>1 and quantized layouts stay on the regular loader.
|
||||
_supports_mmap_loading: ClassVar[bool] = True
|
||||
_PROFILER_TARGETS: ClassVar[list[str]] = [
|
||||
"_prepare_reference_videos",
|
||||
"encode_prompt",
|
||||
@@ -648,6 +645,10 @@ class MiniMaxH3Pipeline(
|
||||
od_config.quantization_config,
|
||||
"transformer",
|
||||
)
|
||||
if transformer_quant_config is not None:
|
||||
# Quantized parameters may have packed weights and scale tensors
|
||||
# whose runtime layout is owned by quant-method loader callbacks.
|
||||
self._supports_mmap_loading = False
|
||||
self.transformer = MiniMaxH3DiTModel(
|
||||
od_config,
|
||||
quant_config=transformer_quant_config,
|
||||
|
||||
Reference in new issue
Block a user