Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.
feat(lane): the torch backend's CUDA gates run on a T4 rented from Modal — the commit's tree in a new environment, the install's check frame and every torch_rife test on CUDA, none skipped
Soohong Kim24bb4c468ad2
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 0081d4d..a4e0e77 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -9,7 +9,8 @@ All notable public changes to `sprite-gen` are recorded here. Versions track the- **New: RIFE's torch backend runs rife-v4.6 in PyTorch for compute GPUs without Vulkan.** `SPRITE_GEN_RIFE_BACKEND=torch` runs the same rife-v4.6 in PyTorch (`sprite_gen/video/rife_torch.py`). It serves a GPU the binary cannot run on: rife-ncnn-vulkan needs Vulkan, and a GPU offered for compute alone (CUDA with no Vulkan driver) has none. The network is rife-v4.6's IFNet written again from Practical-RIFE's `IFNet_HDv3` (MIT, notice in NOTICE). Its weights are read out of the binary's own model files (SHA-256 pinned, the binary's float16 weights), with no other download. One run does what one call of the binary does with `-x -z`. The pair is turned eight ways and run both ways in time, with flows averaged at each of four levels. The loop follows rife-ncnn-vulkan's `RIFE::process_v4` (MIT, notice in NOTICE). `SPRITE_GEN_RIFE_DEVICE` names `cuda` (default) or `cpu`. `SPRITE_GEN_RIFE_TTA` means the same for both backends. The default augmentation stays `-x -z`. To install: `pip install "sprite-gen[torch]"` (new extra: `torch>=2.13.0,<3`). Then run: `sprite-gen rife install --backend torch` (new flag; defaults to `SPRITE_GEN_RIFE_BACKEND`). This unpacks the model, and makes a check frame through PyTorch on `SPRITE_GEN_RIFE_DEVICE`. It reads the model only, so a Linux ARM machine the binary does not run on is not refused. A CPU-only host installs PyTorch's CPU build first: `pip install torch==2.13.0 --index-url https://download.pytorch.org/whl/cpu` (192 MB, against the CUDA build's 527 MB plus its CUDA libraries). Nothing falls back. With torch chosen the binary is never looked for or run. `cuda` where PyTorch finds no CUDA is refused naming why (a CPU-only PyTorch, or a CUDA that finds no GPU) and does not run on the CPU. `mps` (Apple's GPU) is refused (no lane measures it; on a Mac the binary runs on the GPU already). A backend or device named wrong is refused. A device that fails as the network is put on it or as a frame runs (out of its memory, its driver or CUDA failing) is a RIFE that fails, in PyTorch's own words: the loop fails with its record, and the install's check frame fails. PyTorch not installed, or no model where the backend looks (`SPRITE_GEN_RIFE_MODEL`, else the install root), is RIFE not installed, as the binary missing is. Under `--repair auto` the loop is cut as filmed with the warning, and its record names the torch install line. On CUDA each frame runs with cuDNN deterministic, its benchmark off and convolutions in IEEE float32 (no TF32). The same frame twice is the same bytes on one GPU, driver and PyTorch. What made a frame is the RIFE's identity: backend, model bytes loaded, network code, PyTorch, on CUDA the GPU, driver, CUDA, cuDNN and those settings; on the CPU its instruction set. Because of this identity, `--between-cache` never hands one backend's or GPU's frame to another. Measured on synthetic walkers: Seven walker pairs (clean, outline lost, ghost, torn, a cross-fade to look at) get the same verdicts from the binary on an Apple GPU, the binary on Mesa llvmpipe and the torch backend on a CPU. The torch frame lies 0.005 to 0.052 of 255 on average from the binary's Apple GPU frame. The binary's own llvmpipe frame lies 0.007 to 0.25. A 960 x 960 frame of a synthetic walker with `-x -z`: On an Apple M4 Max CPU (12 threads), 3.3 to 3.6 s; the binary on that Mac's GPU takes 1.27 to 1.37 s. In a Modal container of two CPUs (the app's job size), 22.6 to 28.5 s on two threads; the binary on Mesa llvmpipe in the same container takes 127.7 to 131.5 s. The torch backend's frames are not the binary's bytes, which is one reason the binary stays the default. [loop-repair](docs/loop-repair.md) section 1- **New: a host with no GPU sends the torch backend's frames to a GPU elsewhere (`SPRITE_GEN_RIFE_EXECUTOR`).** The host names a send of its own, `SPRITE_GEN_RIFE_EXECUTOR=module:attr`: a function from a request's bytes to its answer's. It reaches `sprite_gen.video.rife_torch.serve` on the GPU's machine, the same sprite-gen with PyTorch and the model installed there. The engine knows nothing of what carries the bytes, and the host needs no PyTorch. A frame is one call (its two runs made there), and a read is one call (its two runs and sixteen passes, the passes reduced there to how far they disagree). A RIFE asks the executor what it is once, as it is made (the probe, which takes the cold start), so a `video-loop` makes at most 53 calls. The RIFE holds that answer for its life, and every request carries it. An executor that is not it any more (another GPU, driver or image) makes nothing, and the RIFE fails naming what differs (`gpu: Tesla T4 -> NVIDIA L4`). An answer from another identity is not handed on. So one RIFE never hands on frames of two GPUs, and a frame taken from `--between-cache` is the frame it would make; the next RIFE asks again and keys its frames anew. Refused: an executor named with the binary's backend or with `SPRITE_GEN_RIFE_DEVICE` (the device is the executor's), a send that cannot be imported, and an executor whose `rife.py` or protocol is another (run the same sprite-gen on both sides). A send that raises, an answer that does not read (not the format, damaged or cut short on the way, or not the frame's size) and the executor's own failure are each a RIFE that fails, in its words; nothing is asked again or run elsewhere. The host names one GPU type for the executor (no fallback list) and does not deploy it anew while a run goes on. Requests and answers are a compressed NumPy archive, read with `allow_pickle=False`, each member whole so its CRC-32 is checked before its array is read: an answer damaged on the way hands on no other pixels. Reports name `executor` and the executor's `device` and `gpu`; the overlapped wrap counts `runs` and `executor_calls`. [loop-repair](docs/loop-repair.md) section 1- **Lane: `scripts/linux_lane.sh` tests PyTorch 2.13.0 CPU after the suite.** After the suite, PyTorch 2.13.0 CPU is installed into the same environment. It runs `sprite-gen rife install --backend torch`'s check frame. It runs every test marked `torch_rife` with `SPRITE_GEN_RIFE_DEVICE=cpu`, with none skipped. `--rife-only` runs the same. `--rife-unmeasured` lets `torch_rife` tests skip as it lets `real_rife` ones. CUDA is not measured by this lane.-- **Tests**: `tests/video/test_rife_torch.py` (the eight ways undo themselves and are the single passes' eight turns; flows of a textured patch run alone each of the sixteen ways and turned back point alike, where a wrong sign, a transpose's x/y, or a backward swap puts one elsewhere; `-z` and `-x` give the same frame the other way in time and flipped; the install check frame's disc lands half way; the model loads strict and other bytes are refused by SHA-256; the same frame twice is the same bytes and the identity names what makes it; seven recorded synthetic walker pairs in `tests/fixtures/rife-walkers` are judged as the binary judged them with no binary, the frame within twice the binary's own GPU-to-GPU gap, and alike to this machine's binary where both run; a device that fails as the network is put on it or as a frame runs (out of its memory, its driver, CUDA not starting, a CUDA call deferred to its start) is a RIFE that fails in PyTorch's words, a TypeError there is raised as it is, a loop whose device fails as the network is put on it fails with its record, and the install's check frame fails; without PyTorch: torch chosen and not installed is RIFE not installed and the binary is never run, a loop's record names it, a backend or device named wrong is refused before anything is looked for, cuda where there is none is refused, a model not the pinned one is refused; with a runner stood in: reports name rife-torch and count runs, the loop and the alignment name the torch backend, and a frame kept by one runner is not taken for another); `tests/video/test_rife_executor.py` (a frame is one call and a read one call, and the RIFE probes once as it is made, their bytes the same device's in this process with this host's augmentation; every request names the engine code and the identity held; the host runs without PyTorch; the identity is the executor's as the RIFE was made; a T4 frame kept is the RIFE's own after the executor turns L4, which it then refuses to make anew, and the next RIFE misses and keeps the L4 frame under its own key; an executor whose GPU, driver, network code, weights, PyTorch, cuDNN or determinism changed makes nothing, the field named; an answer from another identity is neither handed on nor kept; another container of the same identity runs on, and the next RIFE takes every frame with its probe alone; a T4 and L4 pool is refused at the first L4 request; a frame made while this host's augmentation changed is not kept; other engine code or another protocol is refused before anything loads; a request that does not read, is pickled or was damaged on the way is answered so, in the reading's words; a send, an answer or an executor that fails is a RIFE that fails, in its words; an answer damaged in a member's local header, a compressed block, an array's header or its own bytes, or its end record, or cut short, is a RIFE that fails in the words of what reading it raised, which is its cause, and undamaged is the frame made here; each byte of the probe's, a frame's and a read's answer damaged in turn fails the RIFE or reads as it was made, nothing else raised and no other pixels handed on; a reading that cannot read what `pack` writes raises as it is, a fault of the code; an answer that is not bytes does not read; an executor named with the binary, with a device, or not there is refused and the binary never runs; a loop names the executor, and a loop whose executor's answer was damaged on the way fails with its record (`failed`, in the decompressor's words, the gait fallback's frames removed); marked `torch_rife`: `rife_torch.serve` makes the frame and the read of the backend in this process, loaded once); `tests/video/test_rife_install.py` (a zip whose model is not the pinned one installs nothing for both backends; `--backend torch` installs on a machine the binary does not run on and checks its frame through torch); `tests/release/test_lane_rife_collection.py` (a test RIFE decides carries `real_rife` or `torch_rife`); new pytest mark `torch_rife` (skipped where PyTorch, the model or the named device is missing).+- **Lane: `scripts/t4_lane.py` tests the torch backend on an NVIDIA T4, rented from Modal.** `modal run scripts/t4_lane.py` builds the checked-out commit's tree into an image as the Linux lane installs a clean clone: Python 3.14, PyTorch 2.13.0 from PyPI (its Linux wheel is the CUDA 13 build), the tree with `.[dev]`, and the model by `sprite-gen rife install --backend torch`, where the engine looks for no binary. On one T4 it makes the install's check frame on CUDA and runs every test marked `torch_rife` and not `real_rife` on CUDA, with none skipped. `--whole-suite` first runs the whole suite in that environment, PyTorch in it, as the Linux lane's RIFE-less run does. A commit passes the lanes where the Linux lane passed at it and one T4 lane run at it exited 0. [release](docs/release.md)+- **Tests**: `tests/video/test_rife_torch.py` (the eight ways undo themselves and are the single passes' eight turns; flows of a textured patch run alone each of the sixteen ways and turned back point alike, where a wrong sign, a transpose's x/y, or a backward swap puts one elsewhere; `-z` and `-x` give the same frame the other way in time and flipped; the install check frame's disc lands half way; the model loads strict and other bytes are refused by SHA-256; the same frame twice is the same bytes and the identity names what makes it; seven recorded synthetic walker pairs in `tests/fixtures/rife-walkers` are judged as the binary judged them with no binary, the frame within twice the binary's own GPU-to-GPU gap, and alike to this machine's binary where both run; a device that fails as the network is put on it or as a frame runs (out of its memory, its driver, CUDA not starting, a CUDA call deferred to its start) is a RIFE that fails in PyTorch's words, a TypeError there is raised as it is, a loop whose device fails as the network is put on it fails with its record, and the install's check frame fails; without PyTorch: torch chosen and not installed is RIFE not installed and the binary is never run, a loop's record names it, a backend or device named wrong is refused before anything is looked for, cuda where there is none is refused, a model not the pinned one is refused; with a runner stood in: reports name rife-torch and count runs, the loop and the alignment name the torch backend, and a frame kept by one runner is not taken for another); `tests/video/test_rife_executor.py` (a frame is one call and a read one call, and the RIFE probes once as it is made, their bytes the same device's in this process with this host's augmentation; every request names the engine code and the identity held; the host runs without PyTorch; the identity is the executor's as the RIFE was made; a T4 frame kept is the RIFE's own after the executor turns L4, which it then refuses to make anew, and the next RIFE misses and keeps the L4 frame under its own key; an executor whose GPU, driver, network code, weights, PyTorch, cuDNN or determinism changed makes nothing, the field named; an answer from another identity is neither handed on nor kept; another container of the same identity runs on, and the next RIFE takes every frame with its probe alone; a T4 and L4 pool is refused at the first L4 request; a frame made while this host's augmentation changed is not kept; other engine code or another protocol is refused before anything loads; a request that does not read, is pickled or was damaged on the way is answered so, in the reading's words; a send, an answer or an executor that fails is a RIFE that fails, in its words; an answer damaged in a member's local header, a compressed block, an array's header or its own bytes, or its end record, or cut short, is a RIFE that fails in the words of what reading it raised, which is its cause, and undamaged is the frame made here; each byte of the probe's, a frame's and a read's answer damaged in turn fails the RIFE or reads as it was made, nothing else raised and no other pixels handed on; a reading that cannot read what `pack` writes raises as it is, a fault of the code; an answer that is not bytes does not read; an executor named with the binary, with a device, or not there is refused and the binary never runs; a loop names the executor, and a loop whose executor's answer was damaged on the way fails with its record (`failed`, in the decompressor's words, the gait fallback's frames removed); marked `torch_rife`: `rife_torch.serve` makes the frame and the read of the backend in this process, loaded once); `tests/video/test_rife_install.py` (a zip whose model is not the pinned one installs nothing for both backends; `--backend torch` installs on a machine the binary does not run on and checks its frame through torch); `tests/release/test_lane_rife_collection.py` (a test RIFE decides carries `real_rife` or `torch_rife`); `tests/release/test_t4_lane.py` (the T4 lane installs the PyTorch and the Python the Linux lane does); new pytest mark `torch_rife` (skipped where PyTorch, the model or the named device is missing).## v2.45.2 - The new `video-loop --overlap-wrap off` turns the overlapped wrap off on its own; the motion anchor's fine search is faster and gives the same valuesdiff --git a/SECURITY.md b/SECURITY.mdindex 270d881..a05a3ac 100644--- a/SECURITY.md+++ b/SECURITY.md@@ -67,5 +67,6 @@ safedeps gates run --root . --strict```GitHub-hosted CI is not used for this repository: the test gates and the release-build run on the maintainer's own Linux runner through `scripts/linux_lane.sh`-(see [docs/release.md](docs/release.md)).+build run on the maintainer's own Linux runner through `scripts/linux_lane.sh`, and+the RIFE torch backend's CUDA gates on a T4 rented from Modal through+`scripts/t4_lane.py` (see [docs/release.md](docs/release.md)).diff --git a/docs/release.md b/docs/release.mdindex 6fea27f..6e47680 100644--- a/docs/release.md+++ b/docs/release.md@@ -1,6 +1,6 @@# 릴리즈 — 태그를 push 하고, 레인이 빌드한 것으로 릴리즈 페이지를 낸다-> Owns: How a vX.Y.Z tag becomes a release page, what the lane builds and the publisher attaches, and what stays manual · Index: [docs/README.md](README.md)+> Owns: How a vX.Y.Z tag becomes a release page, the lanes a commit passes (Linux, and a T4 for the torch backend on CUDA), what the lane builds and the publisher attaches, and what stays manual · Index: [docs/README.md](README.md)릴리즈 페이지는 손으로 만들지 않는다. `vX.Y.Z` 태그를 push 한 뒤 `scripts/release_publish.py` 가그 태그의 `CHANGELOG.md` 절을 본문으로 페이지를 만든다. 사람이 `gh release create` 의 인자를@@ -8,10 +8,11 @@페이지만 빠져서, 릴리즈 목록에는 v2.5.2 가 Latest 로 남아 있었던 적이 있다.GitHub-hosted CI(GitHub Actions)는 쓰지 않는다. 테스트 게이트와 wheel·sdist 빌드는 메인테이너의-리눅스 러너에서 `scripts/linux_lane.sh` 가 돌리고, 페이지를 내는 기계는 아무것도 빌드하지 않고-레인이 만든 것을 붙인다.+리눅스 러너에서 `scripts/linux_lane.sh` 가 돌리고, RIFE torch 판의 CUDA 게이트는 Modal 에서 빌린 T4 에서+`scripts/t4_lane.py` 가 돌린다(아래 "T4 레인"). 페이지를 내는 기계는 아무것도 빌드하지 않고 레인이 만든+것을 붙인다.-레인이 통과했다는 것은 한 번의 실행이 exit 0 으로 끝났거나, 같은 커밋에서 `--rife-unmeasured "<이유>"`+리눅스 레인이 통과했다는 것은 한 번의 실행이 exit 0 으로 끝났거나, 같은 커밋에서 `--rife-unmeasured "<이유>"`실행(exit 3, RIFE 를 재지 못했다고 끝에 적는다)과 `--rife-only` 실행(exit 0)이 둘 다 끝났다는뜻이다. RIFE 는 rife-ncnn-vulkan 을 돌릴 수 있는 Vulkan 드라이버가 있어야 잴 수 있다 — WSL1 의 Mesalavapipe 에서는 첫 업로드에서 죽는다 — 그래서 그런 호스트에서는 RIFE 를 떼어 내되 조용히 건너뛰지는@@ -35,7 +36,7 @@ RIFE 의 torch 백엔드(`SPRITE_GEN_RIFE_BACKEND=torch`, docs/loop-repair.md 1판정 비교)은 `real_rife` 단계에서 빼고 이 단계에서 돈다. `--rife-unmeasured` 는 이 단계를 돌지 않고, 그실행에서는 `torch_rife` 가 붙은 시험도 RIFE 때문에 건너뛸 수 있는 것으로 친다.`tests/release/test_lane_rife_collection.py` 의 표시 검사도 두 표시를 같이 받는다. CUDA 위의 torch 판은-이 레인이 재지 않는다.+이 레인이 재지 않고 T4 레인이 잰다.표시 없이 RIFE 가 없을 때 건너뛰거나 모이지 않는 시험은 두 실행 어느 쪽도 재지 않는다. 그래서`--rife-unmeasured` 는 시험을 `pytest --rife-unmeasured` 로 돌리고, 그 실행에서 건너뛴 것마다 — skip@@ -46,6 +47,37 @@ RIFE 의 torch 백엔드(`SPRITE_GEN_RIFE_BACKEND=torch`, docs/loop-repair.md 1있는 척하는 대역을 둔 채 한 번, 없는 채 한 번 모아, 모이는지나 skip 표시의 판정이 갈리는 시험마다표시를 요구하고 없으면 그 이름을 대고 실패한다.+## T4 레인 — torch 판을 CUDA 에서++`scripts/t4_lane.py` 는 Modal 에서 빌린 NVIDIA T4 하나에서 torch 판을 CUDA 로 잰다. 메인테이너의 Modal+작업 공간에서, 잴 커밋을 체크아웃한 트리(커밋되지 않은 변경이 없는)로 돌린다:++```bash+modal run --env <환경> scripts/t4_lane.py # 게이트+modal run --env <환경> scripts/t4_lane.py --whole-suite # 그 앞에 스위트 전체도+```++HEAD 의 트리(`git archive`)를 이미지로 짓는다. 리눅스 레인이 깨끗한 클론에 까는 것처럼, Python 3.14 의 새+가상 환경에 PyPI 의 PyTorch 2.13.0 과 트리(`pip install -e ".[dev]"`)를 깐다. PyPI 의 리눅스 휠은 CUDA 13+판이다(`pip install "sprite-gen[torch]"` 이 받는 것). 의존성도 PyPI 에서 받으므로 PyTorch 인덱스의 오래된+사본이 끼지 않는다. 모델은 `sprite-gen rife install --backend torch` 로 엔진이 바이너리를 찾지 않는 디렉터리에+둔다. 스위트가 부르는 도구(ffmpeg, libwebp 1.5 의 img2webp, node, git)도 이미지에 있다. 그리고 T4 에서:++- 설치의 확인 프레임을 CUDA 로 만든다(`sprite-gen rife install --backend torch`, `SPRITE_GEN_RIFE_DEVICE=cuda`).+- `--whole-suite` 면 그 환경(PyTorch 가 든)에서 스위트 전체를 CUDA 로 돈다. `pytest --rife-unmeasured` 로+ 돌리므로 바이너리가 닿지 않아 건너뛰는 `real_rife` 말고 다른 건너뜀은 실패다(리눅스 레인의 RIFE 없는+ 실행과 같다).+- `torch_rife` 가 붙고 `real_rife` 는 붙지 않은 시험 전부를 CUDA 로 돈다. 하나라도 건너뛰거나 표시된 시험이+ 없으면 실패다. 둘이 함께 붙은 시험(같은 기계의 바이너리와 torch 판의 판정 비교)은 리눅스 레인 몫이다. T4 의+ GPU 는 계산만 내주므로 바이너리가 쓰지 못한다.++실행은 함수 호출 id, GPU 와 드라이버, 단계마다의 출력을 찍는다. 모든 단계가 통과해야 exit 0 이다. T4 레인이+통과했다는 것은 그 커밋에서 돈 실행 하나가 exit 0 으로 끝났다는 뜻이다. 두 레인이 같은 PyTorch 와 Python 을+까는지는 `tests/release/test_t4_lane.py` 가 본다.++## 통과는 커밋 하나의 것이다++커밋이 레인을 통과했다는 것은 그 커밋에서 리눅스 레인이 통과하고(위 정의) T4 레인이 통과했다는 뜻이다.통과는 커밋 하나의 것이다. 어떤 커밋에서 잰 레인 — 한 번의 exit 0 이든, `--rife-only` 의 exit 0 이든 —은 다른 커밋의 통과가 아니다. 이전 릴리즈나 부모 커밋의 통과를 다음 커밋으로 옮겨 적지 않고, 머지할커밋과 태그 커밋을 각각 그 SHA 의 깨끗한 클론에서 잰다. `--rife-unmeasured` 로 잰 커밋은 같은 SHA 의@@ -57,8 +89,9 @@ RIFE 의 torch 백엔드(`SPRITE_GEN_RIFE_BACKEND=torch`, docs/loop-repair.md 11. **릴리즈 커밋** — `CHANGELOG.md` 의 `## Unreleased (vX.Y.Z)` 절을 `## vX.Y.Z - <제목>` 으로바꾸고, `pyproject.toml` 의 `version` 과 `SKILL.md` 의 `version:` 을 그 버전으로 맞춘다(둘의 일치는 `tests/packaging/test_version_ssot.py` 가 강제한다).-2. **PR 로 `main` 머지** — `main` 은 보호 브랜치라 직접 push 가 거부된다. 머지할 커밋에서 리눅스- 레인이 통과해야 한다(위 정의) — 러너에서 그 커밋의 깨끗한 클론으로 `scripts/linux_lane.sh`.+2. **PR 로 `main` 머지** — `main` 은 보호 브랜치라 직접 push 가 거부된다. 머지할 커밋에서 두 레인이+ 통과해야 한다(위 정의) — 러너에서 그 커밋의 깨끗한 클론으로 `scripts/linux_lane.sh`, 그 커밋을+ 체크아웃한 트리에서 `modal run scripts/t4_lane.py`.3. **태그 push** — 코드네임 접두사 없는 `vX.Y.Z` 로.```bash@@ -149,3 +182,4 @@ gh release upload vX.Y.Z <clip>.gif --repo aldegad/sprite-gen- [docs/README.md](README.md) — documentation index- `scripts/linux_lane.sh` — the test gates and the release build, on the maintainer's Linux runner+- `scripts/t4_lane.py` — the torch backend's CUDA gates, on a T4 rented from Modaldiff --git a/scripts/linux_lane.sh b/scripts/linux_lane.shindex 99e7c81..bfdc77f 100755--- a/scripts/linux_lane.sh+++ b/scripts/linux_lane.sh@@ -8,7 +8,7 @@# (prepare -> extract -> compose) and the whole test suite. Then RIFE's torch backend on the CPU:# PyTorch (TORCH_VERSION, from PyTorch's CPU index) into the same environment, its install check# frame (`sprite-gen rife install --backend torch`) and every test marked torch_rife, none skipped-# (SPRITE_GEN_RIFE_DEVICE=cpu). Its CUDA run is the T4 lane's (docs/release.md).+# (SPRITE_GEN_RIFE_DEVICE=cpu). Its CUDA run is the T4 lane's (`scripts/t4_lane.py`, docs/release.md).## Run it from a clean clone of the commit being measured, on x86-64 Linux with:# - Python 3.14 (`python3.14` on PATH, or named by SPRITE_GEN_LANE_PYTHON),diff --git a/scripts/t4_lane.py b/scripts/t4_lane.pynew file mode 100644index 0000000..ade18f7--- /dev/null+++ b/scripts/t4_lane.py@@ -0,0 +1,158 @@+# SPDX-License-Identifier: Apache-2.0+"""The torch backend's CUDA gates, on an NVIDIA T4 rented from Modal: the GPU run `scripts/linux_lane.sh` leaves to this+lane (docs/release.md). GitHub-hosted CI is not used.++ modal run [--env <environment>] scripts/t4_lane.py [--whole-suite]++Run it from a checkout of the commit being measured with no uncommitted changes: it measures HEAD, its tree as+`git archive` writes it. The tree is built into an image as the Linux lane installs a clean clone: Python PINNED_PYTHON,+a new virtual environment holding PyTorch TORCH_VERSION from PyPI (its Linux wheel is the CUDA 13 build, the one+`pip install "sprite-gen[torch]"` takes; its dependencies come from PyPI too, never the PyTorch index's older copies),+then the tree (`pip install -e ".[dev]"`) and the model (`sprite-gen rife install --backend torch --no-check`, into a+directory of its own: the engine looks for no binary here, which is the Linux lane's to measure, and nothing here runs+Vulkan). The image holds the whole suite's tools as the Linux lane's host does (ffmpeg, img2webp from libwebp >= 1.5,+node, git). Then, on one T4:++ - the install's check frame on CUDA (`sprite-gen rife install --backend torch` again, SPRITE_GEN_RIFE_DEVICE=cuda);+ - with --whole-suite, the whole suite in that environment, PyTorch in it, on CUDA (`pytest --rife-unmeasured`: the+ tests marked real_rife skip, the binary not being reachable, and any other skip fails unless tests/conftest.py+ names it, as in the Linux lane's RIFE-less run);+ - every test marked torch_rife and not real_rife, on CUDA, none skipped. Those marked both set this machine's binary+ beside the torch backend: the Linux lane runs them.++It prints the function call's id, the GPU, its driver and what each step said, and exits 0 only where every step passed.+A commit has passed the T4 lane where one run of it at that commit exited 0.+"""+from __future__ import annotations++import atexit+import json+import os+import shutil+import subprocess+import sys+import tempfile+import time+from pathlib import Path++import modal++PINNED_PYTHON = "3.14"+PYTHON_IMAGE = "python:3.14.9-slim-trixie"+# The PyTorch the torch backend was measured on, as the Linux lane installs it (there from PyTorch's CPU index).+TORCH_VERSION = "2.13.0"+GPU = "T4"+VENV = "/lane/venv"+SRC = "/lane/src"+RIFE_DIR = "/lane/rife"+++def _fail(why: str) -> None:+ print(f"t4_lane: {why}", file=sys.stderr)+ raise SystemExit(1)+++def _source() -> tuple[str, Path]:+ """HEAD and its tree as `git archive` writes it, from a checkout with no uncommitted changes."""+ root = Path(__file__).resolve().parents[1]++ def git(*args: str) -> str:+ return subprocess.run(["git", "-C", str(root), *args], check=True, capture_output=True, text=True).stdout++ if git("status", "--porcelain", "--untracked-files=no").strip():+ _fail("the checkout has uncommitted changes")+ sha = git("rev-parse", "HEAD").strip()+ work = Path(tempfile.mkdtemp(prefix="t4-lane-"))+ atexit.register(shutil.rmtree, work, True)+ tree = work / "source.tar.gz"+ subprocess.run(["git", "-C", str(root), "archive", "--format=tar.gz", "-o", str(tree), sha], check=True)+ return sha, tree+++# Only where `modal run` starts: the container imports this file again and needs no source of its own.+SHA, TREE = _source() if modal.is_local() else ("", Path("/nonexistent"))++image = (+ modal.Image.from_registry(PYTHON_IMAGE)+ .apt_install("ffmpeg", "webp", "nodejs", "git")+ .env({"PIP_DISABLE_PIP_VERSION_CHECK": "1", "PYTHONDONTWRITEBYTECODE": "1"})+ .run_commands(f"python{PINNED_PYTHON} -m venv {VENV}", f"{VENV}/bin/pip install --quiet torch=={TORCH_VERSION}")+ .add_local_file(TREE, "/lane/source.tar.gz", copy=True)+ .run_commands(+ f"mkdir -p {SRC} && tar -xzf /lane/source.tar.gz -C {SRC} && rm /lane/source.tar.gz",+ f"printf '%s\\n' {SHA} > /lane/SOURCE_SHA",+ f'{VENV}/bin/pip install --quiet -e "{SRC}[dev]"',+ f"{VENV}/bin/pip freeze --exclude-editable > /lane/pip-freeze.txt",+ f"SPRITE_GEN_RIFE_BACKEND=torch {VENV}/bin/sprite-gen rife install --dir {RIFE_DIR} --no-check > /lane/rife-install.json",+ )+)+app = modal.App("sprite-gen-t4-lane", image=image)+++def _step(steps: list[dict], name: str, argv: list[str], env: dict[str, str]) -> subprocess.CompletedProcess[str]:+ print(f"== {name}", flush=True)+ t0 = time.monotonic()+ proc = subprocess.run(argv, cwd=SRC, env=env, capture_output=True, text=True)+ out = proc.stdout + proc.stderr+ steps.append({"name": name, "exit": proc.returncode, "seconds": round(time.monotonic() - t0, 1), "out": out})+ return proc++[email protected](gpu=GPU, cpu=2.0, memory=8192, timeout=7200)+def gates(sha: str, whole_suite: bool) -> dict:+ """The steps above, in this container: their exits and what they said."""+ built = Path("/lane/SOURCE_SHA").read_text().strip()+ rec: dict = {"commit": sha, "image_commit": built, "whole_suite": whole_suite, "steps": [], "passed": False}+ if built != sha:+ rec["why"] = f"the image holds {built}, not {sha}"+ return rec+ model = Path(json.loads(Path("/lane/rife-install.json").read_text())["dir"]) / "rife-v4.6"+ # Nowhere the engine looks for the binary holds one: an empty data directory, nothing on PATH, no SPRITE_GEN_RIFE.+ env = {k: v for k, v in os.environ.items() if not k.startswith("SPRITE_GEN_")}+ env.update(PATH=f"{VENV}/bin:{env.get('PATH', '/usr/local/bin:/usr/bin:/bin')}", XDG_DATA_HOME=tempfile.mkdtemp(),+ SPRITE_GEN_RIFE_MODEL=str(model), SPRITE_GEN_RIFE_DEVICE="cuda")+ steps = rec["steps"]+ rec["pip_freeze"] = Path("/lane/pip-freeze.txt").read_text()+ smi = subprocess.run(["nvidia-smi", "--query-gpu=name,driver_version,memory.total", "--format=csv,noheader"],+ capture_output=True, text=True)+ rec["gpu"] = (smi.stdout or smi.stderr).strip()+ probe = _step(steps, "PyTorch", [f"{VENV}/bin/python", "-c", "import torch; print('torch', torch.__version__, 'cuda', "+ "torch.version.cuda, 'cudnn', torch.backends.cudnn.version(), 'gpu', "+ "torch.cuda.get_device_name() if torch.cuda.is_available() else None)"], env)+ if probe.returncode != 0 or "gpu None" in probe.stdout:+ rec["why"] = "PyTorch finds no CUDA GPU here"+ return rec+ if _step(steps, "RIFE torch backend (sprite-gen rife install --backend torch, its check frame on CUDA)",+ [f"{VENV}/bin/sprite-gen", "rife", "install", "--backend", "torch", "--dir", RIFE_DIR], env).returncode != 0:+ rec["why"] = "the install's check frame failed"+ return rec+ pytest = [f"{VENV}/bin/python", "-m", "pytest", "-q", "-rs", "-p", "no:cacheprovider"]+ if whole_suite and _step(steps, "the whole suite (PyTorch in the environment, on CUDA; the binary not reachable)",+ [*pytest, "--basetemp", tempfile.mkdtemp(), "--rife-unmeasured"], env).returncode != 0:+ rec["why"] = "the whole suite failed"+ return rec+ # No test marked: pytest exits 5 ("no tests ran"), and the lane with it.+ marked = _step(steps, "RIFE torch tests on CUDA (every test marked torch_rife and not real_rife, none skipped)",+ [*pytest, "--basetemp", tempfile.mkdtemp(), "-m", "torch_rife and not real_rife"], env)+ if marked.returncode != 0:+ rec["why"] = "a torch_rife test failed"+ elif any(line.startswith("SKIPPED") for line in marked.stdout.splitlines()):+ rec["why"] = "a torch_rife test skipped; this run is meant to measure them"+ else:+ rec["passed"] = True+ return rec++[email protected]_entrypoint()+def main(whole_suite: bool = False) -> None:+ call = gates.spawn(SHA, whole_suite)+ print(f"t4_lane: commit {SHA}, {GPU}, function call {call.object_id}", flush=True)+ rec = call.get()+ print(f"gpu {rec.get('gpu')}")+ print(rec.get("pip_freeze", "").rstrip())+ for step in rec["steps"]:+ print(f"== {step['name']}: exit {step['exit']}, {step['seconds']} s")+ print(step["out"].rstrip())+ if not rec["passed"]:+ _fail(f"{rec.get('why')} at {SHA} (function call {call.object_id})")+ print(f"t4_lane: the torch backend's CUDA gates passed at {SHA} (function call {call.object_id})")