diff --git a/docs/SETTINGS.md b/docs/SETTINGS.md index d653eace9f..eeb8db134a 100644 --- a/docs/SETTINGS.md +++ b/docs/SETTINGS.md @@ -383,7 +383,7 @@ Off unless you set them. The last column says where each one is described. | `STRATA_WDDM_BUDGET` | number | AMD, Intel Arc | [AMD_HIP.md](AMD_HIP.md) | | `STRATA_WDDM_MARGIN_MIB` | number | AMD | [AMD_HIP.md](AMD_HIP.md) | -## Switches that go back to earlier behaviour (134) +## Switches that go back to earlier behaviour (135) These behaviours are on by default. Setting the switch returns the earlier behaviour; the notes in the register say which version made it the default. @@ -491,6 +491,7 @@ version made it the default. | `STRATA_QFUSE_HC_LOCAL` | text | NVIDIA and AMD | v0.2.16 | - | | `STRATA_QSA_EARLY_EXIT` | number | NVIDIA and AMD, Intel Arc | v0.2.16 | - | | `STRATA_QSA_FUSE_NR` | on / off | NVIDIA and AMD | v0.2.16 | - | +| `STRATA_QWEN4_KERNEL_TABLES` | on / off | NVIDIA and AMD | - | - | | `STRATA_RDNA_KQ_ALL` | on / off | NVIDIA and AMD | v0.2.19 | - | | `STRATA_REMOTE_SPIN` | on / off | NVIDIA, AMD, Intel Arc | v0.2.16 | - | | `STRATA_RESIDENT_PIN` | on / off | NVIDIA and AMD, Intel Arc | v0.2.16 | [DETAILS.md](DETAILS.md), [TROUBLESHOOTING.md](TROUBLESHOOTING.md), [UNSLOTH_Q4.md](UNSLOTH_Q4.md) | diff --git a/engine/src/poly/qwen4.cpp b/engine/src/poly/qwen4.cpp index db716189ab..30ddc5afdf 100644 --- a/engine/src/poly/qwen4.cpp +++ b/engine/src/poly/qwen4.cpp @@ -249,6 +249,15 @@ void Qwen4::load_geometry() { clamp_shexp_ = clamp_exp_; lane_slots_ = true; swiglu_q8_ = true; +#if !defined(STRATA_GPU_METAL) && !defined(STRATA_USE_HIP) + // In a prompt's read of several calls, a call's row tables go to the card by a kernel, not behind the experts' + // copies, as Inkling 2's (kernel_tables_): the same tables reach the same buffers. STRATA_QWEN4_KERNEL_TABLES=0 + // turns it off. + { + const char* v = std::getenv("STRATA_QWEN4_KERNEL_TABLES"); + kernel_tables_ = !(v && v[0] == '0'); + } +#endif #if !defined(STRATA_GPU_METAL) && !defined(STRATA_USE_HIP) // Enable B6=2 (bitwise-exact 2-row-per-block multi-column MMVQ for Q4_K/Q5_K/Q6_K/IQ4_XS) on CUDA unless the user // explicitly set STRATA_B6_MMVQ_ROWS; measured +4-5% on Qwen4 DFlash2 with 0 extra VRAM. diff --git a/terminal/data/settings-register.json b/terminal/data/settings-register.json index 7397636882..6c810bb31d 100644 --- a/terminal/data/settings-register.json +++ b/terminal/data/settings-register.json @@ -42439,6 +42439,39 @@ "retire_after": "", "retired_in": "0.2.16" }, + { + "name": "STRATA_QWEN4_KERNEL_TABLES", + "backends": [ + "cuda-hip" + ], + "reads": [ + { + "file": "engine/src/poly/qwen4.cpp", + "line": 257, + "backend": "cuda-hip", + "fn": "getenv" + } + ], + "parse": "flag", + "default_state": null, + "code_default": null, + "engine_sets": [], + "engine_defaults": [], + "launch_files": [], + "launch_sets": [], + "launch_reads": [], + "doc_mentions": [], + "first_commit": null, + "first_date": null, + "since": null, + "last_commit": null, + "last_date": null, + "status": "rollback", + "owner": "poly", + "note": "Qwen4 (qwen4exp) on CUDA: in a prompt read of several calls, moe_rows() hands a call's row tables to the card by a kernel (copy2) that reads them from pinned memory, as Inkling 2's STRATA_INK_KERNEL_TABLES, instead of a copy that waits behind the layer's expert uploads on the card's one upload copy engine. Same bits, no extra VRAM. Default on; =0 keeps the copies, as before. HIP and Metal never take it (engine/src/poly/qwen4.cpp, engine.cpp moe_rows())", + "retire_after": "", + "retired_in": "" + }, { "name": "STRATA_RAM_ADAPT", "backends": [