mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-05 15:58:53 +00:00
fix(inkling2): a drafter file in a layout the engine cannot read is dropped with one message; it never stops the model
2026-11-23 14:54 UTC unsloth/Inkling-2-Mini-GGUF re-uploaded dspark-Inkling-2-Mini-Q8_0.gguf (402,278,560 -> 503,889,952 bytes) in llama.cpp mainline's "dflash" layout (commit 19bf97a66719d0165f6f8082a9d59581912a3863 "Support mainline llama.cpp"; the old file stays in the repo as dspark-Inkling-2-Mini-Q8_0_Old.gguf). Same drafter (3 blocks, 2304 wide, block 8, taps 5 / 23 / 41 / 48, Markov head), written differently: fuse_weight and the per-block dflare_norm became per-block ctx_mix / ctx_norm, the Markov head's hidden_out projection is folded through the output head into markov_w2 (+ bias) over the real 200058-token vocabulary, mask_embd has 7 rows, token_embd_norm was added. The engines asked for the old names and ended the whole start: "missing tensor 'dspark.markov_head.hidden_out.weight'". strata/core/ink_dspark_layout.hpp: ink_dspark_layout_check() on the plain tensor names a loader collected; the GGUF loader (drafter GGUF and an external mtp.safetensors) and the official-folder safetensors loader drop the drafter when it fails (drafting off for this start, the arena space given back), print ink_dspark_layout_message() once (it names the file, what is missing and which files the engine reads), and the model starts normally. Test ink_dspark_layout_test uses the real tensor lists of the old (54) and the new (58) file.
This commit is contained in:
1 parent
540f3b3dfb
commit
6ef0b4693b
5 files changed
+250
No files matched your search
@@ -337,6 +337,10 @@ if(STRATA_BUILD_TESTS)
|
||||
add_executable(ink_widen_test tests/core/ink_widen_test.cpp)
|
||||
target_include_directories(ink_widen_test PRIVATE include)
|
||||
add_test(NAME ink_widen_test COMMAND ink_widen_test)
|
||||
# a drafter file in a layout the runners do not read (Unsloth's llama.cpp mainline "dflash" file of 2026-11-23) is dropped, never fatal (no GPU)
|
||||
add_executable(ink_dspark_layout_test tests/core/ink_dspark_layout_test.cpp)
|
||||
target_include_directories(ink_dspark_layout_test PRIVATE include)
|
||||
add_test(NAME ink_dspark_layout_test COMMAND ink_dspark_layout_test)
|
||||
# the architecture list the FP4 sm_120 file is built for, from a bare or an inherited CMAKE_CUDA_ARCHITECTURES list (configure-only, no compiler)
|
||||
add_test(NAME ink_sm120a_cmake COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/cmake/ink_sm120a_test.cmake)
|
||||
# how the prompt path's K/V append reaches the host copy under KV streaming: the switch both ways, the backend defaults, no pool (no GPU)
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
// strata-inkling: a drafter file whose layout this engine cannot read must never stop the model from starting.
|
||||
//
|
||||
// 2026-11-23 14:54 UTC Unsloth re-uploaded dspark-Inkling-2-Mini-Q8_0.gguf in llama.cpp mainline's "dflash" layout (503,889,952 bytes; the old
|
||||
// padded-vocab layout is still in the repo as dspark-Inkling-2-Mini-Q8_0_Old.gguf, 402,278,560 bytes). Same drafter (3 blocks, 2304 wide, block 8,
|
||||
// taps 5 / 23 / 41 / 48, Markov head) written differently: fuse_weight and the per-block dflare_norm split into per-block ctx_mix / ctx_norm,
|
||||
// the Markov head's hidden_out projection folded through the output head into markov_w2 (+ bias) over the real 200058-token vocabulary,
|
||||
// mask_embd with 7 rows. The engines look the old names up (dspark.markov_head.hidden_out.weight ...) and stopped the whole start with
|
||||
// "missing tensor 'dspark.markov_head.hidden_out.weight'".
|
||||
//
|
||||
// ink_dspark_layout_check() tells, from the plain tensor names a loader collected, whether the layout is one the runners read. A loader that
|
||||
// gets false drops the drafter (drafting off for this start), prints ink_dspark_layout_message() once and starts the model normally.
|
||||
#pragma once
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
namespace strata::core {
|
||||
|
||||
inline bool ink_dspark_layout_check(const std::set<std::string>& plain_names, std::string* why = nullptr) {
|
||||
static const char* const kRequired[] = {
|
||||
"fuse_weight", "mask_embed", "markov_head.hidden_out.weight", "markov_head.hidden_out.bias", "markov_head.dflare_norm.weight",
|
||||
"markov_head.markov_w1.weight", "layers.0.self_attn.q_proj.weight", "layers.0.dflare_norm.weight"};
|
||||
for (const char* r : kRequired) {
|
||||
if (!plain_names.count(r)) {
|
||||
if (why) {
|
||||
const bool mainline = plain_names.count("markov_w2.weight") || plain_names.count("blk.0.ctx_mix.weight") || plain_names.count("markov_ctx_mix.weight");
|
||||
*why = std::string("missing '") + r + "'" + (mainline ? " (the llama.cpp mainline dflash layout: ctx_mix / markov_w2)" : "");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
inline std::string ink_dspark_layout_message(const std::string& file, const std::string& why) {
|
||||
return "strata-inkling: the drafter file " + file + " is in a layout this engine cannot read yet (" + why +
|
||||
"); drafting is off for this start and the model starts normally. A drafter this engine reads: Unsloth's "
|
||||
"dspark-Inkling-2-Mini-Q8_0_Old.gguf, or the original mtp.safetensors.";
|
||||
}
|
||||
|
||||
} // namespace strata::core
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <filesystem>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
@@ -25,6 +26,7 @@
|
||||
#include "ink_safetensors_loader.h"
|
||||
#include "strata/artifact/gguf_reader.hpp"
|
||||
#include "strata/artifact/strata_reader.hpp"
|
||||
#include "strata/core/ink_dspark_layout.hpp"
|
||||
#include "strata/core/ink_names.hpp"
|
||||
#include "strata/core/mapped_pages.hpp"
|
||||
#include "strata/quant/dequant.hpp"
|
||||
@@ -691,6 +693,7 @@ struct GgufAdapter {
|
||||
// 3. Optional external DSpark drafter (either mtp.safetensors or dspark-*.gguf!)
|
||||
// Auto-discover companion dspark-*.gguf / mtp.safetensors in the model directory when not explicitly provided.
|
||||
std::string dspark_file = explicit_dspark;
|
||||
const size_t dspark_arena0 = sec1_arena.size();
|
||||
if (dspark_file.empty()) {
|
||||
const size_t sep = path.find_last_of("/\\");
|
||||
const std::string dir_path = (sep != std::string::npos) ? path.substr(0, sep) : ".";
|
||||
@@ -786,6 +789,21 @@ struct GgufAdapter {
|
||||
}
|
||||
m.dspark.present = !m.dspark_tensors.empty();
|
||||
}
|
||||
// A drafter in a layout this engine does not read (Unsloth's llama.cpp mainline "dflash" file of 2026-11-23, ...) never stops the model:
|
||||
// say so once, drop it, and start with drafting off.
|
||||
if (m.dspark.present) {
|
||||
std::set<std::string> plain_names;
|
||||
for (const auto& kv : m.dspark_tensors) plain_names.insert(strata::core::ink_dspark_plain(kv.first));
|
||||
std::string why;
|
||||
if (!strata::core::ink_dspark_layout_check(plain_names, &why)) {
|
||||
std::fprintf(stderr, "%s\n", strata::core::ink_dspark_layout_message(dspark_file, why).c_str());
|
||||
m.dspark_tensors.clear();
|
||||
m.dspark.present = false;
|
||||
has_dspark_st = false;
|
||||
dspark_gguf.reset();
|
||||
sec1_arena.resize(dspark_arena0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The trunk, drafter and vision tensors are copied into sec1_arena by now: drop their mapped pages (everything but the routed experts).
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <cstring>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
@@ -17,6 +18,7 @@
|
||||
#include "../image/vae/safetensors_lite.hpp"
|
||||
#include "ink_json.h"
|
||||
#include "strata/artifact/strata_reader.hpp"
|
||||
#include "strata/core/ink_dspark_layout.hpp"
|
||||
#include "strata/core/ink_names.hpp"
|
||||
#include "strata/core/ink_widen.hpp"
|
||||
#include "strata/quant/sk_codecs.hpp"
|
||||
@@ -399,6 +401,8 @@ struct SafetensorsAdapter {
|
||||
}
|
||||
|
||||
if (has_mtp) {
|
||||
const size_t mtp_items0 = sec1_items.size();
|
||||
const uint64_t mtp_total0 = sec1_total_bytes;
|
||||
for (const auto& kv : mtp_shard.st.tensors) {
|
||||
const std::string& name = kv.first;
|
||||
const auto& st_t = kv.second;
|
||||
@@ -420,6 +424,18 @@ struct SafetensorsAdapter {
|
||||
sec1_total_bytes = off + dst_bytes;
|
||||
}
|
||||
m.dspark.present = !m.dspark_tensors.empty();
|
||||
// a drafter in a layout the runners do not read never stops the model: drop it, drafting is off for this start
|
||||
std::set<std::string> plain_names;
|
||||
for (const auto& kv : m.dspark_tensors) plain_names.insert(strata::core::ink_dspark_plain(kv.first));
|
||||
std::string why;
|
||||
if (m.dspark.present && !strata::core::ink_dspark_layout_check(plain_names, &why)) {
|
||||
std::fprintf(stderr, "%s\n", strata::core::ink_dspark_layout_message(mtp_shard.path, why).c_str());
|
||||
m.dspark_tensors.clear();
|
||||
m.dspark.present = false;
|
||||
has_mtp = false;
|
||||
sec1_items.resize(mtp_items0);
|
||||
sec1_total_bytes = mtp_total0;
|
||||
}
|
||||
}
|
||||
|
||||
// 5. Index all routed experts (NVFP4 -> SF4 code_id=15, MXFP8 -> MX8 code_id=16) with ZERO requantization!
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
// strata-inkling: a drafter file in a layout the runners do not read is dropped, never fatal (strata/core/ink_dspark_layout.hpp).
|
||||
// The two real files of unsloth/Inkling-2-Mini-GGUF: dspark-Inkling-2-Mini-Q8_0_Old.gguf (402,278,560 bytes, the layout the engines read) and the
|
||||
// dspark-Inkling-2-Mini-Q8_0.gguf of 2026-11-23 14:54 UTC (503,889,952 bytes, llama.cpp mainline "dflash": ctx_mix / ctx_norm / markov_w2 ...).
|
||||
#include "strata/core/ink_dspark_layout.hpp"
|
||||
#include "strata/core/ink_names.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using namespace strata::core;
|
||||
|
||||
namespace {
|
||||
int failed = 0;
|
||||
#define CHECK(x) do { if (!(x)) { std::fprintf(stderr, "FAIL %s:%d: %s\n", __FILE__, __LINE__, #x); ++failed; } } while (0)
|
||||
|
||||
const std::vector<std::string> kOld = {
|
||||
"dspark_fuse.weight",
|
||||
"dspark_hidden_out.bias",
|
||||
"dspark_hidden_out.weight",
|
||||
"dspark_norm.weight",
|
||||
"joint_proj.bias",
|
||||
"joint_proj.weight",
|
||||
"markov_w1.weight",
|
||||
"mask_embd.weight",
|
||||
"output_norm.weight",
|
||||
"blk.0.attn_k.weight",
|
||||
"blk.0.attn_k_ctx.weight",
|
||||
"blk.0.attn_k_ctx_norm.weight",
|
||||
"blk.0.attn_k_norm.weight",
|
||||
"blk.0.attn_norm.weight",
|
||||
"blk.0.attn_output.weight",
|
||||
"blk.0.attn_q.weight",
|
||||
"blk.0.attn_q_norm.weight",
|
||||
"blk.0.attn_v.weight",
|
||||
"blk.0.attn_v_ctx.weight",
|
||||
"blk.0.dflare_norm.weight",
|
||||
"blk.0.ffn_down.weight",
|
||||
"blk.0.ffn_gate.weight",
|
||||
"blk.0.ffn_norm.weight",
|
||||
"blk.0.ffn_up.weight",
|
||||
"blk.1.attn_k.weight",
|
||||
"blk.1.attn_k_ctx.weight",
|
||||
"blk.1.attn_k_ctx_norm.weight",
|
||||
"blk.1.attn_k_norm.weight",
|
||||
"blk.1.attn_norm.weight",
|
||||
"blk.1.attn_output.weight",
|
||||
"blk.1.attn_q.weight",
|
||||
"blk.1.attn_q_norm.weight",
|
||||
"blk.1.attn_v.weight",
|
||||
"blk.1.attn_v_ctx.weight",
|
||||
"blk.1.dflare_norm.weight",
|
||||
"blk.1.ffn_down.weight",
|
||||
"blk.1.ffn_gate.weight",
|
||||
"blk.1.ffn_norm.weight",
|
||||
"blk.1.ffn_up.weight",
|
||||
"blk.2.attn_k.weight",
|
||||
"blk.2.attn_k_ctx.weight",
|
||||
"blk.2.attn_k_ctx_norm.weight",
|
||||
"blk.2.attn_k_norm.weight",
|
||||
"blk.2.attn_norm.weight",
|
||||
"blk.2.attn_output.weight",
|
||||
"blk.2.attn_q.weight",
|
||||
"blk.2.attn_q_norm.weight",
|
||||
"blk.2.attn_v.weight",
|
||||
"blk.2.attn_v_ctx.weight",
|
||||
"blk.2.dflare_norm.weight",
|
||||
"blk.2.ffn_down.weight",
|
||||
"blk.2.ffn_gate.weight",
|
||||
"blk.2.ffn_norm.weight",
|
||||
"blk.2.ffn_up.weight"
|
||||
};
|
||||
const std::vector<std::string> kNew = {
|
||||
"joint_proj.bias",
|
||||
"joint_proj.weight",
|
||||
"markov_ctx_mix.weight",
|
||||
"markov_ctx_norm.weight",
|
||||
"markov_w1.weight",
|
||||
"markov_w2.bias",
|
||||
"markov_w2.weight",
|
||||
"mask_embd.weight",
|
||||
"output_norm.weight",
|
||||
"token_embd_norm.weight",
|
||||
"blk.0.attn_k.weight",
|
||||
"blk.0.attn_k_ctx.weight",
|
||||
"blk.0.attn_k_ctx_norm.weight",
|
||||
"blk.0.attn_k_norm.weight",
|
||||
"blk.0.attn_norm.weight",
|
||||
"blk.0.attn_output.weight",
|
||||
"blk.0.attn_q.weight",
|
||||
"blk.0.attn_q_norm.weight",
|
||||
"blk.0.attn_v.weight",
|
||||
"blk.0.attn_v_ctx.weight",
|
||||
"blk.0.ctx_mix.weight",
|
||||
"blk.0.ctx_norm.weight",
|
||||
"blk.0.ffn_down.weight",
|
||||
"blk.0.ffn_gate.weight",
|
||||
"blk.0.ffn_norm.weight",
|
||||
"blk.0.ffn_up.weight",
|
||||
"blk.1.attn_k.weight",
|
||||
"blk.1.attn_k_ctx.weight",
|
||||
"blk.1.attn_k_ctx_norm.weight",
|
||||
"blk.1.attn_k_norm.weight",
|
||||
"blk.1.attn_norm.weight",
|
||||
"blk.1.attn_output.weight",
|
||||
"blk.1.attn_q.weight",
|
||||
"blk.1.attn_q_norm.weight",
|
||||
"blk.1.attn_v.weight",
|
||||
"blk.1.attn_v_ctx.weight",
|
||||
"blk.1.ctx_mix.weight",
|
||||
"blk.1.ctx_norm.weight",
|
||||
"blk.1.ffn_down.weight",
|
||||
"blk.1.ffn_gate.weight",
|
||||
"blk.1.ffn_norm.weight",
|
||||
"blk.1.ffn_up.weight",
|
||||
"blk.2.attn_k.weight",
|
||||
"blk.2.attn_k_ctx.weight",
|
||||
"blk.2.attn_k_ctx_norm.weight",
|
||||
"blk.2.attn_k_norm.weight",
|
||||
"blk.2.attn_norm.weight",
|
||||
"blk.2.attn_output.weight",
|
||||
"blk.2.attn_q.weight",
|
||||
"blk.2.attn_q_norm.weight",
|
||||
"blk.2.attn_v.weight",
|
||||
"blk.2.attn_v_ctx.weight",
|
||||
"blk.2.ctx_mix.weight",
|
||||
"blk.2.ctx_norm.weight",
|
||||
"blk.2.ffn_down.weight",
|
||||
"blk.2.ffn_gate.weight",
|
||||
"blk.2.ffn_norm.weight",
|
||||
"blk.2.ffn_up.weight"
|
||||
};
|
||||
|
||||
std::set<std::string> plain(const std::vector<std::string>& gguf) {
|
||||
std::set<std::string> s;
|
||||
for (const auto& n : gguf) s.insert(ink_dspark_plain(ink_dspark_name_from_gguf(n)));
|
||||
return s;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
int main() {
|
||||
std::string why;
|
||||
// the old layout is read
|
||||
CHECK(kOld.size() == 54);
|
||||
CHECK(ink_dspark_layout_check(plain(kOld), &why));
|
||||
CHECK(why.empty());
|
||||
// the mainline layout is not, and the reason names it
|
||||
CHECK(kNew.size() == 58);
|
||||
CHECK(!ink_dspark_layout_check(plain(kNew), &why));
|
||||
CHECK(why.find("markov_head.hidden_out") != std::string::npos || why.find("fuse_weight") != std::string::npos);
|
||||
CHECK(why.find("mainline") != std::string::npos);
|
||||
const std::string msg = ink_dspark_layout_message("dspark-Inkling-2-Mini-Q8_0.gguf", why);
|
||||
CHECK(msg.find("drafting is off for this start and the model starts normally") != std::string::npos);
|
||||
CHECK(msg.find("Q8_0_Old.gguf") != std::string::npos);
|
||||
// a file with one required tensor missing is refused, the others still count
|
||||
for (const char* gone : {"fuse_weight", "mask_embed", "markov_head.hidden_out.weight", "markov_head.hidden_out.bias", "markov_head.dflare_norm.weight"}) {
|
||||
std::set<std::string> s = plain(kOld);
|
||||
s.erase(gone);
|
||||
std::string w;
|
||||
CHECK(!ink_dspark_layout_check(s, &w));
|
||||
CHECK(w.find(gone) != std::string::npos);
|
||||
}
|
||||
// names that arrive with the dspark. prefix (the .strata and mtp.safetensors spelling) pass the same check
|
||||
std::set<std::string> s2;
|
||||
for (const auto& n : kOld) s2.insert(ink_dspark_plain(ink_dspark_name_from_gguf(n)));
|
||||
CHECK(ink_dspark_layout_check(s2, nullptr));
|
||||
if (failed) { std::fprintf(stderr, "%d check(s) failed\n", failed); return 1; }
|
||||
std::printf("ink_dspark_layout_test: all checks passed\n");
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user