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
39 changes: 36 additions & 3 deletions examples/helios_continuation/helios_continuation_dynamo.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,24 @@

# ---------- Protocol ----------

DEFAULT_NEGATIVE_PROMPT = (
"Bright tones, overexposed, static, blurred details, subtitles, style, "
"works, paintings, images, static, overall gray, worst quality, low quality, "
"JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, "
"poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, "
"still picture, messy background, three legs, many people in the background, "
"walking backwards"
)


class GenerateRequest(BaseModel):
prompt: str = ""
negative_prompt: str = ""
negative_prompt: str = DEFAULT_NEGATIVE_PROMPT
height: int = 384
width: int = 640
num_frames: int = 33
seed: int = 42
guidance_scale: float = 1.0
request_id: str = ""
# If cache_id is set, this is a continuation request
cache_id: str = ""
Expand Down Expand Up @@ -140,6 +151,23 @@ def load_model(self):
# Build the pipeline (loads all models)
self.pipeline = build_pipeline(self.server_args)

# Force Distilled-mode pipeline config (sglang may not auto-detect
# these when HeliosDMDScheduler isn't in its registry)
pc = self.server_args.pipeline_config
pc.is_enable_stage2 = True
pc.is_distilled = True
pc.is_amplify_first_chunk = True
pc.pyramid_num_inference_steps_list = [2, 2, 2]
pc.pyramid_num_stages = 3
if not pc.is_cfg_zero_star:
pc.is_cfg_zero_star = False
logger.info(
"Forced Distilled config: stage2=%s, distilled=%s, "
"amplify_first=%s, pyramid_steps=%s",
pc.is_enable_stage2, pc.is_distilled,
pc.is_amplify_first_chunk, pc.pyramid_num_inference_steps_list,
)

# Patch the denoising stage for cache support
from sglang.multimodal_gen.runtime.pipelines_core.stages.model_specific_stages.helios_denoising import (
HeliosChunkedDenoisingStage,
Expand All @@ -156,7 +184,8 @@ def load_model(self):
)

def _build_req(self, prompt, negative_prompt="", height=384, width=640,
num_frames=33, seed=42, request_id=None, extra=None):
num_frames=33, seed=42, guidance_scale=1.0,
request_id=None, extra=None):
"""Construct a Req suitable for pipeline.forward()."""
from sglang.multimodal_gen.configs.sample.sampling_params import SamplingParams
from sglang.multimodal_gen.runtime.entrypoints.utils import prepare_request
Expand All @@ -170,6 +199,7 @@ def _build_req(self, prompt, negative_prompt="", height=384, width=640,
height=height,
width=width,
seed=seed,
guidance_scale=guidance_scale,
request_id=request_id or str(uuid.uuid4())[:8],
output_file_name=f"{request_id or str(uuid.uuid4())[:8]}.mp4",
)
Expand Down Expand Up @@ -258,11 +288,12 @@ def _run():
}
req = self._build_req(
prompt=meta.get("prompt", ""),
negative_prompt=meta.get("negative_prompt", ""),
negative_prompt=meta.get("negative_prompt", DEFAULT_NEGATIVE_PROMPT),
height=meta.get("height", 384),
width=meta.get("width", 640),
num_frames=request.num_frames,
seed=request.seed,
guidance_scale=request.guidance_scale,
request_id=request_id,
extra=extra,
)
Expand All @@ -277,6 +308,7 @@ def _run():
"width": request.width,
"num_frames": request.num_frames,
"seed": request.seed,
"guidance_scale": request.guidance_scale,
"model_path": MODEL_PATH,
},
}
Expand All @@ -287,6 +319,7 @@ def _run():
width=request.width,
num_frames=request.num_frames,
seed=request.seed,
guidance_scale=request.guidance_scale,
request_id=request_id,
extra=extra,
)
Expand Down
4 changes: 4 additions & 0 deletions examples/helios_continuation/helios_latent_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@ def _patched_forward(self, batch, server_args):
server_args=server_args,
)

# Some sglang versions return (latents, ...) tuple instead of tensor
if isinstance(latents, tuple):
latents = latents[0]

# Extract first frame as image_latents for subsequent chunks
if keep_first_frame and is_first_chunk and image_latents is None:
image_latents = latents[:, :, 0:1, :, :]
Expand Down