Repository navigation
Unsloth Studio: restyle a video with Cosmos3-Nano-Sim-Transfer on sd-server - #16975
Conversation
…d sidecar, clear the last clip on submit
…r a cancel during export
…el once the clip is being published
…ocked media lookup
…ges clip in the result Picking a clip now shows one frame next to the edges the model follows and how much of the clip is used (the first 121 frames), before anything heavy runs. A host without the weights or a Cosmos3 sd-server sees why up front instead of an env var error after uploading. The result plays input, edges and output, shows the seed, and the Restyle button can't be double-submitted. Undecodable uploads get a plain message instead of the PyAV exception.
… rail width on the UI scale The progress line counted latent frames (0 to 31), which only means something to someone who knows the VAE; it now counts output frames (1 to 121) and says "Preparing the edges for the model" while the control video is encoded. The header showed the Create tab's model picker, which does nothing for a restyle; it now names the one model Restyle runs. Restyle uses the Generate button's fill, Cancel gets the spinner Create's Cancel has, and the rail width follows the UI scale like the Create rail (two frontend tests that #769 left red).
…n it is stopping, keeps tall results in their pane Picking a new clip left the previous run's three players on screen, even beside an error for the new file. Cancel gave no feedback for the seconds sd-server needs to stop; the button now reads Stopping. On a narrow window the stacked players were centred taller than their pane and drew over the form; they use safe centring and scroll instead. Long high-frame-rate clips are fitted only for the frames kept (a 120 fps source dropped three in four after fitting them).
…he ETA while stopping
|
The two Backend CI reds here,
|
…es the GPU [skip ci]
[skip ci]
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…ancel off the event loop, fence stale clips [skip ci]
…fused cancels keep Cancel usable [skip ci]
…tep that ends the job [skip ci]
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c42ee378b6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if self.holds_gpu() or video.loading_repo_ids() or video.status().get("loaded"): | ||
| return | ||
| gpu_arbiter.release(gpu_arbiter.VIDEO) |
There was a problem hiding this comment.
Release the VIDEO claim atomically with the idle checks
When a Create load overlaps a restyle's cleanup, the load can already hold the arbiter lock without having published its VideoBackend._loading state. These checks then see an idle backend, release() waits for the load's registration to finish, and subsequently drops the new VIDEO residency. A later chat/image acquire therefore skips evicting the still-loading or loaded video pipeline and can allocate alongside it, risking GPU OOM. Use the existing gpu_arbiter.release_if() to evaluate the idle predicate under the same lock as the release, or verify the acquisition epoch before releasing.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in dd739b0: the release goes through gpu_arbiter.release_if(VIDEO, idle), so the idle predicate (runner, Create loading, Create loaded) is evaluated under the same lock as the drop; test_the_video_claim_idle_check_runs_under_the_arbiter_lock.
…e arbiter lock [skip ci]
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
[skip ci]
Adds a Restyle mode to the Unsloth Studio video page: pick a short clip (or a folder of frames), check the edge preview, type a prompt, click Restyle. Unsloth Studio traces Canny edges, sends them to sd-server running NVIDIA's Cosmos3-Nano-Sim-Transfer, shows progress per output frame, and plays input, edges and result side by side. The result also lands in the video gallery.
Why: Cosmos3 restyles a clip on one GPU in under a minute, through the sd-server Unsloth Studio already runs, with no Python model stack.
Draft: needs the Cosmos3 port of stable-diffusion.cpp (unslothai/stable-diffusion.cpp#53) in the Unsloth sd.cpp prebuilt; until that ships, this stays a draft.
Input | edges | restyled, from Unsloth Studio:
Whole flow, cancel, narrow window, bad file, not set up
What's in it
It reuses
SdCppServeras the MiniMax-H3 path does (sd-server,/sdcpp/v1/vid_gen, job polling, cancel) instead of adding a family toVideoBackend. The server is started for each restyle and stopped when it ends, so its roughly 30 GB never sits idle outside the GPU arbiter; it takes the GPU as a video load would and refuses other loads while it runs.core/inference/video_restyle.py: frames at 30 fps (PyAV), cover-crop to 832x480, a numpy Canny that matchescv2.Canny(rgb, 100, 200)pixel for pixel, the edge preview, a setup check (weights set, sd-server built with Cosmos3), and a one-at-a-time runner.routes/video_restyle.py:GET status,POST preview(runs no model),POST restyle, progress, cancel, unload, andinput|control|output.mp4. Jobs are scoped to the account that started them.restyle-panel.tsx), API calls infeatures/video/api.ts.UNSLOTH_COSMOS3_TRANSFER_MODEL,UNSLOTH_COSMOS3_TRANSFER_VAE,SD_SERVER_PATH.Speed
Colab G4 (RTX PRO 6000 Blackwell), Linux, 121-frame car clip, submit to done in the UI, first run after the server loaded unless noted.
e6a98b1a8345e5bdab3a0d2fe290The faster port saves about 3 s in the transformer, but end to end in Unsloth Studio the first run is the same 47.5 s at both sd.cpp commits (
wip-car-light.log,final-fast.log); the 44.5 s is a second run with warm caches.About 4 s edges, 12 s warm-up and control encode, 14 s for the frames, 15 s decode and export with the old port. Restyle against a direct sd-cli run with the same edges and seed: 35.3 dB PSNR mean (measured at
823eb1d, MJPG plus H.264 on our side).Memory and speed
Measured at
d2fe290with sd-server built from stable-diffusion.cppa8345e5, on a Colab G4 (RTX PRO 6000, 96 GB). A Restyle of the car clip peaks at 39.9 GiB (nvidia-smi card total, set in the VAE decode), the same as sd-cli alone, and sd-server keeps 29.3 GiB loaded after the run until it's unloaded. Not run: any other GPU, q8_0 weights.Tests
tests/test_video_restyle.py: 91 passed at7fcc306(GPU handoff, reservations, account retirement, frame prep, Canny, preview, setup check, request body, runner with a fake sd-server, cancel, account scoping, routes, the upload middleware).npm run typecheckpasses, frontend tests 14952/14952, eslint clean onrestyle-panel.tsx.Not run or not done
gpu_arbiterfor room.Before / after on a host without the Cosmos3 weights
Merge base
4accec06avs headc58b2b5d2, two isolated installs (CPU host, video page enabled withUNSLOTH_VIDEO_ALLOW_CPU=1). Before: the mode pills are Create / Train andGET /api/inference/video/restyle/statusis 404. After: Create / Restyle / Train. The Restyle panel shows the "Restyle is not set up here" notice and the Restyle button is disabled; the status route returnsavailable: false.