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.
Decoder read-ahead on Windows follows physical RAM and starts earlier on slow drives
Bowen Xueeb50c374ee0e
diff --git a/freevideo_engine/decode_prefetch.py b/freevideo_engine/decode_prefetch.pyindex aca8b57..1fbeb57 100644--- a/freevideo_engine/decode_prefetch.py+++ b/freevideo_engine/decode_prefetch.py@@ -20,11 +20,32 @@ guard."""import jsonimport os+import sysfrom pathlib import Pathimport threadingimport time-from .encoder_prewarm import CHUNK, GiB, available_memory+from .encoder_prewarm import CHUNK, GiB, available_memory as host_available_memory, cgroup_memory+++def available_memory():+ """Memory the file cache may use for this read: physical RAM, not commit.++ Pages read through a reused buffer sit in the OS file cache. They are+ reclaimable and add nothing to the commit charge, so on Windows the commit+ headroom (which pinned weights and sampling may have used up) is no bound+ here. The cgroup limit on Linux and the system reserve still apply.+ """+ available, complete = host_available_memory()+ try:+ from .system import system_memory+ physical = system_memory().get('physical_available_bytes')+ except Exception:+ physical = None+ if sys.platform == 'win32' and type(physical) is int:+ group = cgroup_memory().get('available_bytes')+ available = physical if group is None else min(physical, group)+ return available, completedef decoder_ranges(base):@@ -61,12 +82,30 @@ class DecoderReadAhead:self.ram_budget_bytes = ram_budget_bytesself.budget_is_estimate = bool(budget_is_estimate)self.drive_idle = False+ self.load_read_rate = None+ self.total_bytes = Noneself.cancelled = threading.Event()self.thread = Noneself.result = dict(state='not-started', read_bytes=0, elapsed_seconds=0.,gpu_allocation_bytes=0, private_buffer_bytes=CHUNK,scope='Decoder-only checkpoint pages; reclaimable OS cache, no GPU residency')+ # Reading from the start of sampling matters only when the drive is too+ # slow to finish in the last two steps. The rate is what the model load+ # measured; unknown (a resident model read nothing) keeps the last two steps.+ EARLY_MARGIN = 1.25++ def due(self, remaining_seconds):+ rate = self.load_read_rate+ if self.thread is not None or not rate or rate <= 0 or remaining_seconds is None:+ return False+ if self.total_bytes is None:+ try:+ self.total_bytes = sum(hi - lo for _, spans, _ in decoder_ranges(self.base) for lo, hi in spans)+ except Exception:+ self.total_bytes = 0+ return self.total_bytes > 0 and self.total_bytes / rate * self.EARLY_MARGIN >= remaining_seconds+def start(self, *, drive_idle=False):if self.thread is not None:returndiff --git a/freevideo_engine/runtime.py b/freevideo_engine/runtime.pyindex 26ea87a..3c21b35 100644--- a/freevideo_engine/runtime.py+++ b/freevideo_engine/runtime.py@@ -780,6 +780,15 @@ class Engine:step_callback(value)if active_steps > 1 and len(self) == prefetch_step:trigger_prefetch()+ elif active_steps > 1 and 1 < len(self) < prefetch_step and owner.drive_idle:+ # A drive too slow to read the decoder in the last two steps+ # starts sooner. The first step carries compilation, so the+ # remaining time comes from the steps after it.+ due = getattr(final_step_callback, 'due', None)+ if due is not None and prefetch_timing['trigger_step'] is None:+ steady = list(self)[1:]+ if due(sum(steady) / len(steady) * (active_steps - len(self))):+ trigger_prefetch()owner = selfstep_seconds = StepTimes()diff --git a/freevideo_engine/worker.py b/freevideo_engine/worker.pyindex b79bbaf..f190ad3 100644--- a/freevideo_engine/worker.py+++ b/freevideo_engine/worker.py@@ -267,6 +267,8 @@ def generate(request, resident=None):metrics['latent_reload_seconds'] = time.perf_counter() - tickmetrics['transformer_released_before_decode'] = resident is None or not resident.engine_on_gpu()else:+ from .sampling_memory import SamplingMemory as _Counters+ load_read_start = _Counters.process_counters().get('read_bytes')tick = time.perf_counter()# Windows charges the allocator room still to be reserved to commit;# the engine keeps that room out of its locked weights.@@ -279,6 +281,8 @@ def generate(request, resident=None):'epoch': time.time(), 'seconds': time.perf_counter() - started}), flush=True)engine, reused = resident.engine(request, factory) if resident is not None else (factory(), False)loaded_seconds = time.perf_counter() - tick+ load_read_end = _Counters.process_counters().get('read_bytes')+ load_read_bytes = (load_read_end - load_read_start) if all(isinstance(v, (int, float)) for v in (load_read_start, load_read_end)) else Nonemetrics.update(config=dict(engine.config), load_seconds=loaded_seconds,resident_engine_cache_hit=reused,load_breakdown=({'resident_lookup_seconds': loaded_seconds} if reused else engine.load_breakdown), phase='sample',@@ -303,6 +307,11 @@ def generate(request, resident=None):def read_decoder_ahead():# Every offloaded layer in memory and none read in the last step.decode_read_ahead.start(drive_idle=getattr(engine, 'drive_idle', False) is True)+ if hasattr(decode_read_ahead, 'due'):+ read_decoder_ahead.due = decode_read_ahead.due+ if not reused and isinstance(load_read_bytes, (int, float)) and loaded_seconds > 0:+ decode_read_ahead.load_read_rate = load_read_bytes / loaded_seconds+ decode_read_ahead.result['load_read_bytes_per_second'] = round(decode_read_ahead.load_read_rate)from .sampling_memory import SamplingMemorymemory_diagnostics = SamplingMemory(torch, Path(request['output']).with_suffix('.sampling-memory.json')).start()from . import frame_preview