radiance 1.7.0

- every model serves without a GPU: libavx covers every op, so `--kernels libavx` alone serves
  every shipped container
- Qwen3-ASR (zivius): speech to text on /v1/audio/transcriptions and live over /v1/realtime
- /v1/messages works with Claude Code as it ships (gearwave00001)
- a long agent conversation keeps its cached history when the client rewrites its last turn
  (manueloverride)
- a stream's first event goes out with the first token, so llama-benchy measures prefill right
- opt-in --prefill-interleave (Smellyyyy, baKon) and --prefill-span (keptn42)
- four-rank TP releases the link early; four-rank selftests and docs/TP4.md (goodman-b)
- NVFP4 and FP8 compressed-tensors imports (devmilan); tools/rad-export for finetunes and LoRA
  adapters (baKon)
- many fixes, among them lost tokens on stop strings under concurrency, keep-alive, MiniCPM5 tool
  arguments and the CPU's vision and audio encoders
- plugin ABI 17 and changed op schemas: out-of-tree plugins must be rebuilt
This commit is contained in:
Deadcode committed 2026-10-16 18:25:18 +02:00
1 parent b068190326
commit 1e968f6e1d
739 files changed
+128447 -84632

No files matched your search

+22 -46
View File
@@ -15,30 +15,12 @@
namespace rad {
namespace {
/* The bounce is one megabyte, allocated on first misaligned use and never on the aligned path.
* Big enough that a misaligned read of a whole weight is a handful of syscalls; small enough that
* a DirectFile nobody misuses costs nothing. */
/* 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; }
/* Fill `bytes` exactly. A short pread inside the file is a torn read, not a smaller one. */
int pread_exact(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) return RAD_E_IO; /* end of file inside a range the caller said was there */
done += r;
}
return RAD_OK;
}
/* As much as the file has, which is what the aligned superset of a misaligned tail asks for.
* Negative is an error; otherwise the byte count. */
/* 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) {
@@ -53,6 +35,14 @@ int64_t pread_some(int fd, void* dst, int64_t bytes, int64_t off) {
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;
return got == bytes ? RAD_OK : RAD_E_IO;
}
int pwrite_exact(int fd, const void* src, int64_t bytes, int64_t off) {
int64_t done = 0;
while (done < bytes) {
@@ -76,9 +66,7 @@ int DirectFile::open(const char* path, int flags) {
close();
const bool want_write = (flags & RAD_DIO_WRITE) != 0;
/* O_RDWR whenever writing, even if the caller only said RAD_DIO_WRITE: a write that does not
* cover a whole block has to read the block first (see write_at), and O_WRONLY would turn that
* into an EBADF at the worst possible moment. */
/* 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;
@@ -87,7 +75,7 @@ int DirectFile::open(const char* path, int flags) {
direct_ = fd_ >= 0;
if (fd_ < 0 && (errno == EINVAL || errno == ENOTSUP || errno == EOPNOTSUPP)) {
/* The filesystem, not the file: tmpfs and some network mounts refuse O_DIRECT outright. */
/* tmpfs and some network mounts refuse O_DIRECT outright. */
if (flags & RAD_DIO_ALLOW_BUFFERED) {
fd_ = ::open(path, oflags, 0600);
direct_ = false;
@@ -145,19 +133,13 @@ int DirectFile::read_at(void* dst, int64_t off, int64_t bytes) {
const bool aligned = (off % A) == 0 && (bytes % A) == 0 &&
((uintptr_t)dst % (uintptr_t)A) == 0;
/* THE PATH THAT MATTERS. One pread, straight into the caller's pinned buffer, no intermediate
* copy anywhere -- which is what makes the mover able to DMA from it (spec §5.4). Every extent
* the .rad container describes lands here, because the container aligns its movement units to
* RAD_ALIGN_UNIT and rad_dev_alloc aligns its pools to the same. */
/* 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);
/* THE ONLY BOUNCE IN THE ENGINE'S READ PATH, and it is here because O_DIRECT gives no
* alternative: the kernel will EINVAL a transfer whose offset, length or buffer is not
* block-aligned, so an unaligned extent can either be read through an aligned superset and
* copied out, or not read at all. It is acceptable here and nowhere else for one reason --
* this path is not the mover's. It serves the tail of a file whose length is not a block
* multiple, and callers reading a header or a footer rather than a movement unit. Anything on
* the step path that finds itself here has a layout bug, not a performance problem. */
/* 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);
@@ -170,9 +152,7 @@ int DirectFile::read_at(void* dst, int64_t off, int64_t bytes) {
const int64_t got = pread_some(fd_, bounce_, span, base);
if (got < 0) return (int)got;
/* A short read is only survivable when the file ends past the slice the caller asked for.
* Otherwise the caller named bytes that are not in the file, which is RAD_E_IO and not a
* partial success (see read_at's contract in the header). */
/* 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));
}
@@ -181,8 +161,7 @@ int DirectFile::read_at(void* dst, int64_t off, int64_t bytes) {
/* ------------------------------------------------------------------ write */
/* The same shape as read_at -- one fast path for whole aligned blocks, and a read-modify-write for
* anything that does not cover a whole block. */
/* 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;
@@ -201,10 +180,8 @@ int DirectFile::write_at(const void* src, int64_t off, int64_t bytes) {
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 blocks the request covers completely. That
* is a wasted read per interior block and it is deliberate: the branchless version is
* short enough to be obviously correct, and this path exists for correctness at a boundary,
* not for throughput. The aligned path above is the one that has to be fast. */
/* 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));
@@ -216,8 +193,7 @@ int DirectFile::write_at(const void* src, int64_t off, int64_t bytes) {
RAD_TRY(pwrite_exact(fd_, bounce_, span, base));
}
/* The last chunk padded the file out to a block boundary. Cut it back, so size() reports what
* was actually written and a later read_at of the tail sees the real end of file. */
/* 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;