MCPcopy Create free account
hub / github.com/Niko1221/Strata / commit

Method commit

engine/metal/src/engine/window.cpp:2763–2798  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2761}
2762
2763bool Window::commit(int n_keep, std::string& err) {
2764 if (n_keep < 1 || n_keep > last_T_) { err = "metal window: commit count out of range"; return false; }
2765 using namespace strata::kernels;
2766 if (last_T_ > 1) {
2767 // the GDN layers: the kept prefix folded into the state (gdn_step over n_keep tokens from the window's own
2768 // inputs, with commit; bitwise the window's trajectory). K/V and indexer cells past the prefix are rewritten
2769 // when those positions run again, before anything reads them.
2770 static const bool lazy = !(std::getenv("STRATA_METAL_LAZY_FOLD") && std::string(std::getenv("STRATA_METAL_LAZY_FOLD")) == "0");
2771 int nf = n_keep;
2772 if (nf > 0) {
2773 if (lazy) {
2774 pend_fold_ = nf; // folded at the start of the next window (from the history parity before the turn)
2775 } else {
2776 std::vector<mtl::Dispatch> ds;
2777 nb_ = false;
2778 fold(ds, nf, hp_);
2779 cx_->run_graph(ds);
2780 }
2781 hp_ = 1 - hp_;
2782 }
2783 }
2784 strata::core::SessionState& ss = *ss_;
2785 for (int t = 0; t < n_keep; ++t) {
2786 if (ple_on_) {
2787 const float* norm = normW_.as<float>() + (size_t) t * NG_HC_DIM;
2788 for (int c = 0; c < NG_HC_DIM; ++c) {
2789 float* col = pleHist_.as<float>() + (size_t) c * NG_HIST;
2790 for (int r = 0; r + 1 < NG_HIST; ++r) col[r] = col[r + 1];
2791 col[NG_HIST - 1] = norm[c];
2792 }
2793 }
2794 ss.ple_prev[0] = ss.ple_prev[1];
2795 ss.ple_prev[1] = last_tokens_[t];
2796 }
2797 return true;
2798}
2799
2800
2801// ================================================================================================ the MTP draft layer

Callers 9

flushFunction · 0.45
new_allocFunction · 0.45
free_allocFunction · 0.45
purge_device_allocationsFunction · 0.45
host_registerFunction · 0.45
window_commitFunction · 0.45
prompt_run_rowsFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45

Calls 3

foldFunction · 0.85
run_graphMethod · 0.80
stringFunction · 0.50

Tested by

no test coverage detected