radiance 1.0.10

- Four-rank Qwen3.8-Flash-Next (PRs 14 and 16 by keptn42): the all-reduce runs fused with the
  hyper-connection's write, and with the MoE gather in front of it, on decode and verify steps on
  the exact wire. The routed experts are split in four classes, so every rank computes the same
  share; moe_gemm_q_mod4 is the new grouped GEMM. The oracle now checks moe_gemm_q on w4nl and
  w5nl containers.
- --embedding-placement and --ngram-placement, each auto | vram | ram | disk. The token embedding
  can live in the pinned host pool, read in place over the link (from PR 17 by mechkbfan). An n-gram
  table can be copied into locked RAM at load instead of read from the container (from PR 15 by
  keptn42). auto takes the fastest tier with room once every other weight is placed, and startup
  prints what it chose and why. A tier that cannot be honoured stops the start with the reason; the
  embedding on disk and the n-gram table in VRAM are refused, since nothing can serve them.
- The expert_tiered placement no longer spends the pinned host pool twice when it falls back to
  layer offload, and a lossy-wire request for a four-rank fused write is a selection miss rather
  than a startup abort.
This commit is contained in:
Deadcode committed 2026-10-05 14:01:30 +02:00
1 parent 2f56e3c477
commit e466fa07e2
56 files changed
+1804 -761

No files matched your search

+16 -55
View File
@@ -20,17 +20,10 @@
* takes one full 32-code step and a masked tail. The table is a file in `dir`, and the filesystem
* there decides how the gather aligns its direct reads: by the alignment the filesystem reports
* (ext4, XFS), or by its block size where it reports none (btrfs, and a tmpfs since Linux 6.6). The
* case says which it ran.
*
* With `resident` the op is asked to copy the table into locked RAM (--ngram-table ram), over a
* table small enough for a default memlock limit. The calls run while the copy is being made, then
* the case waits for the process's locked memory to grow by the table and runs them again, from
* the copy. Where the process may not lock that much the gather says so and keeps reading the file,
* and the case says which of the two it checked; either way every row must be the file's. */
* case says which it ran. */
#include "avx_harness.h"
#include <barrier>
#include <chrono>
#include <cerrno>
#include <cstring>
#include <thread>
@@ -133,23 +126,10 @@ bool ngram_init_case(const Lib& avx) {
return ok && right;
}
/* This process's locked memory, in bytes: VmLck. */
static long long locked_bytes() {
long long kb = 0;
if (std::FILE* f = std::fopen("/proc/self/status", "re")) {
char line[256];
while (std::fgets(line, sizeof line, f)) (void)std::sscanf(line, "VmLck: %lld", &kb);
std::fclose(f);
}
return kb << 10;
}
bool row_gather_case(const Lib& avx, const std::string& dir, int64_t calls, bool verbose,
bool bf16, bool resident) {
bool bf16) {
const RadKernelInfo* r = avx.row("embed_lookup_q");
const char* what = resident ? "embed_lookup_q from a file, resident"
: bf16 ? "embed_lookup_q from a file, bf16 table"
: "embed_lookup_q from a file";
const char* what = bf16 ? "embed_lookup_q from a file, bf16 table" : "embed_lookup_q from a file";
if (!r || !r->launch) {
std::printf(" %s: no row\n", what);
return false;
@@ -170,8 +150,7 @@ bool row_gather_case(const Lib& avx, const std::string& dir, int64_t calls, bool
}
::close((int)ring);
}
/* 2.5 MiB resident, which a default memlock limit of 8 MiB holds. */
const int64_t n = 40, V = int64_t(1) << (resident ? 16 : 21), M = 512, hot = 4096;
const int64_t n = 40, V = int64_t(1) << 21, M = 512, hot = 4096;
const int64_t rb = bf16 ? 2 * n : n;
const float scale = 0.375f;
@@ -259,14 +238,13 @@ bool row_gather_case(const Lib& avx, const std::string& dir, int64_t calls, bool
tensor(const_cast<uint8_t*>(tab), bf16 ? RAD_BF16 : RAD_F8E4M3, {V, n}),
tensor(bf16 ? nullptr : &sc, RAD_BF16, {1}), tensor(out.data(), RAD_BF16, {M, n}),
tensor(nullptr, RAD_I32, {M}) };
RadParam ps[4] = {};
ps[0].key = "M"; ps[0].kind = RAD_P_INT; ps[0].ival = M;
ps[1].key = "n_embd"; ps[1].kind = RAD_P_INT; ps[1].ival = n;
ps[2].key = "n_vocab"; ps[2].kind = RAD_P_INT; ps[2].ival = V;
ps[3].key = "resident"; ps[3].kind = RAD_P_INT; ps[3].ival = 1;
RadParam ps[3] = {};
ps[0].key = "M"; ps[0].kind = RAD_P_INT; ps[0].ival = M;
ps[1].key = "n_embd"; ps[1].kind = RAD_P_INT; ps[1].ival = n;
ps[2].key = "n_vocab"; ps[2].kind = RAD_P_INT; ps[2].ival = V;
RadArgs a{};
a.t = ts.data(); a.n_t = (int)ts.size();
a.p = ps; a.n_p = resident ? 4 : 3;
a.p = ps; a.n_p = 3;
a.rank = rk; a.world_size = 2;
for (int64_t c = 0; c < calls; ++c) {
ts[0].data = &ids[(size_t)(c * M)];
@@ -286,23 +264,9 @@ bool row_gather_case(const Lib& avx, const std::string& dir, int64_t calls, bool
}
}
};
const long long locked0 = locked_bytes();
auto round = [&] {
std::thread t0(rank, 0), t1(rank, 1);
t0.join();
t1.join();
};
round();
/* The copy is made in the background from the first call. Once the locked memory has grown
* by the table it is in place, or about to be, so a short wait more and every call reads it. */
bool copied = false;
if (resident) {
for (int i = 0; i < 300 && !copied; ++i) {
copied = locked_bytes() - locked0 >= V * rb;
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
if (copied) round();
}
std::thread t0(rank, 0), t1(rank, 1);
t0.join();
t1.join();
/* THE ADDRESS RANGE STAYS RESERVED. libavx resolves a table to its file once, by the address
* range of its mapping, for the life of the process (avx_ngram.cpp, table_file) -- the
* engine's container mapping is one. A case that unmapped here could have the next case's file
@@ -315,16 +279,13 @@ bool row_gather_case(const Lib& avx, const std::string& dir, int64_t calls, bool
::unlink(path.c_str());
const bool pass = bad[0] + bad[1] + refused[0] + refused[1] == 0;
const char* from = !resident ? ""
: copied ? ", then as many again from the copy in RAM"
: ", all from the file: the copy was not made here (above)";
if (verbose || !pass)
std::printf(" %s in %s (%s): %lld calls x 2 ranks%s, rows wrong %lld/%lld, "
std::printf(" %s in %s (%s): %lld calls x 2 ranks, rows wrong %lld/%lld, "
"calls refused %lld/%lld %s\n", what, dir.c_str(), granule, (long long)calls,
from, (long long)bad[0], (long long)bad[1], (long long)refused[0],
(long long)bad[0], (long long)bad[1], (long long)refused[0],
(long long)refused[1], pass ? "ok" : "FAIL");
else
std::printf(" %s in %s (%s): %lld calls x 2 ranks%s, every row exact\n", what,
dir.c_str(), granule, (long long)calls, from);
std::printf(" %s in %s (%s): %lld calls x 2 ranks, every row exact\n", what, dir.c_str(),
granule, (long long)calls);
return pass;
}