Add JAX backend with frame-varying random keys
Some checks failed
GPU Worker CI/CD / test (push) Has been cancelled
GPU Worker CI/CD / deploy (push) Has been cancelled

- Add sexp_to_jax.py: JAX compiler for S-expression effects
- Use jax.random.fold_in for deterministic but varying random per frame
- Pass seed from recipe config through to JAX effects
- Fix NVENC detection to do actual encode test
- Add set_random_seed for deterministic Python random

The fold_in approach allows frame_num to be traced (not static)
while still producing different random patterns per frame,
fixing the interference pattern issue.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
gilesb
2026-02-05 11:07:02 +00:00
parent 0534081e44
commit 7411aa74c4
4 changed files with 3793 additions and 7 deletions

View File

@@ -37,19 +37,39 @@ _nvenc_available: Optional[bool] = None
def check_nvenc_available() -> bool:
"""Check if NVENC hardware encoding is available."""
"""Check if NVENC hardware encoding is available and working.
Does a real encode test to catch cases where nvenc is listed
but CUDA libraries aren't loaded.
"""
global _nvenc_available
if _nvenc_available is not None:
return _nvenc_available
try:
# First check if encoder is listed
result = subprocess.run(
["ffmpeg", "-encoders"],
capture_output=True,
text=True,
timeout=5
)
_nvenc_available = "h264_nvenc" in result.stdout
if "h264_nvenc" not in result.stdout:
_nvenc_available = False
return _nvenc_available
# Actually try to encode a small test frame
result = subprocess.run(
["ffmpeg", "-y", "-f", "lavfi", "-i", "testsrc=duration=0.1:size=64x64:rate=1",
"-c:v", "h264_nvenc", "-f", "null", "-"],
capture_output=True,
text=True,
timeout=10
)
_nvenc_available = result.returncode == 0
if not _nvenc_available:
import sys
print("NVENC listed but not working, falling back to libx264", file=sys.stderr)
except Exception:
_nvenc_available = False