merge f-split-gyro (Gyro-S/M trellis port and catalog entries) into f-split-int
This commit is contained in:
commit
bcbf2caf3f
46 files changed
+3770
-90
No files matched your search
+26
-3
@@ -22,6 +22,7 @@
|
||||
#include "strata/core/peer_experts.hpp"
|
||||
#include "strata/kernels/iq_kernels.hpp"
|
||||
#include "strata/kernels/cpu/expert_layout.hpp"
|
||||
#include "strata/kernels/cpu/hadamard.hpp"
|
||||
#include "strata/kernels/bf16_gemv.hpp"
|
||||
#include "strata/kernels/native_router.hpp"
|
||||
#include "strata/kernels/native_moe.hpp"
|
||||
@@ -687,6 +688,13 @@ bool Verifier::init(const WeightTable& wt, const ModelGeometry& g, SessionState&
|
||||
sink_.ctx = this;
|
||||
}
|
||||
|
||||
// APR: the rotated copy of the expert input (nat_xr_, T x N floats) only where a layer's gate/up is
|
||||
// Hadamard-folded; its one reader is that layer's f.had_gu branch in the expert-input step below
|
||||
bool had_gu_any = false;
|
||||
{
|
||||
const auto& lay = strata::kernels::cpu::expert_layout();
|
||||
for (size_t l = 0; lay.native && l < lay.fmt.size(); ++l) had_gu_any = had_gu_any || lay.fmt[l].had_gu;
|
||||
}
|
||||
// ---- the device arena: the same sequence counted, then carved
|
||||
auto carve = [&](Bump& b) {
|
||||
tok_ = b.take<int32_t>(T); step_ = b.take<int32_t>(T * strata::kernels::kStepCount);
|
||||
@@ -715,6 +723,7 @@ bool Verifier::init(const WeightTable& wt, const ModelGeometry& g, SessionState&
|
||||
staging_ = b.take<uint8_t>((uint64_t) kStagingBlobs * strata::kernels::cpu::expert_layout().max_blob);
|
||||
hit_xq_ = b.take<uint8_t>(T * (N / 32) * 34); hit_xs_ = b.take<float>(T * (N / 32));
|
||||
nat_xq_ = b.take<uint8_t>(T * (N / 32) * 36);
|
||||
nat_xr_ = had_gu_any ? b.take<float>(T * N) : nullptr;
|
||||
hit_scratch_ = b.take<uint8_t>(std::max<uint64_t>(
|
||||
strata::kernels::moe_hit_grouped_scratch_bytes((int64_t) (T * K), g.n_embd, g.n_ff),
|
||||
strata::kernels::native_expert_scratch_bytes((int64_t) (T * K), g.n_ff)));
|
||||
@@ -767,6 +776,10 @@ bool Verifier::init(const WeightTable& wt, const ModelGeometry& g, SessionState&
|
||||
return false;
|
||||
}
|
||||
}
|
||||
{ // APR (prism.hadamard, hadamard.txt): the sign vectors on this device, before any graph capture
|
||||
had_sx_ = strata::kernels::hadamard_device_signs(strata::kernels::cpu::hadamard_signs((int) g.n_embd), (int) g.n_embd);
|
||||
had_sh_ = strata::kernels::hadamard_device_signs(strata::kernels::cpu::hadamard_signs((int) g.n_ff), (int) g.n_ff);
|
||||
}
|
||||
sink_.staging = (unsigned long long) staging_;
|
||||
sink_.staging_cap = kStagingBlobs;
|
||||
(void) TS;
|
||||
@@ -1640,8 +1653,17 @@ bool Verifier::record_window(int T, cudaStream_t cs, std::string& err) {
|
||||
if (sh_fork) cudaEventRecord(ev_join_, sh_cs_);
|
||||
}
|
||||
if (strata::kernels::cpu::expert_layout().native) {
|
||||
if (!qdedup)
|
||||
if (!q8_ffn) quantize_q8_1_rows(xm, n, N, nat_xq_ + (size_t) tb * (N / 32) * 36, cs);
|
||||
// APR: Hadamard-folded gate/up take H (s * x); xm itself stays as it is (the shared expert above and the
|
||||
// doorbell copy for the CPU pool, which rotates its own in native_quant_act). The q8_1 image of xm that
|
||||
// STRATA_QFUSE / STRATA_VERIFY_QDEDUP may already have written is of the unrotated input, so a folded layer
|
||||
// always rewrites it from the rotated rows (same stream, after the shared expert has read it).
|
||||
const auto& f = strata::kernels::cpu::expert_layout().fmt[(size_t) l];
|
||||
if (f.had_gu) { // nat_xr_ exists: init carved it because this layer is folded (had_gu_any)
|
||||
hadamard_rows(xm, nat_xr_ + (size_t) tb * N, n, N, f.had_block, had_sx_, cs);
|
||||
quantize_q8_1_rows(nat_xr_ + (size_t) tb * N, n, N, nat_xq_ + (size_t) tb * (N / 32) * 36, cs);
|
||||
} else if (!qdedup && !q8_ffn) {
|
||||
quantize_q8_1_rows(xm, n, N, nat_xq_ + (size_t) tb * (N / 32) * 36, cs);
|
||||
}
|
||||
} else
|
||||
quantize_q8_0_scaled(xm, hit_xq_ + (size_t) tb * (N / 32) * 34, hit_xs_ + (size_t) tb * (N / 32), (int64_t) n * N, cs);
|
||||
stamp(l, 18, grp);
|
||||
@@ -1677,7 +1699,8 @@ bool Verifier::record_window(int T, cudaStream_t cs, std::string& err) {
|
||||
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);
|
||||
NativeExpertLayout L = native_expert_layout(f.gu_type, f.d_type, f.n_embd, f.n_ff);
|
||||
if (f.had_d) { L.had_block = f.had_block; L.d_signs = had_sh_; } // APR: h is rotated in there
|
||||
native_expert_grouped(L, gp, gs, gn, p_dst, p_tok, cap, cap,
|
||||
nat_xq_ + (size_t) tb * (N / 32) * 36, hit_scratch_, dst_buf, cs, gy);
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user