This repository has been archived on 2026-11-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
radiance-sycl/tests/vae_geom_test.cpp
T
Deadcode 6645337f69 radiance 1.13.0
New models:
- Tencent Hy-Memory (HYV3) from its BF16, FP8 and GGUF checkpoints, with its native tool calls
- M2XFP4: metadata-augmented MXFP4 weights for Qwen3.8-27B and its DFlash2 drafter (top-1 89.1% ->
  92.4% against plain MXFP4), its quantiser and recipe, and ParoQuant's M2XFP4 checkpoints
- Gemma 4 E2B/E4B audio input; NVIDIA-Nemotron-3.5-Bolt-E4B in int8 and 4-bit, on two cards by
  default; Ornith-1.5-122B compose files

Speed:
- Weight reads beside the decode all-reduces (qwen35_fp8, gemma3; --weight-prefetch, on by default):
  the 27B MXFP4 with DFlash2 61.2 -> 67.9 tok/s at c1, TranslateGemma 27B +13%
- Head-256 split-KV decode attention at 256 workgroups and without bank conflicts (27B: +3-5% a
  step at 25-41K context), and the prefill KV split for small launches (a short turn over a long
  context decodes the other sequences 27% faster in that step)
- MXFP4 decode gate_up, activation and fp8 quantiser in one launch (27B, Gemma 3 up to 64 rows:
  TranslateGemma +2-5% at 2-8 streams)
- ParoQuant int4/int5 tiled GEMMs 6-9% faster
- Speculation: a step's tokens are sent before the drafter's passes end, no step waits behind one
  that ends its requests, and the MTP head's first draft no longer collapses after short chats in
  the prefix cache

Features:
- --kv-resident N: KV streaming for a context bigger than VRAM (qwen4exp_fp8, GLM-5.3)
- MiniMax-H3: reference media and keyframe conditioning with the VAE encoders
- Krea 2 rebalance presets balanced, detail and subtle
- The dashboard's request history; a stall watch that reports a frozen step's thread and stack
- rad-tune at the served configuration, collectives measured as the exchange; Gemma 4 E2B/E4B's
  per-layer embeddings read ahead off the step path
- A GPTQ calibration tap and recipe for Gemma 4 31B's w4a8 container

Fixes:
- The two-rank all-reduce checks that a peer's push has landed before reducing it
- z-lab's DFlash drafter on Gemma 4 31B keeps drafting after a prefix-cache hit
- MiniMax-H3's modulation rows

Changes: Plugin ABI 31: out-of-tree plugins must be rebuilt. RADIANCE_PREFETCH_BESIDE is
--weight-prefetch now; RADIANCE_NO_HUGE_PAGES, RADIANCE_IDS_EARLY, RADIANCE_ATTN_BAND_SPLIT,
R4D_PREFILL_SPLITS, RAD_PLE_TIMING and RAD_PLE_CACHE_ROWS are gone.
2026-10-27 16:47:35 +01:00

111 lines
4.3 KiB
C++

