Archived
radiance 1.7.0
- every model serves without a GPU: libavx covers every op, so `--kernels libavx` alone serves every shipped container - Qwen3-ASR (zivius): speech to text on /v1/audio/transcriptions and live over /v1/realtime - /v1/messages works with Claude Code as it ships (gearwave00001) - a long agent conversation keeps its cached history when the client rewrites its last turn (manueloverride) - a stream's first event goes out with the first token, so llama-benchy measures prefill right - opt-in --prefill-interleave (Smellyyyy, baKon) and --prefill-span (keptn42) - four-rank TP releases the link early; four-rank selftests and docs/TP4.md (goodman-b) - NVFP4 and FP8 compressed-tensors imports (devmilan); tools/rad-export for finetunes and LoRA adapters (baKon) - many fixes, among them lost tokens on stop strings under concurrency, keep-alive, MiniCPM5 tool arguments and the CPU's vision and audio encoders - plugin ABI 17 and changed op schemas: out-of-tree plugins must be rebuilt
This commit is contained in:
1 parent
b068190326
commit
1e968f6e1d
739 files changed
+128447
-84632
No files matched your search
+20
-39
@@ -1,15 +1,11 @@
|
||||
/* vocab_view.h -- what the sampler needs to know about a vocabulary, and nothing else.
|
||||
/* vocab_view.h -- what the sampler needs to know about a vocabulary.
|
||||
*
|
||||
* The tokeniser lives in core/text/ and belongs to the text frontend. The sampler needs exactly
|
||||
* three facts about a token -- how many there are, its printable piece, and whether it ends
|
||||
* generation -- plus, for DRY's sequence breakers and GBNF's `<token>` syntax, the ability to
|
||||
* tokenise a short literal. Taking a dependency on the whole tokeniser for that would put a
|
||||
* component boundary on the step path and make every sampler test drag a real vocabulary behind
|
||||
* it. An abstract view costs one virtual call per token per grammar step, which is host work the
|
||||
* device is not waiting on.
|
||||
* The sampler needs the token count, each token's piece and whether it ends generation, plus
|
||||
* tokenising a short literal for DRY's sequence breakers and GBNF's `<token>` syntax. This view
|
||||
* keeps the tokeniser (core/text/) out of the sampler and its tests; a virtual call per token per
|
||||
* grammar step is host work the device does not wait on.
|
||||
*
|
||||
* core/text/ implements this over the real vocab; SimpleVocab below implements it over a table,
|
||||
* which is what the tests use.
|
||||
* text/token_view.h implements it over the real vocab; SimpleVocab over a table, for tests.
|
||||
*/
|
||||
#pragma once
|
||||
#include "../rad_internal.h"
|
||||
@@ -27,10 +23,8 @@ public:
|
||||
|
||||
virtual int32_t n_tokens() const = 0;
|
||||
|
||||
/* The token's bytes as they would be appended to the output stream. The grammar walks these,
|
||||
* so a view that returns a display form rather than the exact bytes will admit the wrong
|
||||
* token set -- and the failure mode is plausible text with wrong structure, which is the
|
||||
* hardest kind to notice. */
|
||||
/* The token's exact bytes as appended to the output stream. The grammar walks these; a
|
||||
* display form would make it admit the wrong token set. */
|
||||
virtual const std::string& token_piece(int32_t id) const = 0;
|
||||
|
||||
/* End-of-generation: EOS, EOT, and whatever else this model ends on. A grammar admits one
|
||||
@@ -38,15 +32,14 @@ public:
|
||||
virtual bool is_eog(int32_t id) const = 0;
|
||||
|
||||
/* Tokenise a short literal. Only DRY's sequence breakers and GBNF's `<token>` form need it,
|
||||
* and both are optional features, so a view that has no tokeniser returns
|
||||
* RAD_E_UNSUPPORTED rather than pretending. */
|
||||
* both optional, so a view without a tokeniser returns RAD_E_UNSUPPORTED. */
|
||||
virtual int tokenize(const std::string& text, std::vector<int32_t>* out) const {
|
||||
(void)text; (void)out;
|
||||
return RAD_E_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/* The same with special tokens recognised in the text, so `<tool_call>` comes back as the
|
||||
* one control token a template means by it. Grammar triggers are resolved through this. */
|
||||
/* As tokenize, but recognising special tokens, so `<tool_call>` comes back as the one control
|
||||
* token. Grammar triggers resolve through this. */
|
||||
virtual int tokenize_special(const std::string& text, std::vector<int32_t>* out) const {
|
||||
(void)text; (void)out;
|
||||
return RAD_E_UNSUPPORTED;
|
||||
@@ -54,25 +47,16 @@ public:
|
||||
|
||||
/* ---------------- what a grammar backend derives from this vocabulary ----------------
|
||||
*
|
||||
* A GBNF mask is built over a DECODED form of the whole vocabulary -- every piece as code
|
||||
* points, plus a trie over them -- which costs a full vocabulary scan and is therefore
|
||||
* computed once and kept. It is kept HERE, with the vocabulary's own lifetime, because the
|
||||
* only other place to keep it is a table outside, and the only key such a table has is this
|
||||
* object's ADDRESS. An address is not an identity: a view destroyed and another constructed
|
||||
* in the same storage answers to the same key, and the second one is then served what was
|
||||
* derived for the first -- the decoded vocabulary, the trie over it, and the grammars
|
||||
* compiled against both. The mask that comes out is a mask over another model's tokens: it
|
||||
* admits the wrong set, or nothing at all, and nothing downstream can tell. Tying the cache
|
||||
* to the object makes the question unaskable.
|
||||
*
|
||||
* Opaque and mutable: what is cached is the backend's business and this header is the
|
||||
* sampler's interface, and filling it does not change what the vocabulary says. A backend
|
||||
* that caches nothing pays one null pointer. */
|
||||
* A GBNF mask works over a decoded form of the whole vocabulary (pieces as code points plus a
|
||||
* trie), which costs a full scan and is computed once. It is cached here, with the view's own
|
||||
* lifetime, because an external table could only key on the view's address, and a new view
|
||||
* built in the same storage would then be served the old model's decoded vocabulary and
|
||||
* compiled grammars. Opaque and mutable: its contents are the backend's business and filling
|
||||
* it does not change what the vocabulary says. */
|
||||
mutable std::shared_ptr<void> gbnf_cache;
|
||||
};
|
||||
|
||||
/* A vocabulary held as a table. Not a toy: it is what the sampler tests are written against, and
|
||||
* being able to state a vocabulary in four lines is what makes a grammar test readable. */
|
||||
/* A vocabulary held as a table, for the sampler and grammar tests. */
|
||||
class SimpleVocab : public VocabView {
|
||||
public:
|
||||
SimpleVocab() = default;
|
||||
@@ -85,8 +69,6 @@ public:
|
||||
return id;
|
||||
}
|
||||
|
||||
void mark_eog(int32_t id) { eog_.push_back(id); }
|
||||
|
||||
int32_t n_tokens() const override { return (int32_t)pieces_.size(); }
|
||||
|
||||
const std::string& token_piece(int32_t id) const override {
|
||||
@@ -100,14 +82,13 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Longest-match over the table, which is not BPE and does not pretend to be. It exists so a
|
||||
* DRY sequence breaker or a `<token>` literal resolves in a test; a real vocabulary's merge
|
||||
* machinery lives in core/text/. */
|
||||
/* A table has no special tokens of its own: every piece is matched as written. */
|
||||
int tokenize_special(const std::string& text, std::vector<int32_t>* out) const override {
|
||||
return tokenize(text, out);
|
||||
}
|
||||
|
||||
/* Longest match over the table, not BPE. Enough for a DRY breaker or a `<token>` literal in a
|
||||
* test; real tokenisation lives in core/text/. */
|
||||
int tokenize(const std::string& text, std::vector<int32_t>* out) const override {
|
||||
if (!out) return RAD_E_INVAL;
|
||||
size_t pos = 0;
|
||||
|
||||
Reference in new issue
Block a user