experts: the verify window's PCIe call launches for the groups it has; SwiGLU and q8_1 in one pass (bitwise)
native_expert_grouped launched a block row per possible group (cap = window tokens x 10) for gate/up and down, and SwiGLU and the q8_1 quantization as two kernels over all cap entries. The verify window's PCIe call has no group at all at pcie_frac 0 and usually none otherwise, yet every layer paid ~17k blocks that started only to return plus two passes over entries that are not its own. - gate/up and down stride over the groups (rows y, y + gridDim.y, ...); the PCIe call runs 4 block rows (kPcieGroupRows), the VRAM call keeps one per possible group. Each group's rows are computed by the same warp code in the same order, so the results do not depend on the grid. - SwiGLU + q8_1 in one kernel over the call's own entries [grp_start[0], grp_start[n]); the product is rounded on its own (__fmul_rn; on HIP a plain product under contract(off)) before the block sum, as when it went through memory, and the quantizer body is quantize_q8_1_kernel's (factored out, its PTX unchanged). - STRATA_GROUPED_V1=1 keeps the old launches for A/B timing; native_grouped_parity checks old vs new bitwise (every gate/up x down format, 0..cap groups, entries from 0 and past 0, grid_groups 1..4 and > cap).
This commit is contained in:
1 parent
f2c220f560
commit
e7a5fd30d5
6 files changed
+484
-57
No files matched your search
+8
-5
@@ -745,20 +745,21 @@ bool Verifier::record_window(int T, cudaStream_t cs, std::string& err) {
|
||||
const int32_t* p_start2 = pl + ptr_off + 4 * capx;
|
||||
float* hit_out = hit_out_ + (size_t) tb * K * N;
|
||||
const auto& lay = strata::kernels::cpu::expert_layout();
|
||||
// plan v0.3 P6: the VRAM groups now; the PCIe groups once the copy engine has landed them in staging
|
||||
auto grouped = [&](const unsigned long long* gp, const int32_t* gs, const int32_t* gn) {
|
||||
// plan v0.3 P6: the VRAM groups now; the PCIe groups once the copy engine has landed them in staging.
|
||||
// `gy`: the native launch's groups side by side (0: cap, one block row per possible group).
|
||||
auto grouped = [&](const unsigned long long* gp, const int32_t* gs, const int32_t* gn, int64_t gy) {
|
||||
if (lay.native) {
|
||||
// the layer's GGUF formats (i-quant gate/up, Q2_0 / IQ4_NL down)
|
||||
const auto& f = lay.fmt[(size_t) l];
|
||||
const NativeExpertLayout L = native_expert_layout(f.gu_type, f.d_type, f.n_embd, f.n_ff);
|
||||
native_expert_grouped(L, gp, gs, gn, p_dst, p_tok, cap, cap,
|
||||
nat_xq_ + (size_t) tb * (N / 32) * 36, hit_scratch_, hit_out, cs);
|
||||
nat_xq_ + (size_t) tb * (N / 32) * 36, hit_scratch_, hit_out, cs, gy);
|
||||
} else {
|
||||
moe_grouped_s2(gp, gs, gn, p_dst, p_tok, cap, cap, hit_xq_ + (size_t) tb * (N / 32) * 34,
|
||||
hit_xs_ + (size_t) tb * (N / 32), hit_scratch_, hit_out, cs);
|
||||
}
|
||||
};
|
||||
grouped(p_ptr, p_start, p_counts);
|
||||
grouped(p_ptr, p_start, p_counts, 0);
|
||||
stamp(l, 20, grp);
|
||||
if (device_plan_) 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
|
||||
@@ -769,7 +770,9 @@ bool Verifier::record_window(int T, cudaStream_t cs, std::string& err) {
|
||||
rebase_ptrs((unsigned long long*) p_ptr2, p_counts + 2, stage, (int64_t) lay.blob_bytes(l), cs);
|
||||
}
|
||||
stamp(l, 21, grp);
|
||||
grouped(p_ptr2, p_start2, p_counts + 2);
|
||||
// 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);
|
||||
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);
|
||||
|
||||
Reference in new issue
Block a user