feat: route experimental native expert misses through bounded KAR CUDA

This commit is contained in:
Pavlo Ratushnyi
2026-10-05 14:35:56 +02:00
parent 1ce0bab882
commit 87fdec7be7
12 changed files with 388 additions and 6 deletions
@@ -0,0 +1,69 @@
//! Model-free routed-expert fixture, using the production KAR writer.
use sha2::{Digest, Sha256};
use std::path::Path;
use strata_control::kar_writer::{self, SourceIdentity, Tensor, TensorData};
fn main() -> Result<(), String> {
let args: Vec<_> = std::env::args().collect();
if args.len() != 2 {
return Err("usage: kar-expert-fixture NEW_OUTPUT.kar".into());
}
const H: u64 = 64;
const F: u64 = 32;
const E: u64 = 2;
let scales = vec![0x2800u16; (H * F * E / 32) as usize]; // 1/32
let mut plane = vec![u32::MAX; (H * F / 32) as usize];
plane.extend(vec![0u32; (H * F / 32) as usize]);
let book = [0xbc00u16, 0x3c00]; // expert 0 positive, expert 1 negative
let books: [&[u16]; 1] = [&book];
let planes: [&[u32]; 1] = [&plane];
let raw: Vec<u8> = (0..3)
.flat_map(|_| {
(0..H * F * E).flat_map(|i| {
(if i < H * F {
1.0f32 / 32.0
} else {
-1.0f32 / 32.0
})
.to_le_bytes()
})
})
.collect();
let source = SourceIdentity {
name: "synthetic-routed-experts",
architecture: "synthetic",
builder: "strata-next/kar-expert-fixture-v1",
digest: Sha256::digest(&raw).into(),
total_elements: H * F * E * 3,
bytes: raw.len() as u64,
};
let dims = [[H, F, E], [H, F, E], [F, H, E]];
let names = [
"blk.0.ffn_gate_exps.weight",
"blk.0.ffn_up_exps.weight",
"blk.0.ffn_down_exps.weight",
];
let tensors: Vec<_> = (0..3)
.map(|role| Tensor {
name: names[role],
dims: &dims[role],
source_dtype: 0,
source_digest: Sha256::digest(
&raw[role * (H * F * E * 4) as usize..(role + 1) * (H * F * E * 4) as usize],
)
.into(),
source_offset: role as u64 * H * F * E * 4,
data: TensorData::Nested {
group: 32,
nesting: 0,
planes_min: 1,
planes_max: 1,
scales: &scales,
books: &books,
planes: &planes,
},
})
.collect();
kar_writer::write_archive(Path::new(&args[1]), &source, &tensors)?;
Ok(())
}
+10
View File
@@ -33,3 +33,13 @@ CUDA 13.2/SM 120 compilation and ELF audit passed without GPU inference. The
candidate still needs host glibc 2.43 and an NVIDIA driver; model qualification
is pending. See `deploy/README.md` and `docs/build-validation.md` for the exact
scope, artifact identity and remaining packaging limits.
## Experimental KAR expert integration, 2026-10-05
The pinned upstream commit remains unchanged. Local default-off
`STRATA_NEXT_EXPERIMENTAL_KAR_EXPERTS` adds a native decode cache-miss callback,
linked to the separate `gpu/kar` component. Resident native hits and prefill
retain their IQ weights. The runtime requires explicit archive and precision
environment settings, validates the archive payload and expert geometry, and
rejects unsupported pool/multi-device configurations. This is an experimental
quality arm, not full compressed-model residency or a qualified speedup.
+20
View File
@@ -392,6 +392,26 @@ if(STRATA_ENABLE_CUDA OR STRATA_ENABLE_HIP)
src/core/conversation_snapshot.cpp src/core/conversation_state.cpp src/core/conversation_memory.cpp)
target_include_directories(strata_engine PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(strata_engine PUBLIC strata_core strata_kernels strata_kernels_cpu ${_strata_gpu_runtime_target})
option(STRATA_NEXT_EXPERIMENTAL_KAR_EXPERTS "Build the opt-in KAR native decode cache-miss arm" OFF)
if(STRATA_NEXT_EXPERIMENTAL_KAR_EXPERTS)
if(NOT STRATA_ENABLE_CUDA OR NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
message(FATAL_ERROR "Experimental KAR experts require Linux CUDA")
endif()
if(NOT EXISTS "${STRATA_NEXT_KAR_DIR}/src/kar_expert_miss.cpp")
message(FATAL_ERROR "Set STRATA_NEXT_KAR_DIR to strata-next/gpu/kar")
endif()
add_library(strata_next_kar_experts STATIC
"${STRATA_NEXT_KAR_DIR}/vendor/libkar.cu"
"${STRATA_NEXT_KAR_DIR}/src/kar_expert.cu"
"${STRATA_NEXT_KAR_DIR}/src/kar_expert_miss.cpp")
target_include_directories(strata_next_kar_experts PUBLIC
"${STRATA_NEXT_KAR_DIR}/vendor" "${STRATA_NEXT_KAR_DIR}/include")
target_link_libraries(strata_next_kar_experts PUBLIC ${_strata_gpu_runtime_target})
set_target_properties(strata_next_kar_experts PROPERTIES CUDA_STANDARD 17 CUDA_STANDARD_REQUIRED ON)
target_compile_features(strata_next_kar_experts PRIVATE cxx_std_20)
target_link_libraries(strata_engine PUBLIC strata_next_kar_experts)
target_compile_definitions(strata_engine PUBLIC STRATA_NEXT_EXPERIMENTAL_KAR_EXPERTS=1)
endif()
add_executable(keyless_parity src/kernels/keyless_parity.cpp)
target_link_libraries(keyless_parity PRIVATE strata_engine)
add_test(NAME keyless_parity COMMAND keyless_parity)
@@ -211,6 +211,12 @@ struct GpuPlanSink {
/// The adapter's own state. One per session, reused every layer so the token path allocates nothing (P2.T10).
struct ExpertDispatch {
// Default-off local extension. The callback owns only kind==-1 entries and
// marks completed host rows as kind=3. Native hits/PCIe/remote rows are untouched.
using ExperimentalMiss = bool (*)(void*, int64_t, const float*, const int32_t*,
int64_t, int64_t, int32_t*, float*, std::string&);
ExperimentalMiss experimental_miss = nullptr;
void* experimental_miss_user = nullptr;
strata::kernels::cpu::ExpertPool* pool = nullptr;
ExpertSource* src = nullptr;
RouterLookahead* lookahead = nullptr; ///< CS-T: warms the next layer's predicted file-tier experts
+10 -2
View File
@@ -1745,6 +1745,13 @@ void expert_pool_dispatch_multi(ExpertDispatch& d, const float* x_f, const int32
for (int64_t i = 0; i < n; ++i) if (d.remote[r]->owns(i)) kind[i] = 2;
}
}
if (d.experimental_miss != nullptr) {
static thread_local std::string miss_error;
if (!d.experimental_miss(d.experimental_miss_user, d.layers, x_f, ids,
n_tok, k, kind, out, miss_error)) {
d.failed = true; d.fail = miss_error.c_str(); d.fail_layer = d.layers; return;
}
}
const auto c1 = std::chrono::steady_clock::now();
if (native && lay.fmt[(size_t) d.layers].gu_type == 42) // a native Q2_0 pack: the Q2_0 kernels' activations
for (int64_t t = 0; t < n_tok; ++t) act_quant_any(x_f + (size_t) t * H, H, d.act_multi[(size_t) t]);
@@ -1776,9 +1783,10 @@ void expert_pool_dispatch_multi(ExpertDispatch& d, const float* x_f, const int32
d.fail_expert = e;
return;
}
if (kind[i] >= 0) { // CUDA0, PCIe, or a remote result staged into this row below
if (kind[i] >= 0) { // CUDA0, PCIe, remote, or completed experimental host row
if (kind[i] == 0) ++d.cache_hits;
std::memset(row, 0, (size_t) H * sizeof(float));
if (kind[i] == 3) ++d.cache_refused;
else std::memset(row, 0, (size_t) H * sizeof(float));
continue;
}
++d.cache_refused;
+44
View File
@@ -20,6 +20,9 @@
#include "strata/core/conversation_memory.hpp"
#include "strata/core/coupled_draft.hpp"
#include "strata/core/expert_source.hpp"
#if defined(STRATA_NEXT_EXPERIMENTAL_KAR_EXPERTS)
#include "kar_expert_miss.hpp"
#endif
#include "strata/core/pinned.hpp"
#include "strata/core/remote_experts.hpp"
#include "strata/core/on_device.hpp"
@@ -1891,6 +1894,37 @@ int main(int argc, char** argv) {
rope_cfg.type == RST::YaRN ? "YaRN" : "--yarn-attn-factor", rope_cfg.mscale());
}
}
const char* kar_expert_archive = std::getenv("STRATA_NEXT_KAR_EXPERTS_ARCHIVE");
#if defined(STRATA_NEXT_EXPERIMENTAL_KAR_EXPERTS)
strata::kar::ExpertMiss kar_expert_miss;
if (kar_expert_archive != nullptr) {
const char* level_text = std::getenv("STRATA_NEXT_KAR_EXPERTS_LEVEL");
if (!native_pack || o.no_pool || !split_devs.empty() || remote_caches ||
!level_text || std::strlen(level_text) != 1 || level_text[0] < '1' || level_text[0] > '8' ||
g.n_embd != strata::kernels::cpu::H) {
std::fprintf(stderr, "strata generate: experimental KAR misses require a native pack, one GPU, "
"the expert pool and explicit STRATA_NEXT_KAR_EXPERTS_LEVEL=1..8\n");
return 2;
}
for (const auto& f : strata::kernels::cpu::expert_layout().fmt)
if (f.n_embd != strata::kernels::cpu::H || f.n_ff != strata::kernels::cpu::FF) {
std::fprintf(stderr, "strata generate: unsupported KAR expert geometry\n"); return 2;
}
if (!kar_expert_miss.open(kar_expert_archive, (uint32_t) g.n_layers, (uint32_t) g.n_expert,
(uint32_t) g.n_embd, strata::kernels::cpu::FF,
(uint32_t) (level_text[0] - '0'), err)) {
std::fprintf(stderr, "strata generate: %s\n", err.c_str()); return 1;
}
// Native resident hits are the baseline. Route all otherwise CPU/PCIe
// misses to the explicit experimental arm; use pcie-frac=0 in its baseline.
o.pcie_frac = 0;
}
#else
if (kar_expert_archive != nullptr) {
std::fprintf(stderr, "strata generate: this build has no experimental KAR expert support\n");
return 2;
}
#endif
strata::core::NativeEmbed native_embed;
if (native_pack) {
if (o.native_preset.empty() || o.spec < 2 || o.keep_canonical ||
@@ -3086,6 +3120,12 @@ int main(int argc, char** argv) {
}
Drive drive;
#if defined(STRATA_NEXT_EXPERIMENTAL_KAR_EXPERTS)
if (kar_expert_archive != nullptr) {
drive.d.experimental_miss = &strata::kar::ExpertMiss::dispatch;
drive.d.experimental_miss_user = &kar_expert_miss;
}
#endif
for (int r = 0; r < 3; ++r) if (o.expert_cache_remote[(size_t) r] > 0)
drive.d.remote[drive.d.remote_count++] = &remote_experts[(size_t) r];
drive.d.hit_cpu_order = o.expert_cache_cpu_order;
@@ -4855,6 +4895,10 @@ int main(int argc, char** argv) {
// unknown keys are skipped: the ids start at the first token without '='
}
}
if (kar_expert_archive != nullptr && req_pcie_frac != 0.0) {
std::printf("ERR experimental KAR misses require pcie_frac=0\n");
continue;
}
std::string emb_path;
if (geni && endp != nullptr) {
while (*endp == ' ') ++endp;
+8
View File
@@ -61,3 +61,11 @@ target_compile_features(strata-kar-expert-test PRIVATE cxx_std_20)
target_link_libraries(strata-kar-expert-test PRIVATE strata_kar_expert)
add_test(NAME kar_expert_component COMMAND strata-kar-expert-test)
set_tests_properties(kar_expert_component PROPERTIES TIMEOUT 60)
add_library(strata_kar_miss STATIC src/kar_expert_miss.cpp)
target_compile_features(strata_kar_miss PRIVATE cxx_std_20)
target_link_libraries(strata_kar_miss PUBLIC strata_kar_expert strata_kar_cuda)
add_executable(strata-kar-expert-miss-test src/kar_expert_miss_test.cpp)
target_compile_features(strata-kar-expert-miss-test PRIVATE cxx_std_20)
target_link_libraries(strata-kar-expert-miss-test PRIVATE strata_kar_miss)
add_test(NAME kar_expert_miss COMMAND strata-kar-expert-miss-test "${CMAKE_BINARY_DIR}/expert-fixture.kar")
set_tests_properties(kar_expert_miss PROPERTIES TIMEOUT 60)
+31 -2
View File
@@ -10,8 +10,8 @@ one F32 matrix scratch buffer is reused for decode, multiply, SiLU and down
projection. Allocations happen in `open`, with a fixed geometry cap and GPU
headroom check. Its own stream/event controls ownership and completion.
This is a component under qualification, **not yet a serving cache-miss
adapter**. It has no LRU scheduler, and staging waits for its own upload.
The component has an opt-in native decode cache-miss adapter described below.
It has no LRU scheduler, and staging waits for its own upload.
Its F32 activation arithmetic differs from native quantized expert arithmetic.
No default, model quality or speed claim follows from its oracle passing.
@@ -43,6 +43,35 @@ for compressed weights and 6,758,400 bytes for matrix/activation scratch;
CUDA context overhead is excluded. This is one expert component, not full-model
serving or a comparison with the original IQ3 expert.
### Experimental native decode misses
Build the engine with `STRATA_NEXT_EXPERIMENTAL_KAR_EXPERTS=ON` and
`STRATA_NEXT_KAR_DIR` pointing to this directory. This option is off by default
and requires Linux CUDA. Set `STRATA_NEXT_KAR_EXPERTS_ARCHIVE` to a trusted,
immutable, separately SHA/provenance-verified target-model KAR archive and
`STRATA_NEXT_KAR_EXPERTS_LEVEL` explicitly to its supported level (1–8).
The reader checks directory integrity, every payload CRC and every layer's
expert geometry before allocating its bounded GPU buffers. This integrity
check does not authenticate the archive's pairing with the loaded GGUF.
Large archives can take minutes to verify; configure an appropriate worker
startup deadline. Keep both model and archive unchanged for the worker's life.
The adapter requires the native pack, expert pool and a single GPU. It computes
only native decode-window misses. Native resident hits, prefill, dense weights,
PLE and MTP retain their existing paths. It sets the PCIe miss fraction to zero;
use `--pcie-frac 0` in the comparison baseline as well. This is a mixed precision
experimental arm, not full KAR model residency. Each missed expert is staged
and computed serially on the component's own nonblocking CUDA stream. Its
completed host rows preserve routing order and bypass the CPU expert jobs.
The bounded matrix scratch is reused; no decoded expert bank is allocated.
The exit diagnostic reports computed route entries and explicit GPU bytes.
The GPU test script also uses the production Rust archive writer to make a
model-free expert bank. It tests eight-token grouped routing against a scalar
oracle (absolute tolerance `1e-6`), preservation of VRAM/PCIe/remote/completed
rows, unsupported archive shape/level and invalid routed IDs. Production
serving does not invoke the fixture generator or Python.
The optional `strata_next_kar_ple_probe` target belongs to the imported
Strata engine build when `STRATA_NEXT_EXPERIMENTAL_KAR_PLE=ON`. It exercises
the separate CPU PLE quality arm on real KAR rows. A successful checksum does
+29
View File
@@ -0,0 +1,29 @@
#pragma once
#include <cstdint>
#include <memory>
#include <string>
namespace strata::kar {
// Experimental native decode cache-miss arm. Prefill and cache hits retain
// the native IQ weights. Not a full compressed-model serving implementation.
class ExpertMiss {
public:
ExpertMiss();
~ExpertMiss();
bool open(const char* archive, uint32_t layers, uint32_t experts,
uint32_t hidden, uint32_t intermediate, uint32_t level,
std::string& error);
bool compute(int64_t layer, const float* input, const int32_t* ids,
int64_t tokens, int64_t k, int32_t* kind, float* output,
std::string& error);
static bool dispatch(void* user, int64_t layer, const float* input,
const int32_t* ids, int64_t tokens, int64_t k,
int32_t* kind, float* output, std::string& error);
uint64_t computed() const;
private:
struct Impl;
std::unique_ptr<Impl> impl_;
};
}
+112
View File
@@ -0,0 +1,112 @@
#include "kar_expert_miss.hpp"
#include "kar_expert.hpp"
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
namespace strata::kar {
struct ExpertMiss::Impl {
int fd=-1;
const uint8_t* mapping=nullptr;
size_t bytes=0;
kar_archive* archive=nullptr;
uint32_t layers=0, experts=0, hidden=0, ff=0;
uint64_t computed=0;
std::vector<const kar_tensor_info*> records;
std::vector<float> input, output;
ResidentExpert resident;
~Impl() {
if(mapping) munmap(const_cast<uint8_t*>(mapping),bytes);
if(fd>=0) close(fd);
if(archive) kar_close(archive);
}
};
ExpertMiss::ExpertMiss() = default;
ExpertMiss::~ExpertMiss() {
if(impl_)std::fprintf(stderr,"strata KAR experimental misses: %llu entries computed; compressed=%llu scratch=%llu bytes\n",
(unsigned long long)impl_->computed,(unsigned long long)impl_->resident.resident_bytes(),
(unsigned long long)impl_->resident.scratch_bytes());
}
uint64_t ExpertMiss::computed() const {return impl_?impl_->computed:0;}
bool ExpertMiss::open(const char* path,uint32_t layers,uint32_t experts,uint32_t hidden,
uint32_t ff,uint32_t level,std::string& error) {
if(impl_ || !path || !*path || layers<1 || layers>512 || experts<1 || experts>65536) {
error="invalid KAR miss configuration";return false;
}
auto p=std::make_unique<Impl>();
// Keep a descriptor to the exact inode used by both mappings. Replacing the
// configured path during validation cannot select a different payload.
p->fd=::open(path,O_RDONLY|O_CLOEXEC);
struct stat st{};
if(p->fd<0 || fstat(p->fd,&st)!=0 || !S_ISREG(st.st_mode) || st.st_size<=0) {
error="KAR miss archive is not a readable regular file";return false;
}
const std::string pinned="/proc/self/fd/"+std::to_string(p->fd);
if(kar_open(pinned.c_str(),KAR_OPEN_VERIFY_PAYLOAD,&p->archive)!=KAR_OK) {
error=std::string("KAR miss archive validation: ")+kar_last_error();return false;
}
p->bytes=static_cast<size_t>(st.st_size);
void* mapped=mmap(nullptr,p->bytes,PROT_READ,MAP_PRIVATE,p->fd,0);
if(mapped==MAP_FAILED) {error="cannot map KAR miss archive";return false;}
p->mapping=static_cast<const uint8_t*>(mapped);
p->layers=layers;p->experts=experts;p->hidden=hidden;p->ff=ff;
const char* roles[]={"gate","up","down"};
for(uint32_t layer=0;layer<layers;++layer)for(uint32_t role=0;role<3;++role) {
const std::string name="blk."+std::to_string(layer)+".ffn_"+roles[role]+"_exps.weight";
const int index=kar_find(p->archive,name.c_str());
if(index<0) {error="missing KAR expert tensor: "+name;return false;}
const auto* t=kar_tensor(p->archive,index);
if(t->n_dims!=3 || t->dims[0]!=(role==2?ff:hidden) ||
t->dims[1]!=(role==2?hidden:ff) || t->dims[2]!=experts ||
t->group!=32 || t->storage_class!=KAR_NESTED || t->nesting!=KAR_TOPDOWN ||
level<t->planes_min || level>t->planes_max) {
error="KAR expert tensor geometry/level mismatch: "+name;return false;
}
p->records.push_back(t);
}
if(!p->resident.open(hidden,ff,level,8,error))return false;
p->input.resize(size_t(hidden)*8);p->output.resize(size_t(hidden)*8);
std::fprintf(stderr,"strata KAR experimental: native decode misses only, level=%u, compressed=%llu scratch=%llu; quality not qualified\n",
level,(unsigned long long)p->resident.resident_bytes(),(unsigned long long)p->resident.scratch_bytes());
impl_=std::move(p);return true;
}
bool ExpertMiss::compute(int64_t layer,const float* input,const int32_t* ids,int64_t tokens,
int64_t k,int32_t* kind,float* output,std::string& error) {
if(!impl_ || layer<0 || layer>=impl_->layers || tokens<1 || tokens>8 || k<1 || k>16 ||
!input || !ids || !kind || !output) {error="invalid KAR miss dispatch";return false;}
auto& p=*impl_;
for(int64_t i=0;i<tokens*k;++i)
if(ids[i]<0 || ids[i]>=int64_t(p.experts)) {error="KAR routed expert out of range";return false;}
for(int64_t i=0;i<tokens*k;++i) {
if(kind[i]>=0)continue;
const uint32_t expert=ids[i];
int64_t positions[8];uint32_t count=0;
// Native top-k routing never duplicates an expert within one token.
for(int64_t j=i;j<tokens*k;++j)if(kind[j]<0 && ids[j]==int32_t(expert)) {
if(count==8) {error="duplicate/oversized KAR routed expert group";return false;}
positions[count]=j;
std::memcpy(p.input.data()+size_t(count)*p.hidden,input+size_t(j/k)*p.hidden,p.hidden*4);
++count;
}
const auto off=size_t(layer)*3;
if(!p.resident.stage(p.mapping,p.bytes,*p.records[off],*p.records[off+1],*p.records[off+2],expert,error) ||
!p.resident.run(p.input.data(),count,error) || !p.resident.finish(p.output.data(),error))return false;
for(uint32_t t=0;t<count;++t) {
std::memcpy(output+size_t(positions[t])*p.hidden,p.output.data()+size_t(t)*p.hidden,p.hidden*4);
kind[positions[t]]=3; // owned host result; the native pool must not zero it
++p.computed;
}
}
return true;
}
bool ExpertMiss::dispatch(void* user,int64_t layer,const float* input,const int32_t* ids,
int64_t tokens,int64_t k,int32_t* kind,float* output,std::string& error) {
if(!user) {error="missing KAR miss owner";return false;}
return static_cast<ExpertMiss*>(user)->compute(layer,input,ids,tokens,k,kind,output,error);
}
}
+44
View File
@@ -0,0 +1,44 @@
#include "kar_expert_miss.hpp"
#include <cmath>
#include <cstdio>
#include <stdexcept>
#include <vector>
namespace {
void require(bool ok, const char* error) { if(!ok)throw std::runtime_error(error); }
}
int main(int argc,char** argv) try {
require(argc==2,"expected model-free archive path");
std::string error;
strata::kar::ExpertMiss miss;
require(!miss.open(argv[1],2,2,64,32,1,error),"missing layer accepted");
require(!miss.open(argv[1],1,2,64,32,2,error),"unavailable level accepted");
require(miss.open(argv[1],1,2,64,32,1,error),error.c_str());
constexpr int H=64,K=2,T=8;
std::vector<float> x(T*H),out(T*K*H,123.0f);
std::vector<int32_t> ids(T*K),kind(T*K,-1);
for(int t=0;t<T;++t) {
for(int c=0;c<H;++c)x[t*H+c]=(t+1)/64.0f;
ids[t*K]=t%2;ids[t*K+1]=1-t%2;
}
// Existing VRAM/PCIe/remote rows belong to their original producers.
kind[1]=0;kind[4]=1;kind[9]=2;
require(miss.compute(0,x.data(),ids.data(),T,K,kind.data(),out.data(),error),error.c_str());
require(miss.computed()==T*K-3,"incorrect computed count");
for(int i=0;i<T*K;++i)for(int c=0;c<H;++c) {
if(i==1 || i==4 || i==9) {require(out[i*H+c]==123,"foreign row overwritten");continue;}
const double sign=ids[i]==0?1.0:-1.0;
const double g=sign*(i/K+1)/32.0;
const double expected=sign*(g/(1+std::exp(-g)))*g;
require(kind[i]==3 && std::abs(out[i*H+c]-expected)<1e-6,"scatter/multiply mismatch");
}
const auto saved=out;
require(miss.compute(0,x.data(),ids.data(),T,K,kind.data(),out.data(),error),error.c_str());
require(out==saved && miss.computed()==T*K-3,"completed rows recomputed");
ids[0]=2;
require(!miss.compute(0,x.data(),ids.data(),T,K,kind.data(),out.data(),error),"invalid expert accepted");
require(out==saved,"rejected dispatch modified output");
require(!miss.compute(1,x.data(),ids.data(),T,K,kind.data(),out.data(),error),"invalid layer accepted");
std::puts("PASS: routed KAR misses, grouped eight-token scatter, foreign/completed rows preserved, invalid dispatch rejected; tolerance 1e-6");
return 0;
} catch(const std::exception& e) {std::fprintf(stderr,"KAR miss test: %s\n",e.what());return 1;}
+5 -2
View File
@@ -9,5 +9,8 @@ if (( used > 1024 )); then
fi
cmake -S "${repo_root}/gpu/kar" -B "${build_dir}" \
-DCMAKE_CUDA_ARCHITECTURES="${STRATA_CUDA_ARCHITECTURES:-native}"
cmake --build "${build_dir}" --parallel "${BUILD_JOBS:-2}" --target strata-kar-expert-test
ctest --test-dir "${build_dir}" --output-on-failure -R '^kar_expert_component$'
cmake --build "${build_dir}" --parallel "${BUILD_JOBS:-2}" --target strata-kar-expert-test strata-kar-expert-miss-test
rm -f "${build_dir}/expert-fixture.kar"
cargo run --locked --manifest-path "${repo_root}/control-plane/Cargo.toml" \
--example kar-expert-fixture -- "${build_dir}/expert-fixture.kar"
ctest --test-dir "${build_dir}" --output-on-failure -R '^kar_expert_(component|miss)$'