From 771c12c225870516063457f58ebfac2f4ebb4093 Mon Sep 17 00:00:00 2001 From: bong-water-water-bong Date: Tue, 10 Nov 2026 03:53:45 -0400 Subject: [PATCH] npu-run: refuse a sealed kernel directory by name instead of "cannot read layer_ctx1.elf" (engine#1862) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit npu-run drives the per-role kernel set (layer_ctx{1,2,17}.elf, lmhead.elf, layer.pdi — npu/lane.cpp:69). Every pack since the sealed route ships the other set (SEALED-T2S.elf, full_i8_*) driven by `serve --device npu` from plan.json, and a find over ~/models and ~/scratch-packs for layer_ctx1.elf returns 0. The bare "cannot read /layer_ctx1.elf" read as a missing file rather than a route mismatch. Inspect the directory before constructing the Lane: if it holds SEALED-*/full_i8_* ELFs, say how many, which set npu-run needs, and that the sealed route is driven by `1bit serve --device npu` from plan.json. If it holds neither, say that. A directory that does have layer_ctx1.elf is untouched (it still fails inside Lane on the next file, as before). Verified device-free, three arms: 1. bonsai2-27b-t2s2/kernels-m16 -> "holds the sealed full-ELF kernel set (18 ELF(s)) ..." 2. an empty directory -> "no kernel set in ...: neither layer_ctx1.elf ... nor a SEALED-*/full_i8_* ELF ..." 3. a directory with a layer_ctx1.elf -> check does not fire; Lane fails on layer.pdi as before --- app/main.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/app/main.cpp b/app/main.cpp index 4cefcafaf..523d0b98d 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -148,6 +148,32 @@ int run_npu(int argc, char** argv) { std::istringstream in(ids); for (int t; in >> t;) prompt.push_back(t); + // engine#1862: a kernel directory from the sealed/full-ELF generation has no layer_ctx*.elf, and the bare + // "cannot read /layer_ctx1.elf" from npu/lane.cpp reads as a missing file rather than a different route. + // Name the generation that IS there, and the command that drives it. + { + namespace fs = std::filesystem; + if (!fs::exists(fs::path(kernel_dir) / "layer_ctx1.elf")) { + int sealed = 0; + std::error_code ec; + for (const auto& ent : fs::directory_iterator(kernel_dir, ec)) { + const std::string name = ent.path().filename().string(); + if (ent.path().extension() == ".elf" && + (name.rfind("SEALED-", 0) == 0 || name.rfind("full_i8_", 0) == 0)) + ++sealed; + } + if (sealed > 0) + throw std::runtime_error( + kernel_dir + " holds the sealed full-ELF kernel set (" + std::to_string(sealed) + + " ELF(s)), which npu-run does not drive: npu-run needs layer_ctx{1,2,17}.elf, lmhead.elf and " + "layer.pdi. The sealed route is driven by `1bit serve --device npu` from the pack's plan.json " + "(engine#1862)"); + throw std::runtime_error("no kernel set in " + kernel_dir + + ": neither layer_ctx1.elf (the per-role set npu-run drives) nor a SEALED-*/full_i8_* " + "ELF (the sealed set) is present"); + } + } + const onebit::npu::Model model(model_dir); auto t0 = std::chrono::steady_clock::now(); onebit::npu::Lane lane(model, kernel_dir);