I'll explore how structure video parameters flow through the codebase. Let me start by examining the key files you mentioned and understanding the parameter flow.
Assistant
I'll explore the uni3c_* parameter flow through the codebase systematically. Let me start by examining the key files you mentioned.
Assistant
I'll explore the existing parameter consolidation patterns in your codebase. Let me start by examining the key files you mentioned.
Assistant
Now let me search for schema/validation patterns and examine the phase_config file:
Assistant
Now let me examine the task_conversion.py file to understand the full flow:
Assistant
Now let me search for more details about how the structure_* parameters flow through video_utils.py:
Assistant
Now let me examine the wgp.py file to see how uni3c params are consumed:
Assistant
Now let me examine the params module files to see how they structure and validate configs:
Assistant
Let me get more context on that function signature and how structure params are consumed:
Assistant
Let me read the generate_video function signature and the part where it passes uni3c to the model:
Assistant
Let me check for more config/task conversion patterns:
Assistant
Now let me check for where orchestrator creates structure guidance:
Assistant
Now let me check the any2video.py file to see how uni3c is consumed there:
Assistant
Excellent! Now let me trace the orchestrator's entry point and parameter extraction:
Assistant
Let me get the task_conversion.py file to see how it implements the existing parse_phase_config:
Assistant
Let me get more context on the any2video.py function signature and where it passes uni3c_data to the model:
Assistant
Now let me look at how travel_between_images.py sets up these params for orchestrator:
Assistant
Perfect! Now let me check for any migration or versioning patterns:
Assistant
Now let me search for where structure_videos gets into the orchestrator payload:
Assistant
Perfect! Now let me look at the orchestrator section in task_registry.py to see where auto-enable happens:
Assistant
Let me look at the task.py to see how it structures consolidation:
Assistant
Perfect! Let me create a comprehensive visual map document. Let me read the key sections to understand the flow better:
Assistant
Excellent! Now let me check the vace.py to see how it handles complex nested configs:
Assistant
Let me check what happens before that auto-enable section to understand the full flow:
Assistant
Now let me trace where TravelSegmentProcessor returns structure_type:
Assistant
Perfect! Now let me create a comprehensive map. Let me also check the segment_params structure to understand the complete flow:
Assistant
Assistant
Assistant
Perfect! Now I have a comprehensive view. Let me create a detailed exploration report:
Phase config: additional_loras (dict of URL -> multiplier)
Smart merging (lines 266-292):
python
def merge(self, other: 'LoRAConfig') -> 'LoRAConfig':
"""Merge another LoRAConfig, with other taking precedence for duplicates."""
# Phase-config multipliers take precedence over regular ones
if other_entry.is_phase_config_multiplier():
merged_entries[existing_idx] = other_entry
Status tracking (LoRAEntry dataclass):
PENDING: URL needs downloading
DOWNLOADED: Has local_path
LOCAL: Local file reference
B. Phase Config (source/params/phase.py)
This wraps the existing complex parse_phase_config() function:
Validation with auto-correction (task_conversion.py, lines 35-51):
python
# Auto-correct num_phases
if len(steps_per_phase) != num_phases or len(phases_config) != num_phases:
inferred_phases = len(steps_per_phase)
# ... logging and auto-correction
Phase-specific multiplier format (lines 134-164):
Phase-config multipliers use semicolon separators: "1.0;0.5;0.2"
Regular multipliers use comma separators: "1.0,0.5"
C. TaskConfig (source/params/task.py)
This is your main consolidation hub combining 4 sub-configs:
@classmethod
def from_segment_params(cls, segment_params, orchestrator_payload, individual_params=None, **context):
"""Precedence: individual_params > segment_params > orchestrator_payload"""
merged = {}
if orchestrator_payload:
merged.update(orchestrator_payload)
if segment_params:
merged.update(segment_params)
if individual_params:
merged.update(individual_params)
return cls.from_params(merged, **context)
3. BACKWARD COMPATIBILITY PATTERNS
A. Parameter Aliasing Pattern (source/params/generation.py, lines 40-62)
The codebase handles multiple names for the same param:
python
# Handle image parameter aliases for img2img tasks
image_start = params.get('image_start')
if not image_start:
image_start = params.get('image') or params.get('image_url')
# Handle steps aliases
num_inference_steps=params.get('num_inference_steps') or params.get('steps'),
# Handle denoising strength aliases
denoising_strength=params.get('denoising_strength') or params.get('denoise_strength') or params.get('strength'),
B. Validation with Logging (task_conversion.py, lines 35-51, 325-336)
python
# Auto-correct mismatches and log
if len(steps_per_phase) != num_phases:
headless_logger.warning(
f"phase_config mismatch: ... Auto-correcting num_phases to {inferred_phases}",
task_id=task_id
)
# Layer 1 Uni3C logging - detect whitelist failures early
if "use_uni3c" in generation_params:
headless_logger.info(f"[UNI3C] Task {task_id}: use_uni3c=...")
elif db_task_params.get("use_uni3c"):
# CRITICAL: Detect when whitelist is missing the param
headless_logger.warning(
f"[UNI3C] Task {task_id}: ⚠️ use_uni3c was in db_task_params but NOT in generation_params!"
)
C. Dual Naming with Precedence (lora_utils.py, lines 45-50)
python
# Handle Wan2.2 Lightning LoRA collisions by prefixing parent folder
if url_filename in ["high_noise_model.safetensors", "low_noise_model.safetensors"]:
parts = url.split("/")
if len(parts) > 2:
parent = parts[-2].replace("%20", "_")
url_filename = f"{parent}_{url_filename}"
Cleanup pattern (lines 198-255):
python
def cleanup_legacy_lora_collisions():
"""Remove legacy generic LoRA filenames that collide with new uniquely-named versions."""
# Runs at worker startup to clean old collision-prone files
4. PARAM NORMALIZATION/VALIDATION PATTERNS
A. ParamGroup.validate() Pattern (base.py + all subclasses)
Each config group implements validation:
python
def validate(self) -> List[str]:
"""Return list of validation errors (empty if valid)."""
return [] # Subclasses override
# Parse multipliers
multipliers_raw = params.get('loras_multipliers') or params.get('lora_multipliers') or []
if isinstance(multipliers_raw, str):
# Could be space-separated or comma-separated
if ';' in multipliers_raw:
# Phase-config format: space-separated strings with semicolons
multipliers = multipliers_raw.split()
elif ',' in multipliers_raw:
multipliers = [m.strip() for m in multipliers_raw.split(',')]
else:
multipliers = multipliers_raw.split()
elif isinstance(multipliers_raw, list):
multipliers = multipliers_raw
C. Warn on Similar Keys (base.py, lines 84-88)
python
def warn_similar_key(params, expected, alternatives, task_id=""):
"""Log a warning if we find a similar but not exact key."""
for alt in alternatives:
if alt in params and expected not in params:
logger.warning(f"Found '{alt}' but expected '{expected}' - using '{alt}'")
5. KEY OBSERVATIONS FOR YOUR CONSOLIDATION
A. Three-Tier Precedence is Standard
Your codebase consistently uses 3-level precedence:
if structure_videos array present:
├─ Validate all configs have same structure_type
├─ Call create_composite_guidance_video()
└─ Upload result → structure_guidance_video_url
PATH B: Single Legacy Video (lines 1212-1324):
code
elif structure_video_path present:
├─ Call create_structure_guidance_video() or create_trimmed_structure_video()
└─ Upload result → structure_guidance_video_url
Location B: Segment Payload Construction
Lines: 1900-2000
What gets passed to each segment:
python
segment_payload["structure_video_path"] = orchestrator_payload.get("structure_video_path")
segment_payload["structure_type"] = structure_type
segment_payload["structure_guidance_video_url"] = orchestrator_payload.get("structure_guidance_video_url")
segment_payload["structure_videos"] = orchestrator_payload.get("structure_videos") # Full array for segment's own extraction
segment_payload["use_uni3c"] = is_uni3c_type if structure_type else orchestrator_payload.get("use_uni3c", False)
Key Decision Point (lines 1975-1993):
If structure_videos present → segment computes its own guidance locally
If structure_guidance_video_url present → segment downloads pre-computed guidance
structure_video_path = (segment_params.get("structure_video_path")
or orchestrator.get("structure_video_path"))
structure_videos = (segment_params.get("structure_videos")
or orchestrator.get("structure_videos"))
structure_type = (segment_params.get("structure_type")
or orchestrator.get("structure_type", "flow"))
Multi-structure extraction (lines 185-222):
python
if structure_videos and not structure_guidance_video_url:
# Segment computes its OWN guidance locally
local_guidance_path = extract_segment_structure_guidance(
structure_videos=structure_videos,
segment_index=segment_idx,
segment_frames_expanded=segment_frames,
frame_overlap_expanded=frame_overlaps,
...motion_strength, canny_intensity, depth_contrast
)
generation_params = {
# ... base params ...
"video_guide": str(guide_video_path), # From TravelSegmentProcessor output
"video_mask": str(mask_video_path), # From TravelSegmentProcessor output
"video_prompt_type": "V" | "M" | "U" | ..., # From TravelSegmentProcessor output
# ... for Uni3C ...
"use_uni3c": True, # Auto-enabled if structure_type == "uni3c"
"uni3c_guide_video": guide_video_path, # Same as video_guide
"uni3c_strength": motion_strength, # From structure_video_motion_strength
"uni3c_start_percent": 0.0,
"uni3c_end_percent": 1.0,
}
generation_task = GenerationTask(
id=task_id,
model=model_name,
prompt=prompt,
parameters=generation_params # Passed to WGP
)
task_queue.submit_task(generation_task)
VACE Video Guide Usage (via video_prompt_type):
"V" in video_prompt_type → WGP uses video_guide as motion conditioning
"M" in video_prompt_type → WGP uses video_mask to freeze frames
"U" → Raw unprocessed guide (non-VACE)
Uni3C Usage (if structure_type == "uni3c"):
Extracts from uni3c_guide_video directly
Strength controlled by uni3c_strength
ControlNet encoding happens in WGP
7. PARAMETER PRECEDENCE & OVERRIDE HIERARCHY
Individual Segment Parameters (HIGHEST priority)
code
individual_segment_params.structure_*
↓ if not present
segment_params.structure_*
↓ if not present
orchestrator_details.structure_*
↓ if not present
system_defaults (mostly 1.0, "flow", "adjust")
Per-Parameter Precedence:
Parameter
Source 1
Source 2
Source 3
Default
structure_videos
individual_seg_params
segment_params
orchestrator_details
[]
structure_type
segment_params
orchestrator_details
(extracted from structure_videos[0])
"flow"
structure_guidance_video_url
segment_params
orchestrator_details (pre-computed)
—
None
motion_strength
segment_params
orchestrator_details
—
1.0
canny_intensity
segment_params
orchestrator_details
—
1.0
depth_contrast
segment_params
orchestrator_details
—
1.0
8. FINAL OUTPUT MAP: VACE → Video
code
Guide Video (structure_guidance_video_url)
↓
TravelSegmentProcessor.create_guide_video()
↓
apply_structure_motion_with_tracking()
├─ Downloads pre-computed guidance OR
├─ Extracts local guidance from structure_videos
└─ Fills unguidanced frame ranges with motion/edge/depth visualizations
↓
Composite Guide Video (e.g., flow visualizations)
↓
WGP receives: video_guide + video_mask + video_prompt_type
├─ If video_prompt_type contains "V": VACE uses video_guide as motion ControlNet
├─ If video_prompt_type contains "M": VACE freezes masked frames
└─ If use_uni3c=True: Uni3C ControlNet processes video_guide directly
↓
Generated Video Output
9. COMPLETE TOUCHPOINT SUMMARY
READ Touchpoints (structure_ params consumed):*
✅ task_registry.py:152-176 - Extracts from orchestrator/segment/individual
✅ travel_between_images.py:1948-1950 - Writes structure params to segment_payload
✅ travel_between_images.py:1993 - Sets use_uni3c based on structure_type
✅ travel_segment_processor.py:453-464 - Auto-enables uni3c when structure_type=="uni3c"
✅ task_registry.py:802-809 - Injects uni3c_* params into generation_params
10. SPECIAL CASES & AUTO-BEHAVIORS
Uni3C Auto-Enable (task_registry.py:449-465)
python
if detected_structure_type == "uni3c" and guide_video_path:
orchestrator_details["use_uni3c"] = True
orchestrator_details["uni3c_guide_video"] = guide_video_path
# Extract uni3c_strength from structure_videos[0].motion_strength
Video Prompt Type Construction (travel_segment_processor.py:420-484)
python
if is_vace_model:
vpt_components = []
if structure_type != "uni3c":
vpt_components.append("V") # Only if NOT uni3c (avoid double-feeding)
if mask_video_path:
vpt_components.append("M")
video_prompt_type = "".join(vpt_components) # e.g., "VM", "V", "M"
else:
video_prompt_type = "U" + ("M" if mask_video_path else "") # Non-VACE fallback
Structure Type Detection (travel_segment_processor.py:155-180)
python
structure_type = (
segment_params.get("structure_type") or
segment_params.get("structure_video_type") or
orchestrator.get("structure_type") or
orchestrator.get("structure_video_type") or
(structure_videos[0].get("structure_type") if structure_videos else "flow")
)
This mapping shows the complete journey of structure video parameters from API ingestion through VACE guide video generation!
Perfect! Now I have all the information I need. Let me create a comprehensive analysis document:
UNI3C Parameter Flow Analysis
Based on my exploration of the codebase, here's the complete flow of uni3c_* parameters through the system:
1. WHERE UNI3C_* PARAMS ARE FIRST DEFINED/RECEIVED
Entry Points:
A. Travel Orchestrator (travel_between_images.py lines 1049-1325)
structure_type is defined from structure_videos config or top-level settings
Validated against allowed types: ["flow", "canny", "depth", "raw", "uni3c"]
motion_strength is extracted (used as uni3c_strength when structure_type="uni3c")
structure_guidance_video_url is set after processing structure videos
Source locations:
Line 1110-1125: Structure type validation
Line 1126: Motion strength extraction (orchestrator_payload.get("structure_video_motion_strength", 1.0))
Line 1155-1195: Composite video creation with structure type, url uploaded to structure_guidance_video_url
Line 1196: orchestrator_payload["structure_type"] = structure_type
B. Travel Segment Payload Builder (travel_between_images.py lines 1949-2009)
# Line 443: Segment processor returns detected_structure_type
detected_structure_type = segment_outputs.get("structure_type")
# Lines 449-464: AUTO-ENABLE LOGIC
if detected_structure_type == "uni3c" and guide_video_path:
dprint_func(f"[UNI3C_AUTO] Task {task_id}: Auto-enabling uni3c mode (structure_type='uni3c' detected)")
# Set use_uni3c in orchestrator_details (picked up by UNI3C MODE section)
orchestrator_details["use_uni3c"] = True
orchestrator_details["uni3c_guide_video"] = guide_video_path
# Extract uni3c-specific params from structure_videos config
structure_videos = segment_params.get("structure_videos") or full_orchestrator_payload.get("structure_videos", [])
if structure_videos:
first_config = structure_videos[0]
if "uni3c_strength" not in orchestrator_details:
orchestrator_details["uni3c_strength"] = first_config.get("motion_strength", 1.0)
if "uni3c_end_percent" not in orchestrator_details:
orchestrator_details["uni3c_end_percent"] = first_config.get("uni3c_end_percent", 1.0)
if "uni3c_start_percent" not in orchestrator_details:
orchestrator_details["uni3c_start_percent"] = first_config.get("uni3c_start_percent", 0.0)
Key Points:
Condition: structure_type == "uni3c" AND guide video exists
Shows final values before injection to generation_params
Layer 3 (wgp.py:5260-5270): Function entry
Logs "ENABLED" or "DISABLED" status
Full parameter dump
Layer 4 (any2video.py:1624-1629): Model entry
Model-level parameter confirmation
7. CRITICAL FLOW SUMMARY
code
INPUT: orchestrator_payload with structure_videos[type="uni3c"]
↓
PROCESS: TravelSegmentProcessor detects structure_type="uni3c"
↓
TRIGGER: detected_structure_type == "uni3c" → AUTO-ENABLE
↓
ACTION: orchestrator_details["use_uni3c"] = True (master flag)
↓
PROPAGATE: Resolved through generation_params with precedence
↓
INJECT: All uni3c_* params added to generation_params
↓
PASS: WGP.generate_video() receives uni3c_* in function signature
↓
FORWARD: All uni3c_* passed to any2video() function call
↓
BUILD: any2video() builds uni3c_data dict with:
- controlnet (loaded model)
- controlnet_weight (from uni3c_strength)
- render_latent (encoded guide video)
- start/end percents (for timestep window)
- offload flag (from keep_on_gpu)
↓
CONSUME: uni3c_data used in denoising loop for motion guidance
8. FILES MAPPED
Key Locations:
Component
File
Lines
Purpose
Orchestrator Input
travel_between_images.py
1049-1325
Define structure_type, create guidance video
Segment Payload
travel_between_images.py
1949-2009
Map orchestrator params to segment tasks
Processor
travel_segment_processor.py
150-183, 486-542
Detect structure_type, return in outputs
Auto-Enable Logic
task_registry.py
449-464
Trigger use_uni3c=True on uni3c detection
UNI3C Resolution
task_registry.py
748-809
Extract params with precedence, inject to generation_params
DB Task Whitelist
task_conversion.py
280-318
Define accepted uni3c_* parameters
WGP Entry
wgp.py
5250-5270
Function signature, Layer 3 logging
WGP Pass-through
wgp.py
6141-6148
Forward to any2video()
Any2Video Processing
any2video.py
688-1742
Load guide, encode, build uni3c_data dict
This comprehensive flow shows uni3c_* parameters starting from orchestrator structure video configurations, through segment processing with auto-enable logic triggered by structure_type="uni3c", and finally consumed in the model's denoising loop as motion guidance via the Uni3C ControlNet.