Skip to content

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.

Background kernel compile starts about 5 seconds after ComfyUI opens when none is on record for...

Bowen Xuefbe6aa55c185
diff --git a/freevideo_engine/background_compile.py b/freevideo_engine/background_compile.py
index 3b6b998..377c09a 100644
--- a/freevideo_engine/background_compile.py
+++ b/freevideo_engine/background_compile.py
@@ -3,7 +3,8 @@
The first request after an update, a repair, a new installation or a GPU
driver update compiles its kernels; on a 12 GB Windows laptop that cost 50 s of
a 564 s request. Nobody waits for this compile here. Once ComfyUI has had no
-work for START_DELAY seconds, precompile runs at the lowest CPU and disk
+work for START_DELAY seconds (OWED_DELAY when no compile is on record for this
+installation), precompile runs at the lowest CPU and disk
priority. A queued prompt stops it within POLL seconds, and a generation, a
prompt rewrite or a calibration stops it before taking the GPU. Kernels
compiled by then stay in the caches, and the request compiles the rest as it
@@ -25,6 +26,9 @@ from . import processes
from .long_paths import io_path
START_DELAY = 30.
+# A compile that is owed (nothing compiled yet for this code, driver or GPU)
+# starts this soon after ComfyUI loads, before the user's first request.
+OWED_DELAY = 5.
MAX_DELAY = 600.
POLL = .25
# Longer than the Linux supervisor takes to end every descendant (4.5 s):
@@ -37,6 +41,27 @@ RELEASE_SECONDS = 15.
ATTEMPTS = 8
+def compile_owed(root):
+ """True when no finished compile on record matches this installation's code.
+
+ Reads only the receipt and the compute sources, without tensors or a GPU
+ query; the compile itself decides again with the full identity, so a wrong
+ "owed" costs one early start that ends at once with the receipt's skip.
+ """
+ import json
+ try:
+ previous = json.loads((Path(root) / 'precompile.json').read_text(encoding='utf-8'))
+ identity = previous['identity']
+ if not previous.get('success') or not identity:
+ return True
+ from .tuning import COMPUTE_FILES, digest
+ package = Path(__file__).parent
+ return (identity.get('source_sha256') != {name: digest(package / name) for name in COMPUTE_FILES}
+ or identity.get('dependency_manifest_sha256') != digest(package / 'dependencies.json'))
+ except Exception:
+ return True
+
+
class BackgroundCompile:
def __init__(self):
self.guard = threading.Lock()
@@ -112,9 +137,12 @@ class BackgroundCompile:
return True
def _work(self, command, environment, cwd, log, busy, delay):
+ # The first wait may be shorter than the retry backoff, which always
+ # starts from START_DELAY: a stopped or crowded-out run is not hammered.
+ pause = START_DELAY
for attempt in range(ATTEMPTS):
if attempt:
- delay = min(2 * delay, MAX_DELAY)
+ pause = delay = min(2 * pause, MAX_DELAY)
if not self._quiet(busy, delay):
return
with self.guard:
diff --git a/freevideo_engine/comfy_nodes.py b/freevideo_engine/comfy_nodes.py
index 06f103a..c217c4c 100644
--- a/freevideo_engine/comfy_nodes.py
+++ b/freevideo_engine/comfy_nodes.py
@@ -439,7 +439,7 @@ def start_background_compile():
"""Compile recent request shapes once this session is idle; see background_compile."""
import os
from server import PromptServer
- from .background_compile import COMPILE
+ from .background_compile import COMPILE, OWED_DELAY, START_DELAY, compile_owed
if os.environ.get('FREEVIDEO_BACKGROUND_COMPILE', 'auto').lower() in ('0', 'off', 'false'):
return False
root, machine = comfy_bridge.installation()
@@ -455,7 +455,8 @@ def start_background_compile():
return COMPILE.start([machine['python'], '-B', '-m', 'freevideo_engine.precompile',
'--config', str(root / 'machine.json'), '--background'],
environment=environment, cwd=str(source), log=root / 'precompile.log',
- lock=environment.get('FREEVIDEO_LOCK_PATH') or root / 'engine.lock', busy=busy)
+ lock=environment.get('FREEVIDEO_LOCK_PATH') or root / 'engine.lock', busy=busy,
+ delay=OWED_DELAY if compile_owed(root) else START_DELAY)
class FreeVideoExtension(ComfyExtension):