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

Prompt path: STRATA_PREFILL_DUMP_R_ALL=FILE, every position's final residual as BF16 (opt-in, for distillation data)

Niko122148d10a4996d7
diff --git a/src/prefill/prefill.cpp b/src/prefill/prefill.cpp
index e4ddd1c1b..83ddd1b51 100644
--- a/src/prefill/prefill.cpp
+++ b/src/prefill/prefill.cpp
@@ -2110,6 +2110,28 @@ bool Prefill::run(const int64_t* tokens, int64_t n, int64_t pos0, std::string& e
std::fclose(f);
}
}
+ if (const char* dump = std::getenv("STRATA_PREFILL_DUMP_R_ALL")) {
+ // S25 (draft-layer distillation data, opt-in): every position's final multi-stream residual as BF16
+ // (round-to-nearest-even), rows in position order, appended across chunks and requests: [n][hc*n_embd]
+ cudaStreamSynchronize(m.cs);
+ if (std::FILE* f = std::fopen(dump, "ab")) {
+ constexpr int64_t kRows = 512;
+ std::vector<float> rows((size_t) (kRows * D));
+ std::vector<uint16_t> out((size_t) (kRows * D));
+ for (int64_t t0 = 0; t0 < T; t0 += kRows) {
+ const int64_t nr = std::min<int64_t>(kRows, T - t0);
+ cudaMemcpy(rows.data(), m.R + t0 * D, (size_t) (nr * D) * 4, cudaMemcpyDeviceToHost);
+ for (int64_t i = 0; i < nr * D; ++i) {
+ uint32_t u;
+ std::memcpy(&u, &rows[(size_t) i], 4);
+ u += 0x7fffu + ((u >> 16) & 1u);
+ out[(size_t) i] = (uint16_t) (u >> 16);
+ }
+ std::fwrite(out.data(), 2, (size_t) (nr * D), f);
+ }
+ std::fclose(f);
+ }
+ }
if (on_chunk || on_stage_chunk) {
const auto toc = Clock::now();
if (cudaStreamSynchronize(m.cs) != cudaSuccess) {