Small-card prompt path: keep the switch helper out of the CUDA kernel headers

small_card_kernels_on() moves from core/sm120_series.hpp to
prefill/pf_fused_override.hpp (strata::prefill), next to the other reader of the
small-card override. sm120_series.hpp is byte-identical to its state before the
previous commit again, so none of the CUDA kernel translation units under src/kernels/cuda sees
a changed header. Behaviour is unchanged: same rule, same defaults, same way back
(STRATA_PF_SMALL_FUSED=0). generate.cpp and the unit test call the function in
its new place.
This commit is contained in:
Niko1221 committed 2026-11-12 17:29:24 +01:00
1 parent 6d7a183f0c
commit 8ce488608d
4 files changed
+12 -10

No files matched your search

+1 -4
View File
@@ -150,7 +150,7 @@ inline bool prefill_layer_major_resolve(const char* env, bool hip, int stages, b
/// `fused_env_set` (STRATA_PF_FUSED named, either value) leaves the expert path alone and with it the walk (a fused layout declines it anyway);
/// `lm_env_set` (STRATA_PREFILL_LAYER_MAJOR named) leaves the walk alone.
struct SmallCardPromptPath {
bool fused_off = false; ///< read the prompt in MMQ's buffer layout (no fused layout or ring, so the walk runs); the native fused kernels still run there (small_card_kernels_on)
bool fused_off = false; ///< read the prompt with the unfused experts (STRATA_PF_FUSED=0 as far as the engine is concerned)
bool layer_major = false; ///< and take the layer-major walk for a prompt of two chunks or more (STRATA_PREFILL_LAYER_MAJOR=1)
bool any() const { return fused_off || layer_major; }
};
@@ -164,8 +164,5 @@ inline SmallCardPromptPath small_card_prompt_path(long long default_chunk, bool
r.layer_major = !lm_env_set;
return r;
}
/// Whether the small-card prompt path runs the native fused expert kernels inside MMQ's buffer layout (the layer-major walk's groups and the streamed chunks): yes, unless
/// STRATA_PF_SMALL_FUSED is "0" (the way back: MMQ's kernels there, as before). `env` is getenv's answer. HIP builds never reach the rule.
inline bool small_card_kernels_on(const char* env) { return !(env != nullptr && env[0] == '0'); }
} // namespace strata
@@ -23,4 +23,9 @@ inline std::atomic<int>& pf_fused_override() {
/// a variable the user named is never changed (the small-card rule steps aside for it anyway).
inline int pf_fused_env_effective(int env, int ov) { return env < 0 && ov == kPfFusedKernelsOnly ? 1 : env; }
/// Whether the small-card prompt path (strata::small_card_prompt_path, core/sm120_series.hpp: MMQ's buffer layout so the layer-major walk runs) also runs the native
/// fused expert kernels inside that layout (the walk's groups and the streamed chunks): yes, unless STRATA_PF_SMALL_FUSED is "0" (the way back: MMQ's kernels there,
/// as before). `env` is getenv's answer. HIP builds never reach the rule.
inline bool small_card_kernels_on(const char* env) { return !(env != nullptr && env[0] == '0'); }
} // namespace strata::prefill
+5 -5
View File
@@ -631,12 +631,12 @@ int main() {
CHECK(pp.any() == r.fires);
CHECK(pp.fused_off == r.fires && pp.layer_major == r.fires);
if (pp.fused_off) {
CHECK(small_card_kernels_on(nullptr)); // unset: the native fused kernels run in MMQ's buffer layout
CHECK(small_card_kernels_on(""));
CHECK(small_card_kernels_on("1"));
CHECK(!small_card_kernels_on("0")); // the way back: MMQ's kernels, as before
CHECK(prefill::small_card_kernels_on(nullptr)); // unset: the native fused kernels run in MMQ's buffer layout
CHECK(prefill::small_card_kernels_on(""));
CHECK(prefill::small_card_kernels_on("1"));
CHECK(!prefill::small_card_kernels_on("0")); // the way back: MMQ's kernels, as before
}
const int ov = pp.fused_off ? (small_card_kernels_on(nullptr) ? prefill::kPfFusedKernelsOnly : 0) : -1;
const int ov = pp.fused_off ? (prefill::small_card_kernels_on(nullptr) ? prefill::kPfFusedKernelsOnly : 0) : -1;
// STRATA_PF_FUSED as the fused kernels' rule reads it: unset reads as 1 on the small-card path only
CHECK(prefill::pf_fused_env_effective(-1, ov) == (r.fires ? 1 : -1));
CHECK(prefill::pf_fused_env_effective(0, ov) == 0); // "0" stays off
+1 -1
View File
@@ -11111,7 +11111,7 @@ int main(int argc, char** argv) {
const int64_t chunk_default = chunk;
// MMQ's buffer layout (so the layer-major walk runs); the native fused kernels still run in the walk's groups and the streamed chunks
// (pf_fused_override.hpp), unless STRATA_PF_SMALL_FUSED=0 keeps MMQ's kernels there as before
if (pp.fused_off) strata::prefill::pf_fused_override().store(strata::small_card_kernels_on(std::getenv("STRATA_PF_SMALL_FUSED")) ? strata::prefill::kPfFusedKernelsOnly : 0);
if (pp.fused_off) strata::prefill::pf_fused_override().store(strata::prefill::small_card_kernels_on(std::getenv("STRATA_PF_SMALL_FUSED")) ? strata::prefill::kPfFusedKernelsOnly : 0);
if (pp.layer_major) {
#if defined(_WIN32)
_putenv_s("STRATA_PREFILL_LAYER_MAJOR", "1");