mirror of
https://github.com/Niko1221/Strata.git
synced 2026-11-07 14:21:06 -10:00
gfx12: STRATA_HEAD_MIX_MULTI=1 by default (exact; own function, droppable alone)
The final hyper-connection mixer of the verify window and of the draft layer as one fused_gr_read_multi instead of one gr_read per token (PR 3264, author bsorensen110). Kept apart from the main gfx12 table in gfx12_extra.hpp so it merges with the table on another branch without touching it; STRATA_GFX12_DEFAULTS=0, STRATA_DEFAULTS=026 and a variable the user sets decide first. R9700 (p620, IQ3_S, serve, static residency, 8 interleaved pairs with an A/A arm): json_extract +0.82% (6/8), agent +0.63% (6/8), code_py -0.96% (3/8, that prompt's A/A moves 3.5% a pair); greedy ids identical in 16/16 and 15/16 request sets.
This commit is contained in:
1 parent
55ab701e1b
commit
82eaeb4221
4 files changed
+114
No files matched your search
@@ -1826,6 +1826,9 @@ if(STRATA_BUILD_TESTS)
|
||||
target_include_directories(amd_community_test_dot_off PRIVATE include)
|
||||
target_compile_definitions(amd_community_test_dot_off PRIVATE EXPECT_DOT_BUILT=0 STRATA_AMD_COMMUNITY_DOT_OFF=1)
|
||||
add_test(NAME amd_community_test_dot_off COMMAND amd_community_test_dot_off WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
add_executable(gfx12_extra_test src/core/gfx12_extra_test.cpp src/core/arch_defaults.cpp) # gfx12 extra defaults and their off switches
|
||||
target_include_directories(gfx12_extra_test PRIVATE include)
|
||||
add_test(NAME gfx12_extra_test COMMAND gfx12_extra_test)
|
||||
add_executable(nv_defaults_test src/core/nv_defaults_test.cpp src/core/nv_defaults.cpp) # the sm_121 (GB10) table and its two off switches
|
||||
target_include_directories(nv_defaults_test PRIVATE include)
|
||||
add_test(NAME nv_defaults_test COMMAND nv_defaults_test)
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
// include/strata/core/gfx12_extra.hpp - defaults for gfx12 (RDNA4: R9700, RX 9070, RX 9060) that came out of the PR-AMD pass of 2026-11-01 and are
|
||||
// kept apart from the main table (arch_defaults.cpp) so each can be dropped alone. Same off switches as that table: STRATA_GFX12_DEFAULTS=0
|
||||
// and STRATA_DEFAULTS=026 give the old behaviour, and a variable the user sets is never overridden.
|
||||
//
|
||||
// Exact (bit for bit the same answers):
|
||||
// STRATA_HEAD_MIX_MULTI=1 the final hyper-connection mixer of the verify window and of the draft layer as one fused_gr_read_multi
|
||||
// instead of one gr_read per token (#3264, bsorensen110). R9700 (p620, IQ3_S, serve, static residency,
|
||||
// 8 interleaved pairs, A/A beside it): json_extract +0.82% (6/8 pairs), agent +0.63% (6/8), code_py -0.96%
|
||||
// (3/8; that prompt's A/A moves +-3.5% a pair), greedy ids identical in 16/16 and 15/16 request sets.
|
||||
#pragma once
|
||||
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "strata/core/defaults_026.hpp"
|
||||
#include "strata/kernels/gfx_arch.hpp"
|
||||
|
||||
namespace strata::core {
|
||||
|
||||
/// `defaults026`: STRATA_DEFAULTS=026 (defaults_026.hpp reads it once, so a test passes it).
|
||||
inline std::vector<std::pair<std::string, std::string>> gfx12_exact_extra_env(const char* gcn_arch, bool defaults026) {
|
||||
std::vector<std::pair<std::string, std::string>> t;
|
||||
if (!strata::kernels::gfx_arch_is_gfx12(gcn_arch)) return t;
|
||||
const char* off = std::getenv("STRATA_GFX12_DEFAULTS");
|
||||
if (off != nullptr && off[0] == '0') return t;
|
||||
if (defaults026) return t;
|
||||
t.push_back({"STRATA_HEAD_MIX_MULTI", "1"});
|
||||
return t;
|
||||
}
|
||||
inline std::vector<std::pair<std::string, std::string>> gfx12_exact_extra_env(const char* gcn_arch) {
|
||||
return gfx12_exact_extra_env(gcn_arch, strata::qwen_defaults_026());
|
||||
}
|
||||
|
||||
} // namespace strata::core
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "strata/core/arch_defaults.hpp"
|
||||
#include "strata/core/defaults_026.hpp"
|
||||
#include "strata/core/amd_community.hpp"
|
||||
#include "strata/core/gfx12_extra.hpp"
|
||||
|
||||
#include "strata/kernels/gfx_arch.hpp"
|
||||
|
||||
@@ -208,6 +209,19 @@ std::vector<std::string> apply_arch_defaults(const char* gcn_arch, bool integrat
|
||||
set_default(kv);
|
||||
set.push_back(kv.first);
|
||||
}
|
||||
{ // gfx12 extras kept apart from the table (gfx12_extra.hpp); not counted in the returned list
|
||||
std::vector<std::string> extra;
|
||||
for (const auto& kv : gfx12_exact_extra_env(gcn_arch)) {
|
||||
if (std::getenv(kv.first.c_str()) != nullptr) continue;
|
||||
set_default(kv);
|
||||
extra.push_back(kv.first);
|
||||
}
|
||||
if (!extra.empty()) {
|
||||
std::fprintf(stderr, "strata: gfx12 (RDNA4): exact extra switches on by default (STRATA_GFX12_DEFAULTS=0 turns them off; a switch you set is kept): ");
|
||||
for (size_t i = 0; i < extra.size(); ++i) std::fprintf(stderr, "%s%s", i ? " " : "", extra[i].c_str() + 7);
|
||||
std::fprintf(stderr, "\n");
|
||||
}
|
||||
}
|
||||
if (!set.empty()) {
|
||||
const bool g12 = strata::kernels::gfx_arch_is_gfx12(gcn_arch);
|
||||
std::fprintf(stderr, "strata: %s: %zu exact speed switches on by default (%s=0 turns "
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
// src/core/gfx12_extra_test.cpp - the gfx12 extra defaults (gfx12_extra.hpp) and their off switches (no GPU needed).
|
||||
#include "strata/core/arch_defaults.hpp"
|
||||
#include "strata/core/gfx12_extra.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
|
||||
static int fails = 0;
|
||||
#define CHECK(c) do { if (!(c)) { std::printf("FAIL line %d: %s\n", __LINE__, #c); ++fails; } } while (0)
|
||||
static void unset(const char* k) {
|
||||
#if defined(_WIN32)
|
||||
_putenv_s(k, "");
|
||||
#else
|
||||
unsetenv(k);
|
||||
#endif
|
||||
}
|
||||
static void put(const char* k, const char* v) {
|
||||
#if defined(_WIN32)
|
||||
_putenv_s(k, v);
|
||||
#else
|
||||
setenv(k, v, 1);
|
||||
#endif
|
||||
}
|
||||
static bool has(const std::vector<std::pair<std::string, std::string>>& t, const char* k, const char* v) {
|
||||
for (const auto& kv : t) if (kv.first == k && kv.second == v) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
int main() {
|
||||
using namespace strata::core;
|
||||
unset("STRATA_GFX12_DEFAULTS");
|
||||
unset("STRATA_DEFAULTS");
|
||||
unset("STRATA_HEAD_MIX_MULTI");
|
||||
// the exact extra: gfx12 only
|
||||
CHECK(has(gfx12_exact_extra_env("gfx1201"), "STRATA_HEAD_MIX_MULTI", "1"));
|
||||
CHECK(has(gfx12_exact_extra_env("gfx1200:xnack-"), "STRATA_HEAD_MIX_MULTI", "1"));
|
||||
for (const char* other : {"gfx1100", "gfx1151", "gfx1030", "gfx906", "gfx1010", "", "gfx12010"}) CHECK(gfx12_exact_extra_env(other).empty());
|
||||
CHECK(gfx12_exact_extra_env(nullptr).empty());
|
||||
// the off switches
|
||||
put("STRATA_GFX12_DEFAULTS", "0");
|
||||
CHECK(gfx12_exact_extra_env("gfx1201").empty());
|
||||
unset("STRATA_GFX12_DEFAULTS");
|
||||
CHECK(gfx12_exact_extra_env("gfx1201", true).empty()); // STRATA_DEFAULTS=026
|
||||
CHECK(!gfx12_exact_extra_env("gfx1201", false).empty());
|
||||
// apply: sets it, keeps a value the user set, does nothing off gfx12 or with the switch off
|
||||
apply_arch_defaults("gfx1201", false);
|
||||
CHECK(std::getenv("STRATA_HEAD_MIX_MULTI") != nullptr && std::string(std::getenv("STRATA_HEAD_MIX_MULTI")) == "1");
|
||||
unset("STRATA_HEAD_MIX_MULTI");
|
||||
put("STRATA_HEAD_MIX_MULTI", "0");
|
||||
apply_arch_defaults("gfx1201", false);
|
||||
CHECK(std::string(std::getenv("STRATA_HEAD_MIX_MULTI")) == "0");
|
||||
unset("STRATA_HEAD_MIX_MULTI");
|
||||
apply_arch_defaults("gfx1100", false);
|
||||
CHECK(std::getenv("STRATA_HEAD_MIX_MULTI") == nullptr);
|
||||
put("STRATA_GFX12_DEFAULTS", "0");
|
||||
apply_arch_defaults("gfx1201", false);
|
||||
CHECK(std::getenv("STRATA_HEAD_MIX_MULTI") == nullptr);
|
||||
if (fails == 0) std::printf("gfx12_extra_test: OK\n");
|
||||
return fails == 0 ? 0 : 1;
|
||||
}
|
||||
Reference in new issue
Block a user