[Bugfix][Examples][MammothModa2] Serve T2I via LLM-typed DiT stage (#7199) + benchmark harness and profiler wiring (#7293)
Signed-off-by: quan-yi-ai <82917002+quan-yi-ai@users.noreply.github.com> Co-authored-by: Hongsheng Liu <liuhongsheng4@huawei.com>
This commit is contained in:
1 parent
b9cf74352a
commit
65f5a1d5b3
12 files changed
+933
-71
No files matched your search
@@ -24,6 +24,7 @@ from vllm_omni.diffusion.distributed.utils import get_local_device
|
||||
from vllm_omni.diffusion.layers.norm import RMSNorm
|
||||
from vllm_omni.diffusion.model_loader.diffusers_loader import DiffusersPipelineLoader
|
||||
from vllm_omni.diffusion.models.interface import SupportsComponentDiscovery
|
||||
from vllm_omni.diffusion.profiler.diffusion_pipeline_profiler import DiffusionPipelineProfilerMixin
|
||||
from vllm_omni.diffusion.request import OmniDiffusionRequest
|
||||
from vllm_omni.diffusion.worker.input_batch import InputBatch
|
||||
from vllm_omni.diffusion.worker.request_batch import DiffusionRequestBatch
|
||||
@@ -337,7 +338,7 @@ class _RequestConditioning:
|
||||
image_mask: torch.Tensor
|
||||
|
||||
|
||||
class MammothModa2DiTPipeline(nn.Module, SupportsComponentDiscovery):
|
||||
class MammothModa2DiTPipeline(nn.Module, DiffusionPipelineProfilerMixin, SupportsComponentDiscovery):
|
||||
"""
|
||||
MammothModa2 DiT + VAE generation stage (non-autoregressive).
|
||||
|
||||
@@ -424,12 +425,6 @@ class MammothModa2DiTPipeline(nn.Module, SupportsComponentDiscovery):
|
||||
|
||||
self._llm_hidden_size = llm_hidden_size
|
||||
|
||||
# Cache-DiT lifecycle: the diffusion runner enables the configured
|
||||
# backend (``cache_backend`` on the deploy YAML stage entry) at startup
|
||||
# and transfers ownership here via the request-scoped protocol;
|
||||
# forward() then reconciles per-request state (step count, CFG parity).
|
||||
# The runner also emits the cache summary when
|
||||
# ``enable_cache_dit_summary`` is set.
|
||||
self._cache_dit_runtime = RequestScopedCacheDiTRuntime(self)
|
||||
self._cache_dit_config: DiffusionCacheConfig | None = None
|
||||
if str(getattr(od_config, "cache_backend", "") or "").lower() == "cache_dit":
|
||||
@@ -440,6 +435,14 @@ class MammothModa2DiTPipeline(nn.Module, SupportsComponentDiscovery):
|
||||
else DiffusionCacheConfig.from_dict(cache_config or {})
|
||||
)
|
||||
|
||||
profiler_targets = ["gen_transformer.forward", "gen_vae.decode"]
|
||||
if self.gen_image_condition_refiner is not None:
|
||||
profiler_targets.append("gen_image_condition_refiner.forward")
|
||||
self.setup_diffusion_pipeline_profiler(
|
||||
profiler_targets=profiler_targets,
|
||||
enable_diffusion_pipeline_profiler=self.od_config.enable_diffusion_pipeline_profiler,
|
||||
)
|
||||
|
||||
def adopt_cache_dit_backend(self, backend: CacheDiTBackend) -> None:
|
||||
"""Adopt a runner-installed Cache-DiT backend (request-scoped protocol)."""
|
||||
|
||||
|
||||
@@ -25,3 +25,18 @@ def apply_declared_extra_args(
|
||||
if not declared:
|
||||
return
|
||||
sampling_params.extra_args = {**(sampling_params.extra_args or {}), **declared}
|
||||
|
||||
|
||||
def ar_grid_max_tokens(ar_width: int, ar_height: int) -> int | None:
|
||||
"""Return the AR-stage ``max_tokens`` for MammothModa2-style visual-token grids.
|
||||
|
||||
The AR stage emits one visual token per grid cell, one EOL token per row,
|
||||
and one final look-ahead token, so the generation budget is
|
||||
``ar_height * (ar_width + 1) + 1``. Shared by the online serving path and
|
||||
the offline example so a grid-contract change cannot desynchronize one
|
||||
copy. Returns ``None`` when the grid is absent or non-positive, letting
|
||||
callers keep their existing default.
|
||||
"""
|
||||
if ar_width <= 0 or ar_height <= 0:
|
||||
return None
|
||||
return ar_height * (ar_width + 1) + 1
|
||||
Reference in new issue
Block a user