Support per-chunk timeline durations
tests / test (push) Canceled after 0s
tests / windows-storage (push) Canceled after 0s

This commit is contained in:
2026-11-10 11:46:19 +00:00
parent 3716b02a57
commit 92135c0db0
13 changed files with 153 additions and 58 deletions
+2 -2
View File
@@ -137,7 +137,7 @@ class H3ContinuumSamplerV2:
"dynamicPrompts": True,
"tooltip": (
"Fixed: one prompt. List: separate chunks with a line containing ---. "
"Timeline: use [0-5s], [5-10s], ... or [Chunk 1] headers."
"Timeline: use [0-5s], [5-10s], ... for equal chunks, or use contiguous ranges such as [0-10s], [10-15s] for per-chunk durations."
),
},
),
@@ -393,7 +393,7 @@ class H3ContinuumSamplerV2:
chunk_seconds=float(chunk_seconds),
prompt_hashes=list(prompt_plan["hashes"]),
timeline_video_source=timeline_video_source,
),
) and len(set(prompt_plan.get("chunk_durations") or [float(chunk_seconds)] * int(chunks))) == 1,
mode="Custom",
selectors_by_slot=reference_routing_request.selectors_by_slot,
)
+42 -14
View File
@@ -143,7 +143,27 @@ def _parse_timeline(script,chunks,chunk_seconds,*,ignore_list_separators=False):
scored.sort(reverse=True,key=lambda row:(row[0],row[1])); selected=scored[0][2]; prompts.append(selected["prompt"]); previous_prompt=selected["prompt"]; previous_source=f"{selected['source']} at line {selected['line_number']}"
diagnostics.append({"level":"info","code":"H3C-P000","message":f"Chunk {chunk_index} source: {previous_source}"})
if len(scored)>1 and abs(scored[0][0]-scored[1][0])<1e-9: notes.append(f"chunk {chunk_index} had an equal-overlap timeline tie; used the earlier section")
return prompts,notes,diagnostics
time_sections = [item for item in sections if item["kind"] == "time"]
durations = None
if len(time_sections) >= chunks:
candidate = sorted(time_sections, key=lambda item: (item["start"], item["end"]))[:chunks]
contiguous = abs(candidate[0]["start"]) <= 1e-6 and all(
abs(candidate[index]["start"] - candidate[index - 1]["end"]) <= 1e-6
for index in range(1, len(candidate))
)
if contiguous:
durations = [round(item["end"] - item["start"], 6) for item in candidate]
if any(value < CHUNK_SECONDS_MIN or value > CHUNK_SECONDS_MAX for value in durations):
raise PromptPlanError(
f"timeline chunk durations must be between {CHUNK_SECONDS_MIN:.1f} and {CHUNK_SECONDS_MAX:.1f} seconds"
)
prompts = [item["prompt"] for item in candidate]
diagnostics.extend(
{"level": "info", "code": "H3C-P000", "message": f"Chunk {index + 1} source: {item['source']}"}
for index, item in enumerate(candidate)
)
notes.append("derived per-chunk durations from timeline headers")
return prompts,notes,diagnostics,durations
def _has_timeline_header(script):
return any(_TIMELINE_HEADER.match(line) or _CHUNK_HEADER.match(line) for line in str(script).splitlines())
def _has_list_separator(script):
@@ -168,28 +188,28 @@ def resolve_prompt_mode(mode,script):
def make_prompt_plan(*,mode,script,chunks,chunk_seconds):
chunks=int(chunks); chunk_seconds=float(chunk_seconds)
if not 1<=chunks<=16: raise PromptPlanError("chunks must be between 1 and 16")
if not CHUNK_SECONDS_MIN<=chunk_seconds<=CHUNK_SECONDS_MAX: raise PromptPlanError(f"chunk_seconds must be between {CHUNK_SECONDS_MIN:.1f} and {CHUNK_SECONDS_MAX:.1f}")
notes=[]; diagnostics=[]
if not CHUNK_SECONDS_MIN<=chunk_seconds<=CHUNK_SECONDS_MAX: raise PromptPlanError(f"chunk_seconds must be between {CHUNK_SECONDS_MIN:.1f} and {CHUNK_SECONDS_MAX:.1f}")
notes=[]; diagnostics=[]; durations=[chunk_seconds]*chunks
try:
resolved_mode=resolve_prompt_mode(mode,script)
if mode==PROMPT_FORMAT_AUTO:
detected={PROMPT_MODE_FIXED:PROMPT_FORMAT_FIXED,PROMPT_MODE_LIST:PROMPT_FORMAT_LIST,PROMPT_MODE_TIMELINE:PROMPT_FORMAT_TIMELINE}[resolved_mode]; notes.append(f"Auto detected {detected}")
if resolved_mode==PROMPT_MODE_FIXED: prompt=_normalize_prompt(script,label="fixed prompt"); prompts=[prompt]*chunks
if resolved_mode==PROMPT_MODE_FIXED: prompt=_normalize_prompt(script,label="fixed prompt"); prompts=[prompt]*chunks; durations=[chunk_seconds]*chunks
elif resolved_mode==PROMPT_MODE_LIST:
prompts,parse_notes,list_sources=_parse_list(script,chunks); notes.extend(parse_notes)
if _has_timeline_header(script):
diagnostics.append(_mixed_syntax_diagnostic(timeline_active=False))
diagnostics.extend({"level":"info","code":"H3C-P000","message":f"Chunk {index+1} source: List section {source}"} for index,source in enumerate(list_sources))
elif resolved_mode==PROMPT_MODE_TIMELINE:
mixed_syntax=_has_list_separator(script)
prompts,parse_notes,diagnostics=_parse_timeline(script,chunks,chunk_seconds,ignore_list_separators=mixed_syntax); notes.extend(parse_notes)
elif resolved_mode==PROMPT_MODE_TIMELINE:
mixed_syntax=_has_list_separator(script)
prompts,parse_notes,diagnostics,durations=_parse_timeline(script,chunks,chunk_seconds,ignore_list_separators=mixed_syntax); notes.extend(parse_notes)
if mixed_syntax: diagnostics.insert(0,_mixed_syntax_diagnostic(timeline_active=True))
else: raise PromptPlanError(f"unknown prompt mode: {resolved_mode!r}")
except (PromptPlanError,TypeError,ValueError) as exc:
resolved_mode=PROMPT_MODE_FIXED; prompts=[_normalize_prompt(script,label="fixed prompt")]*chunks
resolved_mode=PROMPT_MODE_FIXED; prompts=[_normalize_prompt(script,label="fixed prompt")]*chunks; durations=[chunk_seconds]*chunks
notes.append("Prompt syntax was not recognized; used Fixed prompt fallback")
diagnostics=[{"level":"warning","code":"H3C-P100","message":str(exc)}]
result={"magic":PROMPT_PLAN_MAGIC,"schema_version":PROMPT_PLAN_SCHEMA_VERSION,"mode":resolved_mode,"chunks":chunks,"chunk_seconds":chunk_seconds,"prompts":prompts,"hashes":[prompt_hash(p) for p in prompts],"notes":notes}
result={"magic":PROMPT_PLAN_MAGIC,"schema_version":PROMPT_PLAN_SCHEMA_VERSION,"mode":resolved_mode,"chunks":chunks,"chunk_seconds":chunk_seconds,"chunk_durations":durations,"prompts":prompts,"hashes":[prompt_hash(p) for p in prompts],"notes":notes}
if diagnostics: result["diagnostics"]=diagnostics
return result
def validate_prompt_plan(plan):
@@ -197,9 +217,14 @@ def validate_prompt_plan(plan):
if int(plan.get("schema_version",-1))!=PROMPT_PLAN_SCHEMA_VERSION: raise PromptPlanError(f"unsupported prompt-plan schema {plan.get('schema_version')}; expected {PROMPT_PLAN_SCHEMA_VERSION}")
chunks=int(plan.get("chunks",0)); prompts=plan.get("prompts"); hashes=plan.get("hashes")
if not 1<=chunks<=16: raise PromptPlanError("prompt-plan chunks are invalid")
try: chunk_seconds=float(plan.get("chunk_seconds"))
try: chunk_seconds=float(plan.get("chunk_seconds"))
except (TypeError,ValueError): raise PromptPlanError("prompt-plan chunk_seconds is invalid") from None
if not CHUNK_SECONDS_MIN<=chunk_seconds<=CHUNK_SECONDS_MAX: raise PromptPlanError(f"prompt-plan chunk_seconds must be between {CHUNK_SECONDS_MIN:.1f} and {CHUNK_SECONDS_MAX:.1f}")
if not CHUNK_SECONDS_MIN<=chunk_seconds<=CHUNK_SECONDS_MAX: raise PromptPlanError(f"prompt-plan chunk_seconds must be between {CHUNK_SECONDS_MIN:.1f} and {CHUNK_SECONDS_MAX:.1f}")
durations=plan.get("chunk_durations")
if durations is None: durations=[chunk_seconds]*chunks
if not isinstance(durations,list) or len(durations)!=chunks: raise PromptPlanError("prompt-plan chunk duration count does not match chunks")
durations=[float(value) for value in durations]
if any(value<CHUNK_SECONDS_MIN or value>CHUNK_SECONDS_MAX for value in durations): raise PromptPlanError("prompt-plan contains an invalid chunk duration")
if not isinstance(prompts,list) or len(prompts)!=chunks: raise PromptPlanError("prompt-plan prompt count does not match chunks")
if not isinstance(hashes,list) or len(hashes)!=chunks: raise PromptPlanError("prompt-plan hash count does not match chunks")
for index,prompt in enumerate(prompts):
@@ -207,7 +232,8 @@ def validate_prompt_plan(plan):
if hashes[index]!=prompt_hash(prompt): raise PromptPlanError(f"prompt-plan hash mismatch at chunk {index+1}")
diagnostics=plan.get("diagnostics")
if diagnostics is not None and (not isinstance(diagnostics,list) or not all(isinstance(item,dict) for item in diagnostics)): raise PromptPlanError("prompt-plan diagnostics are invalid")
return plan
plan["chunk_durations"]=durations
return plan
def build_sampler_prompt_plan(*,prompt_mode,prompt_script,sequence_prompt,prompt_plan,chunks,chunk_seconds):
chunks=int(chunks); chunk_seconds=float(chunk_seconds)
if sequence_prompt is not None: return make_prompt_plan(mode=prompt_mode,script=sequence_prompt,chunks=chunks,chunk_seconds=chunk_seconds)
@@ -216,7 +242,8 @@ def build_sampler_prompt_plan(*,prompt_mode,prompt_script,sequence_prompt,prompt
prompts=list(plan["prompts"])
if len(prompts)<chunks: prompts.extend([prompts[-1] if prompts else ""]*(chunks-len(prompts)))
elif len(prompts)>chunks: prompts=prompts[:chunks]
result=dict(plan); result["chunks"]=chunks; result["chunk_seconds"]=chunk_seconds; result["prompts"]=prompts; result["hashes"]=[prompt_hash(p) for p in prompts]
result=dict(plan); result["chunks"]=chunks; result["chunk_seconds"]=chunk_seconds; result["chunk_durations"]=list(plan.get("chunk_durations") or [chunk_seconds]*int(plan["chunks"]))[:chunks]; result["prompts"]=prompts; result["hashes"]=[prompt_hash(p) for p in prompts]
if len(result["chunk_durations"])<chunks: result["chunk_durations"].extend([chunk_seconds]*(chunks-len(result["chunk_durations"])))
if int(plan["chunks"])!=chunks or abs(float(plan["chunk_seconds"])-chunk_seconds)>1e-6: result["notes"]=list(plan.get("notes") or [])+["adapted connected prompt plan to Sampler chunk settings"]
return validate_prompt_plan(result)
return make_prompt_plan(mode=prompt_mode,script=prompt_script,chunks=chunks,chunk_seconds=chunk_seconds)
@@ -230,7 +257,8 @@ def apply_prompt_overrides(plan,overrides):
return validate_prompt_plan(result)
def prompt_plan_report(plan):
plan=validate_prompt_plan(plan); unique=len(set(plan["hashes"])); note="; ".join(plan.get("notes") or [])
result=f"Prompt plan: {plan['mode']}; {plan['chunks']} chunks; {unique} unique prompt(s); {plan['chunk_seconds']:.3f}s per chunk."
durations=plan.get("chunk_durations") or [plan["chunk_seconds"]]*plan["chunks"]
result=f"Prompt plan: {plan['mode']}; {plan['chunks']} chunks; durations [{', '.join(f'{value:g}s' for value in durations)}]; total {sum(durations):g}s; {unique} unique prompt(s)."
if note: result+=" "+note+"."
diagnostics=list(plan.get("diagnostics") or [])
if not diagnostics: return result+"\nPrompt Preflight: OK."
+28 -17
View File
@@ -80,26 +80,35 @@ def _record_context_diagnostics(*,tracker,reports,state,continuity,reused):
except Exception as exc:
reports.append(f"context diagnostics source chunk {state.get('clip_index','?')}: unavailable ({exc})")
def _check_decode_memory_budget(*,width,height,chunks,chunk_seconds):
target_frames=max(1,int(round(chunks*chunk_seconds*FPS))); max_chunk_frames=max(5,int(round(chunk_seconds*FPS))+39)
def _check_decode_memory_budget(*,width,height,total_seconds,max_chunk_seconds):
target_frames=max(1,int(round(total_seconds*FPS))); max_chunk_frames=max(5,int(round(max_chunk_seconds*FPS))+39)
image_bytes=target_frames*width*height*3*4; transient_bytes=max_chunk_frames*width*height*3*4
required_bytes=image_bytes+int(transient_bytes*1.5)+1*1024**3; estimate_gib=required_bytes/1024**3; available_gib=None
try:
import psutil
available=int(psutil.virtual_memory().available); available_gib=available/1024**3
except ImportError: pass
return estimate_gib,available_gib
return estimate_gib,available_gib
def _plan_durations(plan: dict[str, Any]) -> list[float]:
chunks = int(plan["chunks"])
fallback = float(plan["chunk_seconds"])
values = plan.get("chunk_durations") or [fallback] * chunks
if len(values) != chunks:
raise SequenceRuntimeError("prompt plan duration count does not match chunks")
return [float(value) for value in values]
def _clone_entry_for_reuse(entry):
entry=validate_chunk_entry(entry); result=dict(entry); result["plan"]=copy.deepcopy(entry["plan"]); result["reused"]=True; return result
def _preserved_prefix(*,session,prompt_hashes,chunks,reroll_from_chunk,width,height,chunk_seconds,identity_hash,last_frame_hash,reference_storage_plan=None):
def _preserved_prefix(*,session,prompt_hashes,chunks,reroll_from_chunk,width,height,chunk_seconds,chunk_durations,identity_hash,last_frame_hash,reference_storage_plan=None):
if session is None: return [],[]
notes=[]
try: session=validate_session(session)
except SessionValidationError as exc: return [],[f"saved session was ignored; generated a fresh run ({exc})"]
if int(session["width"])!=int(width) or int(session["height"])!=int(height): return [],["saved session resolution differs; generated a fresh run"]
if abs(float(session["chunk_seconds"])-float(chunk_seconds))>1e-6: return [],["saved session chunk duration differs; generated a fresh run"]
saved_durations=session.get("chunk_durations") or [float(session["chunk_seconds"])]*len(session["chunks"])
if len(saved_durations)!=len(chunk_durations) or any(abs(float(a)-float(b))>1e-6 for a,b in zip(saved_durations,chunk_durations)): return [],["saved session chunk durations differ; generated a fresh run"]
if str(session.get("identity_hash","none"))!=str(identity_hash): return [],["saved session identity differs; generated a fresh run"]
routed_limit=None
if reference_storage_plan is not None:
@@ -526,8 +535,8 @@ def _run_runtime_internal(*,model:Any,clip:Any,video_vae:Any,audio_vae:Any,sampl
if memory_collector is not None:
from ..v3.memory_attribution import capture_attribution_fail_soft
capture_memory=capture_attribution_fail_soft
plan=validate_prompt_plan(prompt_plan); chunks=int(plan["chunks"]); chunk_seconds=float(plan["chunk_seconds"]); prompts=list(plan["prompts"]); prompt_hashes=list(plan["hashes"]); width,height=int(width),int(height)
visible_target_frames=int(round(chunks*chunk_seconds*FPS))
plan=validate_prompt_plan(prompt_plan); chunks=int(plan["chunks"]); chunk_seconds=float(plan["chunk_seconds"]); durations=_plan_durations(plan); prompts=list(plan["prompts"]); prompt_hashes=list(plan["hashes"]); width,height=int(width),int(height)
visible_target_frames=int(round(sum(durations)*FPS))
validate_guide_visible_range(guide_source,target_frames=visible_target_frames)
continuation_transport=str(continuation_transport)
if continuation_transport not in CONTINUATION_TRANSPORTS:
@@ -572,11 +581,11 @@ def _run_runtime_internal(*,model:Any,clip:Any,video_vae:Any,audio_vae:Any,sampl
)
timeline_video_warning=validate_timeline_video_prompts(prompts,timeline_video_source)
decode_estimate_gib=0.0; available_ram_gib=None
if not latent_only: decode_estimate_gib,available_ram_gib=_check_decode_memory_budget(width=width,height=height,chunks=chunks,chunk_seconds=chunk_seconds)
if not latent_only: decode_estimate_gib,available_ram_gib=_check_decode_memory_budget(width=width,height=height,total_seconds=sum(durations),max_chunk_seconds=max(durations))
issues=check_comfy_h3_runtime()
assets=prepare_identity_assets(video_vae,width=width,height=height,first_frame=first_frame,last_frame=last_frame,encode_latents=False)
multi_chunk_flf=bool(chunks>=2 and first_frame is not None and last_frame is not None)
terminal_merge_enabled=_terminal_flf_merge_enabled(multi_chunk_flf=multi_chunk_flf,chunks=chunks,chunk_seconds=chunk_seconds,prompt_hashes=prompt_hashes,timeline_video_source=timeline_video_source)
terminal_merge_enabled=_terminal_flf_merge_enabled(multi_chunk_flf=multi_chunk_flf,chunks=chunks,chunk_seconds=chunk_seconds,prompt_hashes=prompt_hashes,timeline_video_source=timeline_video_source) and len(set(durations)) == 1
if _reference_routing_runtime is not None:
try:
_reference_routing_runtime.check_physical_contract(
@@ -669,7 +678,7 @@ def _run_runtime_internal(*,model:Any,clip:Any,video_vae:Any,audio_vae:Any,sampl
except Exception as exc:
adaptive_observer_unavailable=f"{type(exc).__name__}: {exc}"
effective_reroll_from_chunk=0 if storage_controller is not None and session is not None and bool((session.get("settings") or {}).get("run_storage_validated_prefix")) else int(reroll_from_chunk)
preserved,reuse_notes=_preserved_prefix(session=session,prompt_hashes=prompt_hashes,chunks=chunks,reroll_from_chunk=effective_reroll_from_chunk,width=width,height=height,chunk_seconds=chunk_seconds,identity_hash=sequence_identity_hash,last_frame_hash=assets.last_frame_hash,reference_storage_plan=reference_storage_plan)
preserved,reuse_notes=_preserved_prefix(session=session,prompt_hashes=prompt_hashes,chunks=chunks,reroll_from_chunk=effective_reroll_from_chunk,width=width,height=height,chunk_seconds=chunk_seconds,chunk_durations=durations,identity_hash=sequence_identity_hash,last_frame_hash=assets.last_frame_hash,reference_storage_plan=reference_storage_plan)
if _terminal_strategy_mismatch(session,merge_enabled=terminal_merge_enabled):
preserved=[]
reuse_notes.append("FLF chunk contract changed; regenerated the requested FLF sequence.")
@@ -941,7 +950,7 @@ def _run_runtime_internal(*,model:Any,clip:Any,video_vae:Any,audio_vae:Any,sampl
capture_memory(memory_collector, "finish_phase", phase="conditioning_prompt_clip")
if memory_collector is not None:
capture_memory(memory_collector, "finish_phase", phase="conditioning")
initial_frame_count=align_frame_count_up(int(round(chunk_seconds*FPS))); retained_frames=sum(int(entry["plan"]["net_frames"]) for entry in entries); sampling_reports=[]
retained_frames=sum(int(entry["plan"]["net_frames"]) for entry in entries); sampling_reports=[]
context_diagnostics=ContextDiagnosticsTracker() if bool(debug) else None
if context_diagnostics is not None:
if entries:
@@ -982,6 +991,8 @@ def _run_runtime_internal(*,model:Any,clip:Any,video_vae:Any,audio_vae:Any,sampl
if memory_collector is not None:
capture_memory(memory_collector, "finish_phase", phase="preparation")
for sequence_index in normal_indices:
chunk_seconds_for_chunk=durations[sequence_index]
initial_frame_count=align_frame_count_up(int(round(chunk_seconds_for_chunk*FPS)))
reusing_group=sequence_index<reused_count
if memory_collector is not None:
capture_memory(memory_collector, "start_phase", phase="group_prepare", physical_group=sequence_index+1, logical_chunks=(sequence_index+1,))
@@ -1044,9 +1055,9 @@ def _run_runtime_internal(*,model:Any,clip:Any,video_vae:Any,audio_vae:Any,sampl
physical_group=sequence_index+1,
)
conditioning=attach_keyframes(chunk_cache[conditioning_key],frame_count=total_frames,first_latent=chunk_assets.first_latent,last_latent=chunk_assets.last_latent if include_chunk_last else None); clip_index=1; context_frames=0
chunk_plan=make_plan(continuation=False,clip_index=clip_index,total_frames=total_frames,trim_frames=0,width=width,height=height,context_frames=5,state_capacity_frames=largest_context_capacity(total_frames),requested_extend_seconds=chunk_seconds,debug=debug); reason="initial clip"
chunk_plan=make_plan(continuation=False,clip_index=clip_index,total_frames=total_frames,trim_frames=0,width=width,height=height,context_frames=5,state_capacity_frames=largest_context_capacity(total_frames),requested_extend_seconds=chunk_seconds_for_chunk,debug=debug); reason="initial clip"
else:
context_frames,motion_score,reason=choose_context_frames(continuity,previous_state); desired_cumulative=int(round((sequence_index+1)*chunk_seconds*FPS)); requested_new_frames=max(1,desired_cumulative-retained_frames); shape=make_extension_shape(context_frames,requested_new_frames/FPS); latent=empty_h3_latent(width,height,shape.total_frames)
context_frames,motion_score,reason=choose_context_frames(continuity,previous_state); desired_cumulative=int(round(sum(durations[:sequence_index+1])*FPS)); requested_new_frames=max(1,desired_cumulative-retained_frames); shape=make_extension_shape(context_frames,requested_new_frames/FPS); latent=empty_h3_latent(width,height,shape.total_frames)
include_chunk_last=bool(last_frame is not None and is_final)
conditioning_key=_conditioning_cache_key(prompt,include_last=include_chunk_last,reference_assets=reference_assets)
if following_video:
@@ -1100,7 +1111,7 @@ def _run_runtime_internal(*,model:Any,clip:Any,video_vae:Any,audio_vae:Any,sampl
video_context,audio_context,grid_offset=select_context(previous_state,context_frames,include_audio=bool(audio_continuity)); context_before=context_fingerprint(video_context,audio_context)
conditioning=prepare_conditioning(base_conditioning,video_context=video_context,audio_context=audio_context,audio_grid_offset=grid_offset,context_frames=context_frames,new_frame_count=shape.total_frames,first_frame_policy=POLICY_REPLACE,preserve_last_frame=True)
context_interop_emitted=True
clip_index=int(previous_state["clip_index"])+1; chunk_plan=make_plan(continuation=True,clip_index=clip_index,total_frames=shape.total_frames,trim_frames=context_frames,width=width,height=height,context_frames=context_frames,state_capacity_frames=largest_context_capacity(shape.net_new_frames),requested_extend_seconds=chunk_seconds,debug=debug)
clip_index=int(previous_state["clip_index"])+1; chunk_plan=make_plan(continuation=True,clip_index=clip_index,total_frames=shape.total_frames,trim_frames=context_frames,width=width,height=height,context_frames=context_frames,state_capacity_frames=largest_context_capacity(shape.net_new_frames),requested_extend_seconds=chunk_seconds_for_chunk,debug=debug)
if follow_slice_contract is not None:
chunk_plan[FOLLOW_PLAN_KEY] = follow_slice_contract
if adaptive_observer_event is not None and not reusing_group:
@@ -1673,7 +1684,7 @@ def _run_runtime_internal(*,model:Any,clip:Any,video_vae:Any,audio_vae:Any,sampl
if timeline_video_source is not None: settings["timeline_video_contract"]=timeline_video_source.contract
if guide_source is not None: settings["guide_contract"]=dict(guide_source.contract)
if reference_storage_plan is not None: settings["reference_routing_v1"]=routed_session_settings
new_session=make_session(chunks=entries,width=width,height=height,chunk_seconds=chunk_seconds,identity_hash=sequence_identity_hash,model_fingerprint_value=current_model_fingerprint,parent_session_id=parent_id,reroll_from_chunk=int(reroll_from_chunk),settings=settings)
new_session=make_session(chunks=entries,width=width,height=height,chunk_seconds=chunk_seconds,chunk_durations=durations,identity_hash=sequence_identity_hash,model_fingerprint_value=current_model_fingerprint,parent_session_id=parent_id,reroll_from_chunk=int(reroll_from_chunk),settings=settings)
report_lines=[f"H3 Continuum V3 {PACKAGE_VERSION}",f"Conditioning mode: {conditioning_display}.",prompt_plan_report(plan),"Decode: external ComfyUI Core VAE nodes; full raw AV chunks retained.",accelerators,"Execution: conditioning precomputed; single call-local MODEL clone per chunk; no internal VAE decode.",*reuse_notes,*routing_warnings]
if max_new_physical_groups is not None:
report_lines.append(
@@ -1726,14 +1737,14 @@ def _run_runtime_internal(*,model:Any,clip:Any,video_vae:Any,audio_vae:Any,sampl
else: images,audio,decode_reports=decode_sequence_with_seam(entries=entries,video_vae=video_vae,audio_vae=audio_vae,diagnostics_mode=diagnostics_mode,automatic=seam_correction==SEAM_CORRECTION_AUTO)
duration_report=""
if exact_total_duration:
target_frames=int(round(chunks*chunk_seconds*FPS)); images,audio,duration_report=enforce_total_frames(images,audio,target_frames=target_frames,preserve_final_frame=last_frame is not None)
target_frames=int(round(sum(durations)*FPS)); images,audio,duration_report=enforce_total_frames(images,audio,target_frames=target_frames,preserve_final_frame=last_frame is not None)
last_state=entry_to_state(entries[-1]); parent_id=session.get("session_id") if session is not None else None
settings={"continuity":continuity,"audio_continuity":bool(audio_continuity),"exact_total_duration":bool(exact_total_duration),"prompt_mode":plan["mode"],"base_seed":int(base_seed),"reroll_nonce":int(reroll_nonce),"diagnostics_mode":diagnostics_mode,"initial_state_source":initial_state is not None,"first_frame_hash":assets.first_frame_hash,"last_frame_hash":assets.last_frame_hash,"reference_contract":reference_assets.contract if reference_assets is not None else None}
if multi_chunk_flf: settings["flf_execution"]=FLF_STRATEGY
if continuation_transport!=REFERENCE_CONTEXT_V1: settings["continuation_transport"]=continuation_transport
if guide_source is not None: settings["guide_contract"]=dict(guide_source.contract)
if reference_storage_plan is not None: settings["reference_routing_v1"]=routed_session_settings
new_session=make_session(chunks=entries,width=width,height=height,chunk_seconds=chunk_seconds,identity_hash=sequence_identity_hash,model_fingerprint_value=current_model_fingerprint,parent_session_id=parent_id,reroll_from_chunk=int(reroll_from_chunk),settings=settings)
new_session=make_session(chunks=entries,width=width,height=height,chunk_seconds=chunk_seconds,chunk_durations=durations,identity_hash=sequence_identity_hash,model_fingerprint_value=current_model_fingerprint,parent_session_id=parent_id,reroll_from_chunk=int(reroll_from_chunk),settings=settings)
decoded_gib=float(images.shape[0])*float(width)*float(height)*3.0*4.0/(1024.0**3)
report_lines=[f"H3 Continuum V2 {PACKAGE_VERSION}",prompt_plan_report(plan),f"Seam correction: {seam_correction}.",accelerators,"Execution: conditioning precomputed; single call-local MODEL clone per chunk; decode deferred until sampling completed.",*reuse_notes,*routing_warnings]
if diagnostics_mode!=DIAGNOSTICS_OFF: report_lines.extend([f"Decode RAM estimate: {decode_estimate_gib:.2f} GiB including transient headroom"+(f"; available at start {available_ram_gib:.2f} GiB." if available_ram_gib is not None else "."),*sampling_reports,*decode_reports])
+5
View File
@@ -129,6 +129,7 @@ def make_session(
width: int,
height: int,
chunk_seconds: float,
chunk_durations: list[float] | None = None,
identity_hash: str,
model_fingerprint_value: str,
parent_session_id: str | None,
@@ -154,6 +155,7 @@ def make_session(
"width": int(width),
"height": int(height),
"chunk_seconds": float(chunk_seconds),
"chunk_durations": [float(value) for value in (chunk_durations or [chunk_seconds] * len(normalized))],
"identity_hash": str(identity_hash),
"model_fingerprint": str(model_fingerprint_value),
"settings": copy.deepcopy(settings),
@@ -173,6 +175,9 @@ def validate_session(session: dict[str, Any]) -> dict[str, Any]:
raise SessionValidationError("session dimensions are invalid")
if float(session.get("chunk_seconds", 0.0)) <= 0:
raise SessionValidationError("session chunk_seconds is invalid")
durations=session.get("chunk_durations")
if durations is not None and (not isinstance(durations,list) or len(durations)!=len(session.get("chunks") or [])):
raise SessionValidationError("session chunk_durations are invalid")
chunks = session.get("chunks")
if not isinstance(chunks, list) or not chunks:
raise SessionValidationError("session contains no chunks")