Archived
New models: - Fish Audio drama-3: speech with speaker tags and inline direction, voices cloned from reference clips (the `references` field of /v1/audio/speech and the streaming session), two cards - Gemma 4 E2B/E4B (KV-shared layers, per-layer embeddings, clipped vision linears), with NVIDIA-Nemotron-3.5-Bolt-E4B in bf16 with DFlash and vision on one card, and E4B recipes Speed: - MXFP4 GEMMs for one to 64 rows and a tiled prefill GEMM at TN=4 from 1024 rows: the 27B MXFP4 with DFlash2 decodes about 1% faster at c1, 5% at c4 and 14% at c16 - The fp8 and int8 LM heads read their weight once for 65 to 128 rows - A prefill step of one sequence runs in two pieces on a second lane at two ranks (qwen35_fp8, gemma3): a 45K-token prompt on the 27B fp8 in 15.1 s instead of 16.2 s - Gemma 3's fused all-reduce junctions also under a lossy wire - --draft-short-from N: a block drafter runs its shorter block from N decoding sequences on (off by default; with 8 on the 27B MXFP4: c8 +12%, c16 +18%, c64 +32%, c1 unchanged) - --tp-attn-split rows: GLM-5.3-Flash's MLA attention split by rows over the ranks, 18 to 21% faster prefill; lossy, `heads` stays the default - --draft-coupling on: Qwen3.8-Flash-Next's MTP drafter samples its proposals from its reranked top-8 and the target's draw is coupled to it; pays at high temperatures (c1 at T 1.0: 155 -> 178 tok/s), costs at low ones; off by default Features: - Edited prompts on windowed models (Gemma 4) reuse their prefix: periodic window snapshots, and snapshot-backed prefix KV kept across recomputes (an edited tail on Gemma 4 31B: 96 s -> 2.6 s) - DELETE /sessions/<label> and DELETE /sessions?id=<id> forget one stored conversation - --state-cache-dtype f16: the delta-net state cache at half the memory (qwen35 plugins; lossy) Fixes: - A browser's CORS preflight allows DELETE Changes: Plugin ABI 27: out-of-tree plugins must be rebuilt. The environment switches the PRs added are flags now (--tp-attn-split, --draft-coupling, --state-cache-dtype).
111 lines
5.0 KiB
C++
111 lines
5.0 KiB
C++
/* plugin/spechub/spechub.h -- the plugin-private contract between its host half and its kernels.
|
|
*
|
|
* Plugin-private ON PURPOSE: core/ must never include this, and everything the CORE needs (the wire
|
|
* row and the coupling arithmetic) already lives in abi/rad_spechub.h. Only the packed call structs
|
|
* and the argument readers are here, shared by the host reference and the device launch.
|
|
*/
|
|
#ifndef RAD_PLUGIN_SPECHUB_H
|
|
#define RAD_PLUGIN_SPECHUB_H
|
|
|
|
#include "rad_abi.h"
|
|
#include "rad_plugin.h" /* rad_param_geti/getdim: the pure readers, inline and total */
|
|
#include "rad_spechub.h"
|
|
|
|
#include <cmath>
|
|
#include <cstdint>
|
|
|
|
#if defined(__HIPCC__)
|
|
#define RAD_SPECHUB_HD __host__ __device__
|
|
#else
|
|
#define RAD_SPECHUB_HD
|
|
#endif
|
|
|
|
/* A draft round's operands, packed once for both the device launch and the host reference. */
|
|
struct RadMtpCoupleProposeCall {
|
|
int32_t* idx; /* [M, 8] INOUT: this rank's shortlist; column 0 is the proposal */
|
|
const float* val; /* [M, 8] the shortlist's scores */
|
|
const int32_t* card; /* [batch] RadBatch::seq_ids: the slot the advance writes */
|
|
const uint32_t* draw; /* [M, DRAW_WORDS] RadMtpCoupleDraw */
|
|
uint32_t* state; /* [rounds, M, STATE_WORDS] RadMtpCoupleState */
|
|
int64_t M;
|
|
int64_t vocab;
|
|
int64_t ld_idx, ld_val, ld_draw, st_round, st_row;
|
|
int round;
|
|
};
|
|
|
|
/* The verify's operands: the sampler's own candidate plane, its parameter rows, the bound state
|
|
* rows and the token plane the pick already wrote. */
|
|
struct RadMtpCoupleVerifyCall {
|
|
const int32_t* idx; /* [M, n_cand] */
|
|
const float* val; /* [M, n_cand] */
|
|
const uint32_t* params; /* [M, 24 words] RadSampleParams */
|
|
const uint32_t* state; /* [M, STATE_WORDS] RadMtpCoupleState */
|
|
int32_t* token; /* [M] or [M, 1] */
|
|
int64_t M, n_cand, vocab, ld[5];
|
|
};
|
|
|
|
int rad_mtp_couple_propose_shape(const RadParam*, int, int, RadOpdDesc*);
|
|
int rad_mtp_couple_verify_shape(const RadParam*, int, int, RadOpdDesc*);
|
|
int rad_mtp_couple_propose_args(const RadArgs*, RadMtpCoupleProposeCall*);
|
|
int rad_mtp_couple_verify_args(const RadArgs*, RadMtpCoupleVerifyCall*);
|
|
|
|
/* The geometry/validation the shape hooks and the arg readers share. `op` 0 proposes, 1 verifies. */
|
|
int rad_couple_validate(const RadArgs*, int op, int64_t* M, int64_t* vocab, int64_t* n_cand);
|
|
|
|
/* The op set. Two schemas, two device rows and two host-reference rows. */
|
|
int rad_spechub_schema_count();
|
|
const RadOpSchema* rad_spechub_schema_at(int i);
|
|
RadKernelInfo rad_spechub_row(int i, RadLaunchFn launch);
|
|
|
|
/* The launches. */
|
|
int rad_mine_mtp_couple_propose_launch(const RadArgs*, RadStream);
|
|
int rad_mine_mtp_couple_verify_launch(const RadArgs*, RadStream);
|
|
int rad_ref_mtp_couple_propose(const RadArgs*, RadStream);
|
|
int rad_ref_mtp_couple_verify(const RadArgs*, RadStream);
|
|
|
|
/* One propose row, host and device: x ~ Q over the final eight. Column 0 is what ADV_ROUND and
|
|
* ADV_TAKE read, and it becomes x only for a valid sampled row. */
|
|
static inline RAD_SPECHUB_HD void rad_mtp_couple_propose_row(const RadMtpCoupleProposeCall& c,
|
|
int64_t row) {
|
|
RadMtpCoupleState s{};
|
|
s.draw = *reinterpret_cast<const RadMtpCoupleDraw*>(c.draw + row * c.ld_draw);
|
|
int32_t* idx = c.idx + row * c.ld_idx;
|
|
s.round = c.round;
|
|
s.x = idx[0];
|
|
for (int i = 0; i < 8; ++i) s.ids[i] = -1;
|
|
if (s.draw.mode == 1) {
|
|
s.status = -1;
|
|
if (s.draw.card == c.card[row] &&
|
|
rad_mtp_couple_build_q(idx, c.val + row * c.ld_val, c.vocab, &s)) {
|
|
const double u = rad_spechub_uniform(s.draw.seed, s.draw.base,
|
|
RAD_MTP_COUPLE_KEY_DRAFT + (uint64_t)c.round);
|
|
s.x = s.ids[rad_mtp_couple_pick(s, u)];
|
|
s.status = 1;
|
|
idx[0] = s.x;
|
|
} else {
|
|
s.count = 0;
|
|
for (int i = 0; i < 8; ++i) { s.ids[i] = -1; s.q[i] = 0; }
|
|
}
|
|
}
|
|
*reinterpret_cast<RadMtpCoupleState*>(c.state + (c.round - 1) * c.st_round + row * c.st_row) = s;
|
|
}
|
|
|
|
/* One verify row, after sample_pick. A row without a valid bound state keeps the ordinary token. */
|
|
static inline RAD_SPECHUB_HD void rad_mtp_couple_verify_row(const RadMtpCoupleVerifyCall& c,
|
|
int64_t row) {
|
|
const auto& s = *reinterpret_cast<const RadMtpCoupleState*>(c.state + row * c.ld[3]);
|
|
if (s.status != 1) return;
|
|
const auto& p = *reinterpret_cast<const RadSampleParams*>(c.params + row * c.ld[2]);
|
|
if ((p.flags & RAD_SP_GREEDY) || s.draw.seed != p.seed || s.pos != p.pos ||
|
|
!rad_mtp_couple_state_valid(s, c.vocab))
|
|
return;
|
|
int32_t out = -1;
|
|
if (rad_mtp_couple_decide(s, c.idx + row * c.ld[0], c.val + row * c.ld[1], c.n_cand, c.vocab,
|
|
rad_spechub_uniform(p.seed, p.pos, RAD_SAMPLE_KEY_ACCEPT),
|
|
rad_spechub_uniform(p.seed, p.pos, RAD_SAMPLE_KEY_RESID), &out))
|
|
c.token[row * c.ld[4]] = out;
|
|
}
|
|
|
|
#undef RAD_SPECHUB_HD
|
|
#endif /* RAD_PLUGIN_SPECHUB_H */
|