voipmonitor's picture
Add deepseek41-trellismx-2.35bpw v3_full predictor (1M exact TrellisMX + 4K-16K longctx + Slot-0 + byte-weighted knapsack)
b099645 verified
|
Raw History Blame Contribute Delete
8.49 kB
metadata
license: apache-2.0
library_name: hyperflare
tags:
  - moe
  - expert-offloading
  - prefetching
  - hyperflare
  - safetensors

Hyperflare MoE Offload Predictors

Learned lookahead predictors (ShadowRecurDepthAttn with early-layer Embed-Reshapers) and non-uniform per-layer knapsack partitions for 3-tier (VRAM / host RAM / NVMe) Mixture-of-Experts weight offloading in Hyperflare (hyperflare-recipes + Helios AsyncTransfer ABI v1).

Repository Layout

Each model subdirectory holds a self-contained checkpoint package adhering to schema hyperflare.shadow_recur_depth_attn.v1:

Directory Target Model MoE Geometry (L x E, H, top-k) Router Horizons (k_dma, k_nvme) Predictor Width (d_model, r_in, e_dim) Learned Params model.safetensors
glm53/ GLM-5.3-Flash (lukealonso/GLM-5.3-Flash-NVFP4) 42 x 288, H=4096, top-8 Sigmoid + bias k_dma=1, k_nvme=4 d=1024, r=256, e=256 112,576,864 214.8 MiB
qwen38/ Qwen3.8-Flash-Next (local-inference-lab/Qwen3.8-Flash-Next-NVFP4) 48 x 512, H=2560, top-10 Softmax k_dma=2, k_nvme=4 d=512, r=128, e=128 56,289,792 107.5 MiB
deepseek41/ DeepSeek-V4.1-Flash (deepseek-ai/DeepSeek-V4.1-Flash-1017) 40 x 384, H=5120, top-6 Sqrt(softplus) + bias k_dma=1, k_nvme=4 d=1024, r=128, e=128 96,643,712 184.4 MiB
deepseek41-trellismx-2.35bpw/ DeepSeek-V4.1-Flash 2.35 bpw Hybrid TrellisMX (local-inference-lab/DeepSeek-V4.1-Flash-1017-TrellisMX-2.35bpw-Offload-FLARE) 40 x 384, H=5120, top-6 (4 variable rates) SqrtSoftplus + bias k_dma=1, k_far=4 d=1024, r=128, e=128, Slot-0 R=512, embed R=512 115,920,334 221.2 MiB

Files inside each model directory:

  • model.safetensors: Full predictor weights (BF16), per-layer calibration metadata (FP32), Embed-Reshaper weights for layers 0..3, and non-uniform knapsack allocation tables with safetensors __metadata__ headers.
  • knapsack.safetensors: Standalone 4-tensor knapsack and horizon file (knapsack.layer_weights, knapsack.priority_order, predictor.k_dma, predictor.k_nvme) for demand-only (--offload-predictor none) or zero-weight direct projection (--offload-predictor direct) deployments.
  • config.json: Structured geometry, architecture dimensions, base model references, and aggregate held-out decode metrics.
  • knapsack_profile.json: Empirical per-layer expert reuse profile and non-uniform slot weights.
  • metrics.json: Per-layer held-out autoregressive decode evaluation metrics.

Predictor Architecture (ShadowRecurDepthAttn)

At each MoE layer l in [0, L - 2], the predictor runs concurrently on an auxiliary CUDA stream during layer l's routed-expert execution to score future experts at two lookahead horizons: RAM-to-VRAM DMA prefetch (l + k_dma, clamping to l + 1 at the last source layer) and NVMe-to-RAM warm staging (l + k_nvme when l + k_nvme < L).

  1. Shared input encoder with per-layer adaptation: A shared canonical hidden-state projection shared.p_in ([D, H]), per-layer low-rank adapter L{l}.lora_a ([R_in, H], with inverse hidden-state scale pre-folded) and L{l}.lora_b ([D, R_in]), and routing-weighted per-layer expert embeddings L{l}.e_emb ([E, E_dim]) projected through shared.e_up ([D, E_dim]).
  2. Cross-layer recurrent state: A shared Pre-RMSNorm GRU (shared.gru_*) maintains a continuous state vector s_l in R^D across MoE depth (s_0 = u_0).
  3. Causal depth-axis self-attention: Four-head causal scaled dot-product attention (d_attn = 256, head dimension 64) over [s_0, ..., s_l] (shared.da_*).
  4. FiLM-modulated shared trunk: Four shared Pre-RMSNorm SwiGLU blocks (shared.b0..b3.*) modulated by per-layer scale and shift tensors (L{l}.film_g, L{l}.film_b of shape [4, D]), plus one shared NVMe-horizon FiLM-SwiGLU block (shared.nv.* with L{l}.nv_film_g/b).
  5. Folded dual-horizon router scoring and calibration: Dense hidden-state distillation heads are algebraically folded into per-layer L{l}.q_dma_w/b and L{l}.q_nvme_w/b matrices and scored as residuals against the target layer's frozen router weights (gamma * h_l @ W_tgt^T + feat @ Q^T + b). Scores are converted to row-relative top-k margins (score - 0.5 * (s_(k) + s_(k+1))) and Platt-calibrated (L{l}.meta) for union probability gating across speculative draft tokens.
  6. Early-layer Embed-Reshapers (embed_L0..L3): Two-layer BF16 SiLU residual MLPs (R = 256) predicting MoE layers 0..3 immediately after the token embedding lookup.

