Token embedding in BF16 from the checkpoint (--embd-gguf)
- tools/embd_bf16_pack.py copies embed_tokens (BF16, as the checkpoint ships it) into a one-tensor GGUF; only the safetensors shard that holds it is needed (3 GB for Qwen/Qwen3.8-Flash-Next). - --embd-gguf PATH: NativeEmbed reads token_embd from that file; iq_embed_rows and iq_dequant_f32 decode BF16 (embed_type_supported). Mapped host memory as before (1.2 GiB instead of 0.3 for IQ4_XS), no VRAM. First-token KL of the GGUF's IQ4_XS embedding against the BF16 one: 0.0015 (1K), 0.0089 (2K; the top token changes), 0.0010 (4K), 0.037 (32K); mean 0.012, ~100x the run-to-run noise. On the NVFP4 fork, whose GGUF embedding is Q8_0, the same comparison gave 0.0025. Decode and prompt speed are unchanged (fork); the start takes ~0.2 s more. Rebased onto 0.1.31 (Niko1221): NativeEmbed::load takes the shard list (one file for --embd-gguf) and checks the model's architecture since 0.1.31 - the one-tensor file says "strata-embd", so only its tensor is checked there; the Q4_K/Q5_K/Q5_1/Q8_0 decoders 0.1.31 added stay beside the BF16 one.
This commit is contained in:
1 parent
c81244d4e9
commit
32727a7a94
5 files changed
+116
-8
No files matched your search
@@ -216,6 +216,8 @@ struct Options {
|
||||
/// combination recorded in bench/results/2026-09-23-attention-ple plus the native indexer, and never the
|
||||
/// <=256-token attention adapter. It becomes the default once P0 shows it is not slower.
|
||||
std::string native_preset;
|
||||
/// The token embedding from this GGUF instead of --native's (tools/embd_bf16_pack.py: BF16 as shipped)
|
||||
std::string embd_gguf;
|
||||
/// Plan v0.3 P2: how the n-gram table is read. Direct (default) = unbuffered SSD reads, table never in RAM.
|
||||
std::string ple_io = "direct";
|
||||
int64_t ple_row_cache = 1 << 20; ///< bounded row cache (rows of 90 B); 0 disables
|
||||
@@ -456,6 +458,8 @@ void usage() {
|
||||
" indexer, RoPE, PLE postops, and the CPU q8_0 contract unless the\n"
|
||||
" expert cache is on. Individual --native-* flags stay for A/B.\n"
|
||||
" --native-head-gguf PATH native Q5_K head from model shard 1; requires --stream-token\n"
|
||||
" --embd-gguf PATH the token embedding from this GGUF instead of --native's (tools/embd_bf16_pack.py:\n"
|
||||
" BF16 as the checkpoint ships it; mapped host memory, no VRAM)\n"
|
||||
" --native-dense-gguf PATH native GDN/QSA/shared projections; repeat for each source model shard\n"
|
||||
" --expert-cache-cpu-order experimental GPU expert reduction matching CPU order\n"
|
||||
" --max-new N tokens to generate (default 16)\n"
|
||||
@@ -1068,6 +1072,7 @@ int main(int argc, char** argv) {
|
||||
else if (a == "--cpu-oracle-q8-0") o.cpu_oracle_q8_0 = true;
|
||||
else if (a == "--native") o.native_preset = next("--native");
|
||||
else if (a == "--native-head-gguf") o.native_head_gguf = next("--native-head-gguf");
|
||||
else if (a == "--embd-gguf") o.embd_gguf = next("--embd-gguf");
|
||||
else if (a == "--native-dense-gguf") o.native_dense_gguf.push_back(next("--native-dense-gguf"));
|
||||
else if (a == "--no-capture") o.no_capture = true;
|
||||
else if (a == "--no-pool") o.no_pool = true;
|
||||
@@ -1766,15 +1771,16 @@ int main(int argc, char** argv) {
|
||||
return 2;
|
||||
}
|
||||
const strata::core::ModelGeometry g0;
|
||||
if (!native_embed.load(o.native_shards, g0.n_embd, 248320, err)) {
|
||||
if (!native_embed.load(o.embd_gguf.empty() ? o.native_shards : std::vector<std::string>{o.embd_gguf}, g0.n_embd,
|
||||
248320, err)) {
|
||||
std::fprintf(stderr, "strata generate: %s\n", err.c_str());
|
||||
return 1;
|
||||
}
|
||||
strata::core::set_native_embed(&native_embed);
|
||||
std::fprintf(stderr, "strata generate: native pack: %s experts (largest blob %.2f MB), token embedding "
|
||||
"type %d in mapped host memory (%.0f MiB)\n",
|
||||
"%s in mapped host memory (%.0f MiB)\n",
|
||||
o.pack.c_str(), (double) strata::kernels::cpu::expert_layout().max_blob / 1e6,
|
||||
native_embed.type(), (double) native_embed.bytes() / 1048576.0);
|
||||
strata::ggml_type_name((uint32_t) native_embed.type()), (double) native_embed.bytes() / 1048576.0);
|
||||
}
|
||||
// Plan v0.3 P1: tensors served in native form are not also loaded in canonical form (~2.7 GB of VRAM back
|
||||
// to the expert cache with --native). `--keep-canonical` loads both, as before.
|
||||
|
||||
Reference in new issue
Block a user