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.
Handle Unicode cache paths for Windows GPU kernels (#7)
Bowen Xue31ccb9af738b
diff --git a/freevideo_engine/bootstrap.py b/freevideo_engine/bootstrap.pyindex d61fe3f..3a225f6 100644--- a/freevideo_engine/bootstrap.py+++ b/freevideo_engine/bootstrap.py@@ -699,6 +699,8 @@ class Installer:HF_HUB_OFFLINE='0', TRANSFORMERS_OFFLINE='0',PIP_DISABLE_PIP_VERSION_CHECK='1',PYTHONUNBUFFERED='1', PYTHONUTF8='1', PYTHONIOENCODING='utf-8', PYTHONPATH=str(SOURCE), OMP_NUM_THREADS='4', MKL_NUM_THREADS='4')+ from .triton_compat import environment as compiler_environment+ self.env = compiler_environment(self.root, self.env)self.env[LOCK_ENV] = str(self.runtime_fd)self.env.update(FREEVIDEO_NETWORK_PLAN=str(self.run_dir / 'plan.json'),FREEVIDEO_NETWORK_EVENTS=str(self.run_dir / 'network.jsonl'))diff --git a/freevideo_engine/comfy_bridge.py b/freevideo_engine/comfy_bridge.pyindex f456676..cd68047 100644--- a/freevideo_engine/comfy_bridge.py+++ b/freevideo_engine/comfy_bridge.py@@ -408,6 +408,11 @@ def progress_message(event):return None+def engine_environment(root, source, environ=None):+ from .triton_compat import environment+ return environment(root, isolated_environment(root, source, environ))++def generate(prompt, width, height, seconds, seed, output_directory, *,source=None, environ=None, metadata=None, progress=None, interrupted=None,release_models=None, export_inputs=None, two_pass=True, encoder_prewarm=None):@@ -416,7 +421,7 @@ def generate(prompt, width, height, seconds, seed, output_directory, *,canvas = validate_request(prompt, width, height, seconds, seed)source = Path(source or source_root()).resolve()root, machine = installation(source, environ)- environment = isolated_environment(root, source, environ)+ environment = engine_environment(root, source, environ)environment.update(FREEVIDEO_HOME=str(root), PYTHONPATH=str(source), PYTHONUNBUFFERED='1',PYTHONUTF8='1', PYTHONIOENCODING='utf-8', NO_COLOR='1', FREEVIDEO_UI_EVENTS='1')for key in ('FREEVIDEO_RUNTIME_LOCK_FD', 'FREEVIDEO_RUNTIME_LOCK_HANDLE'):diff --git a/freevideo_engine/comfy_nodes.py b/freevideo_engine/comfy_nodes.pyindex 02ae54e..d8fe196 100644--- a/freevideo_engine/comfy_nodes.py+++ b/freevideo_engine/comfy_nodes.py@@ -135,7 +135,7 @@ class FreeVideoGenerate(io.ComfyNode):try:if OWNER.process is not None:root, machine = comfy_bridge.installation()- environment = comfy_bridge.isolated_environment(root, comfy_bridge.source_root())+ environment = comfy_bridge.engine_environment(root, comfy_bridge.source_root())environment.update(FREEVIDEO_HOME=str(root), PYTHONPATH=str(comfy_bridge.source_root()))OWNER.warm_encoder(output, machine['python'], environment, busy=busy, notify=warmed)else:diff --git a/freevideo_engine/portable.py b/freevideo_engine/portable.pyindex 8b1f759..45e46e0 100644--- a/freevideo_engine/portable.py+++ b/freevideo_engine/portable.py@@ -112,7 +112,8 @@ def environment(root, value, environ=None):env.pop(key, None)python = inside(root, value['python']).parentenv['PATH'] = os.pathsep.join([str(python), str(python/'Scripts'), str(python/'Lib/site-packages/bin'), env.get('PATH', '')])- return env+ from .triton_compat import environment as compiler_environment+ return compiler_environment(root/'engine', env)def configuration(root, value, hardware):diff --git a/freevideo_engine/resident_process.py b/freevideo_engine/resident_process.pyindex af280df..54fd5b2 100644--- a/freevideo_engine/resident_process.py+++ b/freevideo_engine/resident_process.py@@ -342,13 +342,16 @@ class SessionOwner:def start(self, root, source, python, environment):import hashlibimport psutil+ from .triton_compat import COMPILER_ENVIRONMENT_KEYS, environment as compiler_environment+ environment = compiler_environment(root, environment)self.stop_prewarm()source = Path(source).resolve()signature = hashlib.sha256()for file in sorted((source/'freevideo_engine').glob('*.py')):signature.update(file.name.encode())signature.update(file.read_bytes())- identity = (str(source), str(python), signature.hexdigest(), environment.get('CUDA_VISIBLE_DEVICES'))+ compiler = tuple(environment.get(key) for key in COMPILER_ENVIRONMENT_KEYS)+ identity = (str(source), str(python), signature.hexdigest(), environment.get('CUDA_VISIBLE_DEVICES'), compiler)if self.process is not None and self.process.poll() is None and self.identity == identity:return str(self.endpoint)self.close()diff --git a/freevideo_engine/testing.py b/freevideo_engine/testing.pyindex 00f91a1..dbcb22c 100644--- a/freevideo_engine/testing.py+++ b/freevideo_engine/testing.py@@ -228,18 +228,16 @@ def environment(machine):need their own."""inherited = lambda name, fallback: os.environ.get(name) or fallback- cache = Path(machine['root']) / 'kernel-cache'- return dict(os.environ, FREEVIDEO_HOME=machine['root'], FREEVIDEO_VDN_ROOT=machine['vdn_root'],+ env = dict(os.environ, FREEVIDEO_HOME=machine['root'], FREEVIDEO_VDN_ROOT=machine['vdn_root'],PATH=(str(Path(machine['git']).parent) + os.pathsep if machine.get('git') else '') + os.environ.get('PATH', ''),FREEVIDEO_MODEL_ROOT=machine['model_root'], FREEVIDEO_COMFY_ROOT=machine['comfy_root'],FREEVIDEO_COMFY_PYTHON=machine['comfy_python'],CUDA_VISIBLE_DEVICES=inherited('CUDA_VISIBLE_DEVICES', machine['gpu_uuid']),PYTHONUNBUFFERED='1', PYTHONUTF8='1', PYTHONIOENCODING='utf-8',FREEVIDEO_LOCK_PATH=inherited('FREEVIDEO_LOCK_PATH', str(Path(machine['root']) / 'engine.lock')),- TRITON_CACHE_DIR=inherited('TRITON_CACHE_DIR', str(cache / 'triton')),- CUDA_CACHE_PATH=inherited('CUDA_CACHE_PATH', str(cache / 'cuda')),- TORCHINDUCTOR_CACHE_DIR=inherited('TORCHINDUCTOR_CACHE_DIR', str(cache / 'inductor')),OMP_NUM_THREADS='8', MKL_NUM_THREADS='8')+ from .triton_compat import environment as compiler_environment+ return compiler_environment(machine['root'], env)def command_for(machine, case, destination, args):diff --git a/freevideo_engine/triton_compat.py b/freevideo_engine/triton_compat.pyindex 6b82ec2..7310511 100644--- a/freevideo_engine/triton_compat.py+++ b/freevideo_engine/triton_compat.py@@ -1,6 +1,32 @@-"""Windows Unicode environment compatibility at FreeVideo's Triton entry points."""+"""Windows Unicode compatibility for compiler configuration and kernel loading."""from functools import wrapsimport os+from pathlib import Path+++COMPILER_ENVIRONMENT_KEYS = (+ 'TRITON_CACHE_DIR', 'TORCHINDUCTOR_CACHE_DIR', 'CUDA_CACHE_PATH',+ 'TORCHINDUCTOR_USE_STATIC_CUDA_LAUNCHER',+)+++def environment(root, environ):+ """Configure child compilers before imports, including encoder prewarming."""+ env = dict(environ)+ cache = Path(root) / 'kernel-cache'+ for key, folder in (('TRITON_CACHE_DIR', 'triton'),+ ('TORCHINDUCTOR_CACHE_DIR', 'inductor'),+ ('CUDA_CACHE_PATH', 'cuda')):+ if not env.get(key):+ env[key] = str(cache / folder)+ if os.name == 'nt' and any(not os.path.abspath(env[key]).isascii()+ for key in ('TRITON_CACHE_DIR', 'TORCHINDUCTOR_CACHE_DIR')):+ # The static launcher passes a UTF-8 narrow filename to cuModuleLoad.+ # Triton's normal launcher loads the same cubin bytes with+ # cuModuleLoadData, avoiding Windows filename encoding at that boundary.+ # Keep explicit caller choices and leave torch.compile enabled.+ env.setdefault('TORCHINDUCTOR_USE_STATIC_CUDA_LAUNCHER', '0')+ return envdef activate():