Archived
videos: per-request shift/audio_shift; the fried look is decode/quant, not schedule
Adds `shift` (video) and `audio_shift` (soundtrack) as per-request /v1/videos fields, (0,100], each defaulting to the model's trained shift; echoed in the video object and advertised in the model card as video_shift/video_audio_shift. ABI-invisible: VideoRequest carries the two doubles, video_schedule() re-shifts that stream's sigma grid, and the shifted sigmas ride RadVideoGenBatch::sched -- the plugin reads only sigmas/timesteps, never a shift scalar, so RAD_ABI_VERSION stays 24 and no plugin rebuilds. Diagnosis (cont.20): the review batch's blown-highlight/crushed-black "fried" look is present in the text-only T2VA control at native res (clip 54-79% vs the reference's ~4.5%), so it is not the keyframe/tower path (#52) and not a regression (old ex10 T2VA has clip 51%). It is not the sampler (euler vs res_multistep: clip 53-61% vs 56-65%) and not the shift: the container already runs 12/3 (the reference's settings) and shift=4 leaves clip at ~54%. With sampler, shift and CFG (=1, no guidance) all matched, the gap is downstream of the schedule -- the video VAE decode scale parity and/or the DiT int8 quant, i.e. #37/#44/#45. The shift field ships regardless: correct, useful, and requested. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
cd393a0973
commit
3a7a79fb47
9 files changed
+149
-9
No files matched your search
@@ -2497,6 +2497,8 @@ int Engine::run_server() {
|
||||
in.default_steps = vd.default_steps;
|
||||
in.max_steps = vd.max_steps;
|
||||
in.fixed_steps = vd.n_rungs > 0;
|
||||
in.shift_video = vd.shift_video;
|
||||
in.shift_audio = vd.shift_audio;
|
||||
in.upscale_max = vd.upscale_max;
|
||||
in.upscale_refine = vd.upscale_refine;
|
||||
in.max_lanes = vd.max_lanes;
|
||||
|
||||
+13
-2
@@ -130,6 +130,13 @@ struct VideoRequest {
|
||||
/* The sampler: a RAD_SAMPLER_* value (abi/rad_runtime.h). 0 = Euler, the default; 1 =
|
||||
* res_multistep, the second-order step on the clean estimate. */
|
||||
int32_t sampler = 0;
|
||||
/* The schedule shift of each stream; 0 = the declaration's shift_video/shift_audio. Overriding
|
||||
* it re-shapes the sigma grid the driver stages into RadVideoGenBatch::sched -- the plugin
|
||||
* reads only the shifted sigmas and timesteps, never a shift scalar, so this is NOT an ABI
|
||||
* field and needs no plugin rebuild. The DasiWa workflow runs the video at shift 12 and the
|
||||
* soundtrack at 3; the container may carry a different pair, which is what 0 keeps. */
|
||||
double shift_video = 0.0;
|
||||
double shift_audio = 0.0;
|
||||
/* Latent upscaling (abi/rad_builder.h, RadVideoGenDecl): the factor, 0 for none, and the
|
||||
* evaluations at the full size after it, 0 for the model's default. */
|
||||
double upscale = 0.0;
|
||||
@@ -165,12 +172,16 @@ void video_small_size(const RadVideoGenDecl& d, int32_t width, int32_t height, d
|
||||
|
||||
/* The two schedules a request of `steps` grid points runs (RadVideoGenDecl, "The sampler"): each
|
||||
* the f32 sigmas, last 0, and the model evaluations it takes, the shorter of the two. With a
|
||||
* trained schedule any other step count than n_rungs + 1 gives no steps. */
|
||||
* trained schedule any other step count than n_rungs + 1 gives no steps. `shift_video`/`shift_audio`
|
||||
* above 0 override the declaration's per-stream shift for the exponential sigma shift; 0 keeps the
|
||||
* declaration's. The shift only re-shapes the staged sigmas, so it reaches the plugin through the
|
||||
* schedule region, not the batch. */
|
||||
struct VideoSchedule {
|
||||
std::vector<float> sig_v, sig_a;
|
||||
int32_t steps = 0;
|
||||
};
|
||||
VideoSchedule video_schedule(const RadVideoGenDecl& d, int32_t steps);
|
||||
VideoSchedule video_schedule(const RadVideoGenDecl& d, int32_t steps, double shift_video = 0.0,
|
||||
double shift_audio = 0.0);
|
||||
|
||||
} /* namespace gen */
|
||||
} /* namespace rad */
|
||||
@@ -123,17 +123,21 @@ static std::vector<float> rung_sigmas(double shift, const double* rungs, int32_t
|
||||
return s;
|
||||
}
|
||||
|
||||
VideoSchedule video_schedule(const RadVideoGenDecl& d, int32_t steps) {
|
||||
VideoSchedule video_schedule(const RadVideoGenDecl& d, int32_t steps, double shift_video,
|
||||
double shift_audio) {
|
||||
/* A request's shift overrides the declaration's per stream; 0 keeps the trained value. */
|
||||
const double sv = shift_video > 0.0 ? shift_video : d.shift_video;
|
||||
const double sa = shift_audio > 0.0 ? shift_audio : d.shift_audio;
|
||||
VideoSchedule v;
|
||||
if (d.n_rungs > 0) {
|
||||
if (steps != d.n_rungs + 1) return v;
|
||||
v.sig_v = rung_sigmas(d.shift_video, d.rungs, d.n_rungs);
|
||||
v.sig_a = rung_sigmas(d.shift_audio, d.rungs, d.n_rungs);
|
||||
v.sig_v = rung_sigmas(sv, d.rungs, d.n_rungs);
|
||||
v.sig_a = rung_sigmas(sa, d.rungs, d.n_rungs);
|
||||
v.steps = d.n_rungs;
|
||||
return v;
|
||||
}
|
||||
v.sig_v = shifted_sigmas(d.shift_video, steps);
|
||||
v.sig_a = shifted_sigmas(d.shift_audio, steps);
|
||||
v.sig_v = shifted_sigmas(sv, steps);
|
||||
v.sig_a = shifted_sigmas(sa, steps);
|
||||
const size_t n = std::min(v.sig_v.size(), v.sig_a.size());
|
||||
v.steps = n > 0 ? (int32_t)(n - 1) : 0;
|
||||
return v;
|
||||
@@ -637,7 +641,7 @@ int VideoDriver::submit(std::unique_ptr<VideoRequest> r, std::string* why) {
|
||||
return no("the model could not lay this video out");
|
||||
j->step_rows = j->rows;
|
||||
}
|
||||
j->sched = video_schedule(d, steps);
|
||||
j->sched = video_schedule(d, steps, r->shift_video, r->shift_audio);
|
||||
if (j->sched.steps < 1) return no("the schedule has no steps");
|
||||
if (r->upscale > 1.0) {
|
||||
if (!(d.upscale_max > 1.0)) return no("this model has no latent upscaler");
|
||||
|
||||
@@ -683,6 +683,10 @@ struct VideoGenInfo {
|
||||
int64_t sample_rate = 0, channels = 0;
|
||||
int64_t default_steps = 0, max_steps = 0, max_lanes = 1;
|
||||
bool fixed_steps = false; /* a trained schedule: max_steps grid points and no other */
|
||||
/* The trained per-stream schedule shift (RadVideoGenDecl). The `shift`/`audio_shift` request
|
||||
* fields override these; a request that omits them gets these values, so a client can learn the
|
||||
* baseline the model was converted with. */
|
||||
double shift_video = 0.0, shift_audio = 0.0;
|
||||
/* A latent upscaler: the largest factor (0: none) and the full-size evaluations by default. */
|
||||
double upscale_max = 0.0;
|
||||
int64_t upscale_refine = 0;
|
||||
|
||||
+28
-1
@@ -60,6 +60,7 @@ struct Server::VideoJob {
|
||||
int64_t created_at = 0;
|
||||
uint64_t seed = 0;
|
||||
int32_t sampler = 0; /* the request's RAD_SAMPLER_* */
|
||||
double shift_video = 0, shift_audio = 0; /* the request's shift override; 0: the model's */
|
||||
std::shared_ptr<gen::VideoTicket> ticket;
|
||||
std::thread worker;
|
||||
/* Under Server::videos_m_ from here on. */
|
||||
@@ -274,6 +275,10 @@ void Server::video_caps(json& caps, const IVideoGen* gen) {
|
||||
caps["video_formats"] = json::array({ "mp4", "webm", "webm-av1" });
|
||||
/* The samplers `sampler` accepts; euler is the default and always available. */
|
||||
caps["video_samplers"] = json::array({ "euler", "res_multistep" });
|
||||
/* The schedule shift `shift` (video) and `audio_shift` accept: these are the model's trained
|
||||
* values, which a request that omits the fields runs; a request overrides one or both. */
|
||||
caps["video_shift"] = info.shift_video;
|
||||
caps["video_audio_shift"] = info.shift_audio;
|
||||
}
|
||||
|
||||
HttpResponse Server::handle_video_create(const HttpRequest& req) {
|
||||
@@ -350,7 +355,7 @@ HttpResponse Server::handle_video_create(const HttpRequest& req) {
|
||||
static const char* kKnown[] = {
|
||||
"model", "prompt", "seconds", "size", "input_reference", "seed", "num_inference_steps",
|
||||
"task", "target", "conditions", "user", "latent_upscale", "upscale_refine_steps", "format",
|
||||
"sampler",
|
||||
"sampler", "shift", "audio_shift",
|
||||
};
|
||||
for (auto it = body.begin(); it != body.end(); ++it) {
|
||||
bool known = false;
|
||||
@@ -573,6 +578,24 @@ HttpResponse Server::handle_video_create(const HttpRequest& req) {
|
||||
return error_response(e, req.peer);
|
||||
}
|
||||
}
|
||||
/* The schedule shift per stream. 0 (omitted) runs the model's trained shift; a given value
|
||||
* re-shapes that stream's sigma grid. (0, 100] bounds typos without clipping a real setting;
|
||||
* the shift is safe for any positive value, it only bunches the grid toward the noisy end. */
|
||||
if (has(body, "shift")) {
|
||||
double v = 0;
|
||||
if (!number(body["shift"], &v) || !(v > 0.0) || v > 100.0)
|
||||
return bad("shift", "the video schedule shift: a number in (0, 100], or omit it to run "
|
||||
"the model's trained shift " + rad::fmt("%g", info.shift_video));
|
||||
r->shift_video = v;
|
||||
}
|
||||
if (has(body, "audio_shift")) {
|
||||
double v = 0;
|
||||
if (!number(body["audio_shift"], &v) || !(v > 0.0) || v > 100.0)
|
||||
return bad("audio_shift", "the soundtrack schedule shift: a number in (0, 100], or "
|
||||
"omit it to run the model's trained shift " +
|
||||
rad::fmt("%g", info.shift_audio));
|
||||
r->shift_audio = v;
|
||||
}
|
||||
if (has(body, "latent_upscale")) {
|
||||
double v = 0;
|
||||
if (!(info.upscale_max > 0.0))
|
||||
@@ -807,6 +830,8 @@ HttpResponse Server::handle_video_create(const HttpRequest& req) {
|
||||
j->created_at = unix_now();
|
||||
j->seed = r->seed;
|
||||
j->sampler = r->sampler;
|
||||
j->shift_video = r->shift_video;
|
||||
j->shift_audio = r->shift_audio;
|
||||
j->fmt = fmt;
|
||||
for (const gen::VideoRefMedia& m : r->refs) j->refs.push_back(m.name);
|
||||
j->ticket = std::make_shared<gen::VideoTicket>();
|
||||
@@ -993,6 +1018,8 @@ json Server::video_json(const VideoJob& j) {
|
||||
o["seed"] = j.seed;
|
||||
o["format"] = format_name(j.fmt); /* what /content will return */
|
||||
o["sampler"] = j.sampler == RAD_SAMPLER_RES_MULTISTEP ? "res_multistep" : "euler";
|
||||
if (j.shift_video > 0.0) o["shift"] = j.shift_video; /* 0: the model's trained shift */
|
||||
if (j.shift_audio > 0.0) o["audio_shift"] = j.shift_audio;
|
||||
if (j.refine > 0) {
|
||||
o["latent_upscale"] = j.upscale;
|
||||
o["upscale_refine_steps"] = j.refine;
|
||||
|
||||
@@ -2311,6 +2311,13 @@ curl -s http://localhost:8000/v1/videos/video_.../content -o fox.mp4
|
||||
evaluations, by default; at most 65). The model is guidance-distilled, so there is no guidance
|
||||
scale and no negative prompt. A step-distilled release (FastH3, below) runs only the schedule it
|
||||
was trained on: 9 grid points, and any other count is refused with a 400.
|
||||
- **`sampler`** is `euler` (default, first order) or `res_multistep` (second order on the clean
|
||||
estimate; the DasiWa workflow's choice). **`shift`** and **`audio_shift`** override the exponential
|
||||
shift of the video and soundtrack sigma grids, each a number in `(0, 100]`; omitted, each runs the
|
||||
model's trained shift (a model card's `video_shift` / `video_audio_shift` report those, e.g. 12 / 3).
|
||||
These reshape the noise schedule the driver stages — they reach the kernels as sigmas, not as a new
|
||||
batch field — and never change the model's trained look, which is fixed by its VAE decode and
|
||||
quantisation, not the schedule.
|
||||
- Only text is read: `input_reference` and non-empty `conditions` are refused, as is a `task`
|
||||
other than `t2va`. Fields are JSON or a multipart form (OpenAI's clients send the form).
|
||||
|
||||
|
||||
@@ -604,3 +604,41 @@ step·seed 1234, `first`=standing, `last`=riding; `index.tsv` records status/wal
|
||||
| REF2VA | `ref2va.mp4` | 214 s | 2 image refs (`last`,`first`), not keyframes |
|
||||
|
||||
Each has a matching `.thumb.webp`. These are SEQUENCE clips (single generated run), not loops.
|
||||
|
||||
## cont.20 (2026-10-21) — per-request `shift`, and the "fried" look localized to decode/quant
|
||||
|
||||
The full-resolution frames of a workflow-prompt review batch showed a **blown-highlight / crushed-black
|
||||
"watercolor" look** (the user's "fried"). Measured with HSV + Laplacian-variance across time on native-512
|
||||
frames, versus the reference clips (same `dasiwaHybridV4` finetune, via ComfyUI):
|
||||
|
||||
| render | black% | clip% (blown) |
|
||||
|---|---|---|
|
||||
| reference snow | 1.5–4.7 | **~4.5** |
|
||||
| Radiance snow T2VA (this batch) | 11–15 | **54–79** |
|
||||
| Radiance snow T2VA (old ex10) | 13.7 | 51 |
|
||||
|
||||
Key facts established by this pass:
|
||||
1. **It is in the text-only T2VA control too** — so it is NOT the keyframe/vision-tower path (#52), and
|
||||
the old ex10 T2VA has the same clip% → **not a regression**. The earlier "T2VA is clean" read was an
|
||||
artifact of judging 256² downscaled strips; at native res it was never clean.
|
||||
2. **Sampler is not the lever**: same-seed euler vs res_multistep gives clip 53–61% vs 56–65% — no
|
||||
meaningful change (matches the user's eye).
|
||||
3. **The container already runs shift 12 / 3** (`/v1/models` `video_shift`=12.0, `video_audio_shift`=3.0)
|
||||
— the reference's exact settings. And rendering at `shift=4` leaves clip at ~54%. So shift is not the
|
||||
lever either. CFG is not implemented (single conditioning pass = CFG 1), which already matches the
|
||||
reference's BasicGuider scale-1.
|
||||
4. With sampler, shift and CFG all matched, Radiance still blows ~55% where the reference blows ~4.5% on
|
||||
the same content ⇒ the gap is **downstream of the schedule: the video VAE decode (scale/shift factor
|
||||
value parity) and/or the DiT int8 quant**, i.e. #37/#44/#45 — the deep fidelity work, needing the stock
|
||||
/ golden-latent box (#44). Not a schedule, keyframe, downscale or source-compression issue.
|
||||
|
||||
**Shipped anyway** (the user asked for it, and it is correct and useful for other checkpoints/workflows):
|
||||
`shift` (video) and `audio_shift` (soundtrack) are now per-request `/v1/videos` fields, `(0,100]`, each
|
||||
defaulting to the model's trained shift; echoed in the video object and advertised in the model card as
|
||||
`video_shift`/`video_audio_shift`. Implementation is **ABI-invisible**: `VideoRequest` carries the two
|
||||
doubles, `video_schedule()` re-shifts that stream's sigma grid, and the shifted sigmas are staged through
|
||||
`RadVideoGenBatch::sched` — the plugin reads only sigmas/timesteps, never a shift scalar, so
|
||||
`RAD_ABI_VERSION` stays 24 and no plugin rebuilds. Files: `core/gen/video.h`, `core/gen/video_driver.cpp`,
|
||||
`core/server/iface.h` (`VideoGenInfo` shift), `core/engine.cpp` (populate), `core/server/videos.cpp`
|
||||
(allowlist/parse/echo/caps); tests in `videos_test.cpp`, `video_gen_test.cpp` (host, green). Device:
|
||||
`shift=4` accepted+echoed+renders.
|
||||
@@ -334,6 +334,21 @@ TEST(the_schedule_counts_grid_points_and_shifts_each_modality) {
|
||||
CHECK_EQ(gen::video_schedule(d, 2).steps, 1);
|
||||
}
|
||||
|
||||
/* A request's shift re-shapes ONLY the stream it names; the stream it leaves at 0 keeps the
|
||||
* declaration's trained shift (decl_small is video 12, audio 3). */
|
||||
TEST(a_request_shift_overrides_the_declaration_per_stream) {
|
||||
const RadVideoGenDecl d = decl_small();
|
||||
const gen::VideoSchedule base = gen::video_schedule(d, 50);
|
||||
const gen::VideoSchedule s = gen::video_schedule(d, 50, 6.0, 0.0); /* video -> 6, audio keep 3 */
|
||||
REQUIRE_EQ(s.sig_v.size(), base.sig_v.size());
|
||||
REQUIRE_EQ(s.sig_a.size(), base.sig_a.size());
|
||||
const double b = 1.0 - 30.0 / 49.0;
|
||||
CHECK(std::fabs(s.sig_v[30] - 6.0 * b / (1.0 + 5.0 * b)) < 1e-6); /* re-shifted by 6 */
|
||||
CHECK(std::fabs(s.sig_a[30] - 3.0 * b / (1.0 + 2.0 * b)) < 1e-6); /* still the decl's 3 */
|
||||
CHECK(s.sig_v[30] != base.sig_v[30]); /* video actually moved */
|
||||
CHECK(std::fabs(s.sig_a[30] - base.sig_a[30]) < 1e-9); /* audio untouched */
|
||||
}
|
||||
|
||||
/* A trained schedule (a distilled checkpoint's): its rungs in f32, each modality's shift applied
|
||||
* as the reference's tensor arithmetic does (f32 throughout), then the terminal 0; one evaluation a
|
||||
* rung, and no other step count. */
|
||||
|
||||
@@ -48,6 +48,8 @@ struct FakeVideoGen : IVideoGen {
|
||||
inf.max_ref_images = 9;
|
||||
inf.max_ref_videos = 3;
|
||||
inf.max_ref_audios = 3;
|
||||
inf.shift_video = 12.0;
|
||||
inf.shift_audio = 3.0;
|
||||
}
|
||||
const VideoGenInfo& info() const override { return inf; }
|
||||
int submit(std::unique_ptr<gen::VideoRequest> r, std::string*) override {
|
||||
@@ -161,6 +163,12 @@ TEST(a_video_request_that_cannot_be_served_names_its_field) {
|
||||
CHECK_EQ(v.refused(Videos::body({ { "task", "fl2va" } })), std::string("first_frame"));
|
||||
CHECK_EQ(v.refused(Videos::body({ { "conditions", json::array({ json::object() }) } })),
|
||||
std::string("conditions"));
|
||||
/* The shift: (0, 100], a number; 0 / negative / over the cap / non-numeric are refused. */
|
||||
CHECK_EQ(v.refused(Videos::body({ { "shift", 0 } })), std::string("shift"));
|
||||
CHECK_EQ(v.refused(Videos::body({ { "shift", -1 } })), std::string("shift"));
|
||||
CHECK_EQ(v.refused(Videos::body({ { "shift", 200 } })), std::string("shift"));
|
||||
CHECK_EQ(v.refused(Videos::body({ { "shift", "hot" } })), std::string("shift"));
|
||||
CHECK_EQ(v.refused(Videos::body({ { "audio_shift", 0 } })), std::string("audio_shift"));
|
||||
CHECK_EQ(v.refused({ { "prompt", "p" }, { "target", { { "aspect_ratio", "wide" } } } }),
|
||||
std::string("target"));
|
||||
CHECK_EQ(v.refused(Videos::body({ { "target", { { "aspect_ratio", "16:9" } } } })),
|
||||
@@ -216,6 +224,30 @@ TEST(the_generator_gets_the_size_the_chunks_and_the_steps) {
|
||||
v.wait(str_at(json::parse(r.body, nullptr, false), "id"));
|
||||
}
|
||||
|
||||
/* `shift`/`audio_shift` thread to the request and echo back; omitted, the request carries 0 (the
|
||||
* driver keeps the model's trained shift) and the echo adds neither field. */
|
||||
TEST(the_shift_threads_to_the_request_and_echoes) {
|
||||
Videos v;
|
||||
HttpResponse r = v.create(Videos::body({ { "shift", 6 }, { "audio_shift", 2 } }));
|
||||
REQUIRE_EQ(r.status, 200);
|
||||
CHECK_EQ(v.gen.last().shift_video, 6.0);
|
||||
CHECK_EQ(v.gen.last().shift_audio, 2.0);
|
||||
json o = json::parse(r.body, nullptr, false);
|
||||
CHECK(o.contains("shift"));
|
||||
CHECK_EQ(o["shift"].get<double>(), 6.0);
|
||||
CHECK_EQ(o["audio_shift"].get<double>(), 2.0);
|
||||
v.wait(str_at(o, "id"));
|
||||
|
||||
r = v.create(Videos::body());
|
||||
REQUIRE_EQ(r.status, 200);
|
||||
CHECK_EQ(v.gen.last().shift_video, 0.0);
|
||||
CHECK_EQ(v.gen.last().shift_audio, 0.0);
|
||||
o = json::parse(r.body, nullptr, false);
|
||||
CHECK(!o.contains("shift"));
|
||||
CHECK(!o.contains("audio_shift"));
|
||||
v.wait(str_at(o, "id"));
|
||||
}
|
||||
|
||||
/* Latent upscaling: refused by a model without an upscaler; with one, the factor and the refine
|
||||
* steps reach the generator, a factor of 1 is none, and the refine steps need a factor. */
|
||||
TEST(latent_upscale_reaches_the_generator_where_the_model_has_an_upscaler) {
|
||||
|
||||
Reference in new issue
Block a user