Download HANDOFF.md from shisuiki/Inkling-2-Mini-DFly2: direct link, hf CLI and curl.
- Browser
- Download file 14.5 kB
-
https://huggingface.co/shisuiki/Inkling-2-Mini-DFly2/resolve/main/HANDOFF.md
- Command line
-
hf download hf://shisuiki/Inkling-2-Mini-DFly2/HANDOFF.md
-
curl -L -o HANDOFF.md https://huggingface.co/shisuiki/Inkling-2-Mini-DFly2/resolve/main/HANDOFF.md
Inkling-2-Mini DFly2-KV Drafter — Serving & Kernel Integration Handoff
1. Verified Artifacts
- On
endmin:/data/models/Inkling-2-Mini-DFly2-Pilot/model.safetensors— 71 tensors, allbfloat16,320,368,336params (640,747,008B =640.7 MB), zero NaN/Inf, bit-for-bit verifiedSHA256:48a60f271a7eb7cad3458b7d84bc9332c2b7e7ccb74fc67bea7ba9cc9eec0dbcconfig.json— complete architecture & export metadatatensor_inventory.json— full list of all 71 tensor names, shapes, and dtypeseval_i2m_onpolicy_step956.json— exact side-by-side held-out eval vs. nativeDSpark7(step 956, 2 ep on-policy)eval_i2m_onpolicy_step720.json— 1-epoch on-policy ablation (step 720)eval_i2m_pilot_report.json— pre-on-policy off-policy baseline (step 478) for referencereference_model.py&reference_kernels.py— exact PyTorch/Triton forward contract (I2MDFly2DraftModel.draft_one_block)
- Nebius S3 Archive:
- Exported safetensor (
step 956):s3://q27-dfly2-us-north1/i2m/runs/i2m_dfly2_pilot_onpolicy/export_step_00956/model.safetensors - Resumable un-decayed WSD checkpoints (
step 956&step 720, constantlr = 5e-4):s3://q27-dfly2-us-north1/i2m/runs/i2m_dfly2_pilot_onpolicy/final_step_00956/ckpt.pts3://q27-dfly2-us-north1/i2m/runs/i2m_dfly2_pilot_onpolicy/step_00720/ckpt.pt
- On-policy training corpus (
50shards =501.35Mtokens,51,854unique I2M trajectories):s3://q27-dfly2-us-north1/i2m/data_onpolicy/shards/
- Exported safetensor (
Checkpoint status: Un-decayed WSD On-Policy Pilot (
step 956,2.005Bcumulative tokens =1.002Boff-policy warmup +1.002Bpure Inkling-2-Mini on-policy rollouts, pre-cooldown at constant peaklr = 5e-4, matching Q27 Pilot's un-decayed state). Any future WSD cooldown or extended on-policy run exports the exact same 71 tensor names and shapes as a drop-in swap.
Reference Held-Out Acceptance (γ = 7, max τ = 8.0, 48-Visit BF16 Teacher, 15 Balanced Prompts)
| Drafter | Draft KV Cache | T = 0.0 Overall |
T = 0.6 Overall |
short_1_4k (T=0.0 / 0.6) |
mid_4_12k (T=0.0 / 0.6) |
long_12_30k (T=0.0 / 0.6) |
Verify Steps (T=0.0 / 0.6) |
|---|---|---|---|---|---|---|---|
Native DSpark7 (mtp.safetensors) |
Own 3-layer KV | 3.050 |
3.228 |
2.368 / 2.672 |
3.286 / 3.495 |
3.871 / 3.729 |
319 / 302 |
I2M DFly2-KV Off-Policy (step 478) |
0 bytes | 2.150 |
2.245 |
1.747 / 1.801 |
2.331 / 2.492 |
2.528 / 2.639 |
448 / 433 |
I2M DFly2-KV On-Policy 1-Ep (step 720) |
0 bytes | 3.686 |
3.670 |
3.309 / 3.137 |
3.505 / 3.721 |
4.411 / 4.356 |
261 / 261 |
I2M DFly2-KV On-Policy 2-Ep (step 956) |
0 bytes | 3.645 |
3.722 |
3.473 / 3.505 |
3.200 / 3.320 |
4.486 / 4.549 |
265 / 259 |
2. Exact Architecture & Forward Contract
Core Dimensions (1 Global + 2 Local SWA-1024, DSpark-Matched Size)
hidden_size = 2304,intermediate_size = 8192,num_hidden_layers = 3(320.37Mparams vs. native DSpark7's317.9M)num_attention_heads = 24,num_key_value_heads = 8,head_dim = 128(GQA3:1; TP4:6Q heads /2KV heads per GPU)- Native Inkling-2-Mini attention space (NO RoPE, NO draft short-conv state):
- Sheared relative position bias:
d_rel = 16,rel_extent = 1024,sliding_window_size = 1024 - L2-clipped Q/K (
qk_l2_clip_threshold = 22.627416997969522=16√2) & R (rel_l2_clip_threshold = 8.0) - Unit RMSNorm V (no learnable gamma),
rms_norm_eps = 1e-6 - Log-length scaling on global layer 1 only:
tau(pos) = 1.0 + 0.1 * log(max(pos, 8192) / 8192) - Output gating + sink:
ao_gated = ao * sigmoid(gate) * sigmoid(lse - sink)(note:lseis natural log!)
- Sheared relative position bias:
block_size = 8(1anchor slot0+γ = 7draft slots1..7)target_kv_layers = [20, 23, 22](all in the unlooped epilogue, visits44, 47, 46— 0 bytes of draft context KV cache and 0 bytes of draft conv state!):- Draft
layers.0(local, SWA-1024) → reads targetL20cached(K_ctx, V_ctx) - Draft
layers.1(global, FULL ctx) → reads targetL23cached(K_ctx, V_ctx) - Draft
layers.2(local, SWA-1024) → reads targetL22cached(K_ctx, V_ctx) AttentiveCorrection(local, SWA-1024) → reads targetL22cached(K_ctx, V_ctx)(O(1)bandwidth per slot!)
- Draft
- Shared target weights (NOT stored in
model.safetensors):embed_tokens— CRITICAL: Inkling-2-Mini applies unit RMSNorm + scaling to embeddings (embed_normalized(ids)=rms_norm_no_gamma(embed_tokens(ids)), seereference_kernels.py/ targetembed_tokenspath; exact match toteacher.embed_normalized!).lm_head([200058, 2304]unpadded) with logit soft-capping30.0 * tanh(logits / 30.0).
Step-by-Step Serving Forward Pass (draft_one_block)
Inputs after target prefill/verify emits the accepted anchor token:
anchor_tok([B]): newly accepted/sampled token at 0-indexed positionanchor_pos = ctx_len. (Has NOT yet been processed by the target model.)prev_hidden_normed([B, 2304]): target's post-final-RMSNorm hidden state (target.model.norm(...)) at positionctx_len - 1(the exact state whose logits producedanchor_tok).target_kvs: paired target post-clip/post-norm(K_ctx, V_ctx)for positions0 .. ctx_len - 1from target unlooped epilogue layers[20, 23, 22].
Stage A — Block Input Construction (1× per step, S = 8 tokens at positions anchor_pos .. anchor_pos + 7):
e0 = target.embed_normalized(anchor_tok)([B, 2304]).- Slot
0:h[:, 0] = e0 + mtp_fusion.eh_proj(cat([enorm(e0), hnorm(prev_hidden_normed)], dim=-1)) * mtp_fusion.gate. - Slots
1..7: initialized tomask_embedding([2304]). - Compute
tau_draft[slot] = 1.0 + 0.1 * log(max(anchor_pos + slot, 8192) / 8192)forslot in 0..7(used ONLY on globallayers.1).
Stage B — 3 KV-Sharing Backbone Layers (1 parallel pass over S = 8 tokens):
For i in {0, 1, 2} reading target layer [20, 23, 22]'s cached (K_ctx, V_ctx) (is_local = (i in {0, 2})):
x = input_layernorm(h). (Standard Inkling-2-Mini RMSNorm:weight * rsqrt(mean(x^2) + 1e-6) * x, NOT+1centered!)- Project
q_raw = wq_du(x)([B,8,24,128]),r_raw = wr_du(x)([B,8,24,16]),gate = gate_attn(x)([B,8,24,128]),sink = attn_sink_proj(x)([B,8,24]),k_d = wk_dv(x)([B,8,8,128]),v_d = wv_dv(x)([B,8,8,128]). - Normalize & clip (identical to Inkling-2-Mini target attention,
tau_v = tau_draftifi == 1elseNone):q = i2m_l2_clip(q_raw, q_scale, clip=22.627417, eps=1e-6, tau=tau_v)r = i2m_l2_clip(r_raw, r_scale, clip=8.0, eps=1e-6, tau=tau_v)k_d = i2m_l2_clip(k_d, None, clip=22.627417, eps=1e-6, tau=None)v_d = unit_rms_norm(v_d, eps=1e-6)rel_all = r @ rel_logits_proj([B, 24, 8, 1024]).
- Non-causal (bidirectional) block attention over
[K_ctx | k_d(0..7)]and[V_ctx | v_d(0..7)], scale128^-0.5, GQA24:8:- Context positions
j < anchor_pos(ifis_local, only(anchor_pos + q_slot - j) < 1024): addrel_all[h, q_slot, dist]where0 <= dist < 1024,dist = (anchor_pos + q_slot) - j. - Intra-block positions
kv_slot in 0..7: addrel_all[h, q_slot, q_slot - kv_slot](whenq_slot >= kv_slot) PLUSintra_rel_bias[h, (q_slot - kv_slot) + 15]. - Compute
(ao, lse)via exact online-softmax merge of(ao_ctx, lse_ctx)and the8×8intra-block(ao_blk, lse_blk)— ephemeral(k_d, v_d)are discarded, never written to KV cache!
- Context positions
- Output gate & sink:
ao_gated = ao * sigmoid(gate) * sigmoid(lse - sink)→h = h + wo_ud(ao_gated). - MLP:
h = h + mlp.down_proj(silu(mlp.gate_proj(post_ln(h))) * mlp.up_proj(post_ln(h))). - After
layers.2:h = norm(h).
Stage C — Sequential TreeFlash + SWA-1024 AttentiveCorrection (slot = 0..7, reading target L22 SWA-1024 KV):
- Critical: Slot
0MUST run first withh_k = h[:, 0:1],e_prev = e0,slot_idx = 0so thatblk_k_cache[:, :, 0:1]andblk_v_cache[:, :, 0:1]are populated before draftingslot = 1..7. (Its corrected hidden output is unused.) - For
slot = 1..7(producing drafted tokensd_1 .. d_7, withprev_tok = anchor_tokatslot = 1, thend_{slot-1}):h_n = hidden_norm(h[:, slot:slot+1]),e_n = embed_norm(embed_normalized(prev_tok)),inp = cat([h_n, e_n], dim=-1)([B, 1, 4608]).- SwiGLU delta:
delta = down_proj(silu(gate_proj(inp)) * up_proj(inp)). - AttentiveCorrection delta (
L22SWA-1024, no output sigmoid gate, no sink on ctx read):q = i2m_l2_clip(q_in(inp), q_scale, 22.627417);r = i2m_l2_clip(r_in(inp), r_scale, 8.0);rel_row = r @ rel_logits_proj.- Context read over
L22KV slicec_start = max(0, ctx_len + slot - 1023) .. ctx_len - 1(<= 1024tokens, O(1) bandwidth regardless of context length!) with sheared biasrel_row[dist](dist = ctx_len + slot - j). - Causal intra-block read: append
kb = i2m_l2_clip(k_blk_proj(inp), None, 22.627417),vb = unit_rms_norm(v_blk_proj(inp))toblk_{k,v}_cache(len = slot + 1), compute logitsq @ k_blk^T * 128^-0.5 + block_rel_bias[:, slot - t], applyblock_sinkviap_blk = exp(logits - logaddexp(lse(logits), block_sink)), multiplyread = p_blk @ v_blkbytanh(block_gate(inp) + block_gate_bias[:, slot]). attn_delta = o_proj(ctx_out + read * gate).
h_corr = h[:, slot] + delta + attn_delta.logits = 30.0 * tanh((h_corr @ lm_head.T) / 30.0)→ argmax / sampled_slot.
3. Critical Subtle Gotchas (Check Before Kernel Bring-Up!)
- Standard RMSNorm (NOT
+1Qwen-style!):I2MRMSNormcomputesweight * rsqrt(mean(x^2) + 1e-6) * x(standard Inkling-2-Mini RMSNorm; weights initialized around1.0). - Normalized Embeddings (
embed_normalized): Every embedding lookup (anchor_tokin Stage A,prev_tokin Stage C) MUST apply Inkling-2-Mini's embedding normalization (identical to targetembed_tokensscaling/norm — verify againstreference_model.py/teacher.py!). - Log-Length Scaling
tauONLY on Globallayers.1:layers.0,layers.2, andAttentiveCorrectionare all localSWA-1024(tau = None). Onlylayers.1(paired with global targetL23) scalesqandrbytau(anchor_pos + slot)whenanchor_pos + slot > 8192. - No Output Gate or Sink in
AttentiveCorrectionContext Read: Backbonelayers.{0..2}usesigmoid(gate) * sigmoid(lse - sink).AttentiveCorrectionuses a plain softmax context read overL22(<= 1024tokens) plus ablock_sink-normalized,tanh-gated causal intra-block read (block_gate+block_gate_bias[:, slot]). - 16-Slot / 31-Offset Bias Buffers:
intra_rel_biashas shape[24, 31](center = 15,q_slot - kv_slot in [-7, +7]→ indices8..22);block_rel_biasandblock_gate_biashave shape[24, 16](indices0..7exercised duringblock_size = 8training). - Target Verify Window (
Q = 8): Verifyingγ = 7drafted tokens feeds[anchor_tok, d1..d7](Q = 8tokens) into the 48-visit Inkling-2-Mini target model and checks target logits at[ctx_len .. ctx_len + 7].
4. Tensor Inventory Summary (71 Tensors, All bfloat16)
| Group | Tensor Pattern | Shape | Params | Notes |
|---|---|---|---|---|
| Mask embed | mask_embedding |
[2304] |
2.3K |
Shared across slots 1..7 |
| MTP fusion (slot 0) | mtp_fusion.{enorm,hnorm}.weight, gate, eh_proj.weight |
[2304], [2304, 4608] |
10.6M |
Zero-init per-channel gate |
Backbone Attn ×3 (i=0,1,2) |
wq_du, gate_attn, wo_ud, wk_dv, wv_dv, wr_du, attn_sink_proj |
[3072,2304], [1024,2304], [384,2304], [24,2304] |
3 × 26.9M |
Paired 1-to-1 with target L20 (SWA), L23 (Global), L22 (SWA) |
| Backbone Attn Scales/Bias ×3 | q_scale, r_scale, rel_logits_proj, intra_rel_bias |
[24,128], [24,16], [16,1024], [24,31] |
3 × 20.6K |
Keep FP16/FP32 on sm_70 |
| Backbone MLP ×3 | gate_proj, up_proj, down_proj, {input,post}_layernorm |
[8192,2304], [2304,8192], [2304] |
3 × 56.6M |
SwiGLU, TP4 I_local = 2048 |
| Final norm | norm.weight |
[2304] |
2.3K |
Standard RMSNorm |
| Correction SwiGLU | {hidden,embed}_norm, {gate,up}_proj, down_proj |
[2304,4608], [2304,2304] |
26.5M |
TP4 I_local = 576 |
Correction Attn (L22 SWA) |
q_in, r_in, k_blk_proj, v_blk_proj, o_proj, block_gate |
[3072,4608], [1024,4608], [2304,3072], [24,4608] |
32.6M |
O(1) SWA-1024 context read |
| Correction Scales/Bias | q_scale, r_scale, rel_logits_proj, block_{sink,rel_bias,gate_bias} |
[24,128], [16,1024], [24,16] |
20.6K |
Keep FP16/FP32 on sm_70 |
| Total | 71 tensors | — | 320.37M |
640.7 MB BF16 (160.2 MB/GPU TP4 unquantized) |
5. Volta sm_70 (4× V100-SXM2-16GB, TP4) Serving Notes
- Tiny Footprint & Huge Hybrid KV Gain:
- Even unquantized in FP16, the entire drafter is only
160 MB/GPUat TP4 (~80 MB/GPUif linears are FP8 QPN8 — comparable to DSpark7's weights) while reclaiming 100% of native DSpark7's separate 3-layer KV cache (+16.9%FP16 →+34%FP8 total hybrid KV token capacity onendmin, and composes zero-retrain withTurboQuant K6V4,TS-QJL2(K6V4),K8V4, andELR).
- Even unquantized in FP16, the entire drafter is only
- Exact TP4 Sharding (
6Q heads /2KV heads per GPU):- Every backbone layer (
L20,L23,L22) andAttentiveCorrection(L22) maps 1-to-1 onto each GPU's local2KV heads — zero cross-GPU KV communication. - Stage B reads only 1 global layer (
L23) + 2 SWA-1024 layers (L20,L22), and Stage C's 7 sequential correction slots read only SWA-1024 (L22,<= 1024tokens) — so at long contexts (16K–128K), DFly2-KV has the same1G + 2Lglobal KV read bandwidth as DSpark7 while achieving+0.62to+0.82 τhigher long-context acceptance (4.49–4.55vs3.73–3.87).
- Every backbone layer (
- Zero Rollback State on Rejection:
- Because neither Stage B nor Stage C writes anything to any persistent KV cache or short-conv buffer, speculative rejection requires zero drafter cache rollback.