perf(verify): the shared expert forks after the doorbell when CPU experts are in the window (#783 PR-j)
STRATA_SH_FORK_LATE=0 forks at the top as before. The other two commit-4 changes of the PR are not taken: the shared-expert Q8_1 reuse is already in f-140 as the opt-in STRATA_VERIFY_QDEDUP (and the fused q8_1 store), and the PLE native-key batch is already in f-140 as the opt-in STRATA_PLE_BATCH=1; both would have changed output on the native packs by default. Dropped on purpose: STRATA_VERIFY_PRELAUNCH and the dead copy_rows_from_mapped<ZERO_HITS>. Ported from #783 (stuchapin909, head 4327807), split per piece. Co-authored-by: stuchapin909 <178119976+stuchapin909@users.noreply.github.com>
This commit is contained in:
1 parent
3fd0460ba2
commit
8b5dd7adef
1 file changed
+12
-1
+12
-1
@@ -1087,9 +1087,16 @@ bool Verifier::record_window(int T, cudaStream_t cs, std::string& err) {
|
||||
}
|
||||
stamp(l, 16, grp);
|
||||
const bool q8_ffn = gr_read_group(1, true, inj_, inj2_); // true: nat_xq_ holds the MoE input's q8_1 (STRATA_QFUSE)
|
||||
// with CPU experts in the window the shared expert forks off once the doorbell is published (it no longer
|
||||
// competes with it for the GPU's first microseconds); STRATA_SH_FORK_LATE=0 forks at the top as before
|
||||
static const bool sh_fork_late_env = [] {
|
||||
const char* e = std::getenv("STRATA_SH_FORK_LATE");
|
||||
return !e || e[0] != '0';
|
||||
}();
|
||||
const bool sh_fork = sh_stream_on() && !prof_on_ && sh_cs_ != nullptr && ev_fork_ != nullptr && ev_join_ != nullptr;
|
||||
const bool sh_fork_late = sh_fork && sh_fork_late_env && !ar_on();
|
||||
cudaStream_t sh_stream = sh_fork ? sh_cs_ : cs;
|
||||
if (sh_fork) {
|
||||
if (sh_fork && !sh_fork_late) {
|
||||
cudaEventRecord(ev_fork_, cs);
|
||||
cudaStreamWaitEvent(sh_cs_, ev_fork_, 0);
|
||||
}
|
||||
@@ -1152,6 +1159,10 @@ bool Verifier::record_window(int T, cudaStream_t cs, std::string& err) {
|
||||
doorbell_publish_res(xm, ids_ + tb * K, layer_res, (int) g.n_expert, (int64_t) n * N, (int64_t) n * K,
|
||||
m_x_ + tb * N, m_ids_ + tb * K, m_seq_, cs);
|
||||
}
|
||||
if (sh_fork_late) {
|
||||
cudaEventRecord(ev_fork_, cs);
|
||||
cudaStreamWaitEvent(sh_cs_, ev_fork_, 0);
|
||||
}
|
||||
}
|
||||
stamp(l, 17, grp);
|
||||
bool qdedup = false; // STRATA_VERIFY_QDEDUP took effect: the experts' q8_1 image of xm is already made
|
||||
|
||||
Reference in new issue
Block a user