Held-Out Autoregressive Decode Metrics

Evaluated on held-out autoregressive decode trajectories in exact runtime BF16 inference, comparing ShadowRecurDepthAttn against zero-parameter direct router projection (h_l @ W_tgt^T). W=4 Cov @ 5% / 10% FP measures 4-token speculative draft-window union VRAM-miss coverage at 5% and 10% false-positive transfer overhead relative to true VRAM misses:

Model & Horizon Direct Top-16 Recall Learned Top-16 Recall Direct VRAM-Miss PR-AUC Learned VRAM-Miss PR-AUC Direct W=4 Cov @ 5% / 10% FP Learned W=4 Cov @ 5% / 10% FP
GLM-5.3 DMA (k=1, 41 layers) 0.8776 0.9245 0.7597 0.8280 0.4183 / 0.5401 0.4974 / 0.6343
GLM-5.3 NVMe (k=4, 38 layers) 0.6743 0.8155 0.4927 0.6654 0.2348 / 0.3147 0.3560 / 0.4683
Qwen3.8 DMA (k=2, 47 layers) 0.6741 0.9153 0.5063 0.8326 0.2074 / 0.2803 0.4812 / 0.5891
Qwen3.8 NVMe (k=4, 44 layers) 0.6029 0.8811 0.4208 0.7775 0.1669 / 0.2282 0.4257 / 0.5320
DeepSeek-V4.1 DMA (k=1, 39 layers) 0.8911 0.9391 0.6659 0.7281 0.3551 / 0.4550 0.4236 / 0.5327
DeepSeek-V4.1 NVMe (k=4, 36 layers) 0.7397 0.8427 0.4235 0.5271 0.1884 / 0.2605 0.2620 / 0.3532

Early-layer Embed-Reshaper held-out decode performance (top-16 recall / VRAM-miss PR-AUC):

  • GLM-5.3: L00 0.6976 / 0.6165, L01 0.4667 / 0.3770, L02 0.3778 / 0.2322, L03 0.4828 / 0.3455
  • Qwen3.8: L00 0.8480 / 0.7200, L01 0.6613 / 0.4268, L02 0.6540 / 0.4711, L03 0.5329 / 0.2651
  • DeepSeek-V4.1: L00 0.6644 / 0.2646, L01 0.4842 / 0.0757, L02 0.5034 / 0.0683, L03 0.5431 / 0.0531

Usage

ignition export --tiered-moe-offload defaults to --offload-predictor auto, which automatically downloads the pinned predictor for supported recipes (glm53, qwen38, deepseek41) from this repository. To supply local weights explicitly:

hf download local-inference-lab/hyperflare-offload-predictors --include "deepseek41/*" --local-dir ./predictors

# Learned lookahead predictor + non-uniform knapsack partitioning (DeepSeek-V4.1-Flash TP2)
ignition export deepseek-v4.1-flash \
  --gpus 0,1 \
  --tiered-moe-offload \
  --offload-predictor learned \
  --offload-predictor-weights ./predictors/deepseek41/model.safetensors

# Demand-only offloading with non-uniform knapsack partitioning only
ignition export deepseek-v4.1-flash \
  --gpus 0,1 \
  --tiered-moe-offload \
  --offload-predictor none \
  --offload-predictor-weights ./predictors/deepseek41/knapsack.safetensors

Scope and Compatibility Constraints

  • Each predictor checkpoint is coupled to the exact router weights and hidden-state geometry of its target model (num_moe_layers, num_experts, hidden_size, router_kind). TieredMoeRuntime validates all required tensor names and shapes at load time via validate_offload_checkpoint.
  • glm53 and qwen38 target single-GPU (TP=1) SM120/SM121 NVFP4 exports with --no-mixed-prefill. deepseek41 targets tensor-parallel (TP=2) SM120/SM121 MXFP4 (w4a8_mx repacked) exports where each rank runs its own independent AsyncTransfer channel and predictor over pre-sharded expert slabs.
  • Prefetching is advisory and never changes router outputs or expert arithmetic; numerical parity with fully resident execution is preserved independently of prediction accuracy.