Merge f-ink-025 (db3106ecb4) into int-0225

Conflict in docs/DETAILS.md (the conversation-cache paragraph): kept the new f-ink-025 text (room made before a write, earlier turns first, shutdown writes at most one cap) and the sentence added by f-ink-025-term at its end (Strata starts the CUDA engine with it by default, conversation_cache_gb).
This commit is contained in:
Niko1221 committed 2026-12-02 17:19:44 +01:00
commit d2c6574897
12 files changed
+353 -94

No files matched your search

+1 -1
View File
@@ -1804,7 +1804,7 @@ mean KL from the stock model 0.063 nats (max 4.1), perplexity +15% on code, +2.3
## Inkling-2-Mini conversation cache on disk (CUDA, opt-in)
`strata-inkling --serve --conversation-cache-dir DIR [--conversation-cache-gb N]` (default cap 8 GB) writes a conversation to a file in `DIR` when another request is about to overwrite its slot and when the engine stops, and the first request that continues it reads it back, also after a restart or an app update: the first turn of an old chat reads only its new text. A file holds the conversation's prompt-end checkpoint and the global K/V of its tokens (about 20 KB per token at the default FP8 K/V, 350 MB at 16K tokens, 613 MB at 32K), bound to the engine version, the model file, the K/V type and layout. A file of another model, engine build or K/V layout, a damaged or cut file is ignored and removed; the folder is capped and the least recently used files go first. A chat with pictures is restored only for the same pictures (a SHA-256 of their pixels). With a layer split or the elastic 1M tiers no file is written or read (one log line says so). A hard kill of the engine writes nothing new; the files written earlier stay. Measured on an RTX A6000 (SQ-20 v2): the first token of turn 2 after a restart 0.34 / 0.48 / 0.78 s at 8K / 16K / 32K tokens, against 3.4 / 7.2 / 15.8 s when the engine reads the prompt again. Other backends (HIP, Metal, SYCL) do not export a conversation yet. Strata starts the CUDA engine with it by default: the folder is `conversations/<model file name>` under Strata's state folder (`%LOCALAPPDATA%\Strata` on Windows, `$XDG_STATE_HOME/strata` or `~/.local/state/strata` elsewhere), one folder per model, the cap 8 GB. Set `"conversation_cache_gb": 0` in the run config (or in the Settings view) to turn it off, another number to change the cap; `--conversation-cache-dir` among your own engine arguments wins. The folder holds conversations: delete it to free the space.
`strata-inkling --serve --conversation-cache-dir DIR [--conversation-cache-gb N]` (default cap 8 GB) writes a conversation to a file in `DIR` when another request is about to overwrite its slot and when the engine stops, and the first request that continues it reads it back, also after a restart or an app update: the first turn of an old chat reads only its new text. A file holds the conversation's prompt-end checkpoint and the global K/V of its tokens (about 20 KB per token at the default FP8 K/V, 350 MB at 16K tokens, 613 MB at 32K), bound to the engine version, the model file, the K/V type and layout. A file of another model, engine build or K/V layout, a damaged or cut file is ignored and removed; the folder is capped: room is made before a file is written (so a conversation of about 2.4 GB at 128K tokens never needs the folder to hold the old files and the new one at once), the earlier turns of the same chat go first, then the least recently used files; a conversation larger than the cap is not written, and when the engine stops it writes at most one cap's worth. A chat with pictures is restored only for the same pictures (a SHA-256 of their pixels). With a layer split or the elastic 1M tiers no file is written or read (one log line says so). A hard kill of the engine writes nothing new; the files written earlier stay. Measured on an RTX A6000 (SQ-20 v2): the first token of turn 2 after a restart 0.34 / 0.48 / 0.78 s at 8K / 16K / 32K tokens, against 3.4 / 7.2 / 15.8 s when the engine reads the prompt again. Other backends (HIP, Metal, SYCL) do not export a conversation yet. Strata starts the CUDA engine with it by default: the folder is `conversations/<model file name>` under Strata's state folder (`%LOCALAPPDATA%\Strata` on Windows, `$XDG_STATE_HOME/strata` or `~/.local/state/strata` elsewhere), one folder per model, the cap 8 GB. Set `"conversation_cache_gb": 0` in the run config (or in the Settings view) to turn it off, another number to change the cap; `--conversation-cache-dir` among your own engine arguments wins. The folder holds conversations: delete it to free the space.
## Conversation cache copies on a slow host link (CUDA, opt-in)
+2 -1
View File
@@ -10,7 +10,7 @@ debugging and are kept in `terminal/data/settings-register.json`.
A number or a word is set like any environment variable, for example `STRATA_KVA=1`. In the Terminal, `strata launch --set NAME=value`
puts it in the model's run configuration.
## Switches you can turn on (454)
## Switches you can turn on (455)
Off unless you set them. The last column says where each one is described.
@@ -133,6 +133,7 @@ Off unless you set them. The last column says where each one is described.
| `STRATA_INK_ATTN_PROBE_MAXREC` | number | NVIDIA and AMD | - |
| `STRATA_INK_ATTN_PROBE_MINCTX` | number | NVIDIA and AMD | - |
| `STRATA_INK_ATTN_PROBE_NEEDLE` | on / off | NVIDIA and AMD | - |
| `STRATA_INK_DF2_RING_PLAN` | on / off | NVIDIA and AMD | - |
| `STRATA_INK_DFLASH2_FORCE` | on / off | NVIDIA and AMD | [MODELS.md](MODELS.md) |
| `STRATA_INK_DYNAMIC_PINNED_MIB` | number | NVIDIA and AMD | [DETAILS.md](DETAILS.md) |
| `STRATA_INK_ELASTIC_1M` | text | NVIDIA and AMD | [INKLING_SM120.md](INKLING_SM120.md) |
+3
View File
@@ -322,4 +322,7 @@ if(STRATA_INK_BUILD_PREFIX_TESTS)
add_executable(ink_gov_test ink_gov_test.cpp)
add_test(NAME ink_gov COMMAND ink_gov_test)
set_tests_properties(ink_gov PROPERTIES TIMEOUT 30)
add_executable(ink_df2_budget_test ink_df2_budget_test.cpp)
add_test(NAME ink_df2_budget COMMAND ink_df2_budget_test)
set_tests_properties(ink_df2_budget PROPERTIES TIMEOUT 30)
endif()
+1 -2
View File
@@ -576,8 +576,7 @@ struct InkDFlash2 {
bool room = true;
if (s >= 1) {
size_t vf = 0, vt = 0;
const size_t margin = (s >= 8) ? (1024ull << 20) : (128ull << 20);
room = ink_cuda_mem_info(&vf, &vt) == cudaSuccess && vf > 2 * one + margin;
room = ink_cuda_mem_info(&vf, &vt) == cudaSuccess && ink2::df2_ring_room(vf, one, s); // > 2 rings + 128 MiB (slots 1..7) or + 1 GiB (8 and up): ink_df2_budget.h
}
if (!room || cudaMalloc(&k, one) != cudaSuccess || cudaMalloc(&v, one) != cudaSuccess) {
(void)cudaGetLastError();
+12 -2
View File
@@ -9,6 +9,8 @@
#include <cstdlib>
#include <string>
#include "../ink_df2_budget.h"
namespace strata::ink {
inline std::string& df2_model_path() {
@@ -144,8 +146,16 @@ inline double df2_big_mib(Df2Variant v) {
}
// what the drafter holds on a small card: the bf16 rest (fc, K/V, convolutions, selector, norms: 112 MiB), the block weights, rings (42 MiB a slot, up to 8), scratch and a margin
inline size_t df2_total_mib(Df2Variant v, int slots) {
return (size_t)((df2_f32_path() ? 224.0 : 112.0) + df2_big_mib(v) + 42.0 * (double)(slots < 8 ? slots : 8) + 120.0);
// ring_slots < 0: the rings of the first 8 slots (the shipped rule); >= 0: that many (STRATA_INK_DF2_RING_PLAN, ink_df2_budget.h df2_planned_rings)
inline size_t df2_total_mib(Df2Variant v, int slots, int ring_slots = -1) {
const int rings = ring_slots >= 0 ? ring_slots : (slots < 8 ? slots : 8);
return (size_t)((df2_f32_path() ? 224.0 : 112.0) + df2_big_mib(v) + 42.0 * (double)rings + 120.0);
}
// The rings the K/V planner reserves room for at this slot count on this card (8 unless STRATA_INK_DF2_RING_PLAN=1: then every slot the drafter serves).
inline int df2_planned_rings_here(int max_slots, size_t total_vram, bool all_sf4_vram) {
const char* e = std::getenv("STRATA_INK_DFLASH2_SLOTS");
return ink2::df2_planned_rings(max_slots, all_sf4_vram || (total_vram > 0 && total_vram < (24ull << 30)), e ? std::atoi(e) : 0, ink2::df2_ring_plan_on());
}
// STRATA_INK_DFLASH2 (a file, or a folder holding model.safetensors / dflash2.safetensors), else a sidecar in the model's folder. "" = none found.
+2 -2
View File
@@ -2993,7 +2993,7 @@ struct InkCudaRunner {
// the small compact reserve was sized with the FP8 KV: COMPACT_KV=0 (FP16 KV) left 43 MiB and crashed at the first top-k, so it takes the shipped reserve
// DFlash 2 as the drafter (STRATA_INK_DRAFTER=dflash2): its weights, rings and scratch come out of what the K/V may take
const size_t df2_extra = df2_replaces_dspark(m.path) ? ((opt5060_r.compact_vram && m.all_sf4_vram) ? df2_real_bytes(max_slots)
: ((df2_total_mib(df2_variant(vtot < (24ull << 30)), max_slots) + 180) << 20)) : 0ull;
: ((df2_total_mib(df2_variant(vtot < (24ull << 30)), max_slots, df2_planned_rings_here(max_slots, vtot, m.all_sf4_vram)) + 180) << 20)) : 0ull;
// COMPACT_HYBRID that still placed every expert on the card (a non-SF4 pack such as SQ-15 on a 16 GB card): the compact trunk is built, but every
// workspace after the K/V keeps its non-all_sf4_vram size (moe_ws, d_w_scratch, d_ctrl_*, d_img_emb, the BF16 screen, cuBLAS' own workspace, no slab),
// so it takes its own reserve (strata/core/ink_kv_reserve.hpp) plus the card's rtx_extra_res, and the 128 MiB floor below. Gated to the one case it was measured
@@ -3405,7 +3405,7 @@ struct InkCudaRunner {
if (m.man.has_dspark && df2_replaces_dspark(m.path)) {
size_t vf_l = 0, vt_l = 0;
if (ink_cuda_mem_info(&vf_l, &vt_l, m.primary_gpu) == cudaSuccess)
fp8_later = (df2_total_mib(df2_variant(vt_l < (24ull << 30)), max_slots) + 256ull) << 20;
fp8_later = (df2_total_mib(df2_variant(vt_l < (24ull << 30)), max_slots, df2_planned_rings_here(max_slots, vt_l, m.all_sf4_vram)) + 256ull) << 20;
}
fp8_eng.init(m, max_batch, st, fp8_later);
}
+30 -1
View File
@@ -91,6 +91,7 @@ public:
std::snprintf(name, sizeof name, "conv-%016llx.inc", static_cast<unsigned long long>(key));
const fs::path final_path = fs::path(dir_) / name;
const fs::path tmp_path = fs::path(dir_) / (std::string(name) + ".tmp");
make_room(need, final_path, tokens, pics); // before the write: a file near the cap (a 128K conversation is about 2.4 GB) never needs the folder to hold the old files and the new one at once
FILE* f = std::fopen(tmp_path.string().c_str(), "wb");
if (!f) { err = "cannot write " + tmp_path.string(); return false; }
bool ok = write_header(f, tokens, pics, payload, payload_bytes);
@@ -105,6 +106,7 @@ public:
e.path = final_path; e.tokens = tokens; e.pics = pics;
e.bytes = static_cast<uint64_t>(fs::file_size(final_path, ec));
e.stamp = ++clock_;
written_ += e.bytes;
entries_.push_back(std::move(e));
evict_to(cap_);
return true;
@@ -209,6 +211,31 @@ private:
return true;
}
/// Frees room for a file of "need" bytes: the file of the same key is replaced (not counted), then files this conversation supersedes (their tokens are a strict prefix of it,
/// same pictures: the chat's earlier turns), then the least recently used.
void make_room(uint64_t need, const std::filesystem::path& final_path, const std::vector<int32_t>& tokens, const std::vector<PicSpan>& pics) {
std::error_code ec;
auto total_without = [&]() { uint64_t t = 0; for (const auto& e : entries_) if (e.path != final_path) t += e.bytes; return t; };
while (total_without() + need > cap_) {
size_t victim = entries_.size();
for (size_t i = 0; i < entries_.size(); ++i) {
const Entry& e = entries_[i];
if (e.path == final_path || e.tokens.size() >= tokens.size()) continue;
if (!std::equal(e.tokens.begin(), e.tokens.end(), tokens.begin())) continue;
const int n = static_cast<int>(e.tokens.size());
if (pics_match(e.pics, n, pics) && pics_match(pics, n, e.pics)) { victim = i; break; }
}
if (victim == entries_.size()) {
for (size_t i = 0; i < entries_.size(); ++i)
if (entries_[i].path != final_path && (victim == entries_.size() || entries_[i].stamp < entries_[victim].stamp)) victim = i;
}
if (victim == entries_.size()) break;
std::filesystem::remove(entries_[victim].path, ec);
entries_.erase(entries_.begin() + static_cast<long>(victim));
++evicted_;
}
}
void evict_to(uint64_t cap) {
std::error_code ec;
while (!entries_.empty() && total_bytes() > cap) {
@@ -222,10 +249,12 @@ private:
public:
size_t evicted() const { return evicted_; }
/// Bytes written by save() since the object was made (the serve loop's shutdown pass stops after one cap's worth).
uint64_t written_bytes() const { return written_; }
private:
std::string dir_, identity_;
uint64_t cap_ = 0, id_hash_ = 0, clock_ = 0;
uint64_t cap_ = 0, id_hash_ = 0, clock_ = 0, written_ = 0;
size_t dropped_ = 0, evicted_ = 0;
std::vector<Entry> entries_;
};
@@ -121,6 +121,44 @@ int main() {
CHECK(d.open(root.string(), 1u << 20, ID, err));
CHECK(fs::exists(root / "notes.txt") && !fs::exists(root / "conv-0000000000000001.inc.tmp"));
}
// files near the cap (a 128K conversation is about 2.4 GB against an 8 GB cap): room is made BEFORE the write, the chat's earlier turns go first, the folder never holds more than the cap
{
const fs::path r2 = root / "near";
auto folder_bytes = [&]() { uint64_t t = 0; for (const auto& e : fs::directory_iterator(r2)) if (e.is_regular_file()) t += e.file_size(); return t; };
const uint64_t CAP = 100000;
ink2::ConvDisk d;
CHECK(d.open(r2.string(), CAP, ID, err));
// two files of 60 KB do not fit together: the older one goes, the newer is written, the total stays under the cap
CHECK(d.save(seq(1, 100), {}, blob(60000, 1).data(), 60000, err));
CHECK(d.save(seq(500, 100), {}, blob(60000, 2).data(), 60000, err));
CHECK(d.count() == 1 && d.total_bytes() <= CAP && folder_bytes() <= CAP);
CHECK(!d.has(seq(1, 100), {}) && d.has(seq(500, 100), {}));
// the same conversation written again with a file that alone is nearly the cap: replaced, not evicted by itself
CHECK(d.save(seq(500, 100), {}, blob(95000, 3).data(), 95000, err));
CHECK(d.count() == 1 && folder_bytes() <= CAP);
// larger than the cap: refused, the stored file stays
CHECK(!d.save(seq(900, 100), {}, blob(CAP, 4).data(), CAP, err) && d.count() == 1 && d.has(seq(500, 100), {}));
CHECK(!fs::exists(r2 / "conv-0000000000000000.inc.tmp"));
for (const auto& e : fs::directory_iterator(r2)) CHECK(e.path().extension() != ".tmp");
}
{
const fs::path r3 = root / "supersede";
const uint64_t CAP = 100000;
ink2::ConvDisk d;
CHECK(d.open(r3.string(), CAP, ID, err));
CHECK(d.save(seq(1, 100), {}, blob(30000, 1).data(), 30000, err)); // turn 1
CHECK(d.save(seq(1, 150), {}, blob(40000, 2).data(), 40000, err)); // turn 2 (turn 1 is a prefix of it)
CHECK(d.count() == 2);
CHECK(d.has(seq(1, 100), {})); // the shorter file was used last: plain LRU would now evict turn 2
CHECK(d.save(seq(1, 200), {}, blob(45000, 3).data(), 45000, err)); // turn 3 does not fit next to both
CHECK(d.count() == 2 && d.total_bytes() <= CAP);
CHECK(!d.has(seq(1, 100), {})); // the superseded turn 1 went
CHECK(d.has(seq(1, 150), {}) && d.has(seq(1, 200), {})); // turns 2 and 3 stay
// a different chat does not supersede: its files are only evicted by use
CHECK(d.save(seq(700, 100), {}, blob(30000, 4).data(), 30000, err));
CHECK(d.total_bytes() <= CAP && d.has(seq(700, 100), {}));
CHECK(d.written_bytes() > 0);
}
fs::remove_all(root);
if (failed) { std::fprintf(stderr, "ink_conv_disk_test: %d failed\n", failed); return 1; }
std::printf("ink_conv_disk_test: ok\n");
+69
View File
@@ -0,0 +1,69 @@
// ink_df2_budget.h - the drafter (DFlash 2) context-ring budget, host-only (0.2.25 item 25).
//
// DFlash 2 keeps a context ring of 2 x 20.5 MiB (K and V, "41 MiB") for every slot it drafts for. The runner's K/V planner (ink_runner.cuh) reserves room for the rings of the
// FIRST 8 slots only (df2_total_mib); the rings of slots 8 and up are taken lazily at the slot's first use, only while more than 2 x 20.5 MiB + 1 GiB stay free (ensure_slot), and a
// slot that is refused has no drafter for the rest of the run ("slot_dead"). On an RTX 5090 at 64 slots the K/V planner leaves 1,910 MiB free after the runner and the drafter
// started; the rings of slots 8 to 24 take 697 MiB, the engine's other lazily taken buffers some more, and slots 25 to 31 (the drafter has 32 slots on a 32 GB card) were refused in
// the 11-27 bench runs (rel0223/bench71/results/5090-adm1 and 5090-c1a: "no GPU memory for slot 25's context ring (41 MiB); that slot does not draft").
// STRATA_INK_DF2_RING_PLAN=1 makes the planner count the rings of every slot the drafter serves (up to 32 on a card of 24 GB and more, 16 below), so the K/V split leaves their room
// and the lazy rule above keeps its 1 GiB for the rest of the engine. Default off until the 5090 C64 A/B (kDf2RingPlanDefault is the one switch). Drafting is exact: the greedy
// tokens do not depend on which slots draft; only the speed does.
#pragma once
#include <algorithm>
#include <cstddef>
#include <cstdlib>
#include <cstring>
namespace ink2 {
inline constexpr bool kDf2RingPlanDefault = false;
inline constexpr int kDf2StartRings = 8; // rings taken at start-up, inside the planner's reserve (df2_total_mib)
inline constexpr std::size_t kDf2StartMargin = 128ull << 20; // free memory kept after a ring of slots 1..7
inline constexpr std::size_t kDf2LateMargin = 1024ull << 20; // free memory kept after a ring of slots 8 and up (the multi-slot paths allocate working buffers lazily)
/// STRATA_INK_DF2_RING_PLAN: "1" on, "0" off, anything else the default.
inline bool df2_ring_plan_on() {
const char* e = std::getenv("STRATA_INK_DF2_RING_PLAN");
if (e && std::strcmp(e, "1") == 0) return true;
if (e && std::strcmp(e, "0") == 0) return false;
return kDf2RingPlanDefault;
}
/// How many slots the drafter serves (ink_dspark.cuh init_dflash2): every slot up to 32 on a card of 24 GB and more, 16 on a smaller one or the all-SF4 compact layout;
/// `env_cap` is STRATA_INK_DFLASH2_SLOTS (0 = not set).
inline int df2_drafter_slots(int max_slots, bool small_card, int env_cap) {
int slots = std::max(1, max_slots);
if (env_cap > 0) return std::max(1, std::min(slots, env_cap));
return std::min(slots, small_card ? 16 : 32);
}
/// How many rings the K/V planner reserves room for: the first 8 slots (the shipped rule), or with `plan_all` every slot the drafter serves.
inline int df2_planned_rings(int max_slots, bool small_card, int env_cap, bool plan_all) {
const int slots = std::max(1, max_slots);
if (!plan_all) return std::min(slots, kDf2StartRings);
return std::max(std::min(slots, kDf2StartRings), df2_drafter_slots(max_slots, small_card, env_cap));
}
/// The rule of InkDFlash2::ensure_slot: slot 0 always takes its ring; slot s >= 1 takes it only while more than a ring pair plus its margin is free.
inline bool df2_ring_room(std::size_t free_bytes, std::size_t one_ring_bytes, int slot) {
if (slot < 1) return true;
const std::size_t margin = (slot >= kDf2StartRings) ? kDf2LateMargin : kDf2StartMargin;
return free_bytes > 2 * one_ring_bytes + margin;
}
/// Replays the lazy ring sequence of slots `first`..`last` (inclusive) from `free_bytes` free memory, minus `other_lazy_bytes` that other lazily allocated buffers take before the
/// first of them; returns how many consecutive slots from `first` get a ring (a refused slot is dead for good, and free memory only falls, so the rest are refused too).
inline int df2_rings_that_fit(std::size_t free_bytes, std::size_t other_lazy_bytes, std::size_t one_ring_bytes, int first, int last) {
std::size_t f = free_bytes > other_lazy_bytes ? free_bytes - other_lazy_bytes : 0;
int n = 0;
for (int s = first; s <= last; ++s) {
if (!df2_ring_room(f, one_ring_bytes, s)) break;
const std::size_t pair = 2 * one_ring_bytes;
f = f > pair ? f - pair : 0;
++n;
}
return n;
}
} // namespace ink2
@@ -0,0 +1,69 @@
#include "ink_df2_budget.h"
#include <cstdio>
#include <cstdlib>
#ifdef _WIN32
#define SETENV(k, v) _putenv_s(k, v)
#define UNSETENV(k) _putenv_s(k, "")
#else
#define SETENV(k, v) setenv(k, v, 1)
#define UNSETENV(k) unsetenv(k)
#endif
int main() {
using namespace ink2;
int bad = 0;
auto chk = [&](bool c, const char* what) { if (!c) { std::fprintf(stderr, "FAIL: %s\n", what); ++bad; } };
const std::size_t MiB = 1ull << 20;
const std::size_t one = 41 * MiB / 2; // K ring or V ring: 20.5 MiB, "41 MiB" a slot
// the rule of ensure_slot
chk(df2_ring_room(0, one, 0), "slot 0 always takes its ring");
chk(df2_ring_room(200 * MiB, one, 1), "slot 1 with 200 MiB free: 41 + 128 margin fit");
chk(!df2_ring_room(169 * MiB, one, 1), "slot 1 with 169 MiB free: the 128 MiB margin would be broken (needs more than 169)");
chk(df2_ring_room(170 * MiB, one, 1), "slot 1 with 170 MiB free");
chk(!df2_ring_room(1065 * MiB, one, 8), "slot 8 needs MORE than 41 + 1024 MiB free");
chk(df2_ring_room(1066 * MiB, one, 8), "slot 8 with 1066 MiB free");
chk(!df2_ring_room(500 * MiB, one, 8) && df2_ring_room(500 * MiB, one, 7), "the 1 GiB margin starts at slot 8");
// the 5090 C64 runs of 11-27 (rel0223/bench71/results): 1,910 MiB free after the runner and the drafter started, slots 8..31 take their rings lazily.
// adm1 refused slots 25..31 (17 rings fit), c1a slot 27 and up (19 fit): the other lazily taken buffers between the two points account for 66 to 189 MiB.
chk(df2_rings_that_fit(1910 * MiB, 160 * MiB, one, 8, 31) == 17, "5090 C64 today, 160 MiB of other lazy buffers: slots 8..24 fit, 25..31 do not (the adm1 log)");
chk(df2_rings_that_fit(1910 * MiB, 80 * MiB, one, 8, 31) == 19, "5090 C64 today, 80 MiB of other lazy buffers: slots 8..26 fit, 27..31 do not (the c1a log)");
chk(df2_rings_that_fit(1910 * MiB, 190 * MiB, one, 8, 31) == 16, "190 MiB: one ring fewer");
chk(df2_rings_that_fit(1910 * MiB, 65 * MiB, one, 8, 31) == 20, "65 MiB: one ring more");
// the planner reserves room for the rings of slots 8..31 when asked: 24 more rings of 41 MiB (42 in df2_total_mib's round number) stay free at the start
const std::size_t extra = (std::size_t)(24 * 42) * MiB;
chk(df2_rings_that_fit(1910 * MiB + extra, 160 * MiB, one, 8, 31) == 24, "with the rings in the plan every slot 8..31 gets one");
chk(df2_rings_that_fit(1910 * MiB + extra, 800 * MiB, one, 8, 31) == 24, "also with 800 MiB of other lazy buffers");
chk(df2_rings_that_fit(1910 * MiB + extra, 1900 * MiB, one, 8, 31) < 24, "and not when the other buffers eat everything (the margin rule still protects the engine)");
// how many rings the planner counts
chk(df2_drafter_slots(64, false, 0) == 32 && df2_drafter_slots(64, true, 0) == 16, "the drafter serves 32 slots on a 24 GB+ card, 16 on a small one");
chk(df2_drafter_slots(4, false, 0) == 4 && df2_drafter_slots(0, false, 0) == 1, "never more than the engine's slots, never fewer than 1");
chk(df2_drafter_slots(64, false, 12) == 12 && df2_drafter_slots(8, false, 12) == 8, "STRATA_INK_DFLASH2_SLOTS caps it");
chk(df2_planned_rings(64, false, 0, false) == 8, "switch off: 8 rings, as before");
chk(df2_planned_rings(64, false, 0, true) == 32, "switch on, 64 slots, 32 GB card: 32");
chk(df2_planned_rings(64, true, 0, true) == 16, "switch on, small card: 16");
chk(df2_planned_rings(64, false, 12, true) == 12, "switch on with the slot cap 12: 12");
chk(df2_planned_rings(64, false, 3, true) == 8, "switch on with a cap below 8: the first 8 stay planned, as before");
for (int s = 0; s <= 8; ++s)
chk(df2_planned_rings(s, false, 0, true) == df2_planned_rings(s, false, 0, false), "up to 8 slots the switch changes nothing (exact today's reserve)");
chk(df2_planned_rings(1, true, 0, true) == 1 && df2_planned_rings(0, true, 0, false) == 1, "one slot: one ring");
// the switch
UNSETENV("STRATA_INK_DF2_RING_PLAN");
chk(df2_ring_plan_on() == kDf2RingPlanDefault, "no setting: the default");
SETENV("STRATA_INK_DF2_RING_PLAN", "1");
chk(df2_ring_plan_on(), "1: on");
SETENV("STRATA_INK_DF2_RING_PLAN", "0");
chk(!df2_ring_plan_on(), "0: off");
SETENV("STRATA_INK_DF2_RING_PLAN", "yes");
chk(df2_ring_plan_on() == kDf2RingPlanDefault, "another word: the default");
if (bad) return 1;
std::printf("ink_df2_budget_test: ok\n");
return 0;
}
+3 -1
View File
@@ -1737,8 +1737,10 @@ inline int run_serve_loop(const ServeConfig& cfg, InkModelFile& mf, InkBackend&
}
// 0.2.25 item 1: the engine is stopping (QUIT or the client closed): every slot's conversation that is not running goes to the conversation cache, so the first turn after the restart reads
// it back instead of the prompt. (A hard kill leaves nothing new: the files written at a park stay.)
// At most one cap's worth is written in this pass: with many slots the later files would only evict the earlier ones (a 128K conversation is about 2.4 GB).
if (disk_on) {
for (int s = 0; s < P; ++s) {
const uint64_t w0 = conv_disk.written_bytes();
for (int s = 0; s < P && conv_disk.written_bytes() - w0 < conv_disk.cap(); ++s) {
if (!reqs[s].active) park_current(reqs[s]);
}
}
+123 -84
View File
@@ -3512,10 +3512,10 @@
"launch_sets": [],
"launch_reads": [],
"doc_mentions": [
"docs/DETAILS.md:1807",
"docs/DETAILS.md:1813",
"docs/DETAILS.md:1814",
"docs/DETAILS.md:1821"
"docs/DETAILS.md:1811",
"docs/DETAILS.md:1817",
"docs/DETAILS.md:1818",
"docs/DETAILS.md:1825"
],
"first_commit": "4058aa782b",
"first_date": "2026-11-17",
@@ -3550,9 +3550,9 @@
"launch_sets": [],
"launch_reads": [],
"doc_mentions": [
"docs/DETAILS.md:1807",
"docs/DETAILS.md:1816",
"docs/DETAILS.md:1817"
"docs/DETAILS.md:1811",
"docs/DETAILS.md:1820",
"docs/DETAILS.md:1821"
],
"first_commit": "4058aa782b",
"first_date": "2026-11-17",
@@ -3620,7 +3620,7 @@
"doc_mentions": [
"docs/BATCHING.md:141",
"docs/BATCHING.md:142",
"docs/DETAILS.md:1816"
"docs/DETAILS.md:1820"
],
"first_commit": "4058aa782b",
"first_date": "2026-11-17",
@@ -3662,7 +3662,7 @@
"launch_sets": [],
"launch_reads": [],
"doc_mentions": [
"docs/DETAILS.md:1816"
"docs/DETAILS.md:1820"
],
"first_commit": "4058aa782b",
"first_date": "2026-11-17",
@@ -3800,7 +3800,7 @@
"launch_sets": [],
"launch_reads": [],
"doc_mentions": [
"docs/DETAILS.md:1814"
"docs/DETAILS.md:1818"
],
"first_commit": "4058aa782b",
"first_date": "2026-11-17",
@@ -5707,7 +5707,7 @@
"launch_sets": [],
"launch_reads": [],
"doc_mentions": [
"docs/DETAILS.md:1847"
"docs/DETAILS.md:1851"
],
"first_commit": "4058aa782b",
"first_date": "2026-11-17",
@@ -5746,7 +5746,7 @@
"docs/DETAILS.md:1327",
"docs/DETAILS.md:1515",
"docs/DETAILS.md:1731",
"docs/DETAILS.md:1834",
"docs/DETAILS.md:1838",
"docs/OLDER_GPUS.md:138",
"docs/OLDER_GPUS.md:251",
"docs/release-notes-0.2.7.md:23",
@@ -8078,7 +8078,7 @@
"launch_sets": [],
"launch_reads": [],
"doc_mentions": [
"docs/DETAILS.md:1847"
"docs/DETAILS.md:1851"
],
"first_commit": "4058aa782b",
"first_date": "2026-11-17",
@@ -11176,8 +11176,8 @@
"launch_sets": [],
"launch_reads": [],
"doc_mentions": [
"docs/DETAILS.md:1838",
"docs/DETAILS.md:1846",
"docs/DETAILS.md:1842",
"docs/DETAILS.md:1850",
"docs/GDN_CONTRACT.md:64"
],
"first_commit": "4058aa782b",
@@ -12151,7 +12151,7 @@
"launch_sets": [],
"launch_reads": [],
"doc_mentions": [
"docs/DETAILS.md:1831"
"docs/DETAILS.md:1835"
],
"first_commit": "4058aa782b",
"first_date": "2026-11-17",
@@ -21074,13 +21074,13 @@
"reads": [
{
"file": "engine/src/inkling2/ink_serve.h",
"line": 1002,
"line": 1136,
"backend": "cuda-hip",
"fn": "getenv"
},
{
"file": "engine/src/inkling2/cuda/ink_cuda_backend.cu",
"line": 1835,
"line": 1866,
"backend": "cuda-hip",
"fn": "getenv"
}
@@ -21441,6 +21441,39 @@
"retire_after": "",
"retired_in": ""
},
{
"name": "STRATA_INK_DF2_RING_PLAN",
"backends": [
"cuda-hip"
],
"reads": [
{
"file": "engine/src/inkling2/ink_df2_budget.h",
"line": 27,
"backend": "cuda-hip",
"fn": "getenv"
}
],
"parse": "flag",
"default_state": null,
"code_default": null,
"engine_sets": [],
"engine_defaults": [],
"launch_files": [],
"launch_sets": [],
"launch_reads": [],
"doc_mentions": [],
"first_commit": null,
"first_date": null,
"since": null,
"last_commit": null,
"last_date": null,
"status": "opt-in",
"owner": "inkling2",
"note": "[reviewed] 0.2.25 item 25: 1 = the K/V planner reserves room for the DFlash 2 context rings of every slot the drafter serves (32 on a card of 24 GB and more, 16 below) instead of the first 8, so slots 25 to 31 of a 64-slot RTX 5090 run keep a drafter (rel0223/bench71 logs: no GPU memory for slot 25); MEASURED 12-02 on an RTX 5090, C64, 3 rounds each: ON loses (920 vs 1,285 tok/s at 128 new tokens, 970 vs 1,593 at 512; tokens identical in all 64 requests) the K/V split loses its 768 device tokens (cause not isolated), so it stays off (ink_df2_budget.h)",
"retire_after": "",
"retired_in": ""
},
{
"name": "STRATA_INK_DFLASH2",
"backends": [
@@ -21456,7 +21489,7 @@
},
{
"file": "engine/src/inkling2/cuda/ink_dflash2_path.cuh",
"line": 154,
"line": 164,
"backend": "cuda-hip",
"fn": "getenv"
},
@@ -21732,7 +21765,7 @@
"reads": [
{
"file": "engine/src/inkling2/cuda/ink_dflash2_path.cuh",
"line": 56,
"line": 58,
"backend": "cuda-hip",
"fn": "getenv"
},
@@ -22177,6 +22210,12 @@
"cuda-hip"
],
"reads": [
{
"file": "engine/src/inkling2/cuda/ink_dflash2_path.cuh",
"line": 157,
"backend": "cuda-hip",
"fn": "getenv"
},
{
"file": "engine/src/inkling2/cuda/ink_dspark.cuh",
"line": 1253,
@@ -22186,7 +22225,7 @@
],
"parse": "int",
"default_state": null,
"code_default": null,
"code_default": "0",
"engine_sets": [],
"engine_defaults": [],
"launch_files": [],
@@ -22247,7 +22286,7 @@
"reads": [
{
"file": "engine/src/inkling2/cuda/ink_dflash2_path.cuh",
"line": 124,
"line": 126,
"backend": "cuda-hip",
"fn": "getenv"
},
@@ -22294,13 +22333,13 @@
"reads": [
{
"file": "engine/src/inkling2/cuda/ink_dflash2_path.cuh",
"line": 125,
"line": 127,
"backend": "cuda-hip",
"fn": "getenv"
},
{
"file": "engine/src/inkling2/cuda/ink_dflash2_path.cuh",
"line": 130,
"line": 132,
"backend": "cuda-hip",
"fn": "getenv"
},
@@ -22359,7 +22398,7 @@
},
{
"file": "engine/src/inkling2/cuda/ink_dflash2_path.cuh",
"line": 31,
"line": 33,
"backend": "cuda-hip",
"fn": "getenv"
},
@@ -22591,19 +22630,19 @@
"reads": [
{
"file": "engine/src/inkling2/ink_main.cpp",
"line": 1274,
"line": 1280,
"backend": "cuda-hip",
"fn": "getenv"
},
{
"file": "engine/src/inkling2/ink_main.cpp",
"line": 1274,
"line": 1280,
"backend": "cuda-hip",
"fn": "getenv"
},
{
"file": "engine/src/inkling2/ink_main.cpp",
"line": 1377,
"line": 1383,
"backend": "cuda-hip",
"fn": "getenv"
},
@@ -22620,11 +22659,11 @@
"engine_sets": [
{
"file": "engine/src/inkling2/ink_main.cpp",
"line": 1276
"line": 1282
},
{
"file": "engine/src/inkling2/ink_main.cpp",
"line": 1278
"line": 1284
}
],
"engine_defaults": [],
@@ -22804,13 +22843,13 @@
"reads": [
{
"file": "engine/src/inkling2/ink_serve.h",
"line": 579,
"line": 588,
"backend": "cuda-hip",
"fn": "getenv"
},
{
"file": "engine/src/inkling2/ink_serve.h",
"line": 579,
"line": 588,
"backend": "cuda-hip",
"fn": "getenv"
}
@@ -22824,11 +22863,11 @@
"launch_sets": [],
"launch_reads": [],
"doc_mentions": [],
"first_commit": null,
"first_date": null,
"first_commit": "f773a83ec0",
"first_date": "2026-12-02",
"since": null,
"last_commit": null,
"last_date": null,
"last_commit": "f773a83ec0",
"last_date": "2026-12-02",
"status": "default",
"owner": "inkling2",
"note": "[reviewed] 0.2.25 item 6: 0 = after a failed drafting window the governor (--draft-adapt) pauses a fixed 40 plain steps (before 0.2.25); default: the pause grows 40, 80, 160, 320 with consecutive failed windows and returns to 40 when a window pays (ink_gov.h); drafting stays exact, only when it runs changes",
@@ -22949,7 +22988,7 @@
"reads": [
{
"file": "engine/src/inkling2/cuda/ink_cuda_backend.cu",
"line": 1510,
"line": 1541,
"backend": "cuda-hip",
"fn": "getenv"
}
@@ -23946,13 +23985,13 @@
"reads": [
{
"file": "engine/src/inkling2/ink_serve.h",
"line": 550,
"line": 561,
"backend": "cuda-hip",
"fn": "getenv"
},
{
"file": "engine/src/inkling2/ink_serve.h",
"line": 550,
"line": 561,
"backend": "cuda-hip",
"fn": "getenv"
}
@@ -24348,7 +24387,7 @@
"reads": [
{
"file": "engine/src/inkling2/ink_serve.h",
"line": 568,
"line": 577,
"backend": "cuda-hip",
"fn": "getenv"
}
@@ -24381,7 +24420,7 @@
"reads": [
{
"file": "engine/src/inkling2/ink_serve.h",
"line": 565,
"line": 574,
"backend": "cuda-hip",
"fn": "getenv"
}
@@ -24447,7 +24486,7 @@
"reads": [
{
"file": "engine/src/inkling2/ink_serve.h",
"line": 551,
"line": 562,
"backend": "cuda-hip",
"fn": "getenv"
}
@@ -24480,7 +24519,7 @@
"reads": [
{
"file": "engine/src/inkling2/ink_serve.h",
"line": 556,
"line": 567,
"backend": "cuda-hip",
"fn": "getenv"
}
@@ -24513,7 +24552,7 @@
"reads": [
{
"file": "engine/src/inkling2/ink_serve.h",
"line": 1497,
"line": 1632,
"backend": "cuda-hip",
"fn": "getenv"
},
@@ -24618,7 +24657,7 @@
"reads": [
{
"file": "engine/src/inkling2/ink_main.cpp",
"line": 1305,
"line": 1311,
"backend": "cuda-hip",
"fn": "getenv"
}
@@ -26557,7 +26596,7 @@
"reads": [
{
"file": "engine/src/inkling2/ink_main.cpp",
"line": 1294,
"line": 1300,
"backend": "cuda-hip",
"fn": "getenv"
}
@@ -26662,7 +26701,7 @@
"reads": [
{
"file": "engine/src/inkling2/cuda/ink_cuda_backend.cu",
"line": 2546,
"line": 2577,
"backend": "cuda-hip",
"fn": "getenv"
}
@@ -26728,7 +26767,7 @@
"reads": [
{
"file": "engine/src/inkling2/cuda/ink_cuda_backend.cu",
"line": 2673,
"line": 2704,
"backend": "cuda-hip",
"fn": "env2"
}
@@ -26761,13 +26800,13 @@
"reads": [
{
"file": "engine/src/inkling2/cuda/ink_cuda_backend.cu",
"line": 1930,
"line": 1961,
"backend": "cuda-hip",
"fn": "getenv"
},
{
"file": "engine/src/inkling2/cuda/ink_cuda_backend.cu",
"line": 2294,
"line": 2325,
"backend": "cuda-hip",
"fn": "getenv"
}
@@ -26800,7 +26839,7 @@
"reads": [
{
"file": "engine/src/inkling2/cuda/ink_cuda_backend.cu",
"line": 2298,
"line": 2329,
"backend": "cuda-hip",
"fn": "getenv"
}
@@ -27245,13 +27284,13 @@
"reads": [
{
"file": "engine/src/inkling2/cuda/ink_cuda_backend.cu",
"line": 1926,
"line": 1957,
"backend": "cuda-hip",
"fn": "getenv"
},
{
"file": "engine/src/inkling2/cuda/ink_cuda_backend.cu",
"line": 2142,
"line": 2173,
"backend": "cuda-hip",
"fn": "getenv"
}
@@ -27452,7 +27491,7 @@
"reads": [
{
"file": "engine/src/inkling2/ink_serve.h",
"line": 559,
"line": 580,
"backend": "cuda-hip",
"fn": "getenv"
}
@@ -27497,7 +27536,7 @@
},
{
"file": "engine/src/inkling2/cuda/ink_cuda_backend.cu",
"line": 2332,
"line": 2363,
"backend": "cuda-hip",
"fn": "getenv"
}
@@ -27542,7 +27581,7 @@
},
{
"file": "engine/src/inkling2/cuda/ink_cuda_backend.cu",
"line": 2334,
"line": 2365,
"backend": "cuda-hip",
"fn": "getenv"
}
@@ -27620,7 +27659,7 @@
},
{
"file": "engine/src/inkling2/cuda/ink_cuda_backend.cu",
"line": 2335,
"line": 2366,
"backend": "cuda-hip",
"fn": "getenv"
}
@@ -27686,7 +27725,7 @@
"reads": [
{
"file": "engine/src/inkling2/cuda/ink_cuda_backend.cu",
"line": 1367,
"line": 1398,
"backend": "cuda-hip",
"fn": "getenv"
}
@@ -28602,13 +28641,13 @@
"reads": [
{
"file": "engine/src/inkling2/ink_main.cpp",
"line": 1262,
"line": 1268,
"backend": "cuda-hip",
"fn": "getenv"
},
{
"file": "engine/src/inkling2/ink_main.cpp",
"line": 1382,
"line": 1388,
"backend": "cuda-hip",
"fn": "getenv"
},
@@ -28625,11 +28664,11 @@
"engine_sets": [
{
"file": "engine/src/inkling2/ink_main.cpp",
"line": 1266
"line": 1272
},
{
"file": "engine/src/inkling2/ink_main.cpp",
"line": 1268
"line": 1274
}
],
"engine_defaults": [],
@@ -29161,7 +29200,7 @@
"reads": [
{
"file": "engine/src/inkling2/ink_main.cpp",
"line": 1290,
"line": 1296,
"backend": "cuda-hip",
"fn": "getenv"
}
@@ -29194,7 +29233,7 @@
"reads": [
{
"file": "engine/src/inkling2/ink_main.cpp",
"line": 1287,
"line": 1293,
"backend": "cuda-hip",
"fn": "getenv"
}
@@ -36686,7 +36725,7 @@
"launch_sets": [],
"launch_reads": [],
"doc_mentions": [
"docs/DETAILS.md:1832",
"docs/DETAILS.md:1836",
"docs/MMVQ_IL_TABLE.md:40",
"docs/MMVQ_IL_TABLE.md:42"
],
@@ -36793,7 +36832,7 @@
"launch_sets": [],
"launch_reads": [],
"doc_mentions": [
"docs/DETAILS.md:1834",
"docs/DETAILS.md:1838",
"docs/MMVQ_IL_TABLE.md:19",
"docs/release-notes-0.2.7.md:23"
],
@@ -40343,10 +40382,10 @@
"launch_sets": [],
"launch_reads": [],
"doc_mentions": [
"docs/DETAILS.md:1807",
"docs/DETAILS.md:1815",
"docs/DETAILS.md:1816",
"docs/DETAILS.md:1818"
"docs/DETAILS.md:1811",
"docs/DETAILS.md:1819",
"docs/DETAILS.md:1820",
"docs/DETAILS.md:1822"
],
"first_commit": "4058aa782b",
"first_date": "2026-11-17",
@@ -40528,7 +40567,7 @@
"launch_sets": [],
"launch_reads": [],
"doc_mentions": [
"docs/DETAILS.md:1819"
"docs/DETAILS.md:1823"
],
"first_commit": "4058aa782b",
"first_date": "2026-11-17",
@@ -40563,7 +40602,7 @@
"launch_sets": [],
"launch_reads": [],
"doc_mentions": [
"docs/DETAILS.md:1818"
"docs/DETAILS.md:1822"
],
"first_commit": "4058aa782b",
"first_date": "2026-11-17",
@@ -41727,8 +41766,8 @@
"launch_sets": [],
"launch_reads": [],
"doc_mentions": [
"docs/DETAILS.md:1838",
"docs/DETAILS.md:1843"
"docs/DETAILS.md:1842",
"docs/DETAILS.md:1847"
],
"first_commit": "4058aa782b",
"first_date": "2026-11-17",
@@ -42311,8 +42350,8 @@
"launch_sets": [],
"launch_reads": [],
"doc_mentions": [
"docs/DETAILS.md:1838",
"docs/DETAILS.md:1844"
"docs/DETAILS.md:1842",
"docs/DETAILS.md:1848"
],
"first_commit": "4058aa782b",
"first_date": "2026-11-17",
@@ -42532,8 +42571,8 @@
"launch_sets": [],
"launch_reads": [],
"doc_mentions": [
"docs/DETAILS.md:1838",
"docs/DETAILS.md:1842"
"docs/DETAILS.md:1842",
"docs/DETAILS.md:1846"
],
"first_commit": "4058aa782b",
"first_date": "2026-11-17",
@@ -43035,8 +43074,8 @@
"launch_sets": [],
"launch_reads": [],
"doc_mentions": [
"docs/DETAILS.md:1838",
"docs/DETAILS.md:1845"
"docs/DETAILS.md:1842",
"docs/DETAILS.md:1849"
],
"first_commit": "4058aa782b",
"first_date": "2026-11-17",
@@ -46559,7 +46598,7 @@
"launch_sets": [],
"launch_reads": [],
"doc_mentions": [
"docs/DETAILS.md:1847"
"docs/DETAILS.md:1851"
],
"first_commit": "4058aa782b",
"first_date": "2026-11-17",
@@ -46619,7 +46658,7 @@
"launch_sets": [],
"launch_reads": [],
"doc_mentions": [
"docs/DETAILS.md:1847"
"docs/DETAILS.md:1851"
],
"first_commit": "4058aa782b",
"first_date": "2026-11-17",
@@ -52368,7 +52407,7 @@
"launch_reads": [],
"doc_mentions": [
"docs/DETAILS.md:1362",
"docs/DETAILS.md:1831"
"docs/DETAILS.md:1835"
],
"first_commit": "4058aa782b",
"first_date": "2026-11-17",
@@ -62376,7 +62415,7 @@
"doc_mentions": [
"docs/BATCHING.md:149",
"docs/DETAILS.md:1346",
"docs/DETAILS.md:1823",
"docs/DETAILS.md:1827",
"docs/INTEL.md:429",
"docs/bench-results/2026-10-05-community-arc-b65/benchy-v1/README.md:14",
"docs/bench-results/2026-10-07-community-arc-b65-v01402/BUILD.md:109"