From f9641ff85ef2c5ec86b9abeec8790071500e0794 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Tue, 13 Oct 2026 06:22:45 +0200 Subject: [PATCH] strata-q36: Q8_0 / F16 small tensors widened at load (the Q8_0 file's ssm_alpha / ssm_beta) Qwen3.6-35B-A3B-Q8_0.gguf stores the GDN alpha / beta projections as Q8_0; the engine read only F32 / BF16 there and refused the file. They are now widened to F32 at load (fp16 scale x int8, as ggml). q36_llama_dump: STRATA_DUMP_CTX sets a smaller context / batch for files whose weights leave no VRAM for 4096-token buffers. --- src/qwen35/q36_engine.cu | 14 ++++++++++++-- tools/qwen35/q36_llama_dump.cpp | 8 ++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/qwen35/q36_engine.cu b/src/qwen35/q36_engine.cu index 78c9b7b2..2cc0dd18 100644 --- a/src/qwen35/q36_engine.cu +++ b/src/qwen35/q36_engine.cu @@ -801,8 +801,18 @@ float* upload_f32(const strata::TensorInfo& t, const uint8_t* src) { if (t.type == 0) std::memcpy(h.data(), src, h.size() * 4); else if (t.type == 30) for (size_t i = 0; i < h.size(); ++i) h[i] = bf16_to_f32((uint16_t) (src[2 * i] | (src[2 * i + 1] << 8))); - else { - std::fprintf(stderr, "strata-q36: %s is %s, expected F32 or BF16\n", t.name.c_str(), t.type_name()); + else if (t.type == 1) // F16 + for (size_t i = 0; i < h.size(); ++i) + h[i] = __half2float(__ushort_as_half((unsigned short) (src[2 * i] | (src[2 * i + 1] << 8)))); + else if (t.type == 8 && h.size() % 32 == 0) { + // Q8_0 (the Q8_0 file stores ssm_alpha / ssm_beta so): blocks of an fp16 scale and 32 int8, widened here + for (size_t b = 0; b < h.size() / 32; ++b) { + const uint8_t* q = src + b * 34; + const float d = __half2float(__ushort_as_half((unsigned short) (q[0] | (q[1] << 8)))); + for (int j = 0; j < 32; ++j) h[b * 32 + j] = d * (float) (int8_t) q[2 + j]; + } + } else { + std::fprintf(stderr, "strata-q36: %s is %s, expected F32, BF16, F16 or Q8_0\n", t.name.c_str(), t.type_name()); std::exit(1); } float* d = nullptr; diff --git a/tools/qwen35/q36_llama_dump.cpp b/tools/qwen35/q36_llama_dump.cpp index 0b1a7508..7a2c378a 100644 --- a/tools/qwen35/q36_llama_dump.cpp +++ b/tools/qwen35/q36_llama_dump.cpp @@ -88,8 +88,12 @@ int main(int argc, char** argv) { cap.n_embd = llama_model_n_embd(mdl); cap.n_layer = llama_model_n_layer(mdl); llama_context_params cp = llama_context_default_params(); - cp.n_ctx = 4096; - cp.n_batch = cp.n_ubatch = 4096; + // STRATA_DUMP_CTX: a smaller context / batch (the parity sequences are a few hundred tokens) for a file whose + // weights leave no VRAM for the 4096-token compute buffers (UD-Q6_K_XL on a 32 GB card) + const char* cx = std::getenv("STRATA_DUMP_CTX"); + const int nctx = cx ? std::atoi(cx) : 4096; + cp.n_ctx = nctx; + cp.n_batch = cp.n_ubatch = nctx; cp.op_offload = ngl > 0; // --ngl 0 is the CPU backend: no prompt matmuls offloaded to a GPU either cp.cb_eval = on_tensor; cp.cb_eval_user_data = ∩