mirror of
https://github.com/Niko1221/Strata.git
synced 2026-11-07 14:21:06 -10:00
split: the int8 prompt attention is on for the IQ3_S-type files and off for the others (UD-Q4_K_XL: 57/61 with it off, 55/61 with it on, agent-A8 and A10), like GDN_TC; the variable overrides
This commit is contained in:
1 parent
22f4dbe0e1
commit
f95411b843
4 files changed
+16
-4
No files matched your search
@@ -59,6 +59,7 @@ Engine::Engine(Model& m, int max_ctx, int lanes) : m_(m), max_ctx_(max_ctx) {
|
||||
std::fprintf(stderr, "fnx: note: context %d is within the trained %d: the scaling changes every position's rotary "
|
||||
"and no length needs it\n", max_ctx, m_.ctx_train);
|
||||
}
|
||||
attn_i8_set_default(m_.g.iq_experts()); // the int8 prompt attention: on for the IQ3_S-type files, off for the others
|
||||
gdn_tc_set_default(!m_.g.iq_experts()); // the tensor-core GDN scan: off for the IQ3_S-type files (NVIDIA builds only compile it in)
|
||||
hc1_rows(); // FNX_HC1 checked now, not at the first hc read (inside a graph capture)
|
||||
const int extra_pages = (std::max(lanes, 1) - 1) * lane_block_pages();
|
||||
|
||||
@@ -1433,8 +1433,9 @@ void attn_prompt(const float* qg, const uint16_t* kc, const uint16_t* vc, const
|
||||
const int* n_cells, int card, int C, int r0, int T, float* part, void* st) {
|
||||
if (T == 0) return; // an empty half of a one-row chunk
|
||||
#if !FNX_HIP && FNX_ARCH >= 80
|
||||
// FNX_PFX_ATTN_I8: the INT8 tensor-core kernel (attn_prompt_i8.cuh) on int8 K/V pages, on by default on NVIDIA sm_80+ again (owner 11-03: "do all 5"; FNX_PFX_ATTN_I8=0 turns it off; HIP keeps the f16 kernel)
|
||||
static const bool i8 = env_int("FNX_PFX_ATTN_I8", 1) != 0;
|
||||
// FNX_PFX_ATTN_I8: the INT8 tensor-core kernel (attn_prompt_i8.cuh) on int8 K/V pages, on by default on NVIDIA sm_80+ for the IQ3_S-type files and off for the others (UD-Q4_K_XL lost agent-A8 and A10 with it); FNX_PFX_ATTN_I8=0/1 overrides; HIP keeps the f16 kernel
|
||||
static const int i8_env = (int) env_int("FNX_PFX_ATTN_I8", -1);
|
||||
const bool i8 = i8_env >= 0 ? i8_env != 0 : attn_i8_default();
|
||||
if (i8 && g.q8) {
|
||||
static bool attr[64] = {};
|
||||
int dev = 0;
|
||||
@@ -1920,6 +1921,9 @@ void attn_prep_append(float* qg, float* k, const float* v, const float* q_norm,
|
||||
namespace fnx {
|
||||
static std::atomic<bool> g_gdn_tc_default{true};
|
||||
void gdn_tc_set_default(bool on) { g_gdn_tc_default = on; }
|
||||
static std::atomic<bool> g_attn_i8_default{false};
|
||||
void attn_i8_set_default(bool on) { g_attn_i8_default = on; }
|
||||
bool attn_i8_default() { return g_attn_i8_default.load(); }
|
||||
size_t gdn_scratch_floats(int nv) { return (size_t) MAXT * nv * HS + (size_t) nv * MAXT * GDN_Q + (size_t) MAXT * nv; }
|
||||
|
||||
void gdn_core(const float* qkvz, const float* ab, float* hist, const float* convw, const float* dt, const float* a, const float* nw,
|
||||
|
||||
@@ -120,6 +120,9 @@ void gdn_core_segs(const float* qkvz, const float* ab, const float* convw, const
|
||||
// the file's routed-expert quantization decides the prompt GDN scan: the tensor-core scan is OFF for the IQ3_S-type sets (their suite lost 3 agent tasks with it, UD-Q4 did not) and ON
|
||||
// for the others; FNX_PFX_GDN_TC=0/1 overrides. Set once by Model::Model.
|
||||
void gdn_tc_set_default(bool on);
|
||||
// the same for the int8 prompt attention (FNX_PFX_ATTN_I8): ON for the IQ3_S-type files (their suite shows no loss), OFF for the others (UD-Q4_K_XL lost agent-A8 and A10 with it, 11-03); the variable overrides. Defined in kernels part 4, read by the attention part.
|
||||
void attn_i8_set_default(bool on);
|
||||
bool attn_i8_default();
|
||||
void gdn_prompt(const float* qkvz, const float* ab, float* hist, const float* convw, const float* dt, const float* a,
|
||||
const float* nw, float* S, const int* ctl, int ng, int nk, int nv, const int* vmap, int C, float eps, float* xc,
|
||||
float* sq, float* y32, float* chw, void* st);
|
||||
|
||||
@@ -61,8 +61,12 @@ class HcSplit(unittest.TestCase):
|
||||
|
||||
|
||||
class PerFileSwitches(unittest.TestCase):
|
||||
def test_attention_int8_defaults_on(self):
|
||||
self.assertRegex(text("kernels.cu"), r'env_int\("FNX_PFX_ATTN_I8", 1\)')
|
||||
def test_attention_int8_is_decided_by_the_files_expert_types(self):
|
||||
k, e = text("kernels.cu"), text("engine.cu")
|
||||
# IQ3_S-type files: on (the suite shows no loss); the others (UD-Q4_K_XL lost agent-A8 and A10 with it): off; the variable overrides
|
||||
self.assertRegex(k, r'i8_env = \(int\) env_int\("FNX_PFX_ATTN_I8", -1\)')
|
||||
self.assertRegex(k, r"i8_env >= 0 \? i8_env != 0 : attn_i8_default\(\)")
|
||||
self.assertIn("attn_i8_set_default(m_.g.iq_experts());", e)
|
||||
|
||||
def test_gdn_scan_is_decided_by_the_files_expert_types(self):
|
||||
k, g, m = text("kernels.cu"), text("gguf.cpp"), text("engine.cu")
|
||||
|
||||
Reference in new issue
Block a user