This repository has been archived on 2026-11-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
radiance-sycl/core/sched/mtp_couple_bind.h
T
Deadcode 5a9ce4912b radiance 1.12.0
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).
2026-10-24 13:12:28 +02:00

73 lines
3.8 KiB
C++

/* mtp_couple_bind.h -- the engine's post-commit binding step for a serial drafting row.
*
* Engine::finish_serial_drafter calls this after the commit, once the card's proposal states are
* read back. It decides:
*
* - the position the next build stages the row at: the request's committed output length after
* this commit. It is not rebuilt from the draw's pre-commit base plus the accepted count, which
* differ when a max_tokens or context cut emits fewer tokens than the card accepted;
* - whether the row binds at all: a sequence that is gone from the commit or no longer Running
* will not sample again.
*
* Both come from Scheduler::committed_seq(), filled by commit under the scheduler lock, never from
* the plan's StepEntry::req, which reap() may have freed by now. A header of its own so the rule
* can be tested against a real commit without an Engine (tests/sched_test.cpp).
*/
#pragma once
#include "advance.h"
#include "rad_spechub.h"
#include <cstring>
#include <string>
namespace rad {
/* Where the next build will sample this sequence, after the current step's commit. */
struct MtpCoupleBindPoint {
bool found = false; /* the committed step carried the sequence */
bool live = false; /* and its request was still Running (not finished/cancelled/failed) */
uint64_t n_out = 0; /* its committed output length: what the next build reads as n_out */
};
/* Bind `done` rounds of this row's draw to the positions the next build samples. `rb` is round 1
* of this row in the engine's readback (stride `rb_stride` states), `tok[rd]` the card's token for
* round rd, `S` the card's slot. Fills `out[0, done)` and sets `*n_bound = done`; a sequence that
* is not live binds nothing (`*n_bound = 0`, RAD_OK) and leaves `out` untouched. RAD_E_STATE with
* `why` for a readback that is not this draw's, or is not a state the proposer could have written.
* A sampled round the proposer marked status -1 (a shortlist it could not turn into Q) kept the
* greedy proposal; it is bound as is, the sampler does not couple it, and `*n_malformed` counts it.
* `base` is never read here: it is the draft's coordinate, not the verify's. */
inline int mtp_couple_bind_rounds(const MtpCoupleBindPoint& p, const RadMtpCoupleDraw& d,
const RadMtpCoupleState* rb, int rb_stride, int done,
const StepSlot& S, int64_t vocab, RadMtpCoupleState* out,
int* n_bound, std::string* why, int* n_malformed = nullptr) {
*n_bound = 0;
if (n_malformed) *n_malformed = 0;
if (!p.live) return RAD_OK;
const bool sampled = d.mode == 1;
for (int rd = 1; rd <= done; ++rd) {
const RadMtpCoupleState& st = rb[(size_t)(rd - 1) * (size_t)rb_stride];
const bool malformed = sampled && st.status == -1;
if (std::memcmp(&st.draw, &d, sizeof d) || st.round != rd || st.x != S.tok[rd] ||
(st.status != (sampled ? 1 : 0) && !malformed) ||
(sampled && !malformed && !rad_mtp_couple_state_valid(st, vocab))) {
*why = "MTP coupled: sequence " + std::to_string(d.seq) + " round " +
std::to_string(rd) + " returned status " + std::to_string(st.status) +
" round " + std::to_string(st.round) + " x " + std::to_string(st.x) +
" for card token " + std::to_string(S.tok[rd]) + " (draw " +
(std::memcmp(&st.draw, &d, sizeof d) ? "stale" : "current") +
"); refusing the step";
return RAD_E_STATE;
}
if (malformed && n_malformed) ++*n_malformed;
RadMtpCoupleState b = st;
b.pos = rad_mtp_couple_verify_pos(p.n_out, rd);
out[rd - 1] = b;
}
*n_bound = done;
return RAD_OK;
}
} // namespace rad