Make videos on the computer you already own. FreeVideo runs MiniMax H3 in as little as 8 GB of VRAM and 16 GB of RAM, and adapts its acceleration path to your hardware.
Keep the first pass's planned partitions when a resource retry starts
Bowen Xue1dc635bb971a
diff --git a/freevideo_engine/generate.py b/freevideo_engine/generate.pyindex 93decbe..f1f0d06 100644--- a/freevideo_engine/generate.py+++ b/freevideo_engine/generate.py@@ -822,11 +822,20 @@ def _run(args):request['automatic_pass_cache'] and getattr(args, 'gpu_reserve_gib', None) is None)request['gpu_capacity_bytes'] = min(hardware.vram_total,int(args.vram_gib * 2**30) if args.vram_gib else hardware.vram_total)- if request['automatic_pass_cache']:- from .two_pass import first_pass_policy+ from .two_pass import clamp_first_pass_for_retry, first_pass_policy, keeps_first_pass_on_retry+ retry_keeps = (not args.profile and not request['automatic_pass_cache'] and keeps_first_pass_on_retry(+ report.get('resource_attempts'), getattr(args, 'resource_retries', 2)))+ if request['automatic_pass_cache'] or retry_keeps:first_policy = first_pass_policy(selected, canvas, sampling_plan)if first_policy is not None:first_policy['profile'], _ = apply_compatibility(first_policy['profile'], compatibility_state)+ if retry_keeps:+ # A recovery attempt narrows placement, not the first pass's arithmetic+ # partitions: keep those and never exceed what the retry frees.+ # With the pass cache off only the compute options (chunks, residual+ # offload, prefetch, recompute) take effect; the rest is diagnostic.+ first_policy, clamped = clamp_first_pass_for_retry(first_policy, selected)+ first_policy['retry_clamped'] = clampedrequest['first_pass_policy'] = first_policyreport['first_pass_policy'] = first_policyif resume_decode is not None:diff --git a/freevideo_engine/two_pass.py b/freevideo_engine/two_pass.pyindex 865a558..47c29f7 100644--- a/freevideo_engine/two_pass.py+++ b/freevideo_engine/two_pass.py@@ -358,3 +358,56 @@ def first_pass_policy(profile, canvas, sampling_plan):selected['engine']['steps'] = sampling_plan['base_steps']selected['policy']['engine']['steps'] = sampling_plan['base_steps']return dict(geometry=first, profile=selected)+++# Placement options a recovery attempt may have loosened or tightened. A first+# pass that is kept across a retry never uses more GPU residency, parallel+# workspaces or pinned host memory than the retry itself allows; its compute+# partitions (chunk sizes) are not in this list and stay as planned.+RETRY_MIN_KEYS = ('resident_blocks', 'head_parallelism', 'pin_host_gb')+RETRY_AND_KEYS = ('prefetch', 'pin_host_weights', 'preload_host')+RETRY_OR_KEYS = ('residual_offload', 'fp8_ff_recompute', 'stream_weights')+++def clamp_first_pass_for_retry(first_policy, retry_profile):+ """The first-pass policy limited to the placement a resource retry selected.++ Returns (policy, clamped) where `clamped` maps each option the retry+ tightened to its first-pass and retry values. The input is not modified.+ """+ import copy+ policy = copy.deepcopy(first_policy)+ engine, retry = policy['profile']['engine'], retry_profile['engine']+ clamped = {}+ def set_option(name, value):+ if engine.get(name) != value:+ clamped[name] = {'first_pass': engine.get(name), 'retry': retry.get(name)}+ engine[name] = value+ for name in RETRY_MIN_KEYS:+ if name in retry and name in engine:+ set_option(name, min(engine[name], retry[name]))+ for name in RETRY_AND_KEYS:+ if name in retry and name in engine:+ set_option(name, bool(engine[name] and retry[name]) if isinstance(engine[name], bool) else engine[name])+ for name in RETRY_OR_KEYS:+ if retry.get(name) and not engine.get(name):+ set_option(name, retry[name])+ inner = policy['profile'].get('policy')+ if isinstance(inner, dict) and isinstance(inner.get('engine'), dict):+ inner['engine'].update({name: engine[name] for name in clamped})+ return policy, clamped+++def keeps_first_pass_on_retry(attempts, max_retries):+ """Whether the retry now starting may keep the first pass's planned placement.++ Only the first recovery attempt does, and only while every recovery so far+ kept the arithmetic partitions. The last attempt falls back to the+ conservative profile exactly as before, so a first pass whose own chunk+ sizes were the cause cannot fail the request twice.+ """+ rows = list(attempts or [])+ if len(rows) != 2 or len(rows) - 1 >= max_retries:+ return False+ decision = rows[-1].get('decision') or {}+ return decision.get('numerical_class') != 'compute-partition'