Archive fork in favor of upstream and DUMAS nodes
This commit is contained in:
+20
-103
@@ -29,7 +29,6 @@ from .refine_schedule import (
|
||||
serializable_schedule_contract,
|
||||
)
|
||||
from .refine_sampling import sample_refine_chunk
|
||||
from .tiled_latent_upscale_nodes import _call_native, _unwrap_single_output
|
||||
|
||||
|
||||
class SecondPassContractError(ValueError):
|
||||
@@ -458,7 +457,6 @@ def run_second_pass_groups(
|
||||
refine_schedule: RefineSchedule | None = None,
|
||||
selected_group_indices: Sequence[int] | None = None,
|
||||
temporal_windows_by_group: Mapping[int, Any] | None = None,
|
||||
tiled_upscale_config: Mapping[str, Any] | None = None,
|
||||
) -> tuple[list[dict[str, Any]], list[Any], dict[str, Any], str]:
|
||||
"""Refine complete physical groups while preserving first-pass audio exactly."""
|
||||
|
||||
@@ -503,7 +501,6 @@ def run_second_pass_groups(
|
||||
context_frames = int(detail["context_frames"])
|
||||
physical_seed = derive_refine_seed(int(refine_seed), group_index)
|
||||
group_seeds.append(physical_seed)
|
||||
upscale_seed = None
|
||||
conditioning_sources.append(conditioning_source)
|
||||
route_record = detail.get("reference_routing_v1")
|
||||
inheritance = (
|
||||
@@ -517,74 +514,27 @@ def run_second_pass_groups(
|
||||
"contract_sha256": route_record.get("sha256") if route_record is not None else None,
|
||||
})
|
||||
nested_latent = latent_builder(video_samples, audio_samples)
|
||||
if tiled_upscale_config is None:
|
||||
sample_arguments = dict(
|
||||
model=chunk_model,
|
||||
conditioning=conditioning,
|
||||
latent=nested_latent,
|
||||
sampler=sampler,
|
||||
sigmas=effective_sigmas,
|
||||
seed=physical_seed,
|
||||
enable_preview=bool(enable_preview),
|
||||
)
|
||||
if temporal_windows_by_group is not None:
|
||||
temporal_window = temporal_windows_by_group.get(group_index)
|
||||
if temporal_window is None:
|
||||
raise SecondPassContractError(
|
||||
f"selected physical group {group_index + 1} has no temporal window"
|
||||
)
|
||||
sample_arguments["temporal_window"] = temporal_window
|
||||
sampled = sample_fn(**sample_arguments)
|
||||
else:
|
||||
config = tiled_upscale_config
|
||||
native = config["native"]
|
||||
upscale_seed = derive_refine_seed(
|
||||
int(config.get("seed_base", physical_seed)), group_index
|
||||
)
|
||||
noise = _unwrap_single_output(
|
||||
config["random_noise"]().get_noise(upscale_seed), "RandomNoise"
|
||||
)
|
||||
upscale_sampler = config["sampler"]
|
||||
upscale_sigmas = config.get("sigmas")
|
||||
if upscale_sigmas is None:
|
||||
upscale_sigmas = _unwrap_single_output(
|
||||
config["scheduler"]().get_sigmas(
|
||||
chunk_model,
|
||||
config["scheduler_name"],
|
||||
config["steps"],
|
||||
config["denoise"],
|
||||
),
|
||||
"BasicScheduler",
|
||||
)
|
||||
native_kwargs = {
|
||||
"model": chunk_model,
|
||||
"conditioning": conditioning,
|
||||
"latent": nested_latent,
|
||||
"noise": noise,
|
||||
"sampler": upscale_sampler,
|
||||
"sigmas": upscale_sigmas,
|
||||
"cfg": config["cfg"],
|
||||
"latent_upscale_param": config["latent_upscale_param"],
|
||||
"temporal_split_param": config.get("temporal_split_param"),
|
||||
"spatial_split_param": config["spatial_split_param"],
|
||||
}
|
||||
if config.get("negative") is not None:
|
||||
native_kwargs["negative"] = config["negative"]
|
||||
native_result = _call_native(native, native_kwargs)
|
||||
if not isinstance(native_result, (tuple, list)) or not native_result:
|
||||
sample_arguments = dict(
|
||||
model=chunk_model,
|
||||
conditioning=conditioning,
|
||||
latent=nested_latent,
|
||||
sampler=sampler,
|
||||
sigmas=effective_sigmas,
|
||||
seed=physical_seed,
|
||||
enable_preview=bool(enable_preview),
|
||||
)
|
||||
if temporal_windows_by_group is not None:
|
||||
temporal_window = temporal_windows_by_group.get(group_index)
|
||||
if temporal_window is None:
|
||||
raise SecondPassContractError(
|
||||
f"tiled upscale returned no output for physical group {group_index + 1}"
|
||||
f"selected physical group {group_index + 1} has no temporal window"
|
||||
)
|
||||
sampled = native_result[0]
|
||||
sample_arguments["temporal_window"] = temporal_window
|
||||
sampled = sample_fn(**sample_arguments)
|
||||
refined_video, _temporary_audio = stream_extractor(sampled)
|
||||
if tiled_upscale_config is None:
|
||||
if tuple(refined_video.shape) != tuple(video_samples.shape):
|
||||
raise SecondPassContractError(
|
||||
f"refined video group {group_index} changed B/C/T/H/W geometry"
|
||||
)
|
||||
elif tuple(refined_video.shape[:3]) != tuple(video_samples.shape[:3]):
|
||||
if tuple(refined_video.shape) != tuple(video_samples.shape):
|
||||
raise SecondPassContractError(
|
||||
f"tiled upscale group {group_index} changed B/C/T geometry"
|
||||
f"refined video group {group_index} changed B/C/T/H/W geometry"
|
||||
)
|
||||
if not bool(torch.isfinite(refined_video.float()).all().item()):
|
||||
raise SecondPassContractError(
|
||||
@@ -604,17 +554,9 @@ def run_second_pass_groups(
|
||||
f"reference_inheritance={inheritance}, "
|
||||
f"physical_clip_index={physical_clip_index}, "
|
||||
f"context_frames={context_frames}, "
|
||||
f"refine_seed={physical_seed}, "
|
||||
f"upscale_seed={upscale_seed if upscale_seed is not None else 'n/a'}, "
|
||||
f"shape={tuple(refined_video.shape)}, "
|
||||
f"sampling_passes=1, tiled_upscale={tiled_upscale_config is not None}, "
|
||||
"temporary_audio_discarded=true"
|
||||
f"refine_seed={physical_seed}, shape={tuple(refined_video.shape)}, "
|
||||
"sampling_passes=1, temporary_audio_discarded=true"
|
||||
)
|
||||
if tiled_upscale_config is not None:
|
||||
group_report_lines.append(
|
||||
"tiled sigma source="
|
||||
f"{tiled_upscale_config.get('sigma_source', 'node_steps_fallback')}"
|
||||
)
|
||||
if adaptation_stats is not None:
|
||||
group_report_lines.append(
|
||||
"group "
|
||||
@@ -677,36 +619,11 @@ def run_second_pass_groups(
|
||||
|
||||
passthrough_audio = passthrough_audio_latents(audio_latents)
|
||||
updated_plan = prepared["updated_assembly_plan"]
|
||||
if tiled_upscale_config is not None:
|
||||
if selection_active:
|
||||
raise SecondPassContractError(
|
||||
"tiled upscale mode requires all physical groups; selective tiled "
|
||||
"upscale would produce mixed output geometry"
|
||||
)
|
||||
output_samples = _latent_samples(
|
||||
refined_videos[0], name="tiled refined video group 0"
|
||||
)
|
||||
target_height = int(output_samples.shape[-2]) * 16
|
||||
target_width = int(output_samples.shape[-1]) * 16
|
||||
updated_plan = copy.deepcopy(updated_plan)
|
||||
updated_plan["height"] = target_height
|
||||
updated_plan["width"] = target_width
|
||||
updated_plan["second_pass_contract"]["target_height"] = target_height
|
||||
updated_plan["second_pass_contract"]["target_width"] = target_width
|
||||
for group in updated_plan["second_pass_contract"]["physical_groups"]:
|
||||
group["target_latent_h"] = int(output_samples.shape[-2])
|
||||
group["target_latent_w"] = int(output_samples.shape[-1])
|
||||
group["target_height"] = target_height
|
||||
group["target_width"] = target_width
|
||||
contract = updated_plan["second_pass_contract"]
|
||||
if conditioning_sources and all(
|
||||
source == "refine_context" for source in conditioning_sources
|
||||
):
|
||||
contract["execution"] = (
|
||||
"context_aware_physical_groups_tiled_upscale_audio_locked_v1"
|
||||
if tiled_upscale_config is not None
|
||||
else "context_aware_physical_groups_audio_locked_v3"
|
||||
)
|
||||
contract["execution"] = "context_aware_physical_groups_audio_locked_v3"
|
||||
elif any(source == "refine_context" for source in conditioning_sources):
|
||||
contract["execution"] = "mixed_context_physical_groups_audio_locked_v3"
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user