makepad/libs/ai/hub/tests/h3_tiers.rs
Admin e37c263b9c ai backbone: the hub era — makepad_ai deleted, every backend is a hub pipe; machine residency elections, job leases, ETA placement; the store only stores; creator pipelines run in the app (aicore)
Squashed from work:
- asset-ai: FastH3 4-step fast video backend; clip keyframes on the wire
- asset-ui: loop video chains — text→image→video that ends where it began
- h3: safetensors -> pruned-Q4_K GGUF quantizer for the 24GB DiT tiers
- h3_quant_gguf verify: row-error gates calibrated to the measured Q4_K floor
- asset-ai realtime: the feedback loop — the source anchors, the drifted frame inits
- asset-ai realtime: a feedback loop survives a resize and travels by default
- asset-ai realtime: the feedback loop frees itself from the feed handshake and pauses for its listener
- asset-ai realtime: the outbound encode leaves the loop's critical path
- asset-ai ocr: the ocr domain — Chandra 2 at page resolution, and the tower goes planner-owned
- llm slots: a lane can hold an image span — embedding prefill and a rope cursor of its own
- vision tower on CUDA: the encode leg gets its two missing kernels
- llm/ocr: one M-RoPE grid encoder for both image paths, and a livelock made an error
- vision tower on CUDA: the f16 GEMM keeps the precision it was throwing away
- live: a feed that moves box takes its trip with it — one seed image
- vision tower on CUDA: the tiled attention becomes bit-exact, and tensor cores go
- llm prefill on CUDA: the MMA attention kernel gets the tile a 4-to-1 model needs
- asset-ai ocr: the CUDA encode lane joins the integration — vision-parity sits beside run's three arms, and the kernels
- Merge branch 'ocr-perf-integration' into work
- asset-ai: the live anchor can follow the trip, and text leaves the 5090
- asset-ai: the camera moves the world, and the world starts still
- asset-import: the EA strategy classics, in the one 2D contract
- rtsmap: one seeded generator for tiled strategy maps
- asset-ui: one card for the strategy classics, with a pack dropdown
- asset-ai: music3 reference-audio path, ocr/h3 backends, registry
- asset: mp4 sample index for range-streaming, chat tools, import profiles
- cnc: tiberium is twelve growth frames, not twelve empty variants
- platform: native file and save dialogs, in-house on all three desktops
- chat: the scan holds out for a lane home
- chat: a full home queues you — take the free lane
- chat: the preload has a percentage, and the boundless cap stops showing
- llm cuda: the 32x2 attention tile — even GQA ratios stay on MMA
- sa3 gets a bake path: the sfx model's tables precomputed by a diffusion-side bin
- sqlite_query: anti-join regression test
- td import: HARV's second frame block is its harvesting cycle, not a turret
- asset-ui: sprite enhancement runs on the 32B dev DiT — distillation, not the prompt, was the ceiling
- ai-hub: makepad-asset-ai becomes makepad-ai-hub at libs/ai/hub, the chat pane becomes makepad-chat-ui, the service bin
- asset-ui: test health fixtures grow the realtime field they were born without
- ai-hub: one home at ~/.makepad — weights/ run/ cache/ logs/, the service cache migrates from ai_content by a single re
- ai-hub: subprocess workers die with the node — process groups everywhere, PDEATHSIG on linux, one KILL_ON_JOB_CLOSE Jo
- ai-hub: the hub object — AiHub::in_process, pipes vocabulary, and the local LLM engine generalized out of mpfiles (aic
- strict-json: the dependency-free JSON module gets its own crate; asset-client re-exports it so nothing downstream move
- ai-hub: the machine layer — node entries, the 0600 machine token, and the residency election that IS the lock (aicore
- ai-hub: MPHUB1 — the fabric beacon only dedicated nodes can send (aicore §4)
- ai-hub: job leases — work lives only while it is renewed (aicore §8)
- asset-creator: the pipeline library is born — specs, the deps gate, and the derived-state law (aicore §9)
- ai-hub: RAM residency facts — the CPU-side twin of residency.rs (aicore §3)
- ai-hub: ETA placement primitives — relative GPU throughput, the four-term estimate, and an observable breakdown (aicor
- ai-hub: leases go live on the wire — origin fields on submit, /job/<id>/keepalive, /bye, and the reaper that cancels w
- ai-hub: the chat providers move in — fleet qwen, openai, grok, claude/codex/grok CLIs, the responses driver, and the w
- asset-creator: the engine — one pipeline run against the hub, deps-gated, spliced, cancellable, resumable-by-construct
- ai-hub: the machine node mode — --machine binds loopback, registers in ~/.makepad/run, and exits on its own once idle
- asset-creator: makepad-creator-run — the detached client for runs that must outlive a window (aicore §9)
- ai-hub: a native Claude Messages-API provider — API-key or Claude Code OAuth, bounded SSE streaming, injected tools (a
- route + converse: off makepad_ai — the Agent seam moves to converse, route's cloud dispatcher rides the hub's Claude p
- asset-creator: the preset tables move in — fifteen chain-policy constants shared by every creator app (aicore §9 / P6)
- makepad_ai is deleted — every backend is a hub pipe, the agent seam lives with its consumers (aicore §14, decided 2026
- ai-hub: loads hold the machine residency election — set_model_state claims on Loaded and publishes the service port (a
- ai-hub: chats run the machine election — route to a serving holder, wait on a loading one, claim and publish when open
- ai-hub: pick_for_domain_eta — ETA-ranked placement over the shared hard-filter core (aicore §6 / P4)
- asset-creator: the engine picks a provider per stage at dispatch time — a chain's later stages see fresh fleet state (
- ai-hub: the fabric secret gates the service HTTP surface — bearer on everything but /health and the ticketed peer path
- vj: DREAM runs execute in the app — pipelines.rs becomes the run it used to watch (aicore §9 / F1)
- asset-creator: the runner — generate one thing and put it in the catalog, one implementation for every surface (aicore
- chat-ui: the session runs in the app — no broker anywhere on the chat path (aicore P8 / F5)
- asset-store: assets.query is a first-class query endpoint — the bounded SQL surface outlives the broker (aicore P8 / F
- asset-creator: CreatorTools — the chat tool pack for a store that only stores (aicore §9 / P8)
- asset-store: the shrink — the store stores (aicore P7)
- importer + asset-server host: the coordination era ends (aicore P7)
- store config purge + asset-ui goes fleet-direct; the derive protocol gets its route proof (aicore P7)
- client + chat dispatcher: the dead wire comes out (aicore P7/P8)
- ai-hub: 0.3.0 — the health version says which era a node runs
- ai-hub: the default fleet is 'gen' — apps hear the LAN without env plumbing
- ai-hub: the preload note percents the prefill, not the job bar
- ai-hub: conversations keep their KV — the wire mirror, the lane identity, the in-turn dynamic context (aicore §7)
- ai-hub: an open-think model is thinking from its first token
- libs: the zero-warning sweep — stitch casts say what they mean, xatlas keeps upstream's surface quietly
- zero-warning sweep, round two — the first full-workspace pass
- zero-warning sweep, round three — the model lanes and the deep examples
- zero-warning sweep, round four — the last stragglers
- zero-warning sweep, round five — vj and chat-ui
- zero-warning sweep, round six — three cascades

Co-authored-by: Claude <info@makepad.nl>
2026-09-01 16:46:31 +02:00

204 lines
9.1 KiB
Rust

//! Focused release tests for the quantized MiniMax-H3 tier manifests and
//! their fail-closed selection machinery. Hermetic: registry data + pure
//! decision functions only — no GPU, no network, no model files.
use makepad_ai_hub::gpu::GpuInfo;
use makepad_ai_hub::h3_backend::{
check_canvas_within_tier, check_gpu_requirements, tier_plan_for_spec, H3TierKind,
};
use makepad_ai_hub::registry::Registry;
use makepad_ai_hub::residency::{estimated_peak_mb, DEFAULT_RESERVE_MB};
fn gpu(vram_total_mb: u64, compute_cap: f64) -> GpuInfo {
GpuInfo {
name: Some("fixture".to_string()),
vram_free_mb: Some(vram_total_mb),
vram_total_mb: Some(vram_total_mb),
compute_cap: Some(compute_cap),
}
}
/// The embedded registry's three tier manifests drive the exact fleet
/// placement matrix: q4 on the 4090+, nvfp4 on Blackwell 32GB+, bf16 on the
/// 96GB box — and never the other way around.
#[test]
fn tier_manifests_place_on_the_fleet_exactly() {
let registry = Registry::embedded().unwrap();
let q4 = registry.find("minimax-h3-q4-24g").unwrap();
let nv4 = registry.find("minimax-h3-nvfp4-32g").unwrap();
let bf16 = registry.find("minimax-h3-bf16-96g").unwrap();
let legacy = registry.find("minimax-h3").unwrap();
let fast = registry.find("fasth3-4step").unwrap();
let fast_q4 = registry.find("fasth3-4step-q4-24g").unwrap();
// Role-driven tier selection.
assert_eq!(tier_plan_for_spec(q4).unwrap().kind, H3TierKind::GgufQ4);
assert_eq!(tier_plan_for_spec(nv4).unwrap().kind, H3TierKind::Nvfp4);
assert_eq!(tier_plan_for_spec(bf16).unwrap().kind, H3TierKind::Bf16Tree);
assert_eq!(tier_plan_for_spec(legacy).unwrap().kind, H3TierKind::Bf16Tree);
// The fast lane = the tree with its DiT swapped: unstaged, no ceiling.
let fast_plan = tier_plan_for_spec(fast).unwrap();
assert_eq!(fast_plan.kind, H3TierKind::Bf16Dit);
assert!(!fast_plan.staged && fast_plan.max_pixel_frames.is_none());
// The quantized FastH3 tier is a full GgufQ4 manifest (the in-house
// h3_quant_gguf DiT + the minimax q4 tier's shared TE/VAE set), staged
// and ceilinged exactly like the minimax q4 tier.
let fast_q4_plan = tier_plan_for_spec(fast_q4).unwrap();
assert_eq!(fast_q4_plan.kind, H3TierKind::GgufQ4);
assert!(fast_q4_plan.staged);
assert_eq!(
fast_q4_plan.max_pixel_frames,
tier_plan_for_spec(q4).unwrap().max_pixel_frames
);
assert_eq!(fast_q4.backend, "fast");
assert!(tier_plan_for_spec(q4).unwrap().staged);
assert!(tier_plan_for_spec(nv4).unwrap().staged);
assert!(!tier_plan_for_spec(bf16).unwrap().staged);
// The fleet placement matrix, driven entirely by registry data.
let rtx4090 = gpu(24_564, 8.9); // .123
let rtx5090 = gpu(32_607, 12.0); // .217
let rtx6000 = gpu(97_887, 12.0); // .169
let gate = |spec: &makepad_ai_hub::registry::ModelSpec, gpu: &GpuInfo| {
check_gpu_requirements(&spec.id, spec.min_vram_gb, spec.min_compute_cap, gpu)
};
assert!(gate(q4, &rtx4090).is_ok());
assert!(gate(q4, &rtx5090).is_ok());
assert!(gate(q4, &rtx6000).is_ok());
// The quantized FastH3 tier places exactly like the minimax q4 tier.
assert!(gate(fast_q4, &rtx4090).is_ok());
assert!(gate(fast_q4, &rtx5090).is_ok());
assert!(gate(fast_q4, &rtx6000).is_ok());
assert!(gate(nv4, &rtx4090).is_err(), "nvfp4 must fail closed on sm89");
assert!(gate(nv4, &rtx5090).is_ok());
assert!(gate(nv4, &rtx6000).is_ok());
assert!(gate(bf16, &rtx4090).is_err());
assert!(gate(bf16, &rtx5090).is_err());
assert!(gate(bf16, &rtx6000).is_ok());
// Same VRAM class as the bf16 tree: the 96GB box only.
assert!(gate(fast, &rtx4090).is_err());
assert!(gate(fast, &rtx5090).is_err());
assert!(gate(fast, &rtx6000).is_ok());
// Service discovery and the fleet scheduler add the safety reserve to
// `vram_gb`. Pin this second gate against the actual NVML totals: the
// named quant tiers must remain routable on their real cards, not merely
// pass the backend's independent min-VRAM/compute-cap checks above.
let required = |spec: &makepad_ai_hub::registry::ModelSpec| {
estimated_peak_mb(spec).saturating_add(DEFAULT_RESERVE_MB)
};
assert_eq!(required(q4), 22 * 1024);
assert_eq!(required(fast_q4), 22 * 1024);
assert_eq!(required(nv4), 30 * 1024);
assert_eq!(required(bf16), 92 * 1024);
assert!(required(q4) <= rtx4090.vram_total_mb.unwrap());
assert!(required(fast_q4) <= rtx4090.vram_total_mb.unwrap());
assert!(required(nv4) <= rtx5090.vram_total_mb.unwrap());
assert!(required(bf16) <= rtx6000.vram_total_mb.unwrap());
// A GPU-less/unknown box refuses every gated tier.
for spec in [q4, nv4, bf16, fast_q4] {
assert!(gate(spec, &GpuInfo::default()).is_err(), "{}", spec.id);
}
// The legacy alias keeps its ungated behavior.
assert!(gate(legacy, &GpuInfo::default()).is_ok());
}
/// Measured canvas envelopes: the q4 tier serves the default and 864x480
/// canvases and refuses beyond its pruned-ladder ceiling; nvfp4 serves the
/// full ladder at 124 frames.
#[test]
fn tier_canvas_envelopes_match_the_ladder() {
let registry = Registry::embedded().unwrap();
let q4_limit = tier_plan_for_spec(registry.find("minimax-h3-q4-24g").unwrap())
.unwrap()
.max_pixel_frames;
let nv4_limit = tier_plan_for_spec(registry.find("minimax-h3-nvfp4-32g").unwrap())
.unwrap()
.max_pixel_frames;
for (w, h, f) in [(640, 352, 124), (864, 480, 124), (960, 544, 124), (640, 352, 56)] {
check_canvas_within_tier("q4", q4_limit, w, h, f).unwrap();
}
assert!(check_canvas_within_tier("q4", q4_limit, 1344, 768, 124).is_err());
assert!(check_canvas_within_tier("q4", q4_limit, 960, 544, 243).is_err());
for (w, h, f) in [(960, 544, 124), (1344, 768, 124)] {
check_canvas_within_tier("nv4", nv4_limit, w, h, f).unwrap();
}
assert!(check_canvas_within_tier("nv4", nv4_limit, 1344, 768, 243).is_err());
}
/// Every quantized-tier file is fully pinned (immutable revision + size +
/// sha256 + role) so the peer cache can distribute and verify byte-exact
/// artifacts; totals match the published repos.
#[test]
fn tier_files_are_fully_pinned_and_sized() {
let registry = Registry::embedded().unwrap();
for id in ["minimax-h3-q4-24g", "minimax-h3-nvfp4-32g", "fasth3-4step-q4-24g"] {
let spec = registry.find(id).unwrap();
for file in &spec.files {
assert!(file.role.is_some(), "{id}: {} needs a role", file.cache_as);
let revision = file.revision.as_deref().unwrap_or_else(|| {
panic!("{id}: {} needs an immutable revision", file.cache_as)
});
assert!(
revision.len() == 40 && revision.bytes().all(|b| b.is_ascii_hexdigit()),
"{id}: {} revision must be a commit hash",
file.cache_as
);
assert!(file.size.unwrap_or(0) > 0, "{id}: {}", file.cache_as);
assert_eq!(
file.sha256.as_deref().map(str::len),
Some(64),
"{id}: {}",
file.cache_as
);
}
}
// Download budgets per box: ~35.5 GB for q4, ~34.1 GB for nvfp4 (the
// 5.8 GB VAE/tokenizer set is shared on disk; both carry the 22.7 MB
// RIFE interpolate flownet — stale pre-RIFE pins caught here once).
let total = |id: &str| -> u64 {
registry
.find(id)
.unwrap()
.files
.iter()
.map(|f| f.size.unwrap())
.sum()
};
assert_eq!(total("minimax-h3-q4-24g"), 35_481_501_594);
assert_eq!(total("minimax-h3-nvfp4-32g"), 34_058_552_150);
// fasth3-4step-q4-24g = the in-house 11.4GB FastH3 DiT plus the minimax
// q4 tier's shared TE/VAE/tokenizer set (identical pins, identical cache
// paths — a box carrying the minimax tier only adds the DiT).
assert_eq!(total("fasth3-4step-q4-24g"), 35_489_644_339);
let fast_q4 = registry.find("fasth3-4step-q4-24g").unwrap();
let dit = fast_q4
.files
.iter()
.find(|f| f.role.as_deref() == Some("dit-gguf"))
.unwrap();
// The DiT is a locally-generated artifact: never Hugging Face, peer
// network only — and digest-pinned so peers can verify it.
assert!(dit.local);
assert_eq!(dit.size, Some(11_428_787_200));
assert_eq!(
dit.sha256.as_deref(),
Some("2693c1c6c5218578564306f25fb2bdeeea1f7f6758d126eb37f5644fa47f7b27")
);
let q4_spec = registry.find("minimax-h3-q4-24g").unwrap();
for role in ["te-gguf", "video-vae", "audio-vae", "audio-vae-config", "tokenizer-json"] {
let ours = fast_q4
.files
.iter()
.find(|f| f.role.as_deref() == Some(role))
.unwrap();
let theirs = q4_spec
.files
.iter()
.find(|f| f.role.as_deref() == Some(role))
.unwrap();
assert_eq!(ours.cache_as, theirs.cache_as, "{role} must share the cache path");
assert_eq!(ours.sha256, theirs.sha256, "{role} must share the pinned bytes");
}
}