mirror of
https://github.com/Niko1221/Strata.git
synced 2026-11-07 18:35:04 -10:00
SYCL decode window: under STRATA_VERIFY_NO_HOST with the device plan the graph drops the nodes nobody answers (doorbell publish, three flag waits, the plan copy, the PCIe-share group and its staging); -2% decode on a B70, same tokens (STRATA_VERIFY_LEAN=0 turns it off)
This commit is contained in:
1 parent
beba872b86
commit
46a77907bb
1 file changed
+14
-7
@@ -800,6 +800,13 @@ const float* Verifier::final_R(int t) const { return R_ + (size_t) t * (size_t)
|
||||
bool Verifier::record_window(int T, dpct::queue_ptr cs, std::string &err) {
|
||||
using namespace strata::kernels;
|
||||
const ModelGeometry& g = *g_;
|
||||
// 0.1.43 (STRATA_VERIFY_LEAN=0 turns it off): with the device plan under STRATA_VERIFY_NO_HOST no host ever answers a doorbell, so
|
||||
// a layer's doorbell publish, the three flag waits, the plan copy, the PCIe-share group and its staging kernels are nodes of
|
||||
// the graph that only wait for each other or do nothing: ~9 nodes (~1.4 ms) per layer-window less. The VRAM / mirror groups, the
|
||||
// combine and the answers are the same kernels on the same data.
|
||||
static const bool lean_env = [] { const char* v = std::getenv("STRATA_VERIFY_LEAN"); return !(v && v[0] == '0'); }();
|
||||
static const bool no_host_env = [] { const char* v = std::getenv("STRATA_VERIFY_NO_HOST"); return v && *v && std::strcmp(v, "0") != 0; }();
|
||||
const bool lean = lean_env && no_host_env && device_plan_ && !step_hook_ && !step_hook2_ && !remote_opt_ && !always_publish_ && !g_stepped;
|
||||
const WeightTable& wt = *wt_;
|
||||
SessionState& ss = *ss_;
|
||||
const int64_t N = g.n_embd, HC = g.hc, K = ss.k, C = g.ssm_conv_channels, ZV = g.ssm_value_dim;
|
||||
@@ -1346,7 +1353,7 @@ bool Verifier::record_window(int T, dpct::queue_ptr cs, std::string &err) {
|
||||
if (remote_opt_ || always_publish_)
|
||||
doorbell_publish(xm, ids_ + tb * K, w_ + tb * K, (int64_t) n * N, (int64_t) n * K, m_x_ + tb * N,
|
||||
m_ids_ + tb * K, m_w_ + tb * K, m_seq_, cs);
|
||||
else {
|
||||
else if (!lean) { // (lean: nobody reads the doorbell)
|
||||
const int32_t* layer_res = hits_.d_res != nullptr ? (hits_.d_res + l * g.n_expert) : nullptr;
|
||||
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);
|
||||
@@ -1444,8 +1451,8 @@ bool Verifier::record_window(int T, dpct::queue_ptr cs, std::string &err) {
|
||||
stamp(l, 20, grp);
|
||||
} else {
|
||||
if (device_plan_) { // E-6: skipped when the device planned this group (all its experts resident)
|
||||
wait_flag_ge_or(m_flagA_, ring, skip_ + grp, cs);
|
||||
copy_i32_from_mapped_unless(pl, m_plan_ + (size_t) grp * (size_t) plan_i32_, plan_i32_, skip_ + grp, ring, cs);
|
||||
if (!lean) wait_flag_ge_or(m_flagA_, ring, skip_ + grp, cs);
|
||||
if (!lean) copy_i32_from_mapped_unless(pl, m_plan_ + (size_t) grp * (size_t) plan_i32_, plan_i32_, skip_ + grp, ring, cs);
|
||||
} else {
|
||||
wait_flag_ge(m_flagA_, ring, cs); // the pool published this group's GPU plan
|
||||
copy_i32_from_mapped(pl, m_plan_ + (size_t) grp * (size_t) plan_i32_, plan_i32_, cs);
|
||||
@@ -1455,9 +1462,9 @@ bool Verifier::record_window(int T, dpct::queue_ptr cs, std::string &err) {
|
||||
stamp(l, 20, grp);
|
||||
// stepped mode: the plan copy + VRAM groups end a segment, so they run while the CPU computes its rows
|
||||
if (step_hook2_ && !step_hook2_(l, grp)) { if (err.empty()) err = "verify: stepped split failed"; return false; }
|
||||
if (device_plan_) wait_flag_ge_or(m_flagB_, ring, skip_ + grp, cs);
|
||||
if (device_plan_) { if (!lean) wait_flag_ge_or(m_flagB_, ring, skip_ + grp, cs); }
|
||||
else wait_flag_ge(m_flagB_, ring, cs); // the PCIe share is in staging (DMA) or mapped
|
||||
if (sink_.pcie_mode == 2) { // stage it with a copy kernel, then point at staging
|
||||
if (!lean && sink_.pcie_mode == 2) { // stage it with a copy kernel, then point at staging
|
||||
const int64_t per = G == 2 ? kStagingBlobs / 2 : kStagingBlobs;
|
||||
uint8_t* stage = staging_ + (size_t) (grp * per) * lay.max_blob;
|
||||
fetch_blobs(p_ptr2, p_counts + 2, stage, (int64_t) lay.blob_bytes(l), (int) per, cs);
|
||||
@@ -1466,10 +1473,10 @@ bool Verifier::record_window(int T, dpct::queue_ptr cs, std::string &err) {
|
||||
stamp(l, 21, grp);
|
||||
// the PCIe share is pcie_frac of the misses: a few groups when the cache is cold, usually none (always none at
|
||||
// pcie_frac 0), so its launch is kPcieGroupRows block rows striding over the groups, not cap of them
|
||||
grouped(p_ptr2, p_start2, p_counts + 2, kPcieGroupRows, hit_out);
|
||||
if (!lean) grouped(p_ptr2, p_start2, p_counts + 2, kPcieGroupRows, hit_out); // (lean: the device plan leaves it empty)
|
||||
stamp(l, 22, grp);
|
||||
if (device_plan_) { // no CPU share when the device planned the group: its rows are zeros
|
||||
wait_flag_ge_or(m_flag_, ring, skip_ + grp, cs);
|
||||
if (!lean) wait_flag_ge_or(m_flag_, ring, skip_ + grp, cs);
|
||||
copy_or_zero_from_mapped(parts_out, m_ymiss_ + (size_t) tb * K * N, (long long) n * K * N,
|
||||
skip_ + grp, ring, cs);
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user