[Core] DSpark brick 4c: full block-8 draft composition + exact oracle parity

- k_dspark_split3: split fused qkv [B,5120] -> q/k/v and gate_up [B,18432] -> g/u.
- dspark_draft(): the complete Step-1 linear draft — block [8,D] (slot0 =
  rms(embed(anchor)), rest mask_embed) -> 3 non-causal block-attn layers (fused
  qkv GEMM + per-head norm/NeoX-RoPE + block_attn over committed bf16 ctx ring +
  all B draft slots + o_proj) + SwiGLU MLP -> final norm -> 7-step recurrent
  Markov head (joint=[state;markov_w1[prev];cur[step];context], rnn GEMV, GRU,
  corr/combine, unembed argmax). f32 activations x bf16 weights throughout.
- Parity: full draft vs a complete CPU oracle on REAL mtp weights + synthetic
  trunk/ctx -> 7 token ids EXACT ([158,104,158,104,158,158,158]).
hip 43/43; ld GPU 56/56; CPU -D warnings green.
This commit is contained in:
adm committed 2026-12-02 20:44:01 +01:00
1 parent 142580e9ca
commit f9cde4954a
3 files changed
+303 -1

No files matched your search

+32
View File
@@ -413,6 +413,38 @@ extern "C" int vetta_dspark_corr_combine(const float* cur, const float* corr,
return 0;
}
// Split a fused row-major [B, na+nb+nc] buffer into contiguous a[B,na],
// b[B,nb], c[B,nc] (c may be NULL when nc==0). Used for fused qkv / gate_up.
__global__ void k_dspark_split3(const float* __restrict__ in,
float* __restrict__ a, float* __restrict__ b,
float* __restrict__ c, int B, int na, int nb,
int nc) {
const int idx = blockIdx.x * blockDim.x + threadIdx.x;
const int roww = na + nb + nc;
const int total = B * roww;
if (idx >= total) return;
const int row = idx / roww;
const int col = idx % roww;
const float v = in[idx];
if (col < na) a[(size_t)row * na + col] = v;
else if (col < na + nb) b[(size_t)row * nb + (col - na)] = v;
else if (c) c[(size_t)row * nc + (col - na - nb)] = v;
}
extern "C" int vetta_dspark_split3(const float* in, float* a, float* b,
float* c, int B, int na, int nb, int nc,
vetta_stream_t stream) {
if (B <= 0 || na < 0 || nb < 0 || nc < 0) return 1;
const size_t total = (size_t)B * (na + nb + nc);
if (total == 0) return 1;
const int t = 256;
const size_t grid = (total + t - 1) / t;
hipStream_t s = stream ? (hipStream_t)stream : (hipStream_t)0;
k_dspark_split3<<<grid, t, 0, s>>>(in, a, b, c, B, na, nb, nc);
HIP_CHECK(hipGetLastError());
return 0;
}
// ---- BF16 helpers ----------------------------------------------------------
__device__ __forceinline__ float bf16_to_f32(uint16_t h) {