Archived
radiance 1.8.1
- MiniMax-H3 and FastH3 no longer stop the server on a prompt longer than 16 tokens (FastH3) or 128 tokens (MiniMax-H3) - latent upscaling for the MiniMax-H3 containers: with LBH-123-AI's latent upscaler in the container, `latent_upscale` runs the first steps at a smaller size and refines the latent at the full size; `upscale_refine_steps` sets how many steps refine, and the video object reports both - rad-convert --in-place extends a container whose weights the plugin has regrouped since - plugin ABI 22: out-of-tree plugins must be rebuilt
This commit is contained in:
1 parent
7a7707a955
commit
816e24bd46
43 files changed
+4458
-81
No files matched your search
@@ -898,3 +898,33 @@ model supplies them (`--reuse`, the transformer's tensors listed as `--changed`;
|
||||
header). The distilled model's first evaluation moves 21-23% under any perturbation (the reference
|
||||
itself between bf16 and emulated fp8, or with the fp8 text encoder's conditioning), so its per-step
|
||||
numbers against the reference say little; radiance's frames and the reference's agree by eye.
|
||||
|
||||
## The latent upscaler
|
||||
|
||||
LBH-123-AI's `Minimax_h3_latent_Upscaler` (v1, `LatentResizer3D`, 345M parameters, Apache-2.0) is
|
||||
read as a companion folder of either pipeline, `latent_upscaler/` (its config.json and bf16
|
||||
weights), and declared when the container carries it (RadVideoGenDecl::upscale_max is then its
|
||||
largest factor). The architecture is the ComfyUI node's; the config states the same numbers:
|
||||
|
||||
```
|
||||
input the clean small latent's voxels (patch rows unfolded), normalised a second time with the
|
||||
upscaler's own per-channel mean and deviation (the node's (x - mean) / std on ComfyUI's
|
||||
already-normalised latent), bf16
|
||||
factor (W / W' + H / H') / 2; Linear(1, 64) of (factor - 1), SiLU, Linear(64, 64), in f32;
|
||||
each residual block's SiLU and Linear(64, 1024) gives its (scale, shift)
|
||||
network conv_in 3x3x3 24 -> 512; 18 blocks at the small size; F.interpolate(trilinear,
|
||||
align_corners=False) to the full size with the frame count kept, which is bilinear on
|
||||
each frame (resize_bilinear); 18 blocks at the full size; GroupNorm(32), SiLU,
|
||||
conv_out 3x3x3 512 -> 24. A block list is 12 residual blocks, a temporal block after
|
||||
the 1st, 3rd, .. 11th
|
||||
residual GroupNorm(32) SiLU conv3d; GroupNorm(32) * (1 + scale) + shift, SiLU, conv3d; + x
|
||||
(group_norm, conv3d_ndhwc with the residual added in its store)
|
||||
temporal GroupNorm(32) SiLU, a depthwise (5, 1, 1) convolution over frames (tconv_dw), a 1x1x1
|
||||
one (gemm_nt_bias with the residual)
|
||||
output denormalised, folded back into patch rows (patch_fold), then the video latent and the
|
||||
soundtrack's re-noised to the first full-size step's sigmas with stream 1 of their seeds
|
||||
(flow_renoise)
|
||||
```
|
||||
|
||||
The node runs the network on whole clips here (its temporal chunking is off in the example
|
||||
workflows); every rank runs it whole, its weights in VRAM on each.
|
||||
+16
-1
@@ -2320,6 +2320,21 @@ encoder and decoders taken from a MiniMax-H3 container (`data/recipes/minimax-h3
|
||||
how), served the same way and named `fastvideo-fasth3-8-step-v2`. Its card notes that difficult
|
||||
motion, fine detail and some audio may fall below the base model's; it serves text to video only.
|
||||
|
||||
**Latent upscaling.** A container that carries LBH-123-AI's latent upscaler
|
||||
(`LBH-123-AI/Minimax_h3_latent_Upscaler`, Apache-2.0; the recipe says how to add it to a container,
|
||||
in place) takes **`latent_upscale`**, a factor from 1 to 4: the first steps run at `size` divided
|
||||
by it (each side rounded to a multiple of 32), the clean small latent is enlarged to `size` by the
|
||||
upscaler, re-noised, and the last **`upscale_refine_steps`** run at the full size (3 of FastH3's 8
|
||||
and 12 of the base model's 49 by default). The steps at the small size cost a fraction of a
|
||||
full-size step's, so most of the time goes to the refinement. The video object of an upscaled
|
||||
video carries `latent_upscale`, the `upscale_refine_steps` it ran and `upscale_from`, the small
|
||||
size.
|
||||
|
||||
```sh
|
||||
curl -s http://localhost:8000/v1/videos -H 'Content-Type: application/json' -d '{
|
||||
"prompt": "...", "size": "1344x768", "seed": 7, "latent_upscale": 2}'
|
||||
```
|
||||
|
||||
On two R9700s (`--tp 2`, 300 W) a 5.17 s clip at 1344x768 takes about 68 s with FastH3 and about
|
||||
8.8 minutes with MiniMax-H3's default 50 steps. Both attentions run their scores in int8 and
|
||||
P.V in fp8 (docs/ARCHITECTURES.md); a step's cost grows with the square of the rows, so a longer
|
||||
@@ -2513,7 +2528,7 @@ is the part of a log to paste into an issue. Its sections:
|
||||
warning is also printed as a `W` line of its own.
|
||||
|
||||
```
|
||||
I STARTUP REPORT -- radiance 1.8.0
|
||||
I STARTUP REPORT -- radiance 1.8.1
|
||||
I CONFIGURATION -- every option, the value in force, and where it came from
|
||||
I --model /models/flashnext.rad [command line]
|
||||
I --tp 2 [command line]
|
||||
|
||||
+77
-1
@@ -1073,7 +1073,8 @@ is [video sparse attention](#video-sparse-attention)) and its gated residual
|
||||
`gate_add` `act` none; the soundtrack's vocoder is `conv_t1d`, `snake_aa` and `conv1d` `clamp`
|
||||
([Audio generation](#audio-generation)). Each op rounds where the reference model materialises a
|
||||
bf16 tensor and keeps f32 where it computes in f32; the libref function says which
|
||||
(`libref/ref_gen.cpp`, `libref/ref_video.cpp`).
|
||||
(`libref/ref_gen.cpp`, `libref/ref_video.cpp`). Its latent upscaler's ops are
|
||||
[below](#the-latent-upscaler).
|
||||
|
||||
| op | params | operands |
|
||||
|---|---|---|
|
||||
@@ -1245,6 +1246,81 @@ fp8 P.V form (`v` E4M3 codes, `v_scale` `[n_head * head_dim]`), before the epilo
|
||||
MiniMax-H3: `tile_t`, `tile_h` and `tile_w` 4, `patch` 2, `sparsity` 0.8, `head_dim` 128, the
|
||||
default `scale` `1 / sqrt(head_dim)`.
|
||||
|
||||
### The latent upscaler
|
||||
|
||||
MiniMax-H3's latent upscaler (`LatentResizer3D`) is a 3-D convolutional network over the video
|
||||
latent: its 24 channels to 512 by a 3 x 3 x 3 convolution, residual blocks
|
||||
(`t = silu(GN(x)); h = conv3(t); t = silu(GN(h) (1 + scale) + shift); x = x + conv3(t)`, the
|
||||
scale and shift from the upscale factor's embedding) and temporal blocks
|
||||
(`t = silu(GN(x)); t = dwconv_t5(t); x = x + pwconv(t)`, the 1 x 1 x 1 `pwconv` a `gemm_nt_bias`)
|
||||
at the source size, a spatial bilinear resize, the same blocks at the target size, and
|
||||
`GroupNorm(32)`, SiLU and a 3 x 3 x 3 convolution back to 24 channels. `patch_fold` turns its output
|
||||
back into the transformer's patch rows and `flow_renoise` takes them to the noise level a refining
|
||||
pass starts from. Each op rounds once into its output (`libref/ref_video.cpp`).
|
||||
|
||||
| op | params | operands |
|
||||
|---|---|---|
|
||||
| `conv3d_ndhwc` | `M`(range) `cin` `cout` `k` `kt` `dtype` | `x`, `w`w, `b`w, `geom`, `res`? → `y` |
|
||||
| `group_norm` | `M`(range) `n` `groups` `eps`:f64 `act` `dtype` | `x`, `w`w, `b`w, `mod`?, `stats`:inout → `y` |
|
||||
| `tconv_dw` | `M`(range) `n` `k` `dtype` | `x`, `w`w, `b`w, `geom` → `y` |
|
||||
| `resize_bilinear` | `M`(range) `n` `dtype` | `x`, `geom` → `y` |
|
||||
| `patch_fold` | `M`(range) `C` `pt` `ph` `pw` `mul` `add` `dtype` | `x`, `geom` → `y` |
|
||||
| `flow_renoise` | `M`(range) `n` `stream` `dtype` | `sigma`, `seed`, `x`:inout |
|
||||
|
||||
Activations are voxel rows: row `(t, i, j)` of a `T x H x W` volume is `(t H + i) W + j`, channels
|
||||
innermost (NDHWC). `geom` is the request's volume, i32 on the device (the parameters are fixed at
|
||||
declare). An output holds at least the rows the volume writes; rows past them are not written.
|
||||
Every op honours its activation operands' row pitches. `rd` is a rounding into the output's dtype.
|
||||
|
||||
- `conv3d_ndhwc`: `x [>= T H W, cin]`, `y` and `res` `[>= T H W, cout]`, `geom = (T, H, W)`; `w` is
|
||||
PyTorch's Conv3d weight `[cout, cin, kt, k, k]` (a kernel may relayout it at load, as
|
||||
`conv2d_nhwc`'s layout hook does) and `b [cout]`. Stride 1, zero padding `kt/2` frames and `k/2`
|
||||
rows and columns on each side (`same`; `k` and `kt` odd):
|
||||
`y[(t,i,j), o] = rd(f32(sum over (dt, kh, kw, ci) of w[o, ci, dt, kh, kw]
|
||||
x[(t+dt-kt/2, i+kh-k/2, j+kw-k/2), ci]) + b[o])`, terms outside the volume zero, f32 accumulation
|
||||
in an order of the implementation's (libref: the taps in `(dt, kh, kw)` order, each tap's
|
||||
channels ascending). With `res`, `y = rd(rd(acc + b) + res)`: the convolution's output rounded,
|
||||
then the residual added and rounded, as a block's `skip(x) + h` in bf16. `res` may be the same
|
||||
memory as `y` (the residual added in place); `x` never aliases `y`. x, y, res and w bf16 (also
|
||||
f32), b bf16 or f32. MiniMax-H3: `k` = `kt` = 3, `(cin, cout)` `(24, 512)`, `(512, 512)`,
|
||||
`(512, 24)`.
|
||||
- `group_norm` is PyTorch's `nn.GroupNorm(groups, n)` on `[1, n, T, H, W]`: `x` and `y`
|
||||
`[>= M, n]` (`M` is `y`'s rows), group `g` the channels `[g n/groups, (g+1) n/groups)` of all
|
||||
`M` rows. `mean_g` and the biased `var_g` are over the group's `M n/groups` values, accumulated in
|
||||
f32 or better (libref: f64, two passes, row-major); `rstd_g = 1 / sqrt(f32(var_g) + eps)` in f32.
|
||||
Then, in f32, `v = (x - mean_g) rstd_g w[c] + b[c]`; with `mod` (`[>= 2n]`, f32 or bf16, one row:
|
||||
`scale = mod[0:n]`, `shift = mod[n:2n]`) `v = v (1 + scale[c]) + shift[c]`; `act` `none` or
|
||||
`silu` (`v / (1 + exp(-v))`); one rounding into `y`. `stats` is f32 of at least
|
||||
`groups (2 + 3 1024)` values: afterwards `stats[2g]` and `stats[2g+1]` hold group `g`'s `mean_g`
|
||||
and `rstd_g`, and the rest is the implementation's scratch (partial sums of up to 1024 parts a
|
||||
group; libref leaves it untouched). A kernel may take several launches but must be deterministic,
|
||||
a fixed reduction order with no float atomics. `y` may be the same memory as `x`. `w` and `b`
|
||||
`[n]`, bf16 or f32. MiniMax-H3: `n` 512, `groups` 32, `eps` 1e-5.
|
||||
- `tconv_dw`: a depthwise convolution along the frames (a Conv3d of kernel `(k, 1, 1)`, one group a
|
||||
channel): `geom = (T, H, W)`, `P = H W` rows a frame, `w` PyTorch's `[n, 1, k, 1, 1]` (tap `j` of
|
||||
channel `c` at `c k + j`), `b [n]`, `k` odd:
|
||||
`y[(t, p), c] = rd(f32(sum_j w[c, j] x[(t + j - k/2, p), c]) + b[c])`, frames outside `[0, T)`
|
||||
zero, the sum f32 in ascending `j`. `x` never aliases `y`. MiniMax-H3: `n` 512, `k` 5.
|
||||
- `resize_bilinear`: `geom = (T, h, w, H, W)`, `x [>= T h w, n]`, `y [>= T H W, n]`; each frame
|
||||
resized on its own, as torch's `upsample_bilinear2d` with `align_corners=False` computes it for an
|
||||
output size (not a scale factor): `sh = f32(h) / f32(H)`, `src = max(sh (f32(i) + 0.5) - 0.5, 0)`
|
||||
in f32, `i0 = (int)src`, `i1 = i0 + (i0 < h - 1)`, `l1 = src - i0`, `l0 = 1 - l1`, the same for
|
||||
columns, then
|
||||
`v = l0y (l0x x[i0,j0] + l1x x[i0,j1]) + l1y (l0x x[i1,j0] + l1x x[i1,j1])` in f32 (each product
|
||||
and sum one rounding), rounded once into `y`. Any sizes, shrinking too. The upscaler's
|
||||
`F.interpolate(mode="trilinear")` at an unchanged frame count weighs each frame by exactly 1 and
|
||||
its neighbour by 0, so this is that resize. `x` never aliases `y`.
|
||||
- `patch_fold` is `patch_unfold`'s inverse, normalising: voxel rows
|
||||
`x [(F pt) (Hp ph) (Wp pw), C]` to patch rows `y [F Hp Wp, C pt ph pw]`, `geom = (F, Hp, Wp)`,
|
||||
`y[(f,i,j), c pt ph pw + a ph pw + b pw + d] = f32(f32(x[(f pt + a, i ph + b, j pw + d), c]
|
||||
mul[c]) + add[c])`, `mul` and `add` lists of `C` values kept in f32. `x` bf16 or f32, `y` f32.
|
||||
`M` is `y`'s rows. MiniMax-H3: `C` 24, `pt` 1, `ph` = `pw` = 2.
|
||||
- `flow_renoise` re-noises a clean latent to noise level `s` with a fresh stream, over `x`'s rows:
|
||||
`x[k, c] = f32(f32(f32(1 - s) x[k, c]) + f32(s z(k n + c)))`, `s` = `sigma` (f32 `[1]`),
|
||||
`z(e) = rad_philox_normal_s(seed, stream, e)` (`abi/rad_philox.h`), `seed` u32 `[2]` low word
|
||||
first, `stream` the parameter. `x` f32 `[M, n]` at its row pitch. MiniMax-H3: `n` 96 (the video's
|
||||
patch rows) and 32 (the soundtrack's), `stream` 1.
|
||||
|
||||
## Mixture of experts
|
||||
|
||||
| op | params | operands |
|
||||
|
||||
Reference in new issue
Block a user