Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

Merge S25 f-halo-tps (8 commits) into S26 f-halo-s26-ovh: f-halo-int

Niko12212f6c70f0d159
diff --cc src/core/mtp.cpp
index cf490bbd3,2c1c13e1d..be954b3bb
--- a/src/core/mtp.cpp
+++ b/src/core/mtp.cpp
@@@ -443,9 -554,8 +554,11 @@@ bool MtpDrafter::bind(const WeightTable
vram_ += (uint64_t) (n_dvocab_ * row_bytes) + raw.size();
std::fprintf(stderr, "strata mtp: draft head over %lld tokens (%.1f MiB)\n", (long long) n_dvocab_,
(double) (n_dvocab_ * row_bytes) / 1048576.0);
- if (head->type() == 14 && strata::kernels::native_q6_k_packed_enabled()) // STRATA_Q6_PACKED=1
+ dhead_type_ = head->type();
+ if (q4_head_ && !make_q4_head(err)) return false;
++ if (dhead_type_ == 14 && strata::kernels::native_q6_k_packed_enabled()) // STRATA_Q6_PACKED=1
+ strata::kernels::native_q6_k_pack(dhead_, (int) (row_bytes / 210) * 256, (int) n_dvocab_,
+ "MTP draft head");
}
}
if (coupled_draft_env() && cparams_ == nullptr && !setup_coupled(err)) return false;
diff --cc src/core/native_dense.cpp
index c5778e02b,aae66aec4..d0d9438b8
--- a/src/core/native_dense.cpp
+++ b/src/core/native_dense.cpp
@@@ -171,27 -221,31 +223,50 @@@ bool NativeDense::load(const std::vecto
}
max_in = (std::max)(max_in, (int) ref.ne0);
total += bytes;
- pending.push_back(Pending{&ref, (int) tensor.type, bytes, std::move(data)});
+ // STRATA_Q8_PACKED=1: a second, packed copy of an eligible Q8_0 matrix for the decode MMVQ (the GGUF
+ // copy stays: the prompt path's GEMMs read it).
+ DevicePtr packed;
+ if (tensor.type == 8 && tensor.name != "blk.1.ple_key.weight" && // the PLE has its own kernel
+ strata::kernels::native_q8_0_packed_enabled() &&
+ strata::kernels::native_q8_0_packed_eligible((int) ref.ne0, (int) ref.ne1)) {
+ std::vector<uint8_t> host(bytes);
+ strata::kernels::native_q8_0_pack_host(gguf.tensor_data(tensor), host.data(), (int) ref.ne0,
+ (int) ref.ne1);
+ void* packed_allocation = nullptr;
+ auto packed_status = cudaMalloc(&packed_allocation, bytes);
+ packed.reset(packed_allocation);
+ if (packed_status == cudaSuccess)
+ packed_status = cudaMemcpy(packed.get(), host.data(), bytes, cudaMemcpyHostToDevice);
+ if (packed_status != cudaSuccess) {
+ err = "native dense packed upload " + tensor.name + ": " + cudaGetErrorString(packed_status);
+ return false;
+ }
+ }
+ pending.push_back(Pending{&ref, (int) tensor.type, bytes, std::move(data), std::move(packed)});
}
+ if (hc_q8_requested())
+ for (const auto& tensor : gguf.tensors()) {
+ const bool f32_inject = tensor.type == 0 && tensor.name.ends_with("_inject.weight");
+ if ((tensor.type != 8 && !f32_inject) || !hc_q8_name(tensor.name) || tensor.shape.size() != 2) continue;
+ auto found = table.table_.find(tensor.name);
+ if (found == table.table_.end() || found->second.hc_q8 != nullptr) continue;
+ auto& ref = found->second;
+ if (tensor.shape[0] != (uint64_t) ref.ne0 || tensor.shape[1] != (uint64_t) ref.ne1 || ref.ne0 % 32 != 0) {
+ err = "native dense (STRATA_HC_Q8): incompatible matrix " + tensor.name; return false;
+ }
+ const uint64_t bytes = (uint64_t) ref.ne0 / 32 * 34 * (uint64_t) ref.ne1;
+ void* p = nullptr;
+ std::vector<uint8_t> q8;
+ if (f32_inject) q8 = q8_0_of((const float*) gguf.tensor_data(tensor), (uint64_t) ref.ne0 * (uint64_t) ref.ne1);
+ if (cudaMalloc(&p, bytes) != cudaSuccess ||
+ cudaMemcpy(p, f32_inject ? (const void*) q8.data() : gguf.tensor_data(tensor), bytes,
+ cudaMemcpyHostToDevice) != cudaSuccess) {
+ err = "native dense (STRATA_HC_Q8) upload " + tensor.name; return false;
+ }
+ ref.hc_q8 = p;
+ weights_.push_back(p);
+ hc_q8_bytes += bytes;
+ }
}
if (pending.empty()) { err = "native dense: no supported GDN/QSA matrices in supplied shards"; return false; }
void* allocation = nullptr;
@@@ -206,21 -258,13 +281,24 @@@
item.ref->native_data = item.data.get();
item.ref->native_type = item.type;
item.ref->native_q8_1 = scratch.get();
+ if (item.packed) {
+ strata::kernels::native_q8_0_packed_register(item.data.get(), item.packed.get(), (int) item.ref->ne0,
+ (int) item.ref->ne1);
+ packed_keys_.push_back(item.data.get());
+ packed_bytes += item.bytes;
+ ++packed_count;
+ weights_.push_back(item.packed.release());
+ }
weights_.push_back(item.data.release());
}
+ if (packed_count)
+ std::fprintf(stderr, "native dense: STRATA_Q8_PACKED=1 packed %zu Q8_0 matrices for decode (+%.1f MiB)\n",
+ packed_count, packed_bytes / 1048576.0);
scratch_ = scratch.release();
- bytes_ = total;
+ bytes_ = total + hc_q8_bytes;
+ if (hc_q8_requested())
+ std::fprintf(stderr, "strata: STRATA_HC_Q8=1: %.2f GiB of Q8_0 hyper-connection projections for the verify read\n",
+ (double) hc_q8_bytes / 1073741824.0);
return true;
} catch (const std::exception& error) {
err = std::string("native dense: ") + error.what();