diff --git a/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_decode.cpp b/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_decode.cpp deleted file mode 100644 index c5c49fec0..000000000 --- a/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_decode.cpp +++ /dev/null @@ -1,168 +0,0 @@ -// Copyright © Advanced Micro Devices, Inc., or its affiliates. All rights reserved. -// Portions of this file consist of AI-generated content. - -/// \file inkling2_decode.cpp -/// \brief inkling2_decode: a decode token's routed experts on the NPU -#include "inkling2_decode.hpp" - -#include - -#include -#include -#include -#include - -#include "inkling2_host.hpp" - -using namespace inkling2_host; - -namespace { - -constexpr int UNIT = 4736; // one Q4_K block: a task is whole units -constexpr int X_OFF = 128; // x in a header unit -constexpr int Y_UNIT = 96; // outputs per group -constexpr int GPE = D / (NPU_GROUP * QROWS); // groups per expert: 24 (gate_up 2 FF = D rows, down D rows) -constexpr int C = 16; // channels -constexpr int OP_GEMV_Q4K = 2; -constexpr npu_tiles IT[8] = {IT0, IT1, IT2, IT3, IT4, IT5, IT6, IT7}; -constexpr int NC[2] = {D / 256, FF_PAD / 256}; // column blocks: gate_up 9, down 5 - -static_assert(D == 2 * FF && GPE * NPU_GROUP * QROWS == D, "gate_up and down are 24 groups per expert"); -static_assert(X_OFF + D * 2 <= UNIT, "x fits a header unit"); - -using clk = std::chrono::steady_clock; -double since(clk::time_point& t0) { - const clk::time_point t1 = clk::now(); - const double s = std::chrono::duration(t1 - t0).count(); - t0 = t1; - return s; -} - -void to_bf16(u16* dst, const float* src, int n) { - const __m512i one = _mm512_set1_epi32(1), bias = _mm512_set1_epi32(0x7FFF); - for (int i = 0; i < n; i += 16) { - __m512i v = _mm512_castps_si512(_mm512_loadu_ps(src + i)); - v = _mm512_add_epi32(v, _mm512_add_epi32(_mm512_and_si512(_mm512_srli_epi32(v, 16), one), bias)); - _mm256_storeu_si256(reinterpret_cast<__m256i*>(dst + i), _mm512_cvtepi32_epi16(_mm512_srli_epi32(v, 16))); - } -} - -} // namespace - -inkling2_decode::inkling2_decode(npu_xclbin_manager* npu, const std::string& xclbin) : mgr(npu->register_xclbin(xclbin)) {} - -inkling2_decode::plan& inkling2_decode::get(int kind, int n) { - auto it = this->plans.find(kind * 16 + n); - if (it != this->plans.end()) return it->second; - plan& p = this->plans[kind * 16 + n]; - p.app = this->mgr->create_app(); - const int nc = NC[kind]; - const bool shared_x = kind == 0; - // channel c takes groups [c total / C, (c + 1) total / C) of the (expert slot, group) order: at most two experts - const int total = n * GPE; - p.segs.resize(C); - for (int c = 0; c < C; c++) { - int g = c * total / C; - const int end = (c + 1) * total / C; - while (g < end) { - const int s = g / GPE, m = std::min(end, (s + 1) * GPE) - g; - p.segs[c].push_back({s, g % GPE, m}); - g += m; - } - if (p.segs[c].size() > 2) throw std::runtime_error("inkling2 decode: a channel spans more than two experts"); - } - // io: header units [C][2], then y [C][groups][96] fp32 - p.ybase.resize(C); - size_t yo = (size_t)C * 2 * UNIT; - for (int c = 0; c < C; c++) { - p.ybase[c] = yo; - for (const seg& s : p.segs[c]) yo += (size_t)s.n * Y_UNIT * 4; - } - p.io_bytes = yo; - if (this->io[kind].size() < yo) { - this->io[kind] = p.app.create_bo_buffer(yo); - memset(this->io[kind].data(), 0, yo); - } - // per channel: y (S2MM BD 14 + r), then header and weight tasks (MM2S BDs 6 r ..): at most 4 outstanding - npu_sequence* seq = p.app.seq(); - seq->clear_cmds(); - for (int c = 0; c < C; c++) { - const int col = c % 8, r = c / 8; - const npu_it_channel ch = r ? it_channel_1 : it_channel_0; - int ny = 0; - for (const seg& s : p.segs[c]) ny += s.n; - seq->npu_dma_memcpy_nd(4, 0, S2MM, IT[col], npu_bd_id(14 + r), ch, {0, 0, 0, (uint32_t)(p.ybase[c] / 4)}, - {1, 1, 1, (uint32_t)(ny * Y_UNIT)}, {0, 0, 0, 1}); - int bd = 6 * r; - for (size_t i = 0; i < p.segs[c].size(); i++) { - const seg& s = p.segs[c][i]; - if (i == 0 || !shared_x) - seq->npu_dma_memcpy_nd(1, 0, MM2S, IT[col], npu_bd_id(bd++), ch, {0, 0, 0, (uint32_t)((c * 2 + i) * UNIT)}, - {1, 1, 1, (uint32_t)UNIT}, {0, 0, 0, 1}); - seq->npu_dma_memcpy_nd(1, 1 + s.slot, MM2S, IT[col], npu_bd_id(bd++), ch, - {0, 0, 0, (uint32_t)((size_t)s.g0 * nc * NPU_GROUP * UNIT)}, - {1, 1, 1, (uint32_t)((size_t)s.n * nc * NPU_GROUP * UNIT)}, {0, 0, 0, 1}); - } - } - for (int c = 0; c < C; c++) seq->npu_dma_wait(IT[c % 8], S2MM, c / 8 ? it_channel_1 : it_channel_0); - seq->cmds2seq(); - return p; -} - -void inkling2_decode::start(int kind, bytes& w, size_t base, const int* ex, int n, const float* in) { - clk::time_point t0 = clk::now(); - if (n < 1 || n > MAX_N) throw std::runtime_error("inkling2 decode: 1 to 4 experts per dispatch"); - plan& p = this->get(kind, n); - const int nc = NC[kind]; - const size_t eb = (size_t)GPE * nc * NPU_GROUP * UNIT; // bytes per expert - u8* io = this->io[kind].data(); - // headers: shared x (gate_up) once per channel over all its groups, else one per segment with its expert's input - u16 xb[MAX_N][D]; - const int xn = kind == 0 ? 1 : n, xlen = nc * 256; - for (int s = 0; s < xn; s++) to_bf16(xb[s], in + (size_t)s * (kind == 0 ? D : FF_PAD), xlen); - for (int c = 0; c < C; c++) { - int all = 0; - for (const seg& s : p.segs[c]) all += s.n; - for (size_t i = 0; i < p.segs[c].size(); i++) { - if (i > 0 && kind == 0) break; - u8* h = io + (size_t)(c * 2 + i) * UNIT; - int32_t hw[3] = {OP_GEMV_Q4K, kind == 0 ? all : p.segs[c][i].n, nc}; - memcpy(h, hw, sizeof(hw)); - memcpy(h + X_OFF, xb[kind == 0 ? 0 : p.segs[c][i].slot], (size_t)xlen * 2); - } - } - this->io[kind].sync_to_device(); - bound_arg a[MAX_N]; - for (int s = 0; s < MAX_N; s++) a[s] = {&w, base + (size_t)ex[std::min(s, n - 1)] * eb}; - this->run = p.app.create_run(this->io[kind], a[0], a[1], a[2], a[3]); - this->run.start(); - this->kind = kind; - this->n = n; - this->t_start += since(t0); - this->calls++; -} - -void inkling2_decode::wait(float* out) { - clk::time_point t0 = clk::now(); - this->run.wait(); - plan& p = this->get(this->kind, this->n); - this->io[this->kind].sync_from_device(); - const u8* io = this->io[this->kind].data(); - for (int c = 0; c < C; c++) { - const float* y = reinterpret_cast(io + p.ybase[c]); - for (const seg& s : p.segs[c]) - for (int g = s.g0; g < s.g0 + s.n; g++, y += Y_UNIT) { - if (this->kind == 1) { - memcpy(out + (size_t)s.slot * D + g * Y_UNIT, y, Y_UNIT * 4); - continue; - } - // gate_up storage block j = 3 g + b: gate block j / 2 when even, up block j / 2 when odd - float* o = out + (size_t)s.slot * 2 * FF; - for (int b = 0; b < NPU_GROUP; b++) { - const int j = NPU_GROUP * g + b; - memcpy(o + (j % 2 ? FF : 0) + (j / 2) * QROWS, y + b * QROWS, QROWS * 4); - } - } - } - this->t_wait += since(t0); -} diff --git a/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_decode.hpp b/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_decode.hpp deleted file mode 100644 index 8931743d4..000000000 --- a/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_decode.hpp +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright © Advanced Micro Devices, Inc., or its affiliates. All rights reserved. -// Portions of this file consist of AI-generated content. - -/// \file inkling2_decode.hpp -/// \brief a decode token's routed experts on the NPU (decode.xclbin, FLM_Xclbin/Inkling2/decode), beside the host -/// \note The overlay streams Q4_K weights from DDR through 16 shim channels (shim MM2S 0 and 1 of every column) into -/// 16 GEMV cores (decode_core.cc). A channel's work is a header task (opcode, groups, column blocks, then x as -/// bf16) followed by weight tasks of whole block groups (96 rows x nc column blocks, the grouped layout the -/// prefill buffers hold); the core writes 96 fp32 outputs per group. A dispatch of n experts (n <= 4) spreads -/// their n x 24 groups over the channels in (expert, group) order; the experts are sub-buffers of the layer -/// buffer bound per call (arguments 1 .. 4), so the instruction sequence depends on n only. -/// The NPU streams ~3 experts in about the time the host takes for the other 5, so a token's experts are split. -#pragma once -#include -#include -#include - -#include "npu_utils/npu_utils.hpp" -#include "typedef.hpp" - -class inkling2_decode { -public: - static constexpr int MAX_N = 4; // experts per dispatch (weight arguments) - - /// \param xclbin path of decode.xclbin - inkling2_decode(npu_xclbin_manager* npu, const std::string& xclbin); - - /// \brief start experts ex[0 .. n) of a layer: kind 0 gate_up of x [D] (w at the layer's gate_up), kind 1 down of - /// a [n][FF_PAD] (w at the layer's down) - void start(int kind, bytes& w, size_t base, const int* ex, int n, const float* in); - /// \brief wait for start(): kind 0 out [n][2 FF] (gate rows, then up rows), kind 1 out [n][D] - void wait(float* out); - - // DIAG: seconds in start / wait and calls - double t_start = 0, t_wait = 0; - long calls = 0; - -private: - struct seg { - int slot, g0, n; - }; - struct plan { - npu_app app; - std::vector> segs; // per channel - std::vector ybase; // per channel, bytes into io - size_t io_bytes = 0; - }; - npu_app_manager* mgr; - std::map plans; // kind * 16 + n - buffer io[2]; // per kind: headers, then y - flm_rt::run run; - int kind = -1, n = 0; - plan& get(int kind, int n); -}; diff --git a/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_fused.cpp b/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_fused.cpp index 9d2afeaf7..206864df2 100644 --- a/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_fused.cpp +++ b/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_fused.cpp @@ -941,8 +941,7 @@ void inkling2_fused::add_steps(int j, int stages) { const app_info I = info(j); const proj_plan& PP = I.three ? this->pp3 : this->pp1; const size_t H = I.three ? this->H3 : this->H1; - static const bool same_w = getenv("INKLING2_FUSED_SAMEW") && atoi(getenv("INKLING2_FUSED_SAMEW")); // timing test only - const layer_src& Ls = this->src[same_w ? 0 : I.il]; + const layer_src& Ls = this->src[I.il]; const uint64_t wa = Ls.w->bo().address() + 0x80000000ull; npu_sequence* seq = this->app().seq(); // an MM2S BD at an absolute device address (any buffer): written unpushed, its address patched, then pushed @@ -1069,16 +1068,6 @@ bool inkling2_fused::submit(int stages) { npu_sequence* seq = this->app().seq(); const auto t0 = this->t_build; seq->cmds2seq(); - if (const char* dd = getenv("INKLING2_DUMP_TXN")) { // test only: the first token's streams - static int nd = 0; - if (nd < 49) { - const auto d = seq->dump(); - if (FILE* f = fopen((std::string(dd) + "/s" + std::to_string(nd++) + ".txn").c_str(), "wb")) { - fwrite(d.first, 4, d.second, f); - fclose(f); - } - } - } const auto t1 = std::chrono::steady_clock::now(); xrt::run run = this->app().create_run(this->io, this->wt, this->gl[0], this->gl[1], this->cw); this->t_create += std::chrono::duration(std::chrono::steady_clock::now() - t1).count(); diff --git a/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_host.cpp b/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_host.cpp index 5f3dc5b71..d1f00f69a 100644 --- a/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_host.cpp +++ b/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_host.cpp @@ -939,46 +939,6 @@ void moe(float* out, const float* x, int T, const layer_weights& L, int il, mm_o token_of[r] = i / TOPK; } prof_lap(tp, P_ROUTER); - if (T == 1 && offload && offload->dec_experts() > 0) { - // the first nd of the token's experts on the device, the rest on the host meanwhile - const int nd = std::min(offload->dec_experts(), TOPK); - const int* ex = sel.data(); - static thread_local std::vector GU_buf((size_t)TOPK * 2 * FF), A_buf((size_t)TOPK * FF_PAD, 0.0f), - Z_buf((size_t)TOPK * D); - float* GU = GU_buf.data(); - float* A = A_buf.data(); - float* Z = Z_buf.data(); - constexpr int rb_per_expert = D / QROWS; - auto act = [&](int k0, int k1) { - #pragma omp parallel for schedule(static) - for (int i = k0 * (FF / 16); i < k1 * (FF / 16); i++) { - const int k = i / (FF / 16), c = i % (FF / 16) * 16; - const float* gu = GU + (size_t)k * 2 * FF; - _mm512_storeu_ps(A + (size_t)k * FF_PAD + c, situ16(_mm512_loadu_ps(gu + c), _mm512_loadu_ps(gu + FF + c))); - } - }; - offload->dec_start(il, 0, ex, nd, x); - std::vector jobs; - for (int k = nd; k < TOPK; k++) - jobs.push_back({L.gate_up.rows(ex[k] * rb_per_expert, 2 * FF), x, D, 1, GU + (size_t)k * 2 * FF, 2 * FF}); - qmm(jobs); - offload->dec_wait(GU); - act(0, nd); - offload->dec_start(il, 1, ex, nd, A); - act(nd, TOPK); - jobs.clear(); - for (int k = nd; k < TOPK; k++) - jobs.push_back({L.down.rows(ex[k] * rb_per_expert, D), A + (size_t)k * FF_PAD, FF_PAD, 1, Z + (size_t)k * D, D}); - qmm(jobs); - offload->dec_wait(Z); - for (int c = 0; c < D; c += 16) { - __m512 o = _mm512_setzero_ps(); - for (int k = 0; k < TOPK; k++) o = _mm512_fmadd_ps(_mm512_set1_ps(wsel[k]), _mm512_loadu_ps(Z + (size_t)k * D + c), o); - _mm512_storeu_ps(out + c, o); - } - prof_lap(tp, P_EXPERT); - return; - } if (offload && offload->experts(il, x, T, token_of.data(), count.data(), start.data(), slot_of.data(), wsel.data(), out)) { prof_lap(tp, P_EXPERT); return; diff --git a/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_host.hpp b/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_host.hpp index c4e50f1c5..4726256b7 100644 --- a/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_host.hpp +++ b/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_host.hpp @@ -307,14 +307,6 @@ class mm_offload { const float* G, const bf16_rows* Gb, float* O, const std::function& packed) { return false; } - /// \brief decode (one token): how many of a token's TOPK experts the device takes (0: none); the host runs the rest - /// meanwhile - virtual int dec_experts() const { return 0; } - /// \brief start experts ex[0 .. n) of layer il on the device: kind 0 gate_up of in = x [D], kind 1 down of - /// in = [n][FF_PAD] activations - virtual void dec_start(int il, int kind, const int* ex, int n, const float* in) {} - /// \brief wait for dec_start: kind 0 out [n][2 FF] (gate, then up), kind 1 out [n][D] - virtual void dec_wait(float* out) {} }; /// \brief the model.q4nx tensors, located in place (safetensors container) diff --git a/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_lm_head.cpp b/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_lm_head.cpp index 288d5384f..94f93f096 100644 --- a/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_lm_head.cpp +++ b/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_lm_head.cpp @@ -16,10 +16,6 @@ #include #include -#if !defined(_WIN32) -#include -#endif - #if !defined(FLM_USE_HRX) // see inkling2_fused.hpp using namespace inkling2_host; @@ -71,26 +67,7 @@ void inkling2_lm_head::init(npu_xclbin_manager* npu, const weights& w) { this->app = this->mgr->create_app(); const int rb_all = ROWS / QROWS, rb_real = q.row_blocks(), cbs = q.col_blocks(); const size_t wbytes = (size_t)rb_all * cbs * Q80_BYTES; -#if !defined(_WIN32) // 2 MB pages: Linux only - if (getenv("INKLING2_LMH_HUGE") && atoi(getenv("INKLING2_LMH_HUGE"))) { - constexpr size_t HP = (size_t)2 << 20; - this->huge.n = (wbytes + HP - 1) / HP * HP; - void* p = mmap(nullptr, this->huge.n + HP, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - if (p == MAP_FAILED) throw std::runtime_error("inkling2 lm_head: mmap failed"); - // keep the 2 MB-aligned span, give back the rest - const uintptr_t a = ((uintptr_t)p + HP - 1) / HP * HP; - if (a > (uintptr_t)p) munmap(p, a - (uintptr_t)p); - if ((uintptr_t)p + HP > a) munmap((void*)(a + this->huge.n), (uintptr_t)p + HP - a); - this->huge.p = (void*)a; - madvise(this->huge.p, this->huge.n, MADV_HUGEPAGE); - memset(this->huge.p, 0, this->huge.n); - this->huge_bo = std::make_unique(*this->mgr->get_device(), this->huge.p, this->huge.n); - this->wb = buffer(*this->huge_bo); - } else -#endif - { - this->wb = npu->create_bo_buffer(wbytes); - } + this->wb = npu->create_bo_buffer(wbytes); this->y = npu->create_bo_buffer(ROWS); this->x = npu->create_bo_buffer(2 * D); // per 4 row blocks (a column's 128 rows): stream a (row blocks 0-1), then stream b (2-3), each column block by @@ -156,12 +133,6 @@ void inkling2_lm_head::gen_seq() { seq->cmds2seq(); } -inkling2_lm_head::huge_mem::~huge_mem() { -#if !defined(_WIN32) - if (this->p) munmap(this->p, this->n); -#endif -} - bool inkling2_lm_head::run(const uint16_t* xv, float* logits) { using clk = std::chrono::steady_clock; const auto t0 = clk::now(); diff --git a/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_lm_head.hpp b/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_lm_head.hpp index 391ac8ff9..b71851529 100644 --- a/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_lm_head.hpp +++ b/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_lm_head.hpp @@ -55,13 +55,6 @@ class inkling2_lm_head { npu_app app; xrt::run run_; buffer y, x; - // INKLING2_LMH_HUGE=1: the weights in 2 MB pages (user memory, MADV_HUGEPAGE) instead of a 4 KB-page BO - struct huge_mem { - void* p = nullptr; - size_t n = 0; - ~huge_mem(); - } huge; - std::unique_ptr huge_bo; buffer wb; }; #endif // !FLM_USE_HRX diff --git a/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_prefill.cpp b/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_prefill.cpp index a9ac0ac0b..a84cedc17 100644 --- a/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_prefill.cpp +++ b/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_prefill.cpp @@ -130,26 +130,12 @@ void inkling2_prefill::report() const { const char* names[19] = {"attn in", "attn out", "expert pack", "gate_up start", "situ+down start", "gate_up wait", "down wait", "unpack", "down build wait", "experts total", "attention pack", "attention run", "attention unpack", "proj pack", "proj run", "proj unpack", "gu npu (serial)", "dn npu (serial)", "idle work in experts"}; for (int i = 0; i < 18; i++) std::fprintf(stderr, "inkling2 npu prefill %-16s %8.3f s\n", names[i], this->t[i]); std::fprintf(stderr, "inkling2 npu prefill %ld expert calls, %ld runs\n", this->calls, this->runs); - if (this->dec) - std::fprintf(stderr, "inkling2 npu decode experts: %ld dispatches, start %.3f s, wait %.3f s\n", this->dec->calls, - this->dec->t_start, this->dec->t_wait); const char* kinds[5] = {"attn_in 1x", "attn_in 3x", "attn_out", "attention swa", "attention global"}; for (int i = 0; i < 5; i++) std::fprintf(stderr, "inkling2 npu kind %-16s %8.3f s %ld calls\n", kinds[i], this->npu_t[i], this->npu_n[i]); const char* skinds[7] = {"attn_in 1x", "attn_in 3x", "attn_out", "attention swa", "attention global", "expert gate_up", "expert down"}; for (int i = 0; i < 7; i++) std::fprintf(stderr, "inkling2 npu submit %-16s %8.4f s %ld runs\n", skinds[i], this->npu_s[i], this->npu_sn[i]); } -void inkling2_prefill::set_decode(const std::string& xclbin, int n) { - if (n <= 0 || !std::filesystem::exists(xclbin)) return; - this->dec = std::make_unique(this->npu, xclbin); - this->dec_n = std::min(n, inkling2_decode::MAX_N); -} - -void inkling2_prefill::dec_start(int il, int kind, const int* ex, int n, const float* in) { - layer_buf& B = this->layers[il]; - this->dec->start(kind, B.w, kind == 0 ? B.gate_up : B.down, ex, n, in); -} - size_t inkling2_prefill::expert_rows(int T) { // sized for any routing of T tokens, so the buffers are allocated once per prompt length, not each time // a layer's padded rows set a new maximum (a reallocation zero-fills tens of MB): pick_geometry pads an diff --git a/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_prefill.hpp b/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_prefill.hpp index 926cda348..64bdf4db8 100644 --- a/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_prefill.hpp +++ b/flm-dev-kit/FLM_DLL/detail/inkling2_npu/inkling2_prefill.hpp @@ -15,7 +15,6 @@ #include #include -#include "inkling2_decode.hpp" #include "inkling2_host.hpp" #include "npu_utils/npu_utils.hpp" #include "inkling2_launch.hpp" @@ -65,13 +64,6 @@ class inkling2_prefill final : public inkling2_host::mm_offload { }; dev_layer device_layer(int il) { return {&this->layers[il].w, this->layers[il].o, this->layers[il].gate_up, this->layers[il].down}; } - /// \brief decode: the first n of a token's experts on the NPU (decode.xclbin), the rest on the host meanwhile; n 0 - /// keeps them all on the host - void set_decode(const std::string& xclbin, int n); - int dec_experts() const override { return this->dec ? this->dec_n : 0; } - void dec_start(int il, int kind, const int* ex, int n, const float* in) override; - void dec_wait(float* out) override { this->dec->wait(out); } - private: struct layer_buf { buffer w; @@ -108,8 +100,6 @@ class inkling2_prefill final : public inkling2_host::mm_offload { npu_app_manager* att_mgr = nullptr; // the context attention runs in (mgr with the switches) std::map, npu_app> att_apps; inkling2_launch ll; - std::unique_ptr dec; - int dec_n = 0; /// \brief the dispatch of rows x Din (weights of width Kw) -> Npad, by its geometry npu_app& app(uint32_t rows, uint32_t Din, uint32_t Kw, uint32_t Npad); diff --git a/src/lib/hrx/inkling2_npu.dll b/src/lib/hrx/inkling2_npu.dll index 4f86b03a7..f0239928d 100644 Binary files a/src/lib/hrx/inkling2_npu.dll and b/src/lib/hrx/inkling2_npu.dll differ diff --git a/src/lib/hrx/inkling2_npu.lib b/src/lib/hrx/inkling2_npu.lib index bf4ced265..e3c0ded5d 100644 Binary files a/src/lib/hrx/inkling2_npu.lib and b/src/lib/hrx/inkling2_npu.lib differ diff --git a/src/lib/hrx/libinkling2_npu.so b/src/lib/hrx/libinkling2_npu.so index 4731fd7f1..1f2c8ce85 100644 Binary files a/src/lib/hrx/libinkling2_npu.so and b/src/lib/hrx/libinkling2_npu.so differ diff --git a/src/lib/xrt/inkling2_npu.dll b/src/lib/xrt/inkling2_npu.dll index 340eee798..896099a4f 100644 Binary files a/src/lib/xrt/inkling2_npu.dll and b/src/lib/xrt/inkling2_npu.dll differ diff --git a/src/lib/xrt/inkling2_npu.lib b/src/lib/xrt/inkling2_npu.lib index e2349f644..889ad1418 100644 Binary files a/src/lib/xrt/inkling2_npu.lib and b/src/lib/xrt/inkling2_npu.lib differ diff --git a/src/lib/xrt/libinkling2_npu.so b/src/lib/xrt/libinkling2_npu.so index 1aff6de90..275cf28fe 100644 Binary files a/src/lib/xrt/libinkling2_npu.so and b/src/lib/xrt/libinkling2_npu.so differ