Archived
The gemma4_bf16 architecture (sliding and global attention, the proportional RoPE ladder, the assistant head as a drafter that reads the trunk's cache, the vision tower), its w4a8 decode junctions, the h512/gqa8 and h256/gqa2 attention kernels, compressed-tensors int4 import, multi-EOS from generation_config, the call/reasoning reply format, a window group that keeps the keys a prefill chunk still reads, and window snapshots in checkpoint slots so a prefix hit on a sliding-window trunk resumes. Fixes on top: the investigation switches and diagnostic blocks out of the served paths; int4 import through the checkpoint import framework; attention_k_eq_v from the config; the fused junctions only where every reader takes their pair; a shared-KV head binds no group of its own; the compose file without HSA_ENABLE_IPC_MODE_LEGACY (TP2 fails with it on ROCm 10.1); a checkpoint carries a window only where a hit resumes from it; the README says the linked container is keptn42's calibrated GPTQ build and what the in-tree recipe gives.
This commit is contained in:
commit
7c7f755931
84 files changed
+10292
-230
No files matched your search
@@ -546,6 +546,31 @@ typedef struct RadDrafterDecl {
|
||||
|
||||
int rad_declare_drafter(RadBuilder* b, const RadDrafterDecl* d);
|
||||
|
||||
/* A SERIAL HEAD WITH NO CACHE OF ITS OWN. Every attention layer of it reads one of the TRUNK's
|
||||
* layers' K and V and writes none -- Gemma 4's assistant head, whose layers have a query
|
||||
* projection and nothing else, reads the last sliding and the last global trunk layer. Called
|
||||
* once, after rad_declare_drafter, by a plugin whose serial head is that shape. Additive export: a
|
||||
* plugin that does not call it drafts exactly as before, and RAD_ABI_VERSION does not move.
|
||||
*
|
||||
* What it changes in the serial driver, and each item follows from the head writing nothing:
|
||||
*
|
||||
* NO HISTORY IS OWED. A history pass exists to fill a head's own K and V, and there are none to
|
||||
* fill. The pass carries round 1 alone: ONE row a drafting sequence, at the committed position,
|
||||
* with the token the trunk chose after it and the trunk's hidden state there (out_ids). A
|
||||
* sequence that does not draft gets no row, and a step with nothing to draft no pass.
|
||||
*
|
||||
* EVERY ROUND RUNS AT THAT SAME POSITION, OVER THE SAME CONTEXT. A head with a cache of its own
|
||||
* steps one position a round and attends to what it wrote there. This one has nowhere to write,
|
||||
* and the trunk's cache past the committed position holds the K and V of drafts the last verify
|
||||
* REJECTED, or of nothing. So every round's `seqused` ends at the committed position, and what
|
||||
* the head proposed travels forward in its hidden state and its next input token instead.
|
||||
*
|
||||
* `pos_offset` is where those rows sit for the rotary, as an offset from the committed position:
|
||||
* 0 is the position of the trunk hidden state the head continues from, 1 the position of the token
|
||||
* it embeds. It moves nothing else -- the context ends at the committed position either way -- and
|
||||
* which one a checkpoint was trained with is the plugin's to know. */
|
||||
int rad_drafter_shared_kv(RadBuilder* b, int pos_offset);
|
||||
|
||||
/* ================================================================== the encoder */
|
||||
/* A MEDIA ENCODER THE PLUGIN RUNS ON AN ENCODER PASS (RadBatch::enc), declared for the reason the
|
||||
* logits buffer and the drafter are: the core drives the pass and reads its result, so it has to
|
||||
@@ -679,6 +704,18 @@ int rad_arch_probe(const RadModelMeta* meta, RadArchProbe* out);
|
||||
* UTF-8; NULL reads as "". The engine copies what it needs while loading, so static storage in
|
||||
* the plugin is enough.
|
||||
*
|
||||
* The other family is a call written as a name and ONE object holding its arguments
|
||||
* (args_form = RAD_CHAT_ARGS_OBJECT):
|
||||
*
|
||||
* [call_open] name_prefix NAME name_suffix { key: value, ... } [call_end] [call_close]
|
||||
*
|
||||
* The object is JSON, or a dialect of it: strings between object_string_open and
|
||||
* object_string_close, their text verbatim, and keys written bare (object_bare_keys). Gemma 4 is
|
||||
* "<|tool_call>" / "<tool_call|>", "call:" / "" / "", strings "<|\"|>" / "<|\"|>", bare keys --
|
||||
* `<|tool_call>call:get_weather{city:<|"|>Paris<|"|>}<tool_call|>` -- and the reply's JSON
|
||||
* arguments are that object respelled as JSON. The arg_* fields describe tagged arguments only
|
||||
* and are empty in this family.
|
||||
*
|
||||
* THE STRUCT GROWS AT ITS END AND NEVER CHANGES IN THE MIDDLE. `struct_size` is
|
||||
* sizeof(RadChatFormat) as the plugin was compiled; the engine reads only the fields that size
|
||||
* covers and treats the rest as zero, so a plugin built against an older header keeps loading
|
||||
@@ -700,6 +737,11 @@ enum {
|
||||
RAD_CHAT_THINK_NEVER = 2 /* the model opens its own block, if any */
|
||||
};
|
||||
|
||||
enum {
|
||||
RAD_CHAT_ARGS_TAGGED = 0, /* each argument in its own tags: arg_prefix .. arg_value_suffix */
|
||||
RAD_CHAT_ARGS_OBJECT = 1 /* one object after the name, in JSON or the object_* dialect */
|
||||
};
|
||||
|
||||
typedef struct RadChatFormat {
|
||||
uint32_t struct_size;
|
||||
const char* name; /* for the startup log; NULL is the plugin's name */
|
||||
@@ -739,6 +781,23 @@ typedef struct RadChatFormat {
|
||||
* reply is read unconstrained. */
|
||||
const char* const* triggers;
|
||||
uint32_t n_triggers;
|
||||
|
||||
/* RAD_CHAT_ARGS_*: how a call's arguments are written. Zero is the tagged family above. With
|
||||
* RAD_CHAT_ARGS_OBJECT, name_suffix may be empty -- the name then ends where the object
|
||||
* begins -- and so may call_end, when the object's own closing brace ends the call. */
|
||||
uint32_t args_form;
|
||||
/* RAD_CHAT_ARGS_OBJECT: a string delimiter of the object's dialect besides JSON's `"`. What
|
||||
* stands between the two is the string, verbatim -- the dialect has no escapes. NULL: the
|
||||
* object writes JSON strings only. */
|
||||
const char* object_string_open;
|
||||
const char* object_string_close;
|
||||
/* RAD_CHAT_ARGS_OBJECT: non-zero when the dialect writes a key bare, `key:value`. */
|
||||
uint32_t object_bare_keys;
|
||||
|
||||
/* Non-zero: a reasoning block may open again LATER in the reply -- after its answer, between
|
||||
* calls -- and is read as reasoning there as well, and a reasoning_close with no block open
|
||||
* is not part of the answer. Zero: only a block the reply starts with is reasoning. */
|
||||
uint32_t reasoning_anywhere;
|
||||
} RadChatFormat;
|
||||
|
||||
/* Return the format, or NULL for "derive it from the chat template". Called once at startup. */
|
||||
|
||||
Reference in new issue
Block a user