Repository navigation
Unsloth Studio: Cosmos3 256p, NVIDIA's frame ranges and a per-model frame-rate picker - #16737
Conversation
…e picker Edge and Nano gain the pipeline's 256p tier (320x192, 192x320, 256x256, 320x256, 256x320) and Nano the 480p sizes it lacked, so the custom-size floor drops to 61,440 px and NVIDIA's 448x256 is accepted. VideoFamily gains fps_range / fps_choices: Edge 12-30 (model card), Nano 10, 16, 24, 30 (NVIDIA/cosmos models.md). The status defaults carry them with the frame window, the request is refused outside them, and the Video page shows a picker instead of the fixed label for those families only. Durations, the pipeline fps and the mp4 follow the chosen rate.
… absent Backend CI installs no diffusers, so the unguarded import failed the rest shard. The preset assertions don't need diffusers and now always run; the comparison against the pipeline's bins moves to its own test behind importorskip.
A frame count still offered at the new rate was kept, so Nano at 2 s (49 frames) became 4.9 s at 10 fps.
|
Codex is clean at this head ( Fork mirror CI at
|
Codex Review Summary: ✅ CompletedThis 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. |
…ring render [skip ci]
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. 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". |
… reset to the family default when the preset has none
…mid-load waits for the incoming family
…en the load settles
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. 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". |
# Conflicts: # studio/backend/tests/test_media_generation_preset_settings.py
# Conflicts: # studio/backend/tests/test_video_shape_validation.py
…ts last or first frames) (unslothai#16741) **Builds on unslothai#16737, so this diff includes its commits until that one merges. Review unslothai#16737 first.** ## What Adds a third workflow for Cosmos3-Nano on the Unsloth Studio Video page: **Continue a clip**. You upload a short video, Nano keeps 5 frames from its end (or its start) and generates what happens next. ## Why Predicting the future of a clip is one of the main things Cosmos 3 is built for, and NVIDIA's pipeline already supports it (`Cosmos3OmniPipeline(video=...)`). Unsloth Studio only offered text-to-video and image-to-video, so there was no way to use it. Nano only: Cosmos3-Edge does not accept video input, and the section does not show for it. ## Before / after Merge base `590119d` vs the head, Cosmos3-Nano loaded, theme set in Settings > Appearance. The AFTER frame-rate picker comes from unslothai#16737.   <details><summary>States: first/last choice, clip over 15 s, generating, Cosmos3-Edge (light and dark)</summary>   </details> <details><summary>Messages: a start frame and a clip replacing each other, a 20 s clip, a 3-frame clip</summary>   </details> <details><summary>Full page: generating, result, switching to Cosmos3-Edge with a clip staged, 1024 px</summary>   </details> Screenshots: headless Playwright on a Colab G4, Unsloth Studio at `9358a68` (the head `f6a1402` only drops a toast that never reached the screen). ## Unsloth Studio vs plain diffusers Colab G4 (NVIDIA RTX PRO 6000 Blackwell Server Edition, 96 GB), Linux, backend at `965e910` (the clip decoding is unchanged since; later commits are frontend and one error message). Unsloth Studio loaded `nvidia/Cosmos3-Nano` in auto mode (bf16, no offload) with `UNSLOTH_COSMOS3_SAFETY_CHECKER=0`, since the guardrail repo is gated. 1. Source clip: Nano text-to-video in Unsloth Studio, 832x480, 93 frames at 24 fps, 35 steps, guidance 6, seed 0. Prompt: "A golden retriever bounds through deep fresh snow in a pine forest, kicking up powder with each leap, the camera tracking alongside at dog height." 2. Continue it with the same settings, prompt: "The dog leaps over a fallen log and keeps running as snow falls from the branches above.", once from its last 5 frames and once from its first 5. - Unsloth Studio: `/video/generate` with `continuation_video` and `continuation_keep`. - Plain diffusers: `Cosmos3OmniPipeline(video=<the source's decoded frames>, condition_video_keep=...)` with the model card's setup (`UniPCMultistepScheduler` with `flow_shift=10.0`, `enable_safety_checker=False`). | | last, Unsloth Studio | last, diffusers | first, Unsloth Studio | first, diffusers | |---|---|---|---|---| | generate time | 51.2 s | 51.6 s | 51.2 s | 51.3 s | | nvidia-smi peak | 36.0 GiB | 38.3 GiB | 36.0 GiB | 38.3 GiB | | kept frames vs the source's kept 5 (PSNR, dB) | 34.6, 32.1, 32.8, 33.1, 34.4 | 34.6, 32.0, 32.8, 33.1, 34.5 | 34.2, 31.6, 31.2, 31.8, 32.6 | 34.1, 31.6, 31.2, 31.8, 32.6 | | seam, kept frame 4 to generated frame 5 (PSNR, dB) | 17.4 | 17.5 | 16.8 | 16.8 | | Unsloth Studio vs diffusers, frame 0 / frame 5 / mean from frame 30 (dB) | 39.8 / 31.6 / 15.6 | | 38.6 / 33.4 / 19.1 | | - Both pipelines keep the source's frames (32 to 35 dB is mp4 re-encoding) and carry the motion on with no cut: the seam step sits inside the source clip's own frame-to-frame range (15.5 to 22.3 dB, mean 17.9) for a fast tracking shot. - Unsloth Studio and diffusers start nearly identical and drift apart over the clip: same scene and same events, not bit-identical sampling, as we saw comparing Cosmos3-Edge text-to-video between the two. - The source took 57.1 s at the same 36.0 GiB peak; model load was 185.6 s including the download. Source | plain diffusers | Unsloth Studio, from the last frames:  From the first frames:  <details><summary>Kept frames 0 and 4 and the first generated frame 5 (top row: the source's kept end)</summary>   </details> GIFs are 400 px a panel at 8 fps. ## Memory and speed  Same runs as the table above, measured at `965e910` on the Colab G4 (RTX PRO 6000, 96 GB). Peak is the nvidia-smi card total: Unsloth Studio holds 36.0 GiB through the source and both continuations, plain diffusers peaks at 38.3 GiB. Not run: other GPUs, offloaded loads, 720p. ## UI pass Driven in Unsloth Studio on Colab, light and dark, 1440, 1024 and 768 px. Fixed here: - A clip now sizes the canvas through **Match source**, the way a start frame does. Before, a picked clip kept whatever size was set (800x544 in the run) and was centre-cropped onto it. - A start frame and a clip still replace each other, and a toast now says which one was removed. - A clip over 15 s is flagged under its preview when picked, not only after Generate uploads it. - The too-short refusal reads "This clip has 3 frames at 24 fps, and continuing it needs at least 5. Use a longer clip." instead of a message with a decode count. - The first/last hint uses the same words as the options. Checked and fine: the preview (same player and size as the MiniMax-H3 reference videos), progress (the page's usual step counter and time left), the section hidden for Cosmos3-Edge, the layout at 1024 and 768 px in both themes. Not checked: keyboard-only use and reloading the page with a clip staged. Noticed, not changed: - Picking Cosmos3-Edge with a clip staged drops the clip without a notice. A toast for it fires during the load and is replaced by the load's own toasts, so it was taken out again rather than left in as code that never shows. - No in-app trim for a clip over 15 s, unlike MiniMax-H3 reference videos. - At 768 px the page header overlaps ("Family" label clipped), on main too. ## Tests and status - `studio/backend/tests/test_video_cosmos3.py`: 267 passed, 2 skipped with diffusers 0.42.1; 260 passed, 9 skipped with diffusers blocked (as the `rest` CI shard runs it). `studio/frontend/tests/video-continuation.test.ts`: 9 passed; frontend suite 14942 passed; typecheck clean. Local, macOS, at `f6a1402`. - Head `f6a1402`. Codex at the head: [Didn't find any major issues](LeoBorcherding#767 (comment)) on the fork mirror. - CI at the head: queued at the time of writing. On `8eafc9b`, `Backend CI / (Python 3.13, rest)` failed on this branch (a test imported diffusers unconditionally; fixed by merging unslothai#16737's `a012d26`). `Chat UI Tests (extra)` failed on a `/login` page timeout in `playwright_multi_account.py` that is not this PR's: the same timeout failed on main's push run ([a1e340b](https://github.com/unslothai/unsloth/actions/runs/41917001176/job/126888866411)) and on three other PR branches the same day ([1](https://github.com/unslothai/unsloth/actions/runs/41972119548/job/127062896587), [2](https://github.com/unslothai/unsloth/actions/runs/41964729013/job/127038990526), [3](https://github.com/unslothai/unsloth/actions/runs/41954906457/job/127007374413)). ## Not run 720p, anything other than NVIDIA on Linux, and the Unsloth Desktop app. ## Before / after (maintainer check) Video page settings rail, merge base vs this branch, two isolated Studio installs. No GPU on this host, so the loaded model is not a live load: each side's page is served the status its own backend returns for a Cosmos3 load with a stubbed pipeline. Cosmos3 Edge gets no continuation section; Cosmos3 Nano gains "Continue a clip" (and the frame-rate dropdown from unslothai#16737).   Also fixed here: a portrait phone clip (stored landscape with a display rotation) is now decoded upright, matching ffmpeg's autorotate, before its frames reach the pipeline. --------- Co-authored-by: Daniel Han <[email protected]>
#16741 (Nano video continuation) is stacked on this PR. Merge this one first.
Lets Unsloth Studio's Cosmos3 Edge and Nano families take the generation settings NVIDIA's model cards list, so the release doc can quote NVIDIA's numbers and Unsloth Studio accepts them.
UI: the Video page on a Colab G4, main
590119de67(BEFORE) vs this branch (AFTER), light and dark theme set from Settings, driven with headless Chromium. Shots ata012d267c0unless labelled; the two commits after it touch only the duration snap and the picker text.Durations follow the picked rate and stay inside the frame window. Changing the rate keeps the length you picked, not the frame count (fixed in
74671433c6: ata012d267c0, Nano at 2.0 s became 4.9 s at 10 fps, and Edge at 3.0 s became 6.1 s at 12 fps).An out-of-range rate is refused with a toast instead of starting a job (the page's own request with
fpsrewritten to 31; the controls never send one), and restoring a clip brings its rate back.Also checked, nothing to change: the Trained sizes list shows the five 256p sizes on Edge and Nano; the slider takes arrow keys (24 to 25 moves the duration to 3.1 s); a family without a picker keeps the "24 fps" label; at 1024 and 768 px the rail reflows without clipping. Not driven: switching models with a rate picked.
What changed
590119de67)VideoFamilygainsfps_range/fps_choices(video_families.py).validate_video_request_shaperefuses a rate outside them with aVideoShapeError(422 on/video/generate, 400 withparam: fpson/v1/videos). A family that declares neither is never judged, so every other family behaves as before.defaultscarriesfps_range,fps_choices,min_num_frames,max_num_frames.video-fps.ts). Duration options follow the picked rate and stay inside the frame window; the request, the pipeline'sfpsand the mp4 all use it. Restoring a clip's settings restores its rate, and never a frame count the loaded family refuses. Changing the rate keeps the picked length (the nearest offered duration), not the frame count.Where the numbers come from
Cosmos3OmniPipeline._ACTION_RESOLUTION_BINS["256"], the same table as NVIDIA'scosmos-frameworkVIDEO_RES_SIZE_INFO["256"]andNVIDIA/cosmosdocs/reference/models.md("256p uses 320×192"). The pipeline defines no separate video-generation bins.NVIDIA/cosmosdocs/reference/models.md, Generation settings: "10, 16, 24, 30 FPS (default 24)".models.mdsays 5–300; the card says 5–400; this keeps the card's.)Renders: Colab G4, NVIDIA RTX PRO 6000 Blackwell Server Edition 96 GB, Linux, driver 580.82.07, torch 2.11.0+cu130, diffusers 0.42.1. Unsloth Studio booted from this branch at
4095020d9f(backend identical to the head; later commits touch only the restore logic in the page and a test). Seed 0, card steps (Edge 20, Nano 35), CFG 6, bf16 (transformer_quant: none). Prompts from our own test set. Each Unsloth Studio render is compared with plain diffusersCosmos3OmniPipelineon the same VM (cudnn.benchmark off, card scheduler, untiled VAE, frames through Unsloth Studio's own x264 encode), decoded frame by frame.590119de67and this branch, at the default load (9aaba48470dc38af) and at speed off (50f69a6420eff926), both Unsloth Studio servers on the same VM._native_cudnnattention backend and a channels-last VAE, and base renders the same bytes as the branch there.seam_safe_tile_strideshas no 256p edge case: 192/256/320 px sides fit in one stock 256 px tile or leave an 8-latent edge tile, and 448 px gets the seam-safe 16/10 tiles (covered by the existing tile sweep); every render above decoded untiled anyway.Each card is one setting, Unsloth Studio at speed off on the left and plain diffusers on the right (frame-identical, per the table), 2.2 s per card at the clip's own frame rate. 320x192 clips are upscaled 1.34x (lanczos) to match the cell; 832x480 clips are shown at 448x258.
256p
Frame rate: same prompt and seed on Edge 832x480, 121 frames, each played at its real rate (so 12 fps covers less of the clip in the same 2.2 s)
Image to video: both clips start from this image (generated with Qwen-Image-2.1, cropped to 832x480), prompt "The bee lifts off the flower and flies toward the camera as the petals sway gently in the breeze."
Memory and speed
Measured at the head
2676a6d138on Colab (Tesla T4 15 GB and RTX PRO 6000 96 GB), waves prompt, Auto memory mode. On the T4, where Unsloth Studio offloads and runs fp32, Edge at 448x256 peaks at 7.6 GiB against 11.0 GiB at 832x480, and 121 frames take 249 s instead of 1,217 s. On the 96 GB card Edge drops from 14.4 to 10.1 GiB at 121 frames and Nano from 38.5 to 32.8 GiB at 189 frames. Not run: Nano on a T4 (the VM's 50 GB of host RAM ran out while loading it), L4, A100, H100.Tests: new backend tests in
test_video_cosmos3.py(presets equal the pipeline's tiers, 320x192 / 448x256 accepted and smaller refused, frame snapping, fps validation per family, every other family takes any rate, status payload, generate passes and exports the picked rate) andtests/video-fps.test.ts(options, fallback, duration math identical to before for families without a window, restore, a rate change keeps the picked length: fails ata012d267c0, passes at2676a6d138).test_video_shape_validation.py's 256x256 refusal now skips a family that lists it. Locally on macOS (M5): the video backend suites show the same 23 failures on base and branch (H3 modular loads, native quant/stream builds, prequant download plans: environment), branch +48 passing; frontend typecheck clean; full frontend suite 14,930 pass and 2 fail of 14,933: a KaTeX import check that trips on a symlinkednode_modulesand a timing test.Status: head
2676a6d138. Codex: no major issues at2676a6d138on the fork mirror. CI at2676a6d138: 62 passed;Core/Core zoo(6 jobs) and the parity verdict still queued on the runner pool (all green ata012d267c0; the two new commits are frontend only).connection (dsh, stable)failed becausenpm install -g @deepseek-ai/dshfinds no version on npm (ETARGET); the same job fails the same way on main (9d40777eb1).Noticed, not changed
video_families.py.Not run: Hopper / Ampere (A100 80 GB and H100 were refused by Colab; this ran on Blackwell), the default speed mode against diffusers with a matching attention backend, multi-GPU and offloaded loads at 256p, video continuation, AMD / Apple silicon.
Before / after (maintainer check)
Video page settings rail, merge base vs this branch, two isolated Studio installs. No GPU on this host, so the loaded model is not a live load: each side's page is served the status its own backend returns for a Cosmos3 load with a stubbed pipeline. Edge: the read-only "24 fps" row becomes a 12 to 30 slider. Nano: it becomes a 10 / 16 / 24 / 30 dropdown, and the default canvas is no longer pushed up to the old 204,800 px floor.