Files
Deadcode 3b13fd3266 radiance 2.3.0
New models. Thinking Machines' Inkling 2 Mini by gostar (#584-#586): its text backbone and loop, the
release's NVFP4 and MXFP8 checkpoint read by the converter, an int8 trunk, the vision tower, tensor
parallelism, tool calls (with Warzuponus) and an image processor that matches transformers bit for
bit (millaguie). Inkling's routed experts are served in IQR-V4's four-bit trellis (moe_gemm_iqr),
fitted by GPTQ against Hessians the plugin now records (`--calib-dir`), its token embedding in int8
(read in place by embed_lookup), and incoai's DFlash2 drafter in four bits in place of the release's
DSpark. That container, 14.4 GiB with the vision tower, decodes 190 / 427 / 658 tokens a second at 1
/ 4 / 8 streams at tp 2 on two R9700 with `draft-window: adaptive` (code 240 / 550 / 790,
step-by-step arithmetic 358 / 811 / 1116): 19-43% ahead of the same target with the release's DSpark
drafter and 45-83% ahead of the all-int8 container (26.1 GiB, 124 / 263 / 386), at a mean KL of
0.0066 against the release's weights (int8: 0.0042). DeepSeek-V4.1-Flash on 2.x by baKon (#583),
with its vision tower, its IQ1_S and IQ2_XXS containers and linears and experts served in
llama.cpp's own blocks; parts ported from mikoskinen/r9700-exact-serving by Dad_Vibes' fork.
GLM-5.3-Flash on 2.x with its IQR / IQ8R container, an int8 latent cache and four-card serving by
AnimusNull (#566). Gemma 4 dense on EXL3-V3 by keptn42 (#537), on the EXL3 dense rows and
qwen35_exl3 tensor parallelism by Hero422. NVIDIA's 2-bit Nemotron-3.5-Bolt-74B-A9B on one card by
keptn42 (#477). Wan 2.2 TI2V-5B text-to-video and first-frame video by rkcth (#535). LFM3-1.7B on
RDNA3 iGPUs by DokterSmol (#578). Qwen3.8-27B in bf16 with the DFlash2 drafter, and bf16x12, bf16
weights packed losslessly in 12.25 bits, by eddie168 (#577). Int8 experts for drama-3 by morevgalex
(#598).

Speculative decoding. Draft trees for Qwen3.8-27B's DFlash2 drafts by Kezi (#450, opt-in): one card,
+17% at one stream and +14% at two. --draft-max-lanes and --draft-min-accept, two gates on a block
drafter, and --draft-window-ckpt, its window KV kept in the checkpoint slots, by rkcth (#600-#602).
`draft-window: adaptive` verifies each sequence's drafts up to the first one unlikely to be kept. A
verify's rows share each K and V tile in Inkling's attention by gostar (#608): 93 to 118 tokens a
second at a 70k-token prompt on one card.

Generation. Krea 2 instruction edits with one or two references and registered outfill, LoRA on the
image generators with bias deltas and row-mixer adapters applied per request, and MiniMax-H3's
model-declared sparse attention profiles, by rkcth (#534, #542, #543, #605-#609). MiniMax-H3's audio
reference guide pinned from a frame by 1beb (#595). LTX-2's chunk ceiling raised to 40 by Itoash
(#570).

Fleets and memory. memory.queue-reserve, the hardware queues a card keeps ready, by kevinjd (#589).
memory.pinned-numa-node by Foundry (#580). memory.card-headroom-mib on single-model tensor-parallel
budgets by zihaomu (#624). Parked weights rebuilt on the CPU, memory ownership kept across a failed
handoff and quiescent callbacks serialised, by rkcth (#557-#561). A warm load may unload a parked
model (#592); the first card listed chooses the architecture (#458).

Kernels. libr3d's packed dense IQR GEMM and routed IQR expert rows on gfx1100, and libhalo's GEMV
decode for Qwen3.8-Flash-Next's MoE down, by zihaomu (#562, #620, #622). GGML IQ2_XXS and IQ3_XXS
packed on the card by baKon.

Dashboard. KV cache in tokens (in use, capacity now and with all flexible space), live figures
through long prefill steps, step / decode / prefill / acceptance lines without holes, and expert hit
rates only on tiered models. Seven tile and history defects fixed by Noblistic (#597), vision
encoder and per-card hardware figures by davetha (#574), per-LoRA attribution by dowjames (#552).

Fixed. return_tokens / return_token_ids on the OpenAI endpoints (#571). reasoning_effort "none" and
"minimal" reach a template that takes them as levels, by millaguie (#608). Misaligned loads in the
windowed paged attention over an int8 cache (#540). A retired 27B head refused by name (#541).
rad-convert's GPU trellis jobs kept fed, and --reuse-only, by gostar (#575). jinja's tojson takes
sort_keys by Warzuponus (#582). hfget measures file sizes with stat, by kepler_62f (#623). The
tested C++ compiler is stated in the build guide by lowell80 (#551). The codebase was cleaned up:
shared helpers instead of repeated blocks, and the int8 linear, activation and GEMM code no longer
named after the retired fp8 formats.

Inkling 2 Mini is served in one form: IQR-V4 experts with the DFlash2 drafter
(StillDeadcode/inkling-2-mini-iq4r-v4 on Hugging Face, or
data/recipes/inkling2-mini-iq4r-v4.recipe). A container with the release's DSpark drafter, or with
NVFP4, int8 or 4-bit experts, is refused by name and needs converting again.

Plugin ABI 44: out-of-tree plugins need to be rebuilt.

Thanks to @gostar, @baKon, @Dad_Vibes, @AnimusNull, @keptn42, @Hero422, @rkcth, @DokterSmol,
@eddie168, @morevgalex, @Kezi, @1beb, @Itoash, @kevinjd, @Foundry, @zihaomu, @Noblistic, @davetha,
@dowjames, @Warzuponus, @millaguie, @kepler_62f, @lowell80 and @Code000.
2026-11-26 15:28:37 +01:00

217 lines
7.9 KiB
C++

/* directio.cpp -- see directio.h for why the page cache is not wanted here. */
#include "directio.h"
#include "../rad_internal.h"
#include <algorithm>
#include <cerrno>
#include <cstdlib>
#include <cstring>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
namespace rad {
namespace {
/* Bounce buffer size; allocated on first misaligned use only. */
constexpr int64_t kBounceBytes = 1 << 20;
int64_t align_down(int64_t v, int64_t a) { return v / a * a; }
/* Reads up to `bytes`, stopping at end of file. Returns the byte count, or a negative error. */
int64_t pread_some(int fd, void* dst, int64_t bytes, int64_t off) {
int64_t done = 0;
while (done < bytes) {
ssize_t r = ::pread(fd, (uint8_t*)dst + done, (size_t)(bytes - done), (off_t)(off + done));
if (r < 0) {
if (errno == EINTR) continue;
return RAD_E_IO;
}
if (r == 0) break;
done += r;
}
return done;
}
/* Fill `bytes` exactly. A short pread inside the file is a torn read, not a smaller one: end of
* file inside a range the caller said was there is an error. */
int pread_exact(int fd, void* dst, int64_t bytes, int64_t off) {
const int64_t got = pread_some(fd, dst, bytes, off);
if (got < 0) return (int)got;
if (got != bytes) return RAD_E_IO;
dio_progress.fetch_add((uint64_t)bytes, std::memory_order_relaxed);
return RAD_OK;
}
int pwrite_exact(int fd, const void* src, int64_t bytes, int64_t off) {
int64_t done = 0;
while (done < bytes) {
ssize_t w = ::pwrite(fd, (const uint8_t*)src + done, (size_t)(bytes - done),
(off_t)(off + done));
if (w <= 0) {
if (w < 0 && errno == EINTR) continue;
return RAD_E_IO;
}
done += w;
}
return RAD_OK;
}
} /* namespace */
DirectFile::~DirectFile() { close(); }
int DirectFile::open(const char* path, int flags) {
if (!path || !*path) return RAD_E_INVAL;
close();
const bool want_write = (flags & RAD_DIO_WRITE) != 0;
/* O_RDWR whenever writing: a partial-block write reads the block first (see write_at). */
int oflags = want_write ? O_RDWR : O_RDONLY;
if (flags & RAD_DIO_CREATE) oflags |= O_CREAT;
if (flags & RAD_DIO_TRUNC) oflags |= O_TRUNC;
fd_ = ::open(path, oflags | O_DIRECT, 0600);
direct_ = fd_ >= 0;
if (fd_ < 0 && (errno == EINVAL || errno == ENOTSUP || errno == EOPNOTSUPP)) {
/* tmpfs and some network mounts refuse O_DIRECT outright. */
if (flags & RAD_DIO_ALLOW_BUFFERED) {
fd_ = ::open(path, oflags, 0600);
direct_ = false;
if (fd_ >= 0)
RAD_WARN("directio: %s does not support O_DIRECT; opened buffered. Reads will go "
"through the page cache, which is a second copy of every byte and evicts "
"the weight pool's own pages.", path);
} else {
RAD_ERR("directio: cannot open %s with O_DIRECT: %s. The tier directory must be on a "
"filesystem that supports it.", path, std::strerror(errno));
return RAD_E_IO;
}
}
if (fd_ < 0) {
RAD_ERR("directio: cannot open %s: %s", path, std::strerror(errno));
return RAD_E_IO;
}
return RAD_OK;
}
void DirectFile::close() {
if (fd_ >= 0) ::close(fd_);
fd_ = -1;
direct_ = false;
std::free(bounce_);
bounce_ = nullptr;
bounce_bytes_ = 0;
}
int64_t DirectFile::size() const {
if (fd_ < 0) return -1;
struct stat st{};
if (::fstat(fd_, &st) != 0) return -1;
return (int64_t)st.st_size;
}
int DirectFile::bounce_ready() {
if (bounce_) return RAD_OK;
void* p = nullptr;
if (posix_memalign(&p, (size_t)alignment(), (size_t)kBounceBytes) != 0 || !p)
return RAD_E_NOMEM;
bounce_ = (uint8_t*)p;
bounce_bytes_ = kBounceBytes;
return RAD_OK;
}
/* ------------------------------------------------------------------ read */
int DirectFile::read_at(void* dst, int64_t off, int64_t bytes) {
if (fd_ < 0) return RAD_E_STATE;
if (!dst || off < 0 || bytes < 0) return RAD_E_INVAL;
if (bytes == 0) return RAD_OK;
const int64_t A = alignment();
const bool aligned = (off % A) == 0 && (bytes % A) == 0 &&
((uintptr_t)dst % (uintptr_t)A) == 0;
/* Fast path: one pread straight into the caller's pinned buffer. Every .rad extent lands here
* (movement units and rad_dev_alloc pools are both RAD_ALIGN_UNIT-aligned). */
if (aligned) return pread_exact(fd_, dst, bytes, off);
/* O_DIRECT rejects unaligned transfers with EINVAL, so read an aligned superset through the
* bounce and copy out. This serves file tails and header/footer reads, never the mover; a
* step-path read landing here indicates a layout bug. */
RAD_TRY(bounce_ready());
const int64_t lo = align_down(off, A);
const int64_t hi = align_up(off + bytes, A);
for (int64_t base = lo; base < hi; base += bounce_bytes_) {
const int64_t span = std::min(bounce_bytes_, hi - base);
const int64_t s = std::max(off, base);
const int64_t e = std::min(off + bytes, base + span);
if (e <= s) continue;
const int64_t got = pread_some(fd_, bounce_, span, base);
if (got < 0) return (int)got;
/* A short read is fine only if it still covers the requested slice. */
if (got < e - base) return RAD_E_IO;
std::memcpy((uint8_t*)dst + (s - off), bounce_ + (s - base), (size_t)(e - s));
}
return RAD_OK;
}
int DirectFile::read_covering(void* dst, int64_t off, int64_t bytes, int64_t need) {
if (fd_ < 0) return RAD_E_STATE;
if (!dst || off < 0 || bytes < 0 || need < 0 || need > bytes) return RAD_E_INVAL;
const int64_t A = alignment();
const bool aligned = (off % A) == 0 && (bytes % A) == 0 &&
((uintptr_t)dst % (uintptr_t)A) == 0;
if (!aligned) return read_at(dst, off, need);
const int64_t got = pread_some(fd_, dst, bytes, off);
if (got < 0) return (int)got;
return got >= need ? RAD_OK : RAD_E_IO;
}
/* ------------------------------------------------------------------ write */
/* Aligned writes go straight through; anything else is a read-modify-write of whole blocks. */
int DirectFile::write_at(const void* src, int64_t off, int64_t bytes) {
if (fd_ < 0) return RAD_E_STATE;
if (!src || off < 0 || bytes < 0) return RAD_E_INVAL;
if (bytes == 0) return RAD_OK;
const int64_t A = alignment();
const bool aligned = (off % A) == 0 && (bytes % A) == 0 &&
((uintptr_t)src % (uintptr_t)A) == 0;
if (aligned) return pwrite_exact(fd_, src, bytes, off);
RAD_TRY(bounce_ready());
const int64_t old_size = size();
if (old_size < 0) return RAD_E_IO;
const int64_t lo = align_down(off, A);
const int64_t hi = align_up(off + bytes, A);
for (int64_t base = lo; base < hi; base += bounce_bytes_) {
const int64_t span = std::min(bounce_bytes_, hi - base);
/* Read-modify-write the whole chunk, including fully covered interior blocks. The extra
* reads are deliberate: this path is for correctness at boundaries, not throughput. */
const int64_t got = pread_some(fd_, bounce_, span, base);
if (got < 0) return (int)got;
if (got < span) std::memset(bounce_ + got, 0, (size_t)(span - got));
const int64_t s = std::max(off, base);
const int64_t e = std::min(off + bytes, base + span);
if (e > s)
std::memcpy(bounce_ + (s - base), (const uint8_t*)src + (s - off), (size_t)(e - s));
RAD_TRY(pwrite_exact(fd_, bounce_, span, base));
}
/* The last chunk padded the file to a block boundary; truncate back to the real end. */
const int64_t want = std::max(old_size, off + bytes);
if (size() > want && ::ftruncate(fd_, (off_t)want) != 0) return RAD_E_IO;
return RAD_OK;
}
} /* namespace rad */