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

Method pl_launch

engine/src/core/verify.cpp:6724–6777  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6722}
6723
6724bool Verifier::pl_launch(int T, const int32_t* tokens, int64_t pos0, std::string& err) {
6725 const OnDevice on_device(device_);
6726 if (fl_active_) { err = "verify: a window is already in flight on this verifier"; return false; }
6727 if (released_.load()) { err = "verify: an earlier window never finished on the GPU (#267); restart the engine"; return false; }
6728 if (T < 1 || T > max_t_ || T > strata::kernels::kVerifyMaxT) { err = "verify: window size out of range"; return false; }
6729 SessionState& ss = *ss_;
6730 if (pos0 + T > ss.qsa_states[ss.qsa_primary()].max_cells) { err = "verify: the window runs past the context"; return false; }
6731 const int sl = select_long_on() && pos0 + T >= select_long_at() ? 1 : 0; // the variant this window's context pays off with
6732 if (exec_[sl][T] == nullptr || commit_exec_ == nullptr || ev_done_ == nullptr || pl_ple_rows_.empty()) {
6733 err = "verify: pipelined window not prepared (capture_all)";
6734 return false;
6735 }
6736 if (pre_launch_ && !pre_launch_(cs_, err)) return false;
6737 const Clock::time_point t0 = Clock::now();
6738 last_batch_ = false;
6739 split_logits_materialized_ = false;
6740 bool staged = pl_prestaged_ && last_t_ == T && last_pos0_ == pos0;
6741 for (int t = 0; staged && t < T; ++t) staged = last_tokens_[t] == tokens[t];
6742 if (staged && ss.ple.ready() && ple_stage())
6743 staged = pl_prev_[0] == ss.ple_prev[0] && pl_prev_[1] == ss.ple_prev[1];
6744 pl_prestaged_ = false;
6745 if (!staged) pl_stage(T, tokens, pos0, ss.ple_prev);
6746 const int G = groups_[T] > 0 ? groups_[T] : 1;
6747 fl_T_ = T;
6748 fl_k_ = 0;
6749 fl_total_ = (le_ - lb_) * G;
6750 fl_prof_ = prof_on_ && G == 1 && prof_pin_ != nullptr;
6751 if (trace_h_ != nullptr) std::memset(trace_h_, 0, trace_n_ * 8); // #649: this window's breadcrumbs only
6752 std::atomic_thread_fence(std::memory_order_seq_cst);
6753 trace_ev("WINDOW (pipelined)", -1, -1, pos0 * 16 + T);
6754 ms_host += ms_since(t0);
6755 strata::dispatch::Stats::get().graph_launch(T, ar_on() ? 0 : 1);
6756 if (peer_autonomous_ && fl_ple_) {
6757 if (!ss.ple.table->gather_batch(pl_ple_rows_.data(), (size_t) T, h_ple_, err)) return false;
6758 std::atomic_thread_fence(std::memory_order_seq_cst);
6759 strata_store_fence();
6760 fl_ple_ = false;
6761 }
6762 if (peer_ != nullptr && peer_->valid() && peer_autonomous_) {
6763 if (!peer_->launch_window(parity_, lb_, le_, T, (int) ss.k, 1, G)) {
6764 err = "verify: peer autonomous window launch failed";
6765 return false;
6766 }
6767 }
6768 const cudaError_t le = cudaGraphLaunch(exec_[sl][T], cs_);
6769 trace_ev("LAUNCHED", -1, -1, (int64_t) le);
6770 if (le != cudaSuccess) { if (peer_autonomous_) (void) release_gpu_waits(1000); err = std::string("verify: launch: ") + cudaGetErrorString(le); return false; }
6771 if (fl_prof_) cudaMemcpyAsync(prof_pin_, prof_, prof_h_.size() * 8, cudaMemcpyDeviceToHost, cs_);
6772 if (cudaEventRecord(ev_done_, cs_) != cudaSuccess) { err = "verify: event record failed"; return false; }
6773 (void) cudaStreamQuery(cs_); // WDDM: submit now
6774 fl_active_ = true;
6775 fl_since_ms_ = fl_flush_ms_ = fl_launch_ms_ = now_ms();
6776 return true;
6777}
6778
6779int Verifier::service(PoolMultiFn pool, void* user, std::string& err) {
6780 if (!fl_active_) return 1;

Callers

nothing calls this directly

Calls 15

select_long_onFunction · 0.85
select_long_atFunction · 0.85
strata_store_fenceFunction · 0.85
release_gpu_waitsFunction · 0.85
cudaStreamQueryFunction · 0.85
graph_launchMethod · 0.80
gather_batchMethod · 0.80
launch_windowMethod · 0.80
ms_sinceFunction · 0.70
now_msFunction · 0.70
readyMethod · 0.65
nowFunction · 0.50

Tested by

no test coverage detected