/* vae_geom_test.cpp -- the encode geometry (arch/minimaxh3/rad_vae_geom.cpp) against golden vectors
* produced by the reference VAEs themselves.
*
* The TU is pure host arithmetic, so it is compiled straight in here -- no rad_core, no device.
* tests/data/vae_geom/golden.json comes from gen_golden.py, which runs the reference's encoders on
* CPU (video: EncoderFCN3D and the wrapper's own encode(), encode_temporal() and tiled_encode()
* with the reference's constructor arguments; audio: the DAC encoder). The latent counts below are
* the networks' own output shapes and the constants the reference's own tables, so a mismatch is
* the port disagreeing with the model.
*/
#include "rad_test.h"
#include "rad_vae_geom.h"
#include <nlohmann/json.hpp>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <string>
#include <vector>
using namespace minimaxh3;
namespace {
nlohmann::json& golden() {
static nlohmann::json g = [] {
std::ifstream f(std::string(RAD_VAE_GOLDEN) + "/golden.json");
if (!f.is_open()) {
fprintf(stderr, " FAIL golden.json missing -- regenerate with "
"tests/data/vae_geom/gen_golden.py\n");
std::exit(1);
}
return nlohmann::json::parse(f);
}();
return g;
}
} /* namespace */
TEST(vae_encode_latent_counts) {
/* Every frame count goes through the reference encode() end to end: chunking, the padded last
* clip, the trailing drop. The spatial entries pin the ratio (generated at 32x32) and the
* latent width pins z_channels. */
for (const auto& c : golden()["video"]["encode"]) {
const int64_t t = c["T"];
const auto& z = c["z_shape"];
CHECK_EQ(vae_latent_frames(t), z[2].get<int64_t>());
CHECK_EQ(z[1].get<int64_t>(), 24);
CHECK_EQ(z[3].get<int64_t>() * kVaeRatio, 32);
CHECK_EQ(z[4].get<int64_t>() * kVaeRatio, 32);
}
}
TEST(vae_clip_chain_composes_with_encode) {
/* A full clip's latents times the clip count, less the drop, is the encode count; and a raw
* clip through the causal chain (the golden's tiled_encode cases: no chunking, no drop) has
* vae_clip_latents of its pixel frames. */
for (const auto& c : golden()["video"]["encode"]) {
const int64_t t = c["T"];
if (t < 2) continue;
const int64_t clips = (t + kVaeClipLength - 1) / kVaeClipLength;
CHECK_EQ(clips * vae_clip_latents(kVaeClipLength) - kVaeTokenDrop, c["z_shape"][2].get<int64_t>());
}
for (const auto& c : golden()["video"]["tiled_encode"])
CHECK_EQ(vae_clip_latents(c["x_shape"][2].get<int64_t>()), c["moments_shape"][2].get<int64_t>());
/* A single frame truncates its temporal taps instead of padding them. */
CHECK_EQ(vae_clip_latents(1), 1);
}
TEST(vae_audio_latents_match_encoder) {
/* The wrapper right-pads to the hop and the stride chain divides exactly: the reference
* encoder's own frame count is ceil(samples / 800). */
for (const auto& c : golden()["audio"]["latents"]) {
const int64_t s = c["samples"];
CHECK_EQ(vae_audio_latents(s), c["T"].get<int64_t>());
CHECK_EQ(vae_audio_latents(s) * kAudioHop, c["padded"].get<int64_t>());
}
}
TEST(vae_constants_are_the_reference_tables) {
/* The de-normalization the latents carry: doubles compare bit for bit, since the golden
* carries the same decimal literals. */
const auto& k = golden()["video"]["constants"];
const auto mean = k["latents_mean"].get<std::vector<double>>();
const auto stdv = k["latents_std"].get<std::vector<double>>();
CHECK_EQ(mean.size(), 24u);
CHECK_EQ(stdv.size(), 24u);
for (size_t i = 0; i < mean.size() && i < 24; ++i) {
CHECK(kVaeLatentsMean[i] == mean[i]);
CHECK(kVaeLatentsStd[i] == stdv[i]);
}
const auto pm = k["pixel_mean"].get<std::vector<double>>();
const auto ps = k["pixel_std"].get<std::vector<double>>();
for (size_t i = 0; i < 3; ++i) {
CHECK(kVaePixelMean[i] == pm[i]);
CHECK(kVaePixelStd[i] == ps[i]);
}
}
TEST(vae_geom_rejects_nonsense) {
CHECK_EQ(vae_latent_frames(0), -1);
CHECK_EQ(vae_latent_frames(-5), -1);
CHECK_EQ(vae_clip_latents(0), -1);
CHECK_EQ(vae_audio_latents(-1), -1);
CHECK_EQ(vae_audio_latents(0), 0);
}
RAD_TEST_MAIN()