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++

DeepSeek engine: porting guards for the 12 GB work. The matrix-core attention and its dispatch are now inside #if defined(STRATA_USE_HIP) (a CUDA/sm120 build keeps the scalar path and compiles), and a failed DS4_COPY_HUGETLB allocation falls back to the ordinary arena with a warning instead of leaving that layer's experts in place (the flag is safe on a machine with no huge-page pool). HIP build verified: 8K warm 768.7 / 767.4 / 765.6 ppts with DS4_FAST_ATTN=1, ids 5705e1164a, the agent decode's 81d895366c.

Niko1221219beb573607
diff --git a/src/dsv41/ds4_kernels.cu b/src/dsv41/ds4_kernels.cu
index 218fff205..7656f33a6 100644
--- a/src/dsv41/ds4_kernels.cu
+++ b/src/dsv41/ds4_kernels.cu
@@ -1134,6 +1134,8 @@ __global__ void __launch_bounds__(kThreads) sparse_attn_packed_kernel(const floa
// dims) is the A operand of the scores' product, the key tile is B, and the same tile is B of the values' product (the
// heads' softmaxes and their 512-dim outputs are its rows). The QK and PV sums are the matrix cores' order, not
// sparse_attn_packed_kernel's scalar lanes' - hence opt-in (DS4_FAST_ATTN).
+// (HIP only: the CUDA build keeps the scalar kernels, so this and the dispatch below compile out there.)
+#if defined(STRATA_USE_HIP)
constexpr int kFaHeads = 16; // heads a tile (the matrix's rows)
constexpr int kFaKeys = 16; // keys a tile
constexpr int kFaD = 512; // the head dim
@@ -1283,6 +1285,7 @@ __global__ void __launch_bounds__(kThreads) sparse_attn_wmma_kernel(const float*
out[((size_t) t * heads + hb + h) * kFaD + dm] = o[f][i] / dv;
}
}
+#endif // STRATA_USE_HIP
// the ring's rows are kKvFp8: E4M3 codes, a UE8M0 scale per 32 (decoded: exactly the BF16 values they were made from)
__global__ void ring_to_ext_kernel(const uint8_t* __restrict__ ring, uint16_t* __restrict__ ext, long long p0, int n,
@@ -2262,11 +2265,13 @@ void sparse_attn(const float* q, const uint16_t* win, const void* ckv, const int
}
// DS4_FAST_ATTN=1: the chunked prompt's matrix-core path (16 heads a block, a 16-key tile). The decode and the
// verify windows keep the scalar kernels: one query's heads are not the matrix's rows there.
+#if defined(STRATA_USE_HIP)
if (fast_attn_enabled() && a.gen != 0 && T >= kFaKeys && heads % kFaHeads == 0) {
sparse_attn_wmma_kernel<<<dim3(heads / kFaHeads, T), kThreads, 0, s>>>(q, win, (const uint8_t*) ckv, sel, sel_stride,
a, sink, heads, scale, out);
return;
}
+#endif
// packed rows: as many heads a block as still leaves two blocks a multiprocessor (a decoded row serves them all)
int G = heads_per_block; if (G != 1 && G != 2 && G != 4 && G != 8) {
G = 8;
diff --git a/src/dsv41/ds4_model.cu b/src/dsv41/ds4_model.cu
index 02f33a479..f7e29e0ec 100644
--- a/src/dsv41/ds4_model.cu
+++ b/src/dsv41/ds4_model.cu
@@ -4354,6 +4354,16 @@ struct Model::Impl {
for (int X = 0; X < NH && ok; ++X) {
size_t got = bytes;
base[(size_t) X] = (uint8_t*) (huge ? os::huge_alloc(bytes, &got) : node_map(bytes, X, NH));
+ if (huge && base[(size_t) X] == nullptr) { // no pool on this machine: the ordinary arena instead
+ static bool warned = false;
+ if (!warned) {
+ std::fprintf(stderr, "ds4: DS4_COPY_HUGETLB=1 but no 2 MB huge pages are free (reserve them: sysctl "
+ "vm.nr_hugepages=N); using the ordinary arena\n");
+ warned = true;
+ }
+ got = bytes;
+ base[(size_t) X] = (uint8_t*) node_map(bytes, X, NH);
+ }
ok = base[(size_t) X] != nullptr;
if (ok) {
ram_chunks.push_back(base[(size_t) X]);