Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

raea cloud render farm: one render split across Modal GPUs, a bench of every GPU kind, and an agent box on a Fly Sprite

shinyobjectz775469dbac92
diff --git a/sdk/cloud/bench/frame.py b/sdk/cloud/bench/frame.py
new file mode 100644
index 00000000..e1f36b84
--- /dev/null
+++ b/sdk/cloud/bench/frame.py
@@ -0,0 +1,50 @@
+# One Blender frame timed end to end (bench/gpus.py): the Open Data benchmark's classroom scene at 1920x1080 with its
+# own samples, denoised, on the launcher's Blender. Blender's start and the scene's load and BVH build are timed apart
+# from the render, since a frame split across many GPUs pays them once per container.
+
+import os
+import re
+import subprocess
+import time
+
+SETUP = """
+import bpy, time
+s = bpy.context.scene
+s.render.resolution_x, s.render.resolution_y, s.render.resolution_percentage = 1920, 1080, 100
+s.cycles.use_denoising = True
+p = bpy.context.preferences.addons["cycles"].preferences
+p.compute_device_type = "{kind}" if "{kind}" != "CPU" else "NONE"
+p.get_devices()
+for d in p.devices:
+ d.use = d.type == "{kind}"
+s.cycles.device = "GPU" if "{kind}" != "CPU" else "CPU"
+print("RAEA_SAMPLES", s.cycles.samples, "RAEA_LOADED", time.time())
+"""
+
+
+def classroom(version, kind):
+ # the launcher keeps them in its cache folder, wherever its build put it
+ hits = subprocess.run(["find", "/", "-xdev", "(", "-name", "blender", "-type", "f", "-o", "-name", "*.blend", ")"], capture_output=True, text=True).stdout.split()
+ exe = next((h for h in hits if h.endswith("/blender") and version in h), None) or next((h for h in hits if h.endswith("/blender")), None)
+ blend = next((h for h in hits if h.endswith("/classroom.blend")), None)
+ if not exe or not blend:
+ return {"error": "the launcher's Blender or classroom scene isn't in the image", "exe": exe, "blend": blend, "found": hits[:20]}
+ t = time.time()
+ r = subprocess.run(
+ [exe, "-b", blend, "-E", "CYCLES", "--python-expr", SETUP.format(kind=kind), "-o", "/tmp/frame_####", "-F", "PNG", "-f", "1"],
+ capture_output=True, text=True, timeout=1800,
+ )
+ total = time.time() - t
+ out = r.stdout + r.stderr
+ loaded = re.search(r"RAEA_LOADED ([\d.]+)", out)
+ samples = re.search(r"RAEA_SAMPLES (\d+)", out)
+ render = re.findall(r"Time: (\d+):([\d.]+)", out)
+ render_s = int(render[-1][0]) * 60 + float(render[-1][1]) if render else None
+ return {
+ "ok": r.returncode == 0 and os.path.exists("/tmp/frame_0001.png"),
+ "samples": int(samples.group(1)) if samples else None,
+ "load_s": round(float(loaded.group(1)) - t, 2) if loaded else None,
+ "render_s": render_s,
+ "total_s": round(total, 2),
+ "out": out[-2000:],
+ }
diff --git a/sdk/cloud/bench/gpus.py b/sdk/cloud/bench/gpus.py
new file mode 100644
index 00000000..42c5cc9a
--- /dev/null
+++ b/sdk/cloud/bench/gpus.py
@@ -0,0 +1,154 @@
+# raea cloud's GPU bench (docs/cloud-render.feature CR2): the same raea renders and Blender Cycles scenes on each
+# Modal GPU kind, so a render's price per frame is measured, not guessed. From sdk/cloud:
+#
+# MODAL_PROFILE=shane-25168 modal run bench/gpus.py # every kind in KINDS
+# MODAL_PROFILE=shane-25168 modal run bench/gpus.py --gpus L4,L40S # some
+# MODAL_PROFILE=shane-25168 modal run bench/gpus.py --gpus none # the CPU only (llvmpipe, Cycles on CPU)
+#
+# Each kind runs in its own container at once, and writes bench/results/KIND.json:
+# - device: nvidia-smi's name, memory and driver; the Vulkan device raea opened
+# - start: seconds from the call to the container running (a cold start: image pulled, GPU attached)
+# - raea: wall seconds for test/gpu/edit.tsx (576 lit shadowed blocks, 1080p, 90 frames) and the realtime bench's
+# solari.tsx (a Solari-lit room, 720p, 150 frames), with RAEA_FRAME_LOG's per-frame means (react, sync, gpu ms)
+# - blender: the Open Data benchmark's samples per minute (monster, junkshop, classroom; Blender 5.3, OptiX), the
+# number opendata.blender.org ranks cards by, and one classroom frame at 1920x1080 timed end to end
+# - usd: what the container cost at Modal's list price per second (deploy/modal/prices.py)
+
+import json
+import os
+import subprocess
+import time
+
+import modal
+
+HERE = os.path.dirname(os.path.abspath(__file__))
+CLOUD = os.path.dirname(HERE)
+REPO = os.path.dirname(os.path.dirname(CLOUD))
+RAEA = os.environ.get("RAEA_VERSION", "0.1.6")
+BLENDER = "5.3.0"
+LAUNCHER = "https://download.blender.org/release/BlenderBenchmark2.0/launcher/benchmark-launcher-cli-3.3.0-linux.tar.gz"
+KINDS = ["T4", "L4", "A10", "L40S", "RTX-PRO-6000", "A100-40GB", "H100"]
+SCENES = ["monster", "junkshop", "classroom"]
+
+image = (
+ modal.Image.from_registry("debian:trixie-slim", add_python="3.12")
+ # raea's runtime libraries and NVIDIA's Vulkan driver's (docs/cloud.feature CL13); Blender's X11 and GL libraries
+ .apt_install(
+ "ca-certificates", "curl", "xz-utils", "bzip2", "procps",
+ "libasound2t64", "libfontconfig1", "libvulkan1", "mesa-vulkan-drivers", "vulkan-tools",
+ "libxext6", "libx11-6", "libgl1", "libegl1",
+ "libxi6", "libxxf86vm1", "libxfixes3", "libxrender1", "libxkbcommon0", "libsm6", "libice6",
+ )
+ .run_commands(
+ f"set -e; f=raea-{RAEA}-linux-x86_64.tar.gz; u=https://github.com/shinyobjectz/raea/releases/download/v{RAEA}; "
+ "cd /tmp && curl -fsSL -o $f $u/$f && curl -fsSL -o $f.sha256 $u/$f.sha256 && sha256sum -c $f.sha256 "
+ "&& mkdir -p /opt/raea && tar -xzf $f -C /opt/raea --strip-components=1 && rm -f $f $f.sha256 "
+ "&& ln -s /opt/raea/bin/raea /usr/local/bin/raea && raea --version",
+ # the benchmark launcher, its Blender and its scenes, in the image so a run downloads nothing
+ f"mkdir -p /opt/bench && curl -fsSL {LAUNCHER} | tar -xz -C /opt/bench",
+ f"cd /opt/bench && ./benchmark-launcher-cli blender download {BLENDER} && "
+ f"./benchmark-launcher-cli scenes download --blender-version {BLENDER} {' '.join(SCENES)}",
+ )
+ # NVIDIA's Vulkan driver by the library the container runtime mounts (Modal passes no ICD file in)
+ .add_local_file(os.path.join(CLOUD, "image", "nvidia_icd.json"), "/usr/share/vulkan/icd.d/nvidia_icd.json", copy=True)
+ .env({"WGPU_BACKEND": "vulkan", "NVIDIA_DRIVER_CAPABILITIES": "all"})
+ .add_local_file(os.path.join(CLOUD, "test", "gpu", "edit.tsx"), "/opt/scenes/edit.tsx")
+ .add_local_file(os.path.join(REPO, "bench", "realtime", "cases", "solari.tsx"), "/opt/scenes/solari.tsx")
+ .add_local_file(os.path.join(CLOUD, "deploy", "modal", "prices.py"), "/opt/bench/prices.py")
+ .add_local_file(os.path.join(HERE, "frame.py"), "/opt/bench/frame.py")
+)
+
+app = modal.App("raea-cloud-bench", image=image)
+
+
+def sh(cmd, env=None, timeout=1800):
+ print("bench:", " ".join(cmd)[:160], flush=True)
+ t = time.time()
+ r = subprocess.run(cmd, capture_output=True, text=True, env={**os.environ, **(env or {})}, timeout=timeout)
+ return {"ok": r.returncode == 0, "s": round(time.time() - t, 2), "out": (r.stdout + r.stderr)[-3000:], "stdout": r.stdout}
+
+
+def frame_log(path):
+ # RAEA_FRAME_LOG: frame, react, sync, draw3d, gpu3d, page, gpupage, gpu (ms), tab-separated
+ try:
+ rows = [[float(x) for x in l.split("\t")] for l in open(path) if l.strip() and l[0].isdigit()]
+ except OSError:
+ return None
+ if not rows:
+ return None
+ mean = lambda i: round(sum(r[i] for r in rows) / len(rows), 2)
+ cols = ["react", "sync", "draw3d", "gpu3d", "page", "gpupage", "gpu"]
+ return {"frames": len(rows), **{c: mean(i + 1) for i, c in enumerate(cols) if i + 1 < len(rows[0])}}
+
+
+def raea_renders(on_cpu):
+ # raea's home its own (the launcher keeps its Blender and scenes under root's); on the CPU, lavapipe and no EGL
+ env = {"HOME": "/tmp/home"}
+ if on_cpu:
+ env |= {"VK_DRIVER_FILES": "/usr/share/vulkan/icd.d/lvp_icd.json", "__EGL_VENDOR_LIBRARY_DIRS": "/nonexistent"}
+ os.makedirs("/tmp/home", exist_ok=True)
+ vk = sh(["vulkaninfo", "--summary"], env)["stdout"]
+ out = {"vulkan": [l.split("=")[1].strip() for l in vk.splitlines() if "deviceName" in l]}
+ # each scene as raea renders it by default, then without the clipping check (RAEA_CLIP_CHECK=0), which a render
+ # worker can leave to the box that asked for the render
+ for name in ("edit", "solari"):
+ for clip in ("1", "0"):
+ log = f"/tmp/{name}-{clip}.log"
+ r = sh(["raea", "render", f"/opt/scenes/{name}.tsx", "-o", f"/tmp/{name}-{clip}.mp4"], {**env, "RAEA_FRAME_LOG": log, "RAEA_TIMES": "1", "RAEA_CLIP_CHECK": clip})
+ r.pop("stdout")
+ r["out"] = [l for l in r["out"].splitlines() if l.startswith(("APPLIED", "REFUSED", "raea times", "Error", "error"))] if r["ok"] else r["out"]
+ out[name if clip == "1" else f"{name}-noclip"] = {**r, "frames": frame_log(log)}
+ return out
+
+
+def launcher(*args):
+ return sh(["/opt/bench/benchmark-launcher-cli", *args], timeout=3000)
+
+
+def blender(device_type):
+ devices = launcher("devices", "--blender-version", BLENDER)
+ names = [l.split("\t")[0].strip() for l in devices["out"].splitlines() if device_type in l.split("\t")[1:]]
+ if not names:
+ return {"devices": devices["out"]}
+ r = launcher("benchmark", "--blender-version", BLENDER, "--device-type", device_type, "--device-name", names[0], "--json", *SCENES)
+ try:
+ spm = {s["scene"]["label"]: round(s["stats"]["samples_per_minute"], 1) for s in json.loads(r["stdout"])}
+ except (ValueError, KeyError, TypeError):
+ spm = None
+ return {"device": names[0], "s": r["s"], "samples_per_minute": spm, "out": None if spm else r["stdout"][-3000:]}
+
+
[email protected](cpu=8, memory=32768, timeout=3600)
+def bench(kind: str, called: float) -> dict:
+ import sys
+
+ sys.path.insert(0, "/opt/bench")
+ import frame
+ import prices
+
+ started = time.time()
+ gpu = kind != "none"
+ res = {"kind": kind, "raea_version": RAEA, "blender_version": BLENDER, "start": round(started - called, 1)}
+ res["device"] = sh(["nvidia-smi", "--query-gpu=name,memory.total,driver_version", "--format=csv,noheader"])["out"].strip() if gpu else "cpu"
+ res["raea"] = raea_renders(not gpu)
+ device_type = "OPTIX" if gpu else "CPU"
+ res["blender"] = blender(device_type)
+ res["frame"] = frame.classroom(BLENDER, device_type)
+ res["s"] = round(time.time() - started, 1)
+ res["usd"] = prices.cost(kind, cpu=8, memory_gib=32, seconds=time.time() - called)
+ return res
+
+
[email protected]_entrypoint()
+def main(gpus: str = ",".join(KINDS)):
+ kinds = [g.strip() for g in gpus.split(",") if g.strip()]
+ calls = [(k, bench.with_options(gpu=None if k == "none" else k).spawn(k, time.time())) for k in kinds]
+ os.makedirs(os.path.join(HERE, "results"), exist_ok=True)
+ for kind, call in calls:
+ try:
+ r = call.get()
+ except Exception as e: # one kind failing (no capacity, a crash) leaves the others' results
+ r = {"kind": kind, "error": repr(e)}
+ with open(os.path.join(HERE, "results", f"{kind}.json"), "w") as f:
+ json.dump(r, f, indent=1)
+ print(json.dumps({k: r.get(k) for k in ("kind", "device", "start", "s", "usd", "error")}))
diff --git a/sdk/cloud/bench/report.py b/sdk/cloud/bench/report.py
new file mode 100644
index 00000000..2d302d8a
--- /dev/null
+++ b/sdk/cloud/bench/report.py
@@ -0,0 +1,46 @@
+# bench/results/*.json as the cost tables in docs/cloud-render.md: python3 bench/report.py from sdk/cloud.
+# Prices are a container of 4 cores and 16 GiB (what the farm gives each GPU) at Modal's list price.
+
+import glob
+import json
+import os
+import re
+import sys
+
+sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "deploy", "modal"))
+import prices # noqa: E402
+
+HERE = os.path.dirname(os.path.abspath(__file__))
+ORDER = ["none", "T4", "L4", "A10", "L40S", "RTX-PRO-6000", "A100-40GB", "H100"]
+
+
+def ms(r, name):
+ x = r["raea"].get(name) or {}
+ lines = x.get("out") if isinstance(x.get("out"), list) else [x.get("out") or ""]
+ for l in lines:
+ m = re.search(r"\(([\d.]+) ms a frame", l)
+ if m:
+ return float(m.group(1))
+ return None
+
+
+rows = {}
+for f in glob.glob(os.path.join(HERE, "results", "*.json")):
+ r = json.load(open(f))
+ if not r.get("error"):
+ rows[r["kind"]] = r
+
+print("| GPU | $/h (4 cores, 16 GiB) | cold start | Cycles samples/min (monster, junkshop, classroom) | classroom samples per $ | edit.tsx ms/frame (clip check on, off) | Solari ms/frame (on, off) | $ per 1,000 Solari frames |")
+print("|---|---|---|---|---|---|---|---|")
+for k in [k for k in ORDER if k in rows]:
+ r = rows[k]
+ hour = prices.per_hour("" if k == "none" else k, 8 if k == "none" else 4, 16)
+ spm = r["blender"].get("samples_per_minute") or {}
+ per_dollar = spm.get("classroom", 0) * 60 / hour if spm else 0
+ sol = ms(r, "solari-noclip")
+ name = "CPU only (8 cores)" if k == "none" else k
+ print(
+ f"| {name} | ${hour:.2f} | {r['start']:.0f} s | {spm.get('monster', 0):,.0f}, {spm.get('junkshop', 0):,.0f}, {spm.get('classroom', 0):,.0f} "
+ f"| {per_dollar:,.0f} | {ms(r, 'edit') or 0:,.0f}, {ms(r, 'edit-noclip') or 0:,.0f} | {ms(r, 'solari') or 0:.0f}, {sol or 0:.0f} "
+ f"| ${(sol or 0) / 1000 * 1000 * hour / 3600:.3f} |"
+ )
diff --git a/sdk/cloud/bench/results/A10.json b/sdk/cloud/bench/results/A10.json
new file mode 100644
index 00000000..4ec464a6
--- /dev/null
+++ b/sdk/cloud/bench/results/A10.json
@@ -0,0 +1,104 @@
+{
+ "kind": "A10",
+ "raea_version": "0.1.6",
+ "blender_version": "5.3.0",
+ "start": 60.5,
+ "device": "NVIDIA A10, 23028 MiB, 610.57.04",
+ "raea": {
+ "vulkan": [
+ "NVIDIA A10",
+ "NVIDIA A10",
+ "llvmpipe (LLVM 19.1.7, 256 bits)"
+ ],
+ "edit": {
+ "ok": true,
+ "s": 116.79,
+ "out": [
+ "APPLIED 90 frames rendered to /tmp/edit-1.mp4 (1248.3 ms a frame, pages handed to raea-render on the GPU)",
+ "raea times: the clipping check 90380 ms"
+ ],
+ "frames": {
+ "frames": 90,
+ "react": 152.88,
+ "sync": 76.46,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.12
+ }
+ },
+ "edit-noclip": {
+ "ok": true,
+ "s": 21.91,
+ "out": [
+ "APPLIED 90 frames rendered to /tmp/edit-0.mp4 (223.9 ms a frame, pages handed to raea-render on the GPU)"
+ ],
+ "frames": {
+ "frames": 90,
+ "react": 150.17,
+ "sync": 60.59,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.1
+ }
+ },
+ "solari": {
+ "ok": true,
+ "s": 9.03,
+ "out": [
+ "APPLIED 150 frames rendered to /tmp/solari-1.mp4 (48.7 ms a frame, pages handed to raea-render on the GPU)",
+ "raea times: the clipping check 639 ms"
+ ],
+ "frames": {
+ "frames": 150,
+ "react": 8.09,
+ "sync": 35.26,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.23
+ }
+ },
+ "solari-noclip": {
+ "ok": true,
+ "s": 4.19,
+ "out": [
+ "APPLIED 150 frames rendered to /tmp/solari-0.mp4 (20.1 ms a frame, pages handed to raea-render on the GPU)"
+ ],
+ "frames": {
+ "frames": 150,
+ "react": 7.31,
+ "sync": 11.92,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.01
+ }
+ }
+ },
+ "blender": {
+ "device": "NVIDIA A10",
+ "s": 115.59,
+ "samples_per_minute": {
+ "monster": 1430.0,
+ "junkshop": 1281.4,
+ "classroom": 1027.7
+ },
+ "out": null
+ },
+ "frame": {
+ "ok": true,
+ "samples": 300,
+ "load_s": 0.71,
+ "render_s": 23.95,
+ "total_s": 24.78,
+ "out": "ent_AO.png\n00:01.327 render | Fra: 1 | Mem: 35M | Updating Images | Loading europeMap.png\n00:01.327 render | Fra: 1 | Mem: 35M | Updating Images | Loading base_woodFloor.jpg\n00:01.328 render | Fra: 1 | Mem: 35M | Updating Images | Loading base_brightWood.png\n00:01.328 render | Fra: 1 | Mem: 35M | Updating Images | Loading crinkledPaper_02.png\n00:01.328 render | Fra: 1 | Mem: 35M | Updating Images | Loading pencil_glossyMask.png\n00:01.329 render | Fra: 1 | Mem: 35M | Updating Images | Loading ceiling_AO.png\n00:01.329 render | Fra: 1 | Mem: 35M | Updating Images | Loading pencil_brandMask.png\n00:01.433 render | Fra: 1 | Mem: 261M | Updating Volume\n00:01.433 render | Fra: 1 | Mem: 261M | Updating Camera Volume\n00:01.433 render | Fra: 1 | Mem: 261M | Updating Lookup Tables\n00:01.434 render | Fra: 1 | Mem: 262M | Updating Lights\n00:01.434 render | Fra: 1 | Mem: 262M | Updating Lights | Computing distribution\n00:01.436 render | Fra: 1 | Mem: 263M | Updating Integrator\n00:01.438 render | Fra: 1 | Mem: 265M | Updating Film\n00:01.438 render | Fra: 1 | Mem: 265M | Updating Lookup Tables\n00:01.438 render | Fra: 1 | Mem: 265M | Updating Baking\n00:01.438 render | Fra: 1 | Mem: 265M | Updating Device | Writing constant memory\n00:01.438 render | Fra: 1 | Mem: 265M | Loading denoising kernels (may take a few minutes the first time)\n00:01.448 render | Fra: 1 | Mem: 893M | Sample 0/300\n00:01.517 render | Fra: 1 | Remaining: 00:20.66 | Mem: 1304M | Sample 1/300\n00:20.718 render | Fra: 1 | Mem: 1304M | Sample 300/300\n00:20.718 render | Fra: 1 | Mem: 1304M | Finished\n00:24.544 render | Saved: '/tmp/frame_0001.png'\n00:24.544 render | Time: 00:23.95 (Saving: 00:03.68)\nRAEA_SAMPLES 300 RAEA_LOADED 1794935081.5432343\n\nBlender quit\n"
+ },
+ "s": 295.8,
+ "usd": 0.1716
+}
\ No newline at end of file
diff --git a/sdk/cloud/bench/results/A100-40GB.json b/sdk/cloud/bench/results/A100-40GB.json
new file mode 100644
index 00000000..89f04ab6
--- /dev/null
+++ b/sdk/cloud/bench/results/A100-40GB.json
@@ -0,0 +1,104 @@
+{
+ "kind": "A100-40GB",
+ "raea_version": "0.1.6",
+ "blender_version": "5.3.0",
+ "start": 3.1,
+ "device": "NVIDIA A100-SXM4-40GB, 40960 MiB, 610.57.04",
+ "raea": {
+ "vulkan": [
+ "NVIDIA A100-SXM4-40GB",
+ "NVIDIA A100-SXM4-40GB",
+ "llvmpipe (LLVM 19.1.7, 256 bits)"
+ ],
+ "edit": {
+ "ok": true,
+ "s": 119.27,
+ "out": [
+ "APPLIED 90 frames rendered to /tmp/edit-1.mp4 (1263.9 ms a frame, pages handed to raea-render on the GPU)",
+ "raea times: the clipping check 85969 ms"
+ ],
+ "frames": {
+ "frames": 90,
+ "react": 188.63,
+ "sync": 100.05,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.07
+ }
+ },
+ "edit-noclip": {
+ "ok": true,
+ "s": 28.5,
+ "out": [
+ "APPLIED 90 frames rendered to /tmp/edit-0.mp4 (292.4 ms a frame, pages handed to raea-render on the GPU)"
+ ],
+ "frames": {
+ "frames": 90,
+ "react": 189.02,
+ "sync": 85.74,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.07
+ }
+ },
+ "solari": {
+ "ok": true,
+ "s": 7.41,
+ "out": [
+ "APPLIED 150 frames rendered to /tmp/solari-1.mp4 (34.3 ms a frame, pages handed to raea-render on the GPU)",
+ "raea times: the clipping check 611 ms"
+ ],
+ "frames": {
+ "frames": 150,
+ "react": 9.97,
+ "sync": 19.5,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.02
+ }
+ },
+ "solari-noclip": {
+ "ok": true,
+ "s": 5.28,
+ "out": [
+ "APPLIED 150 frames rendered to /tmp/solari-0.mp4 (25.3 ms a frame, pages handed to raea-render on the GPU)"
+ ],
+ "frames": {
+ "frames": 150,
+ "react": 10.15,
+ "sync": 14.36,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.02
+ }
+ }
+ },
+ "blender": {
+ "device": "NVIDIA A100-SXM4-40GB",
+ "s": 357.16,
+ "samples_per_minute": {
+ "monster": 1225.0,
+ "junkshop": 1227.0,
+ "classroom": 977.9
+ },
+ "out": null
+ },
+ "frame": {
+ "ok": false,
+ "samples": null,
+ "load_s": null,
+ "render_s": null,
+ "total_s": 0.67,
+ "out": "00:00.094 system.path | WARNING Could not get a list of mounted file-systems\n00:00.434 reports | ERROR File format is not supported in file \"/root/.cache/blender-benchmark-launcher/scenes/936f0a528f03eba291c67ea87743a0ebde58938fb87471b262721b89b46b875d/classroom/assets/officeSupplies/._officeSupplies.blend\"\nBlender 5.3.0 (hash 02f0899d78e3 built 2026-11-10 01:31:18)\n\nBlender quit\n"
+ },
+ "s": 524.1,
+ "usd": 0.4001
+}
\ No newline at end of file
diff --git a/sdk/cloud/bench/results/H100.json b/sdk/cloud/bench/results/H100.json
new file mode 100644
index 00000000..4e8ea16c
--- /dev/null
+++ b/sdk/cloud/bench/results/H100.json
@@ -0,0 +1,104 @@
+{
+ "kind": "H100",
+ "raea_version": "0.1.6",
+ "blender_version": "5.3.0",
+ "start": 3.0,
+ "device": "NVIDIA H100 80GB HBM3, 81559 MiB, 610.57.04",
+ "raea": {
+ "vulkan": [
+ "NVIDIA H100 80GB HBM3",
+ "NVIDIA H100 80GB HBM3",
+ "llvmpipe (LLVM 19.1.7, 256 bits)"
+ ],
+ "edit": {
+ "ok": true,
+ "s": 113.6,
+ "out": [
+ "APPLIED 90 frames rendered to /tmp/edit-1.mp4 (1189.9 ms a frame, pages handed to raea-render on the GPU)",
+ "raea times: the clipping check 79664 ms"
+ ],
+ "frames": {
+ "frames": 90,
+ "react": 181.91,
+ "sync": 103.42,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.44
+ }
+ },
+ "edit-noclip": {
+ "ok": true,
+ "s": 25.08,
+ "out": [
+ "APPLIED 90 frames rendered to /tmp/edit-0.mp4 (250.7 ms a frame, pages handed to raea-render on the GPU)"
+ ],
+ "frames": {
+ "frames": 90,
+ "react": 163.06,
+ "sync": 70.64,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.46
+ }
+ },
+ "solari": {
+ "ok": true,
+ "s": 8.24,
+ "out": [
+ "APPLIED 150 frames rendered to /tmp/solari-1.mp4 (34.8 ms a frame, pages handed to raea-render on the GPU)",
+ "raea times: the clipping check 493 ms"
+ ],
+ "frames": {
+ "frames": 150,
+ "react": 10.68,
+ "sync": 20.04,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.04
+ }
+ },
+ "solari-noclip": {
+ "ok": true,
+ "s": 5.88,
+ "out": [
+ "APPLIED 150 frames rendered to /tmp/solari-0.mp4 (24.8 ms a frame, pages handed to raea-render on the GPU)"
+ ],
+ "frames": {
+ "frames": 150,
+ "react": 10.31,
+ "sync": 13.72,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.03
+ }
+ }
+ },
+ "blender": {
+ "device": "NVIDIA H100 80GB HBM3",
+ "s": 405.14,
+ "samples_per_minute": {
+ "monster": 1971.0,
+ "junkshop": 2132.7,
+ "classroom": 1650.8
+ },
+ "out": null
+ },
+ "frame": {
+ "ok": true,
+ "samples": 300,
+ "load_s": 0.77,
+ "render_s": 18.43,
+ "total_s": 19.38,
+ "out": "ard.png\n00:01.835 render | Fra: 1 | Mem: 66M | Updating Images | Loading radiator_AO.png\n00:01.836 render | Fra: 1 | Mem: 66M | Updating Images | Loading ceilingAirVent_AO.png\n00:01.836 render | Fra: 1 | Mem: 66M | Updating Images | Loading europeMap.png\n00:01.837 render | Fra: 1 | Mem: 66M | Updating Images | Loading base_woodFloor.jpg\n00:01.838 render | Fra: 1 | Mem: 66M | Updating Images | Loading base_brightWood.png\n00:01.838 render | Fra: 1 | Mem: 66M | Updating Images | Loading pencil_glossyMask.png\n00:01.840 render | Fra: 1 | Mem: 66M | Updating Images | Loading crinkledPaper_02.png\n00:01.943 render | Fra: 1 | Mem: 292M | Updating Volume\n00:01.943 render | Fra: 1 | Mem: 292M | Updating Camera Volume\n00:01.943 render | Fra: 1 | Mem: 292M | Updating Lookup Tables\n00:01.943 render | Fra: 1 | Mem: 292M | Updating Lights\n00:01.943 render | Fra: 1 | Mem: 292M | Updating Lights | Computing distribution\n00:01.947 render | Fra: 1 | Mem: 293M | Updating Integrator\n00:01.949 render | Fra: 1 | Mem: 295M | Updating Film\n00:01.949 render | Fra: 1 | Mem: 295M | Updating Lookup Tables\n00:01.950 render | Fra: 1 | Mem: 295M | Updating Baking\n00:01.950 render | Fra: 1 | Mem: 295M | Updating Device | Writing constant memory\n00:01.950 render | Fra: 1 | Mem: 295M | Loading denoising kernels (may take a few minutes the first time)\n00:01.972 render | Fra: 1 | Mem: 1830M | Sample 0/300\n00:02.024 render | Fra: 1 | Remaining: 00:15.43 | Mem: 2241M | Sample 1/300\n00:15.776 render | Fra: 1 | Mem: 2241M | Sample 300/300\n00:15.776 render | Fra: 1 | Mem: 2241M | Finished\n00:19.071 render | Saved: '/tmp/frame_0001.png'\n00:19.071 render | Time: 00:18.43 (Saving: 00:03.06)\nRAEA_SAMPLES 300 RAEA_LOADED 1794935319.2765844\n\nBlender quit\n"
+ },
+ "s": 583.6,
+ "usd": 0.7466
+}
\ No newline at end of file
diff --git a/sdk/cloud/bench/results/L4.json b/sdk/cloud/bench/results/L4.json
new file mode 100644
index 00000000..fc144e8a
--- /dev/null
+++ b/sdk/cloud/bench/results/L4.json
@@ -0,0 +1,104 @@
+{
+ "kind": "L4",
+ "raea_version": "0.1.6",
+ "blender_version": "5.3.0",
+ "start": 254.5,
+ "device": "NVIDIA L4, 23034 MiB, 610.57.04",
+ "raea": {
+ "vulkan": [
+ "NVIDIA L4",
+ "NVIDIA L4",
+ "llvmpipe (LLVM 19.1.7, 256 bits)"
+ ],
+ "edit": {
+ "ok": true,
+ "s": 164.9,
+ "out": [
+ "APPLIED 90 frames rendered to /tmp/edit-1.mp4 (1755.1 ms a frame, pages handed to raea-render on the GPU)",
+ "raea times: the clipping check 122706 ms"
+ ],
+ "frames": {
+ "frames": 90,
+ "react": 244.93,
+ "sync": 122.3,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.1
+ }
+ },
+ "edit-noclip": {
+ "ok": true,
+ "s": 33.8,
+ "out": [
+ "APPLIED 90 frames rendered to /tmp/edit-0.mp4 (344.9 ms a frame, pages handed to raea-render on the GPU)"
+ ],
+ "frames": {
+ "frames": 90,
+ "react": 230.13,
+ "sync": 92.46,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.09
+ }
+ },
+ "solari": {
+ "ok": true,
+ "s": 13.47,
+ "out": [
+ "APPLIED 150 frames rendered to /tmp/solari-1.mp4 (71.7 ms a frame, pages handed to raea-render on the GPU)",
+ "raea times: the clipping check 921 ms"
+ ],
+ "frames": {
+ "frames": 150,
+ "react": 13.63,
+ "sync": 50.52,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.02
+ }
+ },
+ "solari-noclip": {
+ "ok": true,
+ "s": 6.75,
+ "out": [
+ "APPLIED 150 frames rendered to /tmp/solari-0.mp4 (34.0 ms a frame, pages handed to raea-render on the GPU)"
+ ],
+ "frames": {
+ "frames": 150,
+ "react": 12.83,
+ "sync": 19.92,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.02
+ }
+ }
+ },
+ "blender": {
+ "device": "NVIDIA L4",
+ "s": 130.36,
+ "samples_per_minute": {
+ "monster": 1808.3,
+ "junkshop": 1353.0,
+ "classroom": 1128.6
+ },
+ "out": null
+ },
+ "frame": {
+ "ok": false,
+ "samples": 10,
+ "load_s": 0.88,
+ "render_s": null,
+ "total_s": 1.02,
+ "out": null
+ },
+ "s": 356.0,
+ "usd": 0.2429
+}
\ No newline at end of file
diff --git a/sdk/cloud/bench/results/L40S.json b/sdk/cloud/bench/results/L40S.json
new file mode 100644
index 00000000..b5c16608
--- /dev/null
+++ b/sdk/cloud/bench/results/L40S.json
@@ -0,0 +1,104 @@
+{
+ "kind": "L40S",
+ "raea_version": "0.1.6",
+ "blender_version": "5.3.0",
+ "start": 3.0,
+ "device": "NVIDIA L40S, 46068 MiB, 620.70.06",
+ "raea": {
+ "vulkan": [
+ "NVIDIA L40S",
+ "NVIDIA L40S",
+ "llvmpipe (LLVM 19.1.7, 256 bits)"
+ ],
+ "edit": {
+ "ok": true,
+ "s": 109.53,
+ "out": [
+ "APPLIED 90 frames rendered to /tmp/edit-1.mp4 (1164.2 ms a frame, pages handed to raea-render on the GPU)",
+ "raea times: the clipping check 80074 ms"
+ ],
+ "frames": {
+ "frames": 90,
+ "react": 171.22,
+ "sync": 85.57,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.07
+ }
+ },
+ "edit-noclip": {
+ "ok": true,
+ "s": 24.11,
+ "out": [
+ "APPLIED 90 frames rendered to /tmp/edit-0.mp4 (247.5 ms a frame, pages handed to raea-render on the GPU)"
+ ],
+ "frames": {
+ "frames": 90,
+ "react": 162.14,
+ "sync": 68.45,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.04
+ }
+ },
+ "solari": {
+ "ok": true,
+ "s": 8.86,
+ "out": [
+ "APPLIED 150 frames rendered to /tmp/solari-1.mp4 (46.3 ms a frame, pages handed to raea-render on the GPU)",
+ "raea times: the clipping check 493 ms"
+ ],
+ "frames": {
+ "frames": 150,
+ "react": 9.31,
+ "sync": 32.86,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.03
+ }
+ },
+ "solari-noclip": {
+ "ok": true,
+ "s": 5.0,
+ "out": [
+ "APPLIED 150 frames rendered to /tmp/solari-0.mp4 (25.1 ms a frame, pages handed to raea-render on the GPU)"
+ ],
+ "frames": {
+ "frames": 150,
+ "react": 9.3,
+ "sync": 14.89,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.01
+ }
+ }
+ },
+ "blender": {
+ "device": "NVIDIA L40S",
+ "s": 119.55,
+ "samples_per_minute": {
+ "monster": 5493.9,
+ "junkshop": 3736.9,
+ "classroom": 3473.8
+ },
+ "out": null
+ },
+ "frame": {
+ "ok": false,
+ "samples": 10,
+ "load_s": 0.61,
+ "render_s": null,
+ "total_s": 0.69,
+ "out": "00:00.088 system.path | WARNING Could not get a list of mounted file-systems\n00:00.387 blend | Read blend: \"/root/.cache/blender-benchmark-launcher/scenes/936f0a528f03eba291c67ea87743a0ebde58938fb87471b262721b89b46b875d/classroom/assets/desks/desks.blend\"\n00:00.393 blend.doversion | WARNING Region type 4 missing in space type \"Info\" (id: 7) - removing region\n00:00.468 cycles | WARNING HIPEW initialization failed: Error opening HIP dynamic library\n00:00.471 reports | ERROR No camera found in scene \"Scene\"\nBlender 5.3.0 (hash 02f0899d78e3 built 2026-11-10 01:31:18)\nRAEA_SAMPLES 10 RAEA_LOADED 1794935025.193915\n\nBlender quit\n"
+ },
+ "s": 272.5,
+ "usd": 0.1978
+}
\ No newline at end of file
diff --git a/sdk/cloud/bench/results/RTX-PRO-6000.json b/sdk/cloud/bench/results/RTX-PRO-6000.json
new file mode 100644
index 00000000..1c6a9d87
--- /dev/null
+++ b/sdk/cloud/bench/results/RTX-PRO-6000.json
@@ -0,0 +1,104 @@
+{
+ "kind": "RTX-PRO-6000",
+ "raea_version": "0.1.6",
+ "blender_version": "5.3.0",
+ "start": 3.6,
+ "device": "NVIDIA RTX PRO 6000 Blackwell Server Edition, 97887 MiB, 610.57.04",
+ "raea": {
+ "vulkan": [
+ "NVIDIA RTX PRO 6000 Blackwell Server Edition",
+ "NVIDIA RTX PRO 6000 Blackwell Server Edition",
+ "llvmpipe (LLVM 19.1.7, 256 bits)"
+ ],
+ "edit": {
+ "ok": true,
+ "s": 72.46,
+ "out": [
+ "APPLIED 90 frames rendered to /tmp/edit-1.mp4 (765.5 ms a frame, pages handed to raea-render on the GPU)",
+ "raea times: the clipping check 50894 ms"
+ ],
+ "frames": {
+ "frames": 90,
+ "react": 115.78,
+ "sync": 74.12,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.02
+ }
+ },
+ "edit-noclip": {
+ "ok": true,
+ "s": 17.92,
+ "out": [
+ "APPLIED 90 frames rendered to /tmp/edit-0.mp4 (182.5 ms a frame, pages handed to raea-render on the GPU)"
+ ],
+ "frames": {
+ "frames": 90,
+ "react": 112.16,
+ "sync": 60.32,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.02
+ }
+ },
+ "solari": {
+ "ok": true,
+ "s": 6.52,
+ "out": [
+ "APPLIED 150 frames rendered to /tmp/solari-1.mp4 (34.2 ms a frame, pages handed to raea-render on the GPU)",
+ "raea times: the clipping check 312 ms"
+ ],
+ "frames": {
+ "frames": 150,
+ "react": 6.66,
+ "sync": 24.91,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.0
+ }
+ },
+ "solari-noclip": {
+ "ok": true,
+ "s": 4.16,
+ "out": [
+ "APPLIED 150 frames rendered to /tmp/solari-0.mp4 (21.3 ms a frame, pages handed to raea-render on the GPU)"
+ ],
+ "frames": {
+ "frames": 150,
+ "react": 8.23,
+ "sync": 12.41,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.0
+ }
+ }
+ },
+ "blender": {
+ "device": "NVIDIA RTX PRO 6000 Blackwell Server Edition",
+ "s": 110.97,
+ "samples_per_minute": {
+ "monster": 7986.6,
+ "junkshop": 6227.3,
+ "classroom": 5329.7
+ },
+ "out": null
+ },
+ "frame": {
+ "ok": true,
+ "samples": 300,
+ "load_s": 0.48,
+ "render_s": 7.8,
+ "total_s": 8.41,
+ "out": "AirVent_AO.png\n00:00.979 render | Fra: 1 | Mem: 34M | Updating Images | Loading europeMap.png\n00:00.983 render | Fra: 1 | Mem: 34M | Updating Images | Loading crinkledPaper.png\n00:00.983 render | Fra: 1 | Mem: 34M | Updating Images | Loading base_woodFloor.jpg\n00:00.984 render | Fra: 1 | Mem: 34M | Updating Images | Loading crinkledPaper_02.png\n00:00.984 render | Fra: 1 | Mem: 34M | Updating Images | Loading base_wallPaint.jpg\n00:00.985 render | Fra: 1 | Mem: 34M | Updating Images | Loading pencil_glossyMask.png\n00:00.986 render | Fra: 1 | Mem: 34M | Updating Images | Loading ceiling_AO.png\n00:01.067 render | Fra: 1 | Mem: 260M | Updating Volume\n00:01.067 render | Fra: 1 | Mem: 260M | Updating Camera Volume\n00:01.067 render | Fra: 1 | Mem: 260M | Updating Lookup Tables\n00:01.067 render | Fra: 1 | Mem: 260M | Updating Lights\n00:01.067 render | Fra: 1 | Mem: 260M | Updating Lights | Computing distribution\n00:01.069 render | Fra: 1 | Mem: 261M | Updating Integrator\n00:01.072 render | Fra: 1 | Mem: 263M | Updating Film\n00:01.072 render | Fra: 1 | Mem: 263M | Updating Lookup Tables\n00:01.072 render | Fra: 1 | Mem: 263M | Updating Baking\n00:01.072 render | Fra: 1 | Mem: 263M | Updating Device | Writing constant memory\n00:01.073 render | Fra: 1 | Mem: 263M | Loading denoising kernels (may take a few minutes the first time)\n00:01.084 render | Fra: 1 | Mem: 1903M | Sample 0/300\n00:01.107 render | Fra: 1 | Remaining: 00:06.90 | Mem: 2314M | Sample 1/300\n00:05.535 render | Fra: 1 | Mem: 2314M | Sample 300/300\n00:05.535 render | Fra: 1 | Mem: 2314M | Finished\n00:08.205 render | Saved: '/tmp/frame_0001.png'\n00:08.205 render | Time: 00:07.80 (Saving: 00:02.50)\nRAEA_SAMPLES 300 RAEA_LOADED 1794934969.801777\n\nBlender quit\n"
+ },
+ "s": 223.9,
+ "usd": 0.2315
+}
\ No newline at end of file
diff --git a/sdk/cloud/bench/results/T4.json b/sdk/cloud/bench/results/T4.json
new file mode 100644
index 00000000..68251762
--- /dev/null
+++ b/sdk/cloud/bench/results/T4.json
@@ -0,0 +1,101 @@
+{
+ "kind": "T4",
+ "raea_version": "0.1.6",
+ "blender_version": "5.3.0",
+ "start": 3.5,
+ "device": "Tesla T4, 15360 MiB, 620.70.06",
+ "raea": {
+ "vulkan": [
+ "Tesla T4",
+ "Tesla T4",
+ "llvmpipe (LLVM 19.1.7, 256 bits)"
+ ],
+ "edit": {
+ "ok": true,
+ "s": 152.39,
+ "out": [
+ "APPLIED 90 frames rendered to /tmp/edit-1.mp4 (1604.6 ms a frame, pages handed to raea-render on the GPU)",
+ "raea times: the clipping check 112243 ms"
+ ],
+ "frames": {
+ "frames": 90,
+ "react": 222.34,
+ "sync": 113.37,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.25
+ }
+ },
+ "edit-noclip": {
+ "ok": true,
+ "s": 32.29,
+ "out": [
+ "APPLIED 90 frames rendered to /tmp/edit-0.mp4 (324.2 ms a frame, pages handed to raea-render on the GPU)"
+ ],
+ "frames": {
+ "frames": 90,
+ "react": 213.13,
+ "sync": 90.48,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.24
+ }
+ },
+ "solari": {
+ "ok": false,
+ "s": 12.15,
+ "out": "APPLIED 150 frames rendered to /tmp/solari-1.mp4 (64.3 ms a frame, pages handed to raea-render on the GPU)\nraea render: 0 errors, 0 warns, 0 notes\n\u001b[2m2026-11-17T17:02:20.850057Z\u001b[0m \u001b[33m WARN\u001b[0m \u001b[2mbevy_core_pipeline::core_3d\u001b[0m\u001b[2m:\u001b[0m MSAA is incompatible with deferred rendering and has been disabled.\n[OpenH264] this = 0x0x2b9eb8000b70, Warning:bEnableFrameSkip = 0,bitrate can't be controlled for RC_QUALITY_MODE,RC_BITRATE_MODE and RC_TIMESTAMP_MODE without enabling skip frame.\nraea times: the clipping check 836 ms\ncorrupted size vs. prev_size while consolidating\n",
+ "frames": {
+ "frames": 150,
+ "react": 11.54,
+ "sync": 45.3,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.48
+ }
+ },
+ "solari-noclip": {
+ "ok": true,
+ "s": 6.19,
+ "out": [
+ "APPLIED 150 frames rendered to /tmp/solari-0.mp4 (30.1 ms a frame, pages handed to raea-render on the GPU)"
+ ],
+ "frames": {
+ "frames": 150,
+ "react": 11.11,
+ "sync": 17.7,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.02
+ }
+ }
+ },
+ "blender": {
+ "device": "Tesla T4",
+ "s": 128.19,
+ "samples_per_minute": {
+ "monster": 591.0,
+ "junkshop": 546.2,
+ "classroom": 435.5
+ },
+ "out": null
+ },
+ "frame": {
+ "ok": false,
+ "samples": null,
+ "load_s": null,
+ "render_s": null,
+ "total_s": 0.77,
+ "out": "00:00.104 system.path | WARNING Could not get a list of mounted file-systems\n00:00.490 reports | ERROR File format is not supported in file \"/root/.cache/blender-benchmark-launcher/scenes/936f0a528f03eba291c67ea87743a0ebde58938fb87471b262721b89b46b875d/classroom/._main.blend\"\nBlender 5.3.0 (hash 02f0899d78e3 built 2026-11-10 01:31:18)\n\nBlender quit\n"
+ },
+ "s": 338.6,
+ "usd": 0.1163
+}
\ No newline at end of file
diff --git a/sdk/cloud/bench/results/none.json b/sdk/cloud/bench/results/none.json
new file mode 100644
index 00000000..d63b6584
--- /dev/null
+++ b/sdk/cloud/bench/results/none.json
@@ -0,0 +1,102 @@
+{
+ "kind": "none",
+ "raea_version": "0.1.6",
+ "blender_version": "5.3.0",
+ "start": 2.9,
+ "device": "cpu",
+ "raea": {
+ "vulkan": [
+ "llvmpipe (LLVM 19.1.7, 256 bits)"
+ ],
+ "edit": {
+ "ok": true,
+ "s": 166.79,
+ "out": [
+ "APPLIED 90 frames rendered to /tmp/edit-1.mp4 (1626.0 ms a frame, pages handed to raea-render on the GPU)",
+ "raea times: the clipping check 89002 ms"
+ ],
+ "frames": {
+ "frames": 90,
+ "react": 290.38,
+ "sync": 307.08,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.0
+ }
+ },
+ "edit-noclip": {
+ "ok": true,
+ "s": 53.11,
+ "out": [
+ "APPLIED 90 frames rendered to /tmp/edit-0.mp4 (558.6 ms a frame, pages handed to raea-render on the GPU)"
+ ],
+ "frames": {
+ "frames": 90,
+ "react": 283.4,
+ "sync": 246.35,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.0
+ }
+ },
+ "solari": {
+ "ok": true,
+ "s": 71.36,
+ "out": [
+ "APPLIED 150 frames rendered to /tmp/solari-1.mp4 (457.9 ms a frame, pages handed to raea-render on the GPU)",
+ "raea times: the clipping check 555 ms"
+ ],
+ "frames": {
+ "frames": 150,
+ "react": 176.11,
+ "sync": 267.56,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.0
+ }
+ },
+ "solari-noclip": {
+ "ok": true,
+ "s": 59.93,
+ "out": [
+ "APPLIED 150 frames rendered to /tmp/solari-0.mp4 (387.5 ms a frame, pages handed to raea-render on the GPU)"
+ ],
+ "frames": {
+ "frames": 150,
+ "react": 176.68,
+ "sync": 204.18,
+ "draw3d": 0.0,
+ "gpu3d": 0.0,
+ "page": 0.0,
+ "gpupage": 0.0,
+ "gpu": 0.0
+ }
+ }
+ },
+ "blender": {
+ "device": "AMD EPYC 7B13",
+ "s": 113.38,
+ "samples_per_minute": {
+ "monster": 140.4,
+ "junkshop": 109.4,
+ "classroom": 78.5
+ },
+ "out": null
+ },
+ "frame": {
+ "ok": true,
+ "samples": 300,
+ "load_s": 0.78,
+ "render_s": 222.87,
+ "total_s": 223.78,
+ "out": "282M | Updating Camera Volume\n00:01.131 render | Fra: 1 | Mem: 282M | Updating Lookup Tables\n00:01.131 render | Fra: 1 | Mem: 282M | Updating Lights\n00:01.131 render | Fra: 1 | Mem: 282M | Updating Lights | Computing distribution\n00:01.133 render | Fra: 1 | Mem: 284M | Updating Integrator\n00:01.134 render | Fra: 1 | Mem: 286M | Updating Film\n00:01.135 render | Fra: 1 | Mem: 285M | Updating Lookup Tables\n00:01.135 render | Fra: 1 | Mem: 286M | Updating Baking\n00:01.135 render | Fra: 1 | Mem: 286M | Updating Device | Writing constant memory\n00:01.135 render | Fra: 1 | Mem: 286M | Loading denoising kernels (may take a few minutes the first time)\n00:01.135 render | Fra: 1 | Mem: 286M | Sample 0/300\n00:02.000 render | Fra: 1 | Remaining: 04:18.65 | Mem: 697M | Sample 1/300\n00:24.932 render | Fra: 1 | Remaining: 03:12.54 | Mem: 697M | Sample 33/300\n00:47.797 render | Fra: 1 | Remaining: 02:48.70 | Mem: 697M | Sample 65/300\n01:10.719 render | Fra: 1 | Remaining: 02:25.62 | Mem: 697M | Sample 97/300\n01:34.020 render | Fra: 1 | Remaining: 02:03.12 | Mem: 697M | Sample 129/300\n01:56.679 render | Fra: 1 | Remaining: 01:39.75 | Mem: 697M | Sample 161/300\n02:19.815 render | Fra: 1 | Remaining: 01:16.88 | Mem: 697M | Sample 193/300\n02:43.585 render | Fra: 1 | Remaining: 00:54.15 | Mem: 697M | Sample 225/300\n03:06.784 render | Fra: 1 | Remaining: 00:31.06 | Mem: 697M | Sample 257/300\n03:29.640 render | Fra: 1 | Remaining: 00:07.93 | Mem: 697M | Sample 289/300\n03:40.081 render | Fra: 1 | Mem: 697M | Sample 300/300\n03:40.081 render | Fra: 1 | Mem: 697M | Finished\n03:43.486 render | Saved: '/tmp/frame_0001.png'\n03:43.486 render | Time: 03:42.87 (Saving: 00:03.39)\nRAEA_SAMPLES 300 RAEA_LOADED 1794935225.9278357\n\nBlender quit\n"
+ },
+ "s": 694.3,
+ "usd": 0.1226
+}
\ No newline at end of file
diff --git a/sdk/cloud/deploy/modal/farm.py b/sdk/cloud/deploy/modal/farm.py
new file mode 100644
index 00000000..945ebdbc
--- /dev/null
+++ b/sdk/cloud/deploy/modal/farm.py
@@ -0,0 +1,329 @@
+# raea cloud's render farm on Modal (docs/cloud-render.feature CR4-CR8): server/jobs.ts's protocol, so a CPU box's
+# `raea render` (RAEA_CLOUD_GPU_URL, server/offload.ts) and the TypeScript client use it unchanged, with one render
+# split across many GPUs at once. From sdk/cloud:
+#
+# MODAL_PROFILE=shane-25168 modal deploy deploy/modal/farm.py
+#
+# POST /v1/jobs?args=JSON[&gpus=N][&gpu=KIND][&max_usd=X] body: the project as a tar. {id}
+# GET /v1/jobs/ID?from=N {log, next, exit?}, held up to 20 s for more
+# GET /v1/jobs/ID/out?as=zst|gz|tar the files the job made or changed; the job is removed
+#
+# - `raea render X.tsx -o OUT.mp4|DIR`: frame 0 renders first on one GPU, to learn the piece's length and the price of
+# a frame; the frames then go out in runs to up to `gpus` GPUs (farm_plan.py sizes them), come back as PNGs, and the
+# coordinator (a CPU) encodes them with the piece's sound
+# - `blender FILE.blend [-o OUT.mp4|DIR] [--frames A-B] [--samples N]`: Cycles on OptiX, split the same way
+# - anything else: `raea ARGS` whole, on one GPU
+# - max_usd: frame 0's price times the frames left; over it, the job stops before the rest start (exit 3)
+# - the clipping check (RAEA_CLIP_CHECK) is off on the GPUs: it is an agent's lint, and on a server's CPU it took more
+# of a render than its frames (bench/gpus.py)
+
+import json
+import os
+import re
+import shutil
+import subprocess
+import time
+import uuid
+
+import modal
+
+HERE = os.path.dirname(os.path.abspath(__file__))
+CLOUD = os.path.dirname(os.path.dirname(HERE))
+RAEA = os.environ.get("RAEA_VERSION", "0.1.6")
+BLENDER = os.environ.get("RAEA_FARM_BLENDER", "5.3.0")
+# The GPUs each kind of job takes, the first Modal has free (bench/gpus.py, 11-17): raea's frames are bound by its CPU
+# (React on QuickJS), so a T4 or an A10 draws them for the least a frame; Cycles gets the most samples a dollar on an
+# L40S or an RTX PRO 6000 (an A100 or H100 has no RT cores: a quarter of that). L4s were scarce (a 254 s start).
+RAEA_GPUS = os.environ.get("RAEA_FARM_RAEA_GPUS", "T4,A10,L4").split(",")
+BLENDER_GPUS = os.environ.get("RAEA_FARM_BLENDER_GPUS", "L40S,RTX-PRO-6000,L4").split(",")
+GPUS = int(os.environ.get("RAEA_FARM_GPUS", "10")) # Modal Starter's GPU limit; Team's is 50
+ROOT = "/farm"
+JOBS = f"{ROOT}/jobs"
+
+image = (
+ modal.Image.from_registry("debian:trixie-slim", add_python="3.12")
+ .apt_install(
+ "ca-certificates", "curl", "xz-utils", "zstd", "procps", "ffmpeg",
+ "libasound2t64", "libfontconfig1", "libvulkan1", "mesa-vulkan-drivers", "vulkan-tools",
+ "libxext6", "libx11-6", "libgl1", "libegl1",
+ "libxi6", "libxxf86vm1", "libxfixes3", "libxrender1", "libxkbcommon0", "libsm6", "libice6",
+ )
+ .run_commands(
+ f"set -e; f=raea-{RAEA}-linux-x86_64.tar.gz; u=https://github.com/shinyobjectz/raea/releases/download/v{RAEA}; "
+ "cd /tmp && curl -fsSL -o $f $u/$f && curl -fsSL -o $f.sha256 $u/$f.sha256 && sha256sum -c $f.sha256 "
+ "&& mkdir -p /opt/raea && tar -xzf $f -C /opt/raea --strip-components=1 && rm -f $f $f.sha256 "
+ "&& ln -s /opt/raea/bin/raea /usr/local/bin/raea && raea --version",
+ f"set -e; v={BLENDER}; curl -fsSL https://download.blender.org/release/Blender${{v%.*}}/blender-$v-linux-x64.tar.xz "
+ "| tar -xJ -C /opt && ln -s /opt/blender-$v-linux-x64/blender /usr/local/bin/blender && blender -b --version | head -1",
+ )
+ .pip_install("fastapi[standard]==0.121.2")
+ .add_local_file(os.path.join(CLOUD, "image", "nvidia_icd.json"), "/usr/share/vulkan/icd.d/nvidia_icd.json", copy=True)
+ .env({"WGPU_BACKEND": "vulkan", "NVIDIA_DRIVER_CAPABILITIES": "all", "RAEA_CLIP_CHECK": "0", "RAEA_AUDIO_MUTE": "1",
+ "RAEA_MODELS": "/models/raea", "RAEA_FEED_MODELS": "/models/feed", "RAEA_LIBRARY_MODELS": "/models/library"})
+ .add_local_python_source("farm_plan", "prices")
+)
+
+app = modal.App(os.environ.get("RAEA_FARM_APP", "raea-farm"), image=image)
+vol = modal.Volume.from_name("raea-farm", create_if_missing=True, version=2)
+# raea's Linux models (deploy/modal/models.sh), read where raea looks for them
+models = modal.Volume.from_name("raea-models", create_if_missing=True, version=2)
+logs = modal.Dict.from_name("raea-farm-logs", create_if_missing=True)
+# the farm's token (RAEA_CLOUD_TOKEN), its own: a CPU box names it as RAEA_CLOUD_GPU_TOKEN
+secret = modal.Secret.from_name(os.environ.get("RAEA_FARM_SECRET", "raea-farm"))
+# a CPU render (the coordinator's sound pass) on lavapipe, with EGL's vendors hidden (docs/cloud.feature CL13)
+CPU_ENV = {"VK_DRIVER_FILES": "/usr/share/vulkan/icd.d/lvp_icd.json", "__EGL_VENDOR_LIBRARY_DIRS": "/nonexistent"}
+
+
+# NVIDIA's shader cache and Cycles' kernels on the farm's volume, so a GPU's start reuses what an earlier one compiled
+CACHES = {"__GL_SHADER_DISK_CACHE": "1", "__GL_SHADER_DISK_CACHE_PATH": f"{ROOT}/cache/nvidia", "__GL_SHADER_DISK_CACHE_SKIP_CLEANUP": "1",
+ "__GL_SHADER_DISK_CACHE_SIZE": str(4 << 30), "XDG_CACHE_HOME": f"{ROOT}/cache/xdg"}
+
+
+# when this container's Python started, for the job's bill (farm_plan.Bill)
+BOOTED = time.time()
+
+
+def life():
+ return {"task": os.environ.get("MODAL_TASK_ID", ""), "boot": BOOTED, "end": time.time()}
+
+
+def run(cmd, cwd=None, env=None, timeout=6 * 3600):
+ t = time.time()
+ for d in (CACHES["__GL_SHADER_DISK_CACHE_PATH"], CACHES["XDG_CACHE_HOME"]):
+ os.makedirs(d, exist_ok=True)
+ r = subprocess.run(cmd, cwd=cwd, capture_output=True, text=True, env={**os.environ, "HOME": "/tmp/home", **CACHES, **(env or {})}, timeout=timeout)
+ return r.returncode, r.stdout + r.stderr, time.time() - t
+
+
+def snapshot(d):
+ out = {}
+ for base, _, files in os.walk(d):
+ for f in files:
+ p = os.path.join(base, f)
+ s = os.stat(p)
+ out[os.path.relpath(p, d)] = f"{s.st_size}:{s.st_mtime_ns}"
+ return out
+
+
+class Log:
+ """The job's output for GET /v1/jobs/ID: the coordinator is its only writer."""
+
+ def __init__(self, id):
+ self.id, self.lines = id, []
+
+ def __call__(self, text, err=False):
+ self.lines.append({"err" if err else "out": text if text.endswith("\n") else text + "\n"})
+ logs[self.id] = self.lines
+
+ def end(self, code):
+ logs[f"{self.id}:exit"] = code
+
+
+# a GPU stays up this long after its last run, billed (farm_plan.SCALEDOWN): at 60 s, the farm's jobs of 11-17 billed
+# about five times their GPUs' working seconds
+SCALEDOWN = 2
+
+
+def on(gpus):
+ return dict(gpu=gpus, cpu=4, memory=16384, volumes={ROOT: vol, "/models": models}, timeout=6 * 3600, max_containers=GPUS, scaledown_window=SCALEDOWN)
+
+
+def kind():
+ """This container's GPU by its price list name (prices.py), for the planner's estimate."""
+ import prices
+
+ name = subprocess.run(["nvidia-smi", "--query-gpu=name", "--format=csv,noheader"], capture_output=True, text=True).stdout
+ return prices.kind_of(name)
+
+
[email protected](**on(RAEA_GPUS))
+def raea_run(id: str, args: list[str], frames: list[int] | None = None, first: int = 0, probe: bool = False, video: bool = False) -> dict:
+ """raea ARGS in the job's folder. With `frames`: those frames to the job's frames/ folder, from frame `first` on,
+ as one H.264 run (frames/run-FIRST.mp4, joined by the coordinator without encoding again) when `video`, else PNGs.
+ With `probe`: frame 0 and the piece's length, size and rate (its manifest). One function for all three, so the
+ container that rendered frame 0 is warm for the next run."""
+ vol.reload()
+ work = f"{JOBS}/{id}/work"
+ if probe:
+ code, out, s = run(["raea", *args, "--frame", "0", "-o", "/tmp/probe.png", "--manifest", "/tmp/probe.json"], cwd=work)
+ m = json.load(open("/tmp/probe.json")) if os.path.exists("/tmp/probe.json") else {}
+ return {"code": code, "out": out[-3000:], "s": s, "length": m.get("length"), "fps": m.get("fps"), "w": m.get("width"), "h": m.get("height"), "kind": kind(), **life()}
+ if frames is None:
+ code, out, s = run(["raea", *args], cwd=work)
+ vol.commit()
+ models.commit() # what raea fetched on first use (RAEA_FEED_MODELS), for every container after
+ return {"code": code, "out": out[-4000:], "s": s}
+ dest = f"{JOBS}/{id}/frames"
+ os.makedirs(dest, exist_ok=True)
+ if video:
+ seg = f"/tmp/run-{first:05d}.mp4"
+ code, out, s = run(["raea", *args, "--at", ",".join(map(str, frames)), "-o", seg], cwd=work)
+ if os.path.exists(seg):
+ shutil.move(seg, f"{dest}/run-{first:05d}.mp4")
+ vol.commit()
+ ms = re.search(r"([\d.]+) ms a frame", out)
+ return {"code": code, "out": out[-2000:], "s": s, "frames": len(frames), "ms": float(ms.group(1)) if ms else None, "kind": kind(), **life()}
+ tmp = f"/tmp/{uuid.uuid4().hex}"
+ code, out, s = run(["raea", *args, "--at", ",".join(map(str, frames)), "-o", tmp], cwd=work)
+ # raea names --at's stills in order (frame-00000.png is the first frame asked for), beside its manifest
+ made = sorted(n for n in os.listdir(tmp) if re.fullmatch(r"frame-\d+\.png", n)) if os.path.isdir(tmp) else []
+ # a frame's time from when the stills were written (raea's stills path doesn't say it), the start excluded
+ t = [os.stat(os.path.join(tmp, n)).st_mtime for n in made]
+ ms = 1000 * (t[-1] - t[0]) / (len(t) - 1) if len(t) > 1 else None
+ # the run's warm-up frames (those before `first`) are dropped
+ for i, name in enumerate(made):
+ if frames[i] >= first:
+ shutil.move(os.path.join(tmp, name), f"{dest}/frame-{frames[i]:05d}.png")
+ vol.commit()
+ return {"code": code, "out": out[-2000:], "s": s, "frames": len(made), "ms": ms, "kind": kind(), **life()}
+
+
+BLENDER_SETUP = """
+import bpy, json, sys
+s = bpy.context.scene
+a = json.loads(sys.argv[sys.argv.index("--") + 1])
+if a.get("samples"): s.cycles.samples = a["samples"]
+if s.render.engine == "CYCLES":
+ p = bpy.context.preferences.addons["cycles"].preferences
+ p.compute_device_type = "OPTIX"
+ p.get_devices()
+ for d in p.devices:
+ d.use = d.type == "OPTIX"
+ s.cycles.device = "GPU"
+print("RAEA_INFO " + json.dumps({"start": s.frame_start, "end": s.frame_end, "fps": s.render.fps / s.render.fps_base,
+ "w": s.render.resolution_x * s.render.resolution_percentage // 100, "h": s.render.resolution_y * s.render.resolution_percentage // 100,
+ "engine": s.render.engine, "samples": s.cycles.samples}))
+"""
+
+
[email protected](**on(BLENDER_GPUS))
+def blender_run(id: str, blend: str, start: int, end: int, opts: dict) -> dict:
+ vol.reload()
+ work = f"{JOBS}/{id}/work"
+ dest = f"{JOBS}/{id}/frames"
+ os.makedirs(dest, exist_ok=True)
+ cmd = ["blender", "-b", blend, "--python-expr", BLENDER_SETUP, "-o", f"{dest}/frame-#####", "-F", "PNG", "-s", str(start), "-e", str(end), "-a", "--", json.dumps(opts)]
+ code, out, s = run(cmd, cwd=work)
+ # a video's frames: this run's H.264 part, encoded here on this GPU's CPUs while the others render theirs
+ if not code and opts.get("video"):
+ import farm_plan
+
+ seg = f"{dest}/run-{start:05d}.mp4"
+ pngs = [f"{dest}/frame-{f:05d}.png" for f in range(start, end + 1)]
+ c, o, _ = farm_plan.encode(dest, seg, opts["fps"], None, run, start=start, frames=end - start + 1)
+ code, out = (c, out + o) if c else (0, out)
+ for p in pngs:
+ if os.path.exists(p):
+ os.remove(p)
+ vol.commit()
+ times = [int(m) * 60 + float(x) for m, x in re.findall(r"Time: (\d+):([\d.]+)", out)]
+ return {"code": code, "out": out[-2000:], "s": s, "frames": end - start + 1, "render_s": times, "kind": kind(), **life()}
+
+
[email protected](cpu=2, memory=4096, volumes={ROOT: vol}, timeout=24 * 3600, secrets=[secret])
+def coordinate(id: str, args: list[str], opts: dict):
+ import farm_plan
+
+ log = Log(id)
+ log(f"raea farm: raea {' '.join(args)}")
+ vol.reload()
+ work = f"{JOBS}/{id}/work"
+ before = snapshot(work)
+ try:
+ code = farm_plan.dispatch(args, {**opts, "id": id}, work, log, raea_run, blender_run, CPU_ENV, run, vol.reload)
+ except Exception as e: # the job's own failure, said in its log; the farm goes on
+ log(f"raea farm: {e!r}", err=True)
+ code = 1
+ vol.commit()
+ after = snapshot(work)
+ with open(f"{JOBS}/{id}/changed.txt", "w") as f:
+ f.write("".join(p + "\n" for p, v in after.items() if before.get(p) != v))
+ shutil.rmtree(f"{JOBS}/{id}/frames", ignore_errors=True)
+ vol.commit()
+ log.end(code)
+
+
[email protected](cpu=1, memory=4096, volumes={ROOT: vol}, secrets=[secret], timeout=3600)
[email protected](max_inputs=32)
+def api():
+ import asyncio
+
+ from fastapi import FastAPI, HTTPException, Request
+ from fastapi.responses import JSONResponse, PlainTextResponse, Response
+
+ web = FastAPI()
+ token = os.environ["RAEA_CLOUD_TOKEN"]
+
+ def check(req: Request):
+ got = req.headers.get("authorization", "").removeprefix("Bearer ") or req.query_params.get("token", "")
+ if got != token:
+ raise HTTPException(401, "a raea cloud token is needed (Authorization: Bearer)")
+
+ @web.get("/healthz")
+ def healthz():
+ return PlainTextResponse("ok")
+
+ @web.get("/v1/health")
+ def health(req: Request):
+ check(req)
+ return {"raea": RAEA, "blender": BLENDER, "device": {"renders": "gpu", "name": f"raea on {'/'.join(RAEA_GPUS)}, Blender on {'/'.join(BLENDER_GPUS)}, up to {GPUS} at once"}, "farm": True, "jobs": []}
+
+ @web.post("/v1/jobs")
+ async def start(req: Request):
+ check(req)
+ args = json.loads(req.query_params.get("args", "null"))
+ if not isinstance(args, list) or not all(isinstance(a, str) for a in args):
+ raise HTTPException(400, "args must be a JSON array of strings: raea's own arguments")
+ q = req.query_params
+ opts = {"gpus": min(int(q.get("gpus", GPUS)), GPUS), "gpu": q.get("gpu"), "max_usd": float(q["max_usd"]) if "max_usd" in q else None}
+ id = str(uuid.uuid4())
+ work = f"{JOBS}/{id}/work"
+ os.makedirs(work)
+ tar = f"{JOBS}/{id}/in.tar"
+ with open(tar, "wb") as f:
+ async for chunk in req.stream():
+ f.write(chunk)
+ # GNU tar reads the compression itself, refuses members with .. and strips a leading /
+ x = subprocess.run(["tar", "-xf", tar, "-C", work, "--no-same-owner", "--no-same-permissions"], capture_output=True, text=True)
+ os.remove(tar)
+ if x.returncode:
+ shutil.rmtree(f"{JOBS}/{id}", ignore_errors=True)
+ raise HTTPException(400, f"the folder didn't unpack: {x.stderr.strip()}")
+ await vol.commit.aio()
+ await logs.put.aio(id, [])
+ await coordinate.spawn.aio(id, args, opts)
+ return {"id": id}
+
+ @web.get("/v1/jobs/{id}")
+ async def follow(id: str, req: Request):
+ check(req)
+ start = int(req.query_params.get("from", 0))
+ until = time.time() + 20
+ while True:
+ lines = await logs.get.aio(id)
+ if lines is None:
+ raise HTTPException(404, "no such job")
+ code = await logs.get.aio(f"{id}:exit")
+ if len(lines) > start or code is not None or time.time() > until:
+ body = {"log": lines[start:], "next": len(lines)}
+ return JSONResponse(body if code is None else {**body, "exit": code})
+ await asyncio.sleep(0.5)
+
+ @web.get("/v1/jobs/{id}/out")
+ def out(id: str, req: Request):
+ check(req)
+ if logs.get(f"{id}:exit") is None:
+ raise HTTPException(404, "no such finished job")
+ vol.reload()
+ pack = {"zst": ["--zstd"], "gz": ["--gzip"], "tar": []}.get(req.query_params.get("as", "zst"), ["--zstd"])
+ r = subprocess.run(["tar", *pack, "-cf", "-", "-C", f"{JOBS}/{id}/work", "--verbatim-files-from", "-T", f"{JOBS}/{id}/changed.txt"], capture_output=True)
+ shutil.rmtree(f"{JOBS}/{id}", ignore_errors=True)
+ vol.commit()
+ for k in (id, f"{id}:exit"):
+ logs.pop(k, None)
+ if r.returncode:
+ raise HTTPException(500, f"the results didn't pack: {r.stderr.decode().strip()}")
+ return Response(r.stdout, media_type="application/octet-stream")
+
+ return web
diff --git a/sdk/cloud/deploy/modal/farm_plan.py b/sdk/cloud/deploy/modal/farm_plan.py
new file mode 100644
index 00000000..57ad1c9a
--- /dev/null
+++ b/sdk/cloud/deploy/modal/farm_plan.py
@@ -0,0 +1,271 @@
+# How the farm (farm.py) splits a job: which kind of job it is, how many GPUs a render is worth, the runs of frames
+# each one takes, what it will cost, and the encode at the end. No Modal here, so test/farm_plan.py runs it on a laptop
+# with stand-in GPUs.
+
+import json
+import math
+import os
+import re
+import shutil
+import threading
+import time
+
+import prices
+
+VIDEO = (".mp4", ".mov")
+COMPOSITION = re.compile(r"\.(tsx|ts|jsx|js|mjs)$")
+# frames rendered on the first GPU after frame 0, to time a frame before the rest go out
+FIRST = 8
+# a GPU's start (container, raea or Blender, the scene) kept to at most this share of what it does
+SHARE = 0.2
+
+
+def split_out(args):
+ """The arguments without -o OUT, and OUT."""
+ if "-o" not in args:
+ return list(args), None
+ i = args.index("-o")
+ return args[:i] + args[i + 2 :], args[i + 1] if i + 1 < len(args) else None
+
+
+def splittable(args):
+ """A `raea render` of a composition to a video or a folder, every frame: the farm can split it."""
+ if not args or args[0] != "render" or any(a in args for a in ("--frame", "--at", "--review", "--bundle", "--audio")):
+ return False
+ rest, out = split_out(args)
+ return out is not None and (out.endswith(VIDEO) or not os.path.splitext(out)[1]) and any(COMPOSITION.search(a) for a in rest[1:])
+
+
+def gpus_for(frames, frame_s, start_s, most):
+ """The GPUs worth starting for `frames` frames of `frame_s` each, when each one first spends `start_s`: the most that
+ keep each one's start at most SHARE of its time, never more than `most`."""
+ if frames <= 0:
+ return 0
+ if frame_s <= 0:
+ return min(most, frames)
+ worth = start_s * (1 - SHARE) / SHARE # the work (s) that makes a start worth it
+ k = math.floor(frames * frame_s / worth + 1e-9) if worth > 0 else frames
+ return max(1, min(most, frames, k))
+
+
+def runs(first, last, k, warm=0):
+ """Frames first..last (inclusive) as `k` contiguous runs, each led by `warm` frames to drop (a renderer's history,
+ Solari's light, settling): [(frames to render, the first one kept)]."""
+ n = last - first + 1
+ k = max(1, min(k, n))
+ out, at = [], first
+ for i in range(k):
+ size = n // k + (1 if i < n % k else 0)
+ lead = max(0, at - warm)
+ out.append((list(range(lead, at + size)), at))
+ at += size
+ return out
+
+
+def price(kind, seconds, cpu=4, memory_gib=16):
+ return prices.cost(kind, cpu=cpu, memory_gib=memory_gib, seconds=seconds)
+
+
+SCALEDOWN = 2 # s a GPU container stays up after its last run (farm.py), billed
+BOOT = 3 # s a container is billed before its Python starts: the bench's cold starts on T4, L40S, RTX PRO 6000 (3-4 s)
+
+
+class Bill:
+ """What Modal bills for a job's GPU containers: each one's life from its boot (or the job's start, for one an
+ earlier job left up) to its last run's end, plus BOOT and SCALEDOWN, at its kind's price with 4 cores and 16 GiB."""
+
+ def __init__(self):
+ self.t0, self.tasks = time.time(), {}
+
+ def add(self, r):
+ if isinstance(r, dict) and r.get("task"):
+ b, e = max(r["boot"], self.t0), r["end"]
+ k, b0, e0 = self.tasks.get(r["task"], (r.get("kind"), b, e))
+ self.tasks[r["task"]] = (k or r.get("kind"), min(b, b0), max(e, e0))
+ return r
+
+ def line(self):
+ up = [(k or "L4", e - b + BOOT + SCALEDOWN) for k, b, e in self.tasks.values()]
+ return f"raea farm: billed about ${sum(price(k, s) for k, s in up):.3f}: {len(up)} GPU containers up {sum(s for _, s in up):.0f} s in all"
+
+
+def encode(frames_dir, out, fps, sound, run, start=0, frames=None):
+ """The frames as OUT (H.264, high quality), with the sound when there is one; `frames` of them from `start`."""
+ cmd = ["ffmpeg", "-y", "-loglevel", "error", "-framerate", str(fps), "-start_number", str(start), "-i", f"{frames_dir}/frame-%05d.png"]
+ if frames:
+ cmd += ["-frames:v", str(frames)]
+ if sound and os.path.exists(sound) and os.path.getsize(sound) > 44:
+ cmd += ["-i", sound, "-c:a", "aac", "-b:a", "256k", "-shortest"]
+ cmd += ["-c:v", "libx264", "-preset", "medium", "-crf", "16", "-pix_fmt", "yuv420p", "-movflags", "+faststart", out]
+ return run(cmd)
+
+
+def join(frames_dir, out, sound, run):
+ """The runs' H.264 videos (run-FIRST.mp4) as OUT, one after another without encoding again, with the sound."""
+ runs_ = sorted(n for n in os.listdir(frames_dir) if re.fullmatch(r"run-\d+\.mp4", n))
+ listing = os.path.join(frames_dir, "runs.txt")
+ with open(listing, "w") as f:
+ f.writelines(f"file '{n}'\n" for n in runs_)
+ cmd = ["ffmpeg", "-y", "-loglevel", "error", "-f", "concat", "-safe", "0", "-i", listing]
+ if sound and os.path.exists(sound) and os.path.getsize(sound) > 44:
+ cmd += ["-i", sound, "-map", "0:v", "-map", "1:a", "-c:a", "aac", "-b:a", "256k", "-shortest"]
+ cmd += ["-c:v", "copy", "-movflags", "+faststart", out]
+ return run(cmd)
+
+
+def keep(frames_dir, out, start=0):
+ """The frames as a folder of PNGs, named as raea names them (frame-00000.png is the first)."""
+ os.makedirs(out, exist_ok=True)
+ for i, name in enumerate(sorted(os.listdir(frames_dir))):
+ shutil.move(os.path.join(frames_dir, name), os.path.join(out, f"frame-{i:05d}.png"))
+
+
+def spread(fn, kind, calls, log, what, bill=None):
+ """`calls` on `fn` at once; each finished run said in the log as it lands. The first failure's code, else 0."""
+ code = 0
+ for r in fn.starmap(calls, order_outputs=False, return_exceptions=True):
+ if isinstance(r, Exception):
+ log(f"raea farm: a run failed: {r!r}", err=True)
+ code = code or 1
+ continue
+ if bill:
+ bill.add(r)
+ log(f"raea farm: {r.get('frames')} {what} on a {r.get('kind') or kind} in {r['s']:.1f} s")
+ if r["code"]:
+ log(r["out"], err=True)
+ code = code or r["code"]
+ return code
+
+
+def raea_render(args, opts, work, log, render, cpu_env, run, reload=lambda: None, bill=None):
+ bill = bill or Bill()
+ id = opts["id"]
+ rest, out = split_out(args)
+ # the sound, on this CPU while the GPUs draw (a video's frames come back without it)
+ sound = f"/tmp/{id}.wav"
+ if out.endswith(VIDEO):
+ t = threading.Thread(target=lambda: run(["raea", *rest, "-o", sound], cwd=work, env=cpu_env))
+ t.start()
+ p = bill.add(render.remote(id, rest, probe=True))
+ if p["code"] or not p["length"]:
+ log(p["out"], err=True)
+ return p["code"] or 1
+ length, fps, kind = p["length"], p["fps"] or 30, p.get("kind") or opts.get("gpu") or "T4"
+ log(f"raea farm: {length} frames at {p['w']}x{p['h']}, {fps} fps; frame 0 on a {kind} in {p['s']:.1f} s")
+ video = out.endswith(VIDEO)
+ n0 = min(length, FIRST)
+ r0 = bill.add(render.remote(id, rest, list(range(n0)), 0, video=video))
+ if r0["code"]:
+ log(r0["out"], err=True)
+ return r0["code"]
+ frame_s = (r0["ms"] or 1000 * r0["s"] / n0) / 1000
+ start_s = max(0.0, r0["s"] - frame_s * n0)
+ left = length - n0
+ k = gpus_for(left, frame_s, start_s, opts["gpus"])
+ cost = price(kind, p["s"] + r0["s"] + k * start_s + left * frame_s)
+ log(f"raea farm: {frame_s * 1000:.0f} ms a frame, {start_s:.1f} s to start; {left} frames left on {k} {kind}s, about ${cost:.3f} in all")
+ if opts.get("max_usd") is not None and cost > opts["max_usd"]:
+ log(f"raea farm: about ${cost:.3f} is over max_usd ${opts['max_usd']:.3f}, so the rest don't start", err=True)
+ return 3
+ # a video's runs can't drop warm-up frames without encoding again, so they have none
+ warm = 0 if video else opts.get("warm", 0)
+ code = spread(render, kind, [(id, rest, f, at, False, video) for f, at in runs(n0, length - 1, k, warm)], log, "frames", bill) if left else 0
+ if code:
+ return code
+ reload() # the other containers' frames
+ frames = f"{os.path.dirname(work)}/frames"
+ dest = os.path.join(work, out)
+ if video:
+ t.join()
+ os.makedirs(os.path.dirname(dest) or ".", exist_ok=True)
+ c, o, s = join(frames, dest, sound, run)
+ log(f"raea farm: joined {out} in {s:.1f} s" if not c else o, err=bool(c))
+ return c
+ keep(frames, dest)
+ return 0
+
+
+def blender_info(blend, work, run):
+ c, o, _ = run(["blender", "-b", blend, "--python-expr", BLENDER_INFO], cwd=work)
+ m = re.search(r"RAEA_INFO (\{.*\})", o)
+ return json.loads(m.group(1)) if m else None
+
+
+BLENDER_INFO = """
+import bpy, json
+s = bpy.context.scene
+print("RAEA_INFO " + json.dumps({"start": s.frame_start, "end": s.frame_end, "fps": s.render.fps / s.render.fps_base,
+ "engine": s.render.engine}))
+"""
+
+
+def blender(args, opts, work, log, render, run, reload=lambda: None, bill=None):
+ bill = bill or Bill()
+ """blender FILE.blend [-o OUT.mp4|DIR] [--frames A-B] [--samples N]"""
+ id = opts["id"]
+ rest, out = split_out(args[1:])
+ blend = next((a for a in rest if a.endswith(".blend")), None)
+ if not blend:
+ log("raea farm: blender needs a .blend", err=True)
+ return 2
+ info = blender_info(blend, work, run)
+ if not info:
+ log(f"raea farm: Blender couldn't open {blend}", err=True)
+ return 2
+ first, last = info["start"], info["end"]
+ if "--frames" in rest:
+ a, _, b = rest[rest.index("--frames") + 1].partition("-")
+ first, last = int(a), int(b or a)
+ o = {"samples": int(rest[rest.index("--samples") + 1])} if "--samples" in rest else {}
+ video = bool(out and out.endswith(VIDEO))
+ if video:
+ o |= {"video": True, "fps": info["fps"]}
+ log(f"raea farm: {blend}, frames {first}-{last} ({info['engine']}), at {info['fps']:g} fps")
+ r0 = bill.add(render.remote(id, blend, first, first, o))
+ if r0["code"]:
+ log(r0["out"], err=True)
+ return r0["code"]
+ kind = r0.get("kind") or opts.get("gpu") or "L40S"
+ frame_s = r0["render_s"][-1] if r0["render_s"] else r0["s"]
+ start_s = max(0.0, r0["s"] - frame_s)
+ left = last - first
+ k = gpus_for(left, frame_s, start_s, opts["gpus"])
+ cost = price(kind, r0["s"] + k * start_s + left * frame_s)
+ log(f"raea farm: frame {first} on a {kind} in {r0['s']:.1f} s ({frame_s:.1f} s rendering); {left} left on {k} {kind}s, about ${cost:.3f} in all")
+ if opts.get("max_usd") is not None and cost > opts["max_usd"]:
+ log(f"raea farm: about ${cost:.3f} is over max_usd ${opts['max_usd']:.3f}, so the rest don't start", err=True)
+ return 3
+ calls = [(id, blend, f[0], f[-1], o) for f, _ in runs(first + 1, last, k)] if left else []
+ code = spread(render, kind, calls, log, "frames", bill) if calls else 0
+ if code:
+ return code
+ reload() # the other containers' frames
+ frames = f"{os.path.dirname(work)}/frames"
+ dest = os.path.join(work, out or "render")
+ if video:
+ os.makedirs(os.path.dirname(dest) or ".", exist_ok=True)
+ c, o2, s = join(frames, dest, None, run)
+ log(f"raea farm: joined {out} in {s:.1f} s" if not c else o2, err=bool(c))
+ return c
+ keep(frames, dest)
+ return 0
+
+
+def dispatch(args, opts, work, log, render, blender_render, cpu_env, run, reload=lambda: None):
+ """The job: a split raea render, a split Blender render, or `raea ARGS` whole on one GPU."""
+ if opts.get("gpu"):
+ render, blender_render = (f.with_options(gpu=opts["gpu"]) for f in (render, blender_render))
+ if args and args[0] == "blender":
+ bill = Bill()
+ code = blender(args, opts, work, log, blender_render, run, reload, bill)
+ log(bill.line())
+ return code
+ bill = Bill()
+ if splittable(args):
+ code = raea_render(args, opts, work, log, render, cpu_env, run, reload, bill)
+ else:
+ r = bill.add(render.remote(opts["id"], args))
+ log(r["out"], err=bool(r["code"]))
+ code = r["code"]
+ log(bill.line())
+ return code
diff --git a/sdk/cloud/deploy/modal/models.sh b/sdk/cloud/deploy/modal/models.sh
new file mode 100755
index 00000000..5f4b0f53
--- /dev/null
+++ b/sdk/cloud/deploy/modal/models.sh
@@ -0,0 +1,68 @@
+#!/bin/bash
+# The models raea runs on Linux, from this Mac into the Modal volume raea-models (docs/cloud-render.md, "Models"), for
+# the farm's GPUs and a cloud box to mount instead of fetching them on each cold start:
+#
+# MODAL_PROFILE=shane-25168 deploy/modal/models.sh # stage and upload
+# deploy/modal/models.sh --dry # stage only, and list what would go
+#
+# /raea perception's folder (RAEA_MODELS): the ONNX and data files no public source serves as raea runs them;
+# Core ML and MLX ports stay on the Mac
+# /library the app library's (RAEA_LIBRARY_MODELS): TrustMark
+# /feed raea's model cache (RAEA_FEED_MODELS), left to raea: it fetches each model from Hugging Face on first use
+# (CLAP, SigLIP 2, EmbeddingGemma 2, Parakeet, Pocket TTS, ...) and the farm keeps what it fetched
+# --all sends this Mac's copies of those too (6 GB: slow from a home connection)
+#
+# Staged as APFS clones (no disk), so the upload never reads a file another session is writing.
+set -euo pipefail
+dry=${1:-}
+stage=$(mktemp -d "${TMPDIR:-/tmp}/raea-models.XXXXXX")
+trap 'rm -rf "${stage:?}"' EXIT
+
+perception=${RAEA_MODELS:-$HOME/.local/share/raea-models}
+feed=${RAEA_FEED_MODELS:-$HOME/.cache/raea-feed/models}
+library=${RAEA_LIBRARY_MODELS:-$HOME/.raea/models}
+
+# name in perception's folder, then the parts that run on Linux
+PERCEPTION=(
+ "beat-this beat_this_small0.onnx"
+ "htdemucs htdemucs_core.onnx"
+ "silero-vad silero_vad.onnx"
+ "transnetv2 transnetv2.onnx LICENSE SOURCE.txt"
+ "yamnet yamnet.onnx yamnet_class_map.csv"
+ "soma body mannequin LICENSE SOMA_neutral.npz SOMA_template_rig.usda"
+ "garments garment-words.npz soma_sdf.npz"
+ "overlay-seg overlay-seg.bpk cut.json"
+)
+# the large ones a public source serves (Hugging Face): sent only with --all
+[ "$dry" = --all ] && PERCEPTION+=(
+ "siglip2-base-p16-224 onnx tokenizer.json tokenizer_config.json special_tokens_map.json config.json preprocessor_config.json"
+ "siglip2-base-p16-256 onnx tokenizer.json tokenizer_config.json special_tokens_map.json config.json preprocessor_config.json"
+ "nomic-embed-v1.5 text"
+)
+for row in "${PERCEPTION[@]}"; do
+ read -r name parts <<<"$row"
+ for p in $parts; do
+ [ -e "$perception/$name/$p" ] || { echo "models: $perception/$name/$p isn't here, left out"; continue; }
+ mkdir -p "$stage/raea/$name"
+ cp -cR "$perception/$name/$p" "$stage/raea/$name/"
+ done
+done
+[ "$dry" = --all ] && for name in clap-htsat-unfused clap-htsat-unfused-fp32 parakeet-tdt-0.6b-v3 pocket-tts silero-vad smart-turn-v3; do
+ [ -d "$feed/$name" ] && { mkdir -p "$stage/feed"; cp -cR "$feed/$name" "$stage/feed/"; } || echo "models: $feed/$name isn't here, left out"
+done
+library_sets=(trustmark)
+[ "$dry" = --all ] && library_sets+=(onnx-community/embeddinggemma-2-ONNX onnx-community/whisper-base)
+for name in "${library_sets[@]}"; do
+ [ -d "$library/$name" ] && { mkdir -p "$stage/library/$(dirname "$name")"; cp -cR "$library/$name" "$stage/library/$(dirname "$name")/"; } || echo "models: $library/$name isn't here, left out"
+done
+# Core ML, MLX and anything the Mac made for itself
+find "$stage" \( -name '*.mlpackage' -o -name '*.mlmodelc' -o -name coreml -o -name mlx -o -name '.DS_Store' \) -prune -exec rm -rf {} +
+
+du -sh "$stage"/* | sed "s|$stage/||"
+[ "$dry" = --dry ] && { find "$stage" -type f | sed "s|$stage/||" | sort; exit 0; }
+[ "${MODAL_PROFILE:-}" = shane-25168 ] || { echo "models: run with MODAL_PROFILE=shane-25168 (raea's own Modal workspace)"; exit 2; }
+modal volume create raea-models --version 2 2>/dev/null || true
+for top in raea feed library; do
+ [ -d "$stage/$top" ] && modal volume put --force raea-models "$stage/$top" "/$top"
+done
+modal volume ls raea-models /
diff --git a/sdk/cloud/deploy/modal/prices.py b/sdk/cloud/deploy/modal/prices.py
new file mode 100644
index 00000000..3f32692c
--- /dev/null
+++ b/sdk/cloud/deploy/modal/prices.py
@@ -0,0 +1,43 @@
+# Modal's list prices (modal.com/pricing, read 2026-11-17), in dollars per second, and what a container cost. A GPU
+# container also pays for its CPU (per physical core, two vCPUs) and memory, which on an L4 is most of the price again
+# at 8 cores and 32 GiB: why bench/gpus.py's numbers come with the container's size.
+
+import re
+
+GPU = {
+ "B300": 0.001972,
+ "B200": 0.001736,
+ "H200": 0.001261,
+ "H100": 0.001097,
+ "RTX-PRO-6000": 0.000842,
+ "A100-80GB": 0.000694,
+ "A100-40GB": 0.000583,
+ "L40S": 0.000542,
+ "A10": 0.000306,
+ "L4": 0.000222,
+ "T4": 0.000164,
+}
+CORE = 0.0000131 # one physical core
+GIB = 0.00000222 # one GiB of memory
+
+
+def per_hour(kind, cpu, memory_gib):
+ return round(3600 * (GPU.get(kind, 0) + cpu * CORE + memory_gib * GIB), 4)
+
+
+def cost(kind, cpu, memory_gib, seconds):
+ return round(seconds * per_hour(kind, cpu, memory_gib) / 3600, 4)
+
+
+def kind_of(name):
+ """nvidia-smi's name for a GPU (NVIDIA L40S, Tesla T4, NVIDIA RTX PRO 6000 Blackwell Server Edition, NVIDIA
+ A100-SXM4-40GB) as its name here, or "" when it isn't one."""
+ n = name.upper()
+ if "RTX PRO 6000" in n:
+ return "RTX-PRO-6000"
+ if "A100" in n:
+ return "A100-80GB" if "80GB" in n else "A100-40GB"
+ for k in ("B300", "B200", "H200", "H100", "L40S", "A10", "L4", "T4"):
+ if re.search(rf"\b{k}\b", n):
+ return k
+ return ""
diff --git a/sdk/cloud/deploy/sprites/box.sh b/sdk/cloud/deploy/sprites/box.sh
new file mode 100755
index 00000000..1a2bbcf5
--- /dev/null
+++ b/sdk/cloud/deploy/sprites/box.sh
@@ -0,0 +1,93 @@
+#!/bin/bash
+# raea cloud's agent box on a Fly Sprite (docs/cloud-render.feature CR11, CR12): raea's Linux release, ACP agents and
+# sdk/cloud's server on the Sprite's own HTTPS URL, its renders sent to the farm's GPUs (deploy/modal/farm.py). A Sprite
+# bills the CPU and memory it actually uses, sleeps when nothing talks to it and keeps its disk, so an agent that mostly
+# waits on its model costs little; the GPUs it needs come from the farm and stop when the render does. From sdk/cloud:
+#
+# deploy/sprites/box.sh up NAME the Sprite, made or completed, and its server started
+# deploy/sprites/box.sh status NAME its URL, raea, the server's health
+# deploy/sprites/box.sh token NAME its RAEA_CLOUD_TOKEN, for the TypeScript client
+#
+# RAEA_VERSION (0.1.6) and AGENTS ("kimi-code claude-acp") pick what goes on; the farm comes from
+# ~/.config/raea-cloud/farm.env (RAEA_CLOUD_GPU_URL, RAEA_CLOUD_GPU_TOKEN). The Sprite's URL stays private to the org.
+set -euo pipefail
+
+# The org is the one raea owns, written once in ~/.config/raea-cloud/sprites.env (RAEA_SPRITES_ORG=...), never taken
+# from the environment, and never one listed in private/cloud/sprites-denied.txt (orgs that belong to other businesses).
+# (No apostrophe may go in a ${VAR:?message}: it opens a quote that swallows the lines after it, as it once did this
+# guard's, and a box went into the wrong org.)
+CONF=${RAEA_SPRITES_ENV:-$HOME/.config/raea-cloud/sprites.env}
+ORG=$( [ -f "$CONF" ] && sed -n 's/^RAEA_SPRITES_ORG=//p' "$CONF" | tail -1 || true)
+[ -n "$ORG" ] || { echo "box: write RAEA_SPRITES_ORG=<the Sprites org raea owns> in $CONF (sprite org list)"; exit 2; }
+DENIED=$(git -C "$(dirname "$0")" rev-parse --show-toplevel 2>/dev/null)/private/cloud/sprites-denied.txt
+if [ -f "$DENIED" ] && grep -qxF "$ORG" "$DENIED"; then
+ echo "box: $ORG belongs to another business ($DENIED); raea boxes go in an org raea owns"
+ exit 2
+fi
+NAME=${2:-}
+[ -n "$NAME" ] || { echo "box: name the Sprite"; exit 2; }
+RAEA_VERSION=${RAEA_VERSION:-0.1.6}
+AGENTS=${AGENTS:-kimi-code claude-acp}
+NODE=24.22.0
+HERE=$(cd "$(dirname "$0")/../.." && pwd)
+FARM=${RAEA_FARM_ENV:-$HOME/.config/raea-cloud/farm.env}
+
+# the Sprite's login shell warns about line editing on every exec; only the command's own status counts
+quiet() { grep --line-buffered -v 'bind: warning' || true; }
+x() { sprite exec -o "$ORG" -s "$NAME" -- bash -c "$*" 2>&1 | quiet; }
+# a file onto the Sprite over exec's stdin (the CLI's own upload times out on large files)
+put() { sprite exec -o "$ORG" -s "$NAME" -- bash -c "mkdir -p \"\$(dirname $2)\" && cat > $2" <"$1" 2>&1 | quiet; }
+
+case "${1:-}" in
+up)
+ [ -f "$FARM" ] || { echo "box: $FARM names no farm (RAEA_CLOUD_GPU_URL, RAEA_CLOUD_GPU_TOKEN)"; exit 2; }
+ sprite list -o "$ORG" | grep -qx "$NAME" || sprite create -o "$ORG" --skip-console --label raea --label raea-cloud "$NAME"
+ # raea's runtime libraries, and Mesa's lavapipe: the box draws previews on its CPU, its renders go to the farm
+ x "sudo DEBIAN_FRONTEND=noninteractive apt-get update -qq && sudo DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends \
+ ca-certificates curl git zstd xz-utils procps ripgrep libasound2t64 libfontconfig1 libvulkan1 mesa-vulkan-drivers vulkan-tools >/dev/null"
+ x "node -v 2>/dev/null | grep -q '^v24' || { curl -fsSL https://nodejs.org/dist/v$NODE/node-v$NODE-linux-x64.tar.xz | sudo tar -xJ -C /opt \
+ && sudo ln -sf /opt/node-v$NODE-linux-x64/bin/node /opt/node-v$NODE-linux-x64/bin/npm /opt/node-v$NODE-linux-x64/bin/npx /usr/local/bin/; }"
+ x "[ \"\$(/opt/raea/bin/raea --version 2>/dev/null)\" = $RAEA_VERSION ] || { set -e; f=raea-$RAEA_VERSION-linux-x86_64.tar.gz; \
+ u=https://github.com/shinyobjectz/raea/releases/download/v$RAEA_VERSION; cd /tmp && curl -fsSL -o \$f \$u/\$f && curl -fsSL -o \$f.sha256 \$u/\$f.sha256 \
+ && sha256sum -c \$f.sha256 && sudo rm -rf /opt/raea && sudo mkdir -p /opt/raea && sudo tar -xzf \$f -C /opt/raea --strip-components=1 && rm -f \$f \$f.sha256; }"
+ # sdk/cloud's server, client and wrapper, as the image has them (image/Dockerfile)
+ pack=$(mktemp)
+ COPYFILE_DISABLE=1 tar -czf "$pack" --no-mac-metadata -C "$HERE" server src image package.json package-lock.json
+ put "$pack" /tmp/raea-cloud.tgz
+ rm -f "$pack"
+ x "sudo mkdir -p /opt/raea-cloud && sudo chown \$(id -u):\$(id -g) /opt/raea-cloud && tar -xzf /tmp/raea-cloud.tgz -C /opt/raea-cloud && rm /tmp/raea-cloud.tgz \
+ && cd /opt/raea-cloud && npm ci --omit=dev --no-fund --no-audit --loglevel=error && node server/agents.ts install $AGENTS \
+ && chmod +x image/*.sh && sudo ln -sf /opt/raea-cloud/image/raea.sh /usr/local/bin/raea"
+ # the box's own token, made once and kept on its disk; the farm's, from this Mac
+ x "[ -s ~/.raea-cloud.env ] || { umask 077; echo RAEA_CLOUD_TOKEN=\$(openssl rand -hex 32) > ~/.raea-cloud.env; }"
+ put "$FARM" /tmp/farm.env
+ x "umask 077; grep -v '^RAEA_CLOUD_GPU_' ~/.raea-cloud.env > ~/.raea-cloud.env.new; cat /tmp/farm.env >> ~/.raea-cloud.env.new; rm /tmp/farm.env; mv ~/.raea-cloud.env.new ~/.raea-cloud.env"
+ for a in $AGENTS; do x "raea skills install --agent $a >/dev/null 2>&1 || echo 'box: raea skills for $a not installed'"; done
+ # the server, as the Sprite's HTTP service on 8080: raea on lavapipe (docs/cloud.feature CL13), renders to the farm
+ start=$(mktemp)
+ cat >"$start" <<'EOF'
+#!/bin/bash
+set -a
+. ~/.raea-cloud.env
+set +a
+export PORT=8080 RAEA_CLOUD_DEVICE=cpu WGPU_BACKEND=vulkan __EGL_VENDOR_LIBRARY_DIRS=/nonexistent
+export VK_DRIVER_FILES=$(ls /usr/share/vulkan/icd.d/lvp_icd*.json | head -1)
+mkdir -p ~/work
+exec node /opt/raea-cloud/server/main.ts
+EOF
+ put "$start" /opt/raea-cloud/image/sprite-start.sh
+ rm -f "$start"
+ x "chmod +x /opt/raea-cloud/image/sprite-start.sh && { sprite-env services list | grep -q '\"raea-cloud\"' \
+ && sprite-env services restart raea-cloud >/dev/null || sprite-env services create raea-cloud --cmd /opt/raea-cloud/image/sprite-start.sh --http-port 8080; }"
+ "$0" status "$NAME"
+ ;;
+status)
+ sprite url -o "$ORG" -s "$NAME" 2>&1 | quiet
+ x "/opt/raea/bin/raea --version; . ~/.raea-cloud.env; curl -fsS -H \"authorization: Bearer \$RAEA_CLOUD_TOKEN\" localhost:8080/v1/health | head -c 600; echo"
+ ;;
+token) x ". ~/.raea-cloud.env; echo \$RAEA_CLOUD_TOKEN" ;;
+*)
+ sed -n '2,13p' "$0"
+ exit 2
+ ;;
+esac
diff --git a/sdk/cloud/server/offload.ts b/sdk/cloud/server/offload.ts
index 89a8c37c..8e2ce1d7 100644
--- a/sdk/cloud/server/offload.ts
+++ b/sdk/cloud/server/offload.ts
@@ -108,7 +108,10 @@ async function main() {
throw new Error(`the GPU worker at ${url} didn't answer: ${(e as Error).message} (RAEA_CLOUD_GPU_FALLBACK=cpu renders here instead)`)
}
say(`rendering on ${new URL(url).host}, ${h.device.renders === "gpu" ? `GPU ${h.device.name}` : `its CPU (${h.device.name})`}: ${p.root} (${(folder.length / 1e6).toFixed(1)} MB) sent`)
- const { exit, files } = await cloud.job(p.args, folder, { as: gnu ? "zst" : "gz", onOutput: (t, s) => (s === "out" ? process.stdout : process.stderr).write(t) })
+ // a render farm's choices (deploy/modal/farm.py): RAEA_CLOUD_GPUS, RAEA_CLOUD_GPU_KIND, RAEA_CLOUD_MAX_USD
+ const n = (v?: string) => (v ? Number(v) : undefined)
+ const farm = { gpus: n(process.env.RAEA_CLOUD_GPUS), gpu: process.env.RAEA_CLOUD_GPU_KIND, maxUsd: n(process.env.RAEA_CLOUD_MAX_USD) }
+ const { exit, files } = await cloud.job(p.args, folder, { as: gnu ? "zst" : "gz", farm, onOutput: (t, s) => (s === "out" ? process.stdout : process.stderr).write(t) })
const back = path.join(tmp, "out.tar")
writeFileSync(back, files)
diff --git a/sdk/cloud/src/index.ts b/sdk/cloud/src/index.ts
index 950762d1..92f764fa 100644
--- a/sdk/cloud/src/index.ts
+++ b/sdk/cloud/src/index.ts
@@ -28,6 +28,14 @@ export interface Health {
jobs: { id: string; running: boolean }[]
}
+/** A render farm's choices for one job (deploy/modal/farm.py): at most `gpus` GPUs at once, of kind `gpu` (Modal's
+ * names: L4, L40S, ...), and a price over `maxUsd` (estimated from the first frames) stops it before the rest. */
+export interface Farm {
+ gpus?: number
+ gpu?: string
+ maxUsd?: number
+}
+
export interface JobLog {
log: ({ out: string } | { err: string })[]
next: number
@@ -105,9 +113,14 @@ export class RaeaCloud {
}
/** Starts `raea ARGS` on a folder sent as a tar (zstd, gzip or none), in a folder of its own on the server (a
- * render job): its id. */
- async startJob(args: string[], folder: Uint8Array, signal?: AbortSignal): Promise<string> {
- const r = await this.call(`/v1/jobs?args=${encodeURIComponent(JSON.stringify(args))}`, { method: "POST", body: new Blob([folder as BlobPart]), headers: { "content-type": "application/octet-stream" }, signal })
+ * render job): its id. `farm` is for raea's render farm (deploy/modal/farm.py), which splits a render across GPUs;
+ * a single server ignores it. */
+ async startJob(args: string[], folder: Uint8Array, signal?: AbortSignal, farm: Farm = {}): Promise<string> {
+ const q = new URLSearchParams({ args: JSON.stringify(args) })
+ if (farm.gpus !== undefined) q.set("gpus", String(farm.gpus))
+ if (farm.gpu) q.set("gpu", farm.gpu)
+ if (farm.maxUsd !== undefined) q.set("max_usd", String(farm.maxUsd))
+ const r = await this.call(`/v1/jobs?${q}`, { method: "POST", body: new Blob([folder as BlobPart]), headers: { "content-type": "application/octet-stream" }, signal })
return ((await r.json()) as { id: string }).id
}
@@ -124,8 +137,8 @@ export class RaeaCloud {
/** A job from start to end: its output to onOutput as it comes; its exit code and the files it made or changed. A
* dropped follow request (a platform's proxy, a cold start) is tried again, up to five times in a row. */
- async job(args: string[], folder: Uint8Array, o: { onOutput?: (text: string, stream: "out" | "err") => void; signal?: AbortSignal; as?: "zst" | "gz" | "tar" } = {}): Promise<{ exit: number; files: Uint8Array }> {
- const id = await this.startJob(args, folder, o.signal)
+ async job(args: string[], folder: Uint8Array, o: { onOutput?: (text: string, stream: "out" | "err") => void; signal?: AbortSignal; as?: "zst" | "gz" | "tar"; farm?: Farm } = {}): Promise<{ exit: number; files: Uint8Array }> {
+ const id = await this.startJob(args, folder, o.signal, o.farm)
let from = 0
for (let misses = 0; ; ) {
let f: JobLog
diff --git a/sdk/cloud/test/farm.ts b/sdk/cloud/test/farm.ts
new file mode 100644
index 00000000..9c54ef4f
--- /dev/null
+++ b/sdk/cloud/test/farm.ts
@@ -0,0 +1,51 @@
+// raea's render farm, live (docs/cloud-render.feature CR9): a job sent the way a CPU box sends one, timed, and its
+// video checked. RAEA_CLOUD_GPU_URL and RAEA_CLOUD_GPU_TOKEN name the farm (~/.config/raea-cloud/farm.env):
+//
+// node test/farm.ts raea [GPUS] test/gpu/edit.tsx to out/edit.mp4
+// node test/farm.ts blender DIR FILE.blend FRAMES [GPUS] [SAMPLES]
+// a Blender scene to out/render.mp4, frames A-B
+import { spawnSync } from "node:child_process"
+import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"
+import os from "node:os"
+import path from "node:path"
+import { RaeaCloud } from "../src/index.ts"
+
+const [kind = "raea", ...rest] = process.argv.slice(2)
+const url = process.env.RAEA_CLOUD_GPU_URL
+const token = process.env.RAEA_CLOUD_GPU_TOKEN
+if (!url || !token) throw new Error("set RAEA_CLOUD_GPU_URL and RAEA_CLOUD_GPU_TOKEN (the farm's)")
+
+const here = path.dirname(new URL(import.meta.url).pathname)
+const [dir, args, gpus] =
+ kind === "blender"
+ ? [rest[0], ["blender", rest[1], "-o", "out/render.mp4", "--frames", rest[2], ...(rest[4] ? ["--samples", rest[4]] : [])], rest[3]]
+ : [path.join(here, "gpu"), ["render", "edit.tsx", "-o", "out/edit.mp4"], rest[0]]
+
+const tmp = mkdtempSync(path.join(os.tmpdir(), "raea-farm-test-"))
+try {
+ // a Mac's tar: gzip, and no AppleDouble files
+ const sent = path.join(tmp, "in.tgz")
+ const pack = spawnSync("tar", ["-czf", sent, "--no-mac-metadata", "-C", dir, "."], { env: { ...process.env, COPYFILE_DISABLE: "1" }, encoding: "utf8" })
+ if (pack.status) throw new Error(`the folder didn't pack: ${pack.stderr}`)
+ const folder = new Uint8Array(readFileSync(sent))
+ const cloud = new RaeaCloud({ url, token })
+ const t0 = performance.now()
+ const at = () => `${((performance.now() - t0) / 1000).toFixed(1).padStart(6)} s`
+ console.log(`${at()} ${(folder.length / 1e6).toFixed(1)} MB to ${new URL(url).host}: raea ${args.join(" ")}`)
+ const { exit, files } = await cloud.job(args, folder, {
+ as: "gz",
+ farm: gpus ? { gpus: Number(gpus) } : {},
+ onOutput: (t) => t.split("\n").filter(Boolean).forEach((l) => console.log(`${at()} ${l}`)),
+ })
+ const back = path.join(tmp, "out.tgz")
+ writeFileSync(back, files)
+ spawnSync("tar", ["-xzf", back, "-C", tmp])
+ const video = path.join(tmp, args[args.indexOf("-o") + 1])
+ const probe = spawnSync("ffprobe", ["-v", "error", "-count_frames", "-select_streams", "v", "-show_entries", "stream=nb_read_frames,width,height", "-of", "csv=p=0", video], { encoding: "utf8" })
+ console.log(`${at()} exit ${exit}; ${path.basename(video)}: ${probe.stdout.trim() || probe.stderr.trim()} (width,height,frames)`)
+ const keep = process.env.RAEA_FARM_KEEP
+ if (keep) spawnSync("cp", [video, keep])
+ process.exitCode = exit
+} finally {
+ rmSync(tmp, { recursive: true, force: true })
+}
diff --git a/sdk/cloud/test/farm_plan.py b/sdk/cloud/test/farm_plan.py
new file mode 100644
index 00000000..e69d905f
--- /dev/null
+++ b/sdk/cloud/test/farm_plan.py
@@ -0,0 +1,111 @@
+# The farm's planner (deploy/modal/farm_plan.py) with stand-in GPUs: python3 test/farm_plan.py from sdk/cloud. The
+# stand-ins write the frames they're asked for, so a split render is checked end to end, ffmpeg's encode included.
+
+import os
+import shutil
+import subprocess
+import sys
+import tempfile
+
+sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "deploy", "modal"))
+import farm_plan as fp # noqa: E402
+
+ok = lambda m: print(f"ok {m}")
+
+
+def run(cmd, cwd=None, env=None, timeout=None):
+ r = subprocess.run(cmd, cwd=cwd, capture_output=True, text=True)
+ return r.returncode, r.stdout + r.stderr, 0.1
+
+
+class FakeGpu:
+ """raea_run's stand-in: a 60-frame piece, frame 0 in 12 s (the start), 0.5 s a frame after."""
+
+ def __init__(self, root, length=60):
+ self.root, self.length, self.calls = root, length, []
+
+ def png(self, path):
+ # a 16x16 grey PNG, made once by ffmpeg
+ src = os.path.join(self.root, "one.png")
+ if not os.path.exists(src):
+ run(["ffmpeg", "-y", "-loglevel", "error", "-f", "lavfi", "-i", "color=c=gray:s=16x16", "-frames:v", "1", src])
+ shutil.copy(src, path)
+
+ def remote(self, id, args, frames=None, first=0, probe=False, video=False):
+ self.calls.append(("probe" if probe else "run", frames, first))
+ if probe:
+ return {"code": 0, "out": "", "s": 12.5, "length": self.length, "fps": 30, "w": 1920, "h": 1080}
+ dest = os.path.join(self.root, "jobs", id, "frames")
+ os.makedirs(dest, exist_ok=True)
+ if video:
+ # the run as one H.264 video, as raea render --at FRAMES -o run.mp4 writes it
+ run(["ffmpeg", "-y", "-loglevel", "error", "-f", "lavfi", "-i", "color=c=gray:s=16x16:r=30", "-frames:v", str(len(frames)), "-c:v", "libx264", "-pix_fmt", "yuv420p", f"{dest}/run-{first:05d}.mp4"])
+ return {"code": 0, "out": "", "s": 12 + 0.5 * len(frames), "frames": len(frames), "ms": 500.0}
+ for f in frames:
+ if f >= first:
+ self.png(f"{dest}/frame-{f:05d}.png")
+ return {"code": 0, "out": "", "s": 12 + 0.5 * len(frames), "frames": len(frames), "ms": 500.0}
+
+ def starmap(self, calls, order_outputs=False, return_exceptions=True):
+ return [self.remote(*c) for c in calls]
+
+
+lines = []
+log = lambda t, err=False: lines.append(t)
+
+assert fp.split_out(["render", "a.tsx", "-o", "out/a.mp4", "--w", "640"]) == (["render", "a.tsx", "--w", "640"], "out/a.mp4")
+assert fp.splittable(["render", "a.tsx", "-o", "a.mp4"]) and fp.splittable(["render", "a.tsx", "-o", "frames"])
+assert not fp.splittable(["render", "a.tsx", "-o", "a.png"]) and not fp.splittable(["render", "a.tsx", "--frame", "3", "-o", "a.mp4"])
+assert not fp.splittable(["guide", "gen"]) and not fp.splittable(["render", "a.tsx", "-o", "a.mp4", "--audio", "a.wav"])
+ok("only a whole-piece render to a video or a folder is split")
+
+# 12 s to start, 0.5 s a frame: a GPU is worth it from 96 frames (its start at most a fifth of its time)
+assert fp.gpus_for(52, 0.5, 12, 10) == 1
+assert fp.gpus_for(960, 0.5, 12, 10) == 10 and fp.gpus_for(480, 0.5, 12, 10) == 5
+# Cycles at 40 s a frame and 20 s to start: a GPU from 2 frames on
+assert fp.gpus_for(240, 40, 20, 50) == 50 and fp.gpus_for(10, 40, 20, 50) == 5
+assert fp.gpus_for(0, 1, 1, 5) == 0
+ok("GPUs are started only where their start is at most a fifth of their work, up to the limit")
+
+r = fp.runs(8, 59, 4)
+assert [x[1] for x in r] == [8, 21, 34, 47] and sum(len(x[0]) for x in r) == 52 and r[-1][0][-1] == 59
+w = fp.runs(8, 59, 2, warm=5)
+assert w[0][0][0] == 3 and w[1][0][0] == 29 and w[1][1] == 34
+ok("frames split into contiguous runs, each led by its warm-up frames")
+
+root = tempfile.mkdtemp()
+work = os.path.join(root, "jobs", "j1", "work")
+os.makedirs(work)
+gpu = FakeGpu(root)
+code = fp.raea_render(["render", "a.tsx", "-o", "out/a.mp4"], {"id": "j1", "gpu": "L4", "gpus": 10}, work, log, gpu, {}, run)
+assert code == 0, lines
+assert gpu.calls[0][0] == "probe" and gpu.calls[1][1] == list(range(8))
+assert len(gpu.calls) == 3, gpu.calls # 52 frames left at 0.5 s with a 12 s start: one GPU more
+assert os.path.getsize(os.path.join(work, "out", "a.mp4")) > 0
+frames = int(subprocess.run(["ffprobe", "-v", "error", "-count_frames", "-select_streams", "v", "-show_entries", "stream=nb_read_frames", "-of", "csv=p=0", os.path.join(work, "out", "a.mp4")], capture_output=True, text=True).stdout.strip())
+assert frames == 60, frames
+ok("a 60-frame render: frame 0, a timed run of 8, the rest on one more GPU, the runs joined into 60 frames")
+
+lines.clear()
+long = FakeGpu(root, length=1000)
+os.makedirs(os.path.join(root, "jobs", "j2", "work"))
+code = fp.raea_render(["render", "a.tsx", "-o", "stills"], {"id": "j2", "gpu": "L4", "gpus": 10, "max_usd": 0.01}, os.path.join(root, "jobs", "j2", "work"), log, long, {}, run)
+assert code == 3 and "over max_usd" in lines[-1] and len(long.calls) == 2, (code, lines)
+ok("over max_usd, the job stops after the timed run and says the price")
+
+code = fp.raea_render(["render", "a.tsx", "-o", "stills"], {"id": "j2", "gpu": "L4", "gpus": 10}, os.path.join(root, "jobs", "j2", "work"), log, long, {}, run)
+out = os.listdir(os.path.join(root, "jobs", "j2", "work", "stills"))
+assert code == 0 and len(out) == 1000 and "frame-00999.png" in out, (code, len(out))
+assert len(long.calls) == 2 + 2 + 10, len(long.calls)
+ok("a 1000-frame render to a folder: 10 GPUs, the frames named as raea names them")
+
+b = fp.Bill()
+t = b.t0
+b.add({"task": "a", "kind": "L40S", "boot": t - 100, "end": t + 10}) # left up by an earlier job: from this job's start
+b.add({"task": "a", "kind": "L40S", "boot": t - 100, "end": t + 20})
+b.add({"task": "b", "kind": "T4", "boot": t + 1, "end": t + 6})
+b.add({"code": 1, "out": "no task id"})
+assert "2 GPU containers up 35 s" in b.line(), b.line()
+ok("the bill: each container from its boot or the job's start to its last run, plus its boot and idle seconds")
+
+shutil.rmtree(root)