Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
6bd8bc9
feat: honor ignore_merges in the BPE tokenizer for o200k-style vocabs
baptisterajaut Nov 21, 2026
9620ae9
feat: inkling2 engine (strata-ink2) and reference path for Inkling-2-…
baptisterajaut Nov 21, 2026
3c7c297
feat: inkling2 oracle checks and stop-gap OpenAI shim
baptisterajaut Nov 21, 2026
52736e2
refactor: address inkling2 experts through per-slot pointer tables
baptisterajaut Nov 21, 2026
1f24ead
feat: inkling2 expert offload to pinned RAM with a device-side LRU (-…
baptisterajaut Nov 21, 2026
2fabb8a
feat: inkling2 DSpark drafter and greedy speculative decoding (--spec…
baptisterajaut Nov 21, 2026
a858056
perf: inkling2 small-T verify kernels (multi-vector GEMVs, grouped ex…
baptisterajaut Nov 21, 2026
e51853c
feat: inkling2 exact sampled speculative decoding, graph-captured ver…
baptisterajaut Nov 21, 2026
a4e207f
fix: inkling2 spec verify with --tc 0 and under expert offload, fallb…
baptisterajaut Nov 21, 2026
5050dca
feat: serve Inkling 2 from the Strata server (reply markers, tool cal…
baptisterajaut Nov 21, 2026
f0e1f75
fix: forced tool_choice in Inkling 2 form (call header and JSON opening)
baptisterajaut Nov 21, 2026
5c86c8d
feat: inkling2 cold experts on the CPU (--cpu-threads), NUMA-placed e…
baptisterajaut Nov 21, 2026
ea559aa
perf: inkling2 CPU experts: lighter visit sync, opt-in int8 activatio…
baptisterajaut Nov 21, 2026
f292ef0
feat: inkling2 STRATA_NUMA_POOL=0 turns the CPU experts NUMA placemen…
baptisterajaut Nov 21, 2026
5bfe4af
perf: inkling2 expert placement by decayed use counts (misses most us…
baptisterajaut Nov 21, 2026
ae362a7
perf: inkling2 CPU experts: vpermps NVFP4 decode, prefetch, fused Swi…
baptisterajaut Nov 21, 2026
5f65029
perf: inkling2 PCIe share of CPU misses, sized per visit from the mea…
baptisterajaut Nov 21, 2026
1096428
fix: inkling2 CPU expert memory bound to its NUMA node, a node full o…
baptisterajaut Nov 21, 2026
6532963
perf: inkling2 NVFP4 expert GEMVs read x through L1, SwiGLU once in g…
baptisterajaut Nov 21, 2026
a16b281
chore: inkling2 validation tools take the checkpoint and work dirs as…
baptisterajaut Nov 21, 2026
bd8c108
merge: upstream main into feat/inkling2
baptisterajaut Nov 21, 2026
b76b43a
inkling2: --kv k8v4 (int8 K, rotated 4-bit V); Turing: the fp32 promp…
merbanan Nov 21, 2026
cbbb95d
perf: inkling2 decode attention keeps k8v4 V loads out of the f16 loo…
baptisterajaut Nov 21, 2026
85af06a
inkling2: --kv k8v8 (int8 K, Hadamard-rotated int8 V)
merbanan Nov 21, 2026
db6849d
inkling2: offload margin 384 -> 128 MiB (INK2_OFF_MARGIN_MIB), the po…
merbanan Nov 21, 2026
b48000c
docs: inkling2 offload margin comment: what the 128 MiB covers, measu…
baptisterajaut Nov 21, 2026
dec6a1e
inkling2: load GGUF files (llama.cpp's merged inkling2_loop layout), …
merbanan Nov 21, 2026
334c0bc
fix: inkling2 GGUF refuses --cpu-threads and --spec (no GGUF kernels …
baptisterajaut Nov 21, 2026
7d38454
inkling2: --kv-grow (the full-attention K/V grows into the expert pools)
merbanan Nov 21, 2026
81ac409
fix: inkling2 --kv-grow pool shrink drops planned CPU-expert promotio…
baptisterajaut Nov 21, 2026
35edb12
inkling2: elastic prompt buffers and staging (--kv-grow with offload)…
merbanan Nov 21, 2026
b63b0a3
fix: inkling2 elastic prompt buffers stay fixed under --spec (its ver…
baptisterajaut Nov 21, 2026
e4377d3
inkling2: short prompts fetch only their routed experts (the routed-p…
merbanan Nov 21, 2026
7e088eb
fix: inkling2 routed short prompts only when the pools hold all their…
baptisterajaut Nov 21, 2026
e17673d
inkling2: big prompt chunks decode each GGUF expert once and run cuBL…
merbanan Nov 21, 2026
2f83ddb
fix: inkling2 decode-once GGUF scratch allocated only for a GGUF mode…
baptisterajaut Nov 21, 2026
6561346
inkling2: long contexts on a small card: the prompt chunk shrinks to …
merbanan Nov 21, 2026
569185f
fix: inkling2 chunk fit counts the staging as the routed-prompt guard…
baptisterajaut Nov 21, 2026
a06ff78
inkling2: dense Q8 GEMV with 16-byte loads (INK2_Q8_WIDE, default on)…
merbanan Nov 21, 2026
48febba
perf: inkling2 GGUF defaults from 3090 measurements: decode-once from…
baptisterajaut Nov 21, 2026
955c8c0
feat: inkling2 conversation cache for --serve: prompt-end checkpoints…
baptisterajaut Nov 21, 2026
5a63687
feat: inkling2 DONE line reports drafts accepted / offered and the pr…
baptisterajaut Nov 21, 2026
b884394
docs: inkling2 conversation cache: no host name in a comment
baptisterajaut Nov 21, 2026
6bbc06f
perf: inkling2 conversation cache: parked rows in power-of-two pinned…
baptisterajaut Nov 22, 2026
af8424b
docs: inkling2 conversation cache: the live checkpoints are not evict…
baptisterajaut Nov 22, 2026
51c5048
fix: inkling2 conversation cache: a conversation being parked counts …
baptisterajaut Nov 22, 2026
4888bf6
fix: inkling2 conversation cache: branch points between conversations…
baptisterajaut Nov 22, 2026
a58cbeb
fix: inkling2 accepts --conversation-cache-slots from Strata configs …
baptisterajaut Nov 22, 2026
7524ae7
feat: inkling2 image input in strata-ink2 (ViT + projector in the eng…
baptisterajaut Nov 21, 2026
fdb2095
feat: serve sends Inkling 2 pictures to strata-ink2 as image= files (…
baptisterajaut Nov 21, 2026
c1207fc
fix: Inkling 2 JPEGs reach strata-ink2 as Pillow-decoded BMP (the ref…
baptisterajaut Nov 21, 2026
eb52e7f
test: inkling2 picture comparison tools (embeddings, multimodal KL), …
baptisterajaut Nov 21, 2026
d3a98a1
docs: inkling2 vision CBA notes (attention at the cap, weights over P…
baptisterajaut Nov 21, 2026
bd533db
fix: inkling2 refuses pictures over 134 MP before decoding them; head…
baptisterajaut Nov 21, 2026
5415261
test: vision_kl.py --together (several pictures in one prompt)
baptisterajaut Nov 22, 2026
cb64c66
feat: inkling2 pictures in the conversation cache: image tokens keyed…
baptisterajaut Nov 22, 2026
078c290
fix: inkling2 thinking off from enable_thinking / Anthropic disabled …
baptisterajaut Nov 21, 2026
ea09d1b
feat: setup installs Inkling-2-Mini (pinned checkpoint, strata-ink2 b…
baptisterajaut Nov 21, 2026
369c7c4
fix: inkling2 setup sizes the offload for small cards (context and re…
baptisterajaut Nov 21, 2026
98c34c2
fix: inkling2 offload sizing counts the VRAM in use and keeps a slack…
baptisterajaut Nov 21, 2026
a8918c9
fix: setup needs CMake 3.25.2 for the engine CUDA20 targets (3.25.1 c…
baptisterajaut Nov 21, 2026
cfcdd1a
fix: inkling2 start message gives its own RAM figure (measured 16.8 G…
baptisterajaut Nov 22, 2026
4539d3b
feat: inkling2 offload configs use --kv-grow with the longest context…
baptisterajaut Nov 22, 2026
24edc26
fix: inkling2 --kv-grow keeps each expert pool at its minimum: prompt…
baptisterajaut Nov 22, 2026
dddda83
feat: inkling2 offload keeps --chunk 1024 and uses i8r (closest 8-bit…
baptisterajaut Nov 22, 2026
dfdf9f4
fix: inkling2 offload sizing counts the prompt buffers a 1024-chunk c…
baptisterajaut Nov 22, 2026
2daf740
feat: inkling2 setup turns pictures on and sizes the conversation cac…
baptisterajaut Nov 22, 2026
dd7fa18
docs: inkling2 engine flags and their measured effect (docs/INKLING2.md)
baptisterajaut Nov 22, 2026
d99e5fa
feat(inkling2): add AMD ROCm/HIP engine support for strata-ink2 and s…
jingx8885 Nov 22, 2026
bc4a937
feat(terminal): enable Inkling-2-Mini setup and HIP engine build on A…
jingx8885 Nov 22, 2026
ddc6038
fix(tests): expect ink2_build HIP flags in test_gh_0217_hipflags
jingx8885 Nov 22, 2026
83a97d8
feat: inkling2 on AMD ROCm/HIP wave32 RDNA (#16 by jingx8885)
baptisterajaut Nov 22, 2026
01f7da1
fix: inkling2 HIP targets on Linux only and out of the default HIP bu…
baptisterajaut Nov 22, 2026
3cbc56b
feat: inkling2 GGUF experts may use one type for layers 0-19 and anot…
baptisterajaut Nov 22, 2026
1f0a0a1
docs: inkling2 GGUF files with a second expert type in layers 20-23, …
baptisterajaut Nov 22, 2026
f2af205
docs: inkling2 --spec greedy output can part from plain decoding at a…
baptisterajaut Nov 22, 2026
454cb91
chore: merge upstream 0.2.19, the official Inkling checkpoint source …
baptisterajaut Nov 22, 2026
81267cc
docs: inkling2 verify products follow decode GEMVs, not decode attention
baptisterajaut Nov 22, 2026
2cea839
fix: keep the official Inkling source out of the catalog table of SQ …
baptisterajaut Nov 22, 2026
41b610c
test: inkling2 offload floor reads pool_slot, pins allow a checkpoint…
baptisterajaut Nov 22, 2026
cad508f
fix: strata-ink2 configs get no --parallel, no Vision shard and a mod…
baptisterajaut Nov 22, 2026
f30718f
fix: /props says strata-ink2 keeps earlier reasoning when its templat…
baptisterajaut Nov 22, 2026
6e237c7
feat: strata-ink2 --spec 1 runs with --cpu-threads, a verify block's …
baptisterajaut Nov 22, 2026
5ae3b0d
feat: inkling2 setup keeps --spec 1 beside the expert offload where t…
baptisterajaut Nov 22, 2026
d3431b1
docs: strata-ink2 --spec 1 with --cpu-threads, measured per card
baptisterajaut Nov 22, 2026
7516ee8
chore: merge upstream 0.2.20, the official Inkling checkpoint keeps i…
baptisterajaut Nov 23, 2026
3f746d1
feat: strata-ink2 --verify-tc 1, the small-T dense products of the sp…
baptisterajaut Nov 23, 2026
2ced29e
feat: strata-ink2 takes a numeric reasoning effort, 0.0 to 0.99, as I…
baptisterajaut Nov 23, 2026
bb137fd
docs: strata-ink2 --verify-tc 1 measured on an RTX 3090, and the nume…
baptisterajaut Nov 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
perf: inkling2 PCIe share of CPU misses, sized per visit from the mea…
…sured CPU and PCIe times
  • Loading branch information
baptisterajaut committed Nov 21, 2026
commit 5f65029572fcc7bdd0181d5d8e398c98ee60cb4b
4 changes: 4 additions & 0 deletions engine/src/inkling2/ink2_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,10 @@ void master(Node* N) {
std::atomic_thread_fence(std::memory_order_seq_cst);
B->ack[N->id] = seq;
last = now_ms();
if (nj) { // the node's time per job for the GPU's PCIe share (the ring seen -> the ack, over 16 visits)
const float us = (float) (1e3 * (last - t_ring) / nj);
B->us_job = B->us_job > 0.0f ? B->us_job + (us - B->us_job) / 16.0f : us;
}
if (g_trace) { // per node, every 2000 rings: busy visits, us from the ring seen to the ack by jobs per visit,
// and the master's phases per busy visit
static thread_local double cnt[K8 + 1], sum[K8 + 1], ph[7], rings = 0, worst = 0;
Expand Down
3 changes: 2 additions & 1 deletion engine/src/inkling2/ink2_cpu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ struct InkBell { // one per node in its memory, registered mapped; GPU writes
volatile unsigned ring; // sequence number of the last visit with CPU jobs
unsigned pad0[15];
volatile unsigned ack[2]; // [node]: the last sequence number done (written in that node's bell)
unsigned pad1[14];
volatile float us_job; // the pool's time per job, us (moving average; the GPU's PCIe share reads it)
unsigned pad1[13];
int layer, n; // the visit's layer, number of jobs
int k[BELL_K], e[BELL_K]; // job j: top-k slot k[j], expert e[j]
unsigned pad2[14];
Expand Down
116 changes: 107 additions & 9 deletions engine/src/inkling2/ink2_engine.cu
Original file line number Diff line number Diff line change
Expand Up @@ -1890,6 +1890,21 @@ struct Slot {
};

struct Bells { ink2cpu::InkBell* b[2]; }; // device views of the per-node doorbells
constexpr int SYNC_MAX = 2; // misses of a visit computed on the GPU over PCIe (the PCIe share), at most
struct SyncArgs { // the PCIe share's state, for k_cache_cpu and k_cpu_wait
const uint8_t* const* xsrc; // [NL * NE] device views of the experts in host memory
const uint8_t** tabA;
const uint8_t** tabB;
uint8_t* stage; // [SYNC_MAX] staging slots of MX_BYTES
const uint8_t** fsrc;
uint8_t** fdst;
int* nfetch;
int* keys; // [SYNC_MAX] the visit's PCIe experts (their table entries point at the staging)
unsigned long long* fbytes;
const uint8_t* home; // [NL * NE] node of each expert
float us_nv, us_mx; // one expert over PCIe, us (0: the share off)
float margin; // us the GPU side adds to the copies (its GEMVs, the background copies' PCIe)
};

struct Engine {
const Ckpt* ck = nullptr;
Expand Down Expand Up @@ -1937,6 +1952,7 @@ struct Engine {
const uint8_t* home_d = nullptr; // [NL * NE] the node holding expert (l, e) (E.home)
unsigned *d_seq = nullptr, *d_cur = nullptr;
float* cnt = nullptr; // [NL * NE] decayed use counts (placement)
SyncArgs sync = {}; // the PCIe share
int *want_nv = nullptr, *want_mx = nullptr, *nwant_nv = nullptr, *nwant_mx = nullptr;
int *pend_nv = nullptr, *pend_mx = nullptr, *npend_nv = nullptr, *npend_mx = nullptr; // [i] = key, [PMAX + i] = slot
const uint8_t **psrc_nv = nullptr, **psrc_mx = nullptr; // promotion copies (k_fetch lists of their own)
Expand Down Expand Up @@ -2375,33 +2391,74 @@ void expert_cache(int l, const int* ids, int n) {
// (place/simeng.py): 2.25 -> 1.42 CPU experts per visit, 14.7 -> 8.6 promotions per token; Strata's adaptive cache with
// a per-token decay, its victims from the whole pool (experts of a pool are all one size). INK2_PLACE=lru: the
// least recently used slot, misses in visit order (the previous policy).
// PCIe share (INK2_PCIE=0: off): k_cache_cpu moves a visit's misses one by one, the busiest node's lowest-ranked
// first, from the CPU to a GPU staging slot over PCIe while that shortens the visit (each node's us per job measured
// by its pool, one copy's us measured at start, plus INK2_PCIE_MARGIN us for the GPU side: 120, from a sweep of
// 0 / 60 / 120 / 200); k_cpu_wait takes them out of the tables. q1 chat at 8 GiB, one node: 4 threads 37.2 -> 40.6
// tok/s, 8 threads 52.4 -> 52.8; the 2 x 22-thread box 66.4 -> 65-66 (it rarely fires there).
constexpr int WANT_MAX = 64, PMAX = 32;
bool g_place_freq = true;
float g_decay = 0.97f, g_gain = 1.0f;
int g_bg_blocks = 4; // INK2_BG_BLOCKS (12 GiB, q1 chat: 4 and 8 blocks 69.8 / 68.9 tok/s, 16: 65.8)
int g_promote_nv = 12, g_promote_mx = 3; // per token (INK2_PROMOTE=nv,mx): ~54 + 25 MB of PCIe in the background
__global__ void k_cache_cpu(int l, const int* __restrict__ ids, const float* __restrict__ x, int* slot_of, unsigned* stamp,
unsigned* clock, int* want, int* nwant, Bells bells, int nodes, unsigned* seq, unsigned* cur,
float* cnt) {
float* cnt, SyncArgs sa) {
__shared__ int nj;
if (threadIdx.x == 0) {
unsigned t = *clock;
int n = 0, nw = *nwant;
int n = 0, nw = *nwant, jk[TOPK], je[TOPK];
for (int k = 0; k < TOPK; ++k) {
const int e = ids[k], key = l * NE + e, sl = slot_of[key];
cnt[key] += 1.0f;
if (sl >= 0) { stamp[sl] = ++t; continue; }
for (int b = 0; b < nodes; ++b) {
bells.b[b]->k[n] = k;
bells.b[b]->e[n] = e;
}
jk[n] = k;
je[n] = e;
++n;
bool have = false;
for (int i = 0; i < nw; ++i) have |= want[i] == key;
if (!have && nw < WANT_MAX) want[nw++] = key;
}
*clock = t;
*nwant = nw;
// PCIe share: while it shortens the visit, the busiest node's lowest-ranked miss is copied to a staging slot
// and computed on the GPU instead: visit ~ max(node jobs x the node's us per job, copies x one copy's us)
const bool nv = l < MXFP8_FIRST;
const float tp = nv ? sa.us_nv : sa.us_mx;
int ns = 0;
if (tp > 0.0f && n) {
const float u[2] = {bells.b[0]->us_job, nodes > 1 ? bells.b[1]->us_job : 0.0f};
int c[2] = {0, 0};
for (int j = 0; j < n; ++j) ++c[nodes > 1 ? sa.home[l * NE + je[j]] : 0];
while (ns < SYNC_MAX) {
const float t0 = c[0] * u[0], t1 = c[1] * u[1];
const int m = t1 > t0 ? 1 : 0;
if (!c[m]) break;
const float now = fmaxf(fmaxf(t0, t1), ns ? ns * tp + sa.margin : 0.0f);
const float after = fmaxf(fmaxf((c[m] - 1) * u[m], m ? t0 : t1), (ns + 1) * tp + sa.margin);
if (after >= now) break;
int j = n - 1;
while ((nodes > 1 ? sa.home[l * NE + je[j]] : 0) != m) --j;
const int key = l * NE + je[j];
uint8_t* st = sa.stage + (size_t) ns * MX_BYTES;
sa.fsrc[ns] = sa.xsrc[key];
sa.fdst[ns] = st;
sa.tabA[key] = st;
sa.tabB[key] = st + (nv ? NV_A : MX_A);
sa.keys[ns] = key;
for (int i = j; i + 1 < n; ++i) { jk[i] = jk[i + 1]; je[i] = je[i + 1]; }
--n;
--c[m];
++ns;
}
*sa.fbytes += (unsigned long long) ns * (nv ? NV_BYTES : MX_BYTES);
}
*sa.nfetch = ns;
for (int j = 0; j < n; ++j)
for (int b = 0; b < nodes; ++b) {
bells.b[b]->k[j] = jk[j];
bells.b[b]->e[j] = je[j];
}
nj = n;
}
__syncthreads();
Expand All @@ -2427,9 +2484,12 @@ __global__ void k_cache_cpu(int l, const int* __restrict__ ids, const float* __r
}
// grid TOPK: block j copies job j's output, from the doorbell of the node holding its expert, once every node has acked
// (a stuck pool traps after ~4 s: an error, not a hang)
__global__ void k_cpu_wait(Bells bells, const uint8_t* __restrict__ home, const unsigned* cur, int nodes, float* ey) {
__global__ void k_cpu_wait(Bells bells, const uint8_t* __restrict__ home, const unsigned* cur, int nodes, float* ey,
SyncArgs sa) {
const volatile ink2cpu::InkBell* b0 = bells.b[0];
const volatile ink2cpu::InkBell* b1 = bells.b[nodes > 1 ? 1 : 0];
if (blockIdx.x == 0 && threadIdx.x == 0) // the GEMVs are done: the PCIe share's experts leave the tables
for (int i = 0; i < *sa.nfetch; ++i) sa.tabA[sa.keys[i]] = sa.tabB[sa.keys[i]] = nullptr;
const unsigned s = *cur;
if (!s) return;
__shared__ int ok;
Expand Down Expand Up @@ -2588,7 +2648,8 @@ void promote_join() {
void expert_cpu_ring(int l, const float* x) {
const bool nv = l < MXFP8_FIRST;
k_cache_cpu<<<1, 256>>>(l, E.ids, x, E.slot_of, nv ? E.stamp_nv : E.stamp_mx, E.clock, nv ? E.want_nv : E.want_mx,
nv ? E.nwant_nv : E.nwant_mx, E.bell_d, E.cpu_nodes, E.d_seq, E.d_cur, E.cnt);
nv ? E.nwant_nv : E.nwant_mx, E.bell_d, E.cpu_nodes, E.d_seq, E.d_cur, E.cnt, E.sync);
if (E.sync.us_nv > 0.0f) k_fetch<<<dim3(FETCH_BLOCKS, SYNC_MAX), 256>>>(E.fsrc, E.fdst, E.nfetch, ex_bytes(l));
}
void setup_cpu() {
if (const char* p = std::getenv("INK2_PROMOTE")) std::sscanf(p, "%d,%d", &g_promote_nv, &g_promote_mx);
Expand All @@ -2613,6 +2674,43 @@ void setup_cpu() {
}
if (E.cpu_nodes < 2) E.bell_d.b[1] = E.bell_d.b[0];
E.home_d = (const uint8_t*) upload(E.home.data(), E.home.size());
// PCIe share (INK2_PCIE=0: off): staging slots, and one expert's copy timed with the kernel that will do it
// (best of 5; INK2_PCIE_US: an NVFP4 expert's us instead, e.g. to play a faster link)
SyncArgs& a = E.sync; // (off: us_nv 0, k_cache_cpu still writes nfetch = 0)
a.xsrc = E.xsrc_d; a.tabA = E.tabA; a.tabB = E.tabB; a.fsrc = E.fsrc; a.fdst = E.fdst; a.nfetch = E.nfetch;
a.fbytes = E.fbytes; a.home = E.home_d;
a.keys = (int*) dalloc(SYNC_MAX * 4);
if (!(std::getenv("INK2_PCIE") && std::string(std::getenv("INK2_PCIE")) == "0")) {
a.stage = (uint8_t*) dalloc((size_t) SYNC_MAX * MX_BYTES);
const uint8_t* srcd = nullptr; // layer 0's expert 0 (an NVFP4 one), its device view
CK(cudaMemcpy(&srcd, E.xsrc_d, sizeof srcd, cudaMemcpyDeviceToHost));
const int one = 1;
CK(cudaMemcpy(E.fsrc, &srcd, sizeof srcd, cudaMemcpyHostToDevice));
CK(cudaMemcpy(E.fdst, &a.stage, sizeof a.stage, cudaMemcpyHostToDevice));
CK(cudaMemcpy(E.nfetch, &one, 4, cudaMemcpyHostToDevice));
cudaEvent_t e0, e1;
CK(cudaEventCreate(&e0));
CK(cudaEventCreate(&e1));
float best = 1e9f;
for (int i = 0; i < 5; ++i) {
CK(cudaEventRecord(e0));
k_fetch<<<dim3(FETCH_BLOCKS, 1), 256>>>(E.fsrc, E.fdst, E.nfetch, NV_BYTES);
CK(cudaEventRecord(e1));
CK(cudaEventSynchronize(e1));
float ms = 0;
CK(cudaEventElapsedTime(&ms, e0, e1));
best = std::min(best, ms);
}
CK(cudaEventDestroy(e0));
CK(cudaEventDestroy(e1));
const int zero = 0;
CK(cudaMemcpy(E.nfetch, &zero, 4, cudaMemcpyHostToDevice));
a.us_nv = std::getenv("INK2_PCIE_US") ? (float) std::atof(std::getenv("INK2_PCIE_US")) : 1e3f * best;
a.us_mx = a.us_nv * (float) MX_BYTES / (float) NV_BYTES;
a.margin = std::getenv("INK2_PCIE_MARGIN") ? (float) std::atof(std::getenv("INK2_PCIE_MARGIN")) : 120.0f;
std::fprintf(stderr, "cpu experts: PCIe share on, an NVFP4 expert over PCIe %.0f us (%.1f GB/s)\n", a.us_nv,
NV_BYTES / (a.us_nv * 1e3));
}
auto zi = [](size_t n) { int* p = (int*) dalloc(n * 4); CK(cudaMemset(p, 0, n * 4)); return p; };
E.d_seq = (unsigned*) zi(1);
E.d_cur = (unsigned*) zi(1);
Expand Down Expand Up @@ -2661,7 +2759,7 @@ void moe(const Layer& Y, const float* x, const float* r, float* mhist, const flo
switch (g_sel_rpw) { case 1: SEL(1) break; case 2: SEL(2) break; case 8: SEL(8) break; default: SEL(4) }
#undef SEL
}
if (E.cpu) k_cpu_wait<<<TOPK, 256>>>(E.bell_d, E.home_d, E.d_cur, E.cpu_nodes, E.ey);
if (E.cpu) k_cpu_wait<<<TOPK, 256>>>(E.bell_d, E.home_d, E.d_cur, E.cpu_nodes, E.ey, E.sync);
k_moe_tail<<<(H + 255) / 256, 256>>>(E.ey, E.wts, mhist, mlp_conv, r, out, E.d_pos);
}

Expand Down