Merge f-027-gh-eng-a (#3622 ARM64 / DGX Spark port, #3806 Gyro-L TQP5/6/7)

# Conflicts:
#	cmake/ggml_tq_overlay_test.cmake
#	src/core/verify.cpp
This commit is contained in:
Niko1221 committed 2026-10-27 01:59:31 +01:00
commit ba8b2bcb9c
30 files changed
+1392 -92

No files matched your search

+20 -18
View File
@@ -79,7 +79,7 @@
#include <cstdlib>
#include <cstring>
#include <exception>
#include <immintrin.h>
#include "strata/platform/cpu_relax.hpp"
#if defined(STRATA_GPU_METAL)
// The Metal backend's decode window (metal/src/engine/window.cpp): this file's init/run/commit hand over to it.
@@ -609,7 +609,7 @@ bool Verifier::release_gpu_waits(int timeout_ms) {
for (uint32_t* p : {h_flag_, h_flagA_, h_flagB_, hflag_in_h_}) // + an overlapped split's hand-off wait
if (p != nullptr) *(volatile uint32_t*) p = UINT32_MAX;
std::atomic_thread_fence(std::memory_order_seq_cst);
_mm_sfence();
strata_store_fence();
const OnDevice on_device(device_);
const Clock::time_point t0 = Clock::now();
for (cudaStream_t s : {cs_, copy_}) {
@@ -2899,7 +2899,7 @@ void Verifier::stage_inputs(int T, const int32_t* tokens, int64_t pos0) {
if (herr_h_ != nullptr) *(volatile uint32_t*) herr_h_ = 0;
if (hdrop_h_ != nullptr) *(volatile uint32_t*) hdrop_h_ = (g_test_drop > 0 && windows + 1 == g_test_drop) ? 1u : 0u;
std::atomic_thread_fence(std::memory_order_seq_cst);
_mm_sfence();
strata_store_fence();
last_t_ = T;
if (rs_on_ && T >= 1 && T <= 8) ++rs_win_[T];
last_pos0_ = pos0;
@@ -2977,7 +2977,7 @@ bool Verifier::adapt_gate_wait(int32_t layer, std::string& err) {
progress_at("verify window: waiting for the adaptive tier's copies of layer", layer);
announced = true;
}
_mm_pause();
strata_cpu_pause();
if ((++spins & 1023u) != 0) continue;
if (Clock::now() - t0 > std::chrono::seconds(20)) {
// the release drains the window's own streams, never the tier's copy stream: say so, and hand out the
@@ -3115,7 +3115,7 @@ bool Verifier::run(int T, const int32_t* tokens, int64_t pos0, PoolMultiFn pool,
const Clock::time_point tp = Clock::now();
if (!ss.ple.table->gather_batch(ple_rows, (size_t) T, h_ple_, err)) return false;
std::atomic_thread_fence(std::memory_order_seq_cst);
_mm_sfence();
strata_store_fence();
ms_host += ms_since(tp);
}
*(volatile uint32_t*) h_flag_ = 1;
@@ -3190,7 +3190,7 @@ bool Verifier::run(int T, const int32_t* tokens, int64_t pos0, PoolMultiFn pool,
const Clock::time_point tp = Clock::now();
if (!ss.ple.table->gather_batch(ple_rows, (size_t) T, h_ple_, err)) return false;
std::atomic_thread_fence(std::memory_order_seq_cst);
_mm_sfence();
strata_store_fence();
*flag = 1;
ms_host += ms_since(tp);
} else {
@@ -3206,7 +3206,7 @@ bool Verifier::run(int T, const int32_t* tokens, int64_t pos0, PoolMultiFn pool,
uint32_t spins = 0;
progress_at("verify window: waiting for the GPU to reach layer", l);
while (*seq < want) {
_mm_pause();
strata_cpu_pause();
if ((++spins & 1023u) != 0) continue;
const auto now = Clock::now();
if (now - last_flush > std::chrono::microseconds(2000)) {
@@ -3242,6 +3242,7 @@ bool Verifier::run(int T, const int32_t* tokens, int64_t pos0, PoolMultiFn pool,
return false;
}
}
strata_load_fence(); // the layer rang: the GPU's activations are read after it (a no-op on x86)
const Clock::time_point b = Clock::now();
if (g_trace) trace_ev("RANG", k, l, (int64_t) std::chrono::duration_cast<std::chrono::microseconds>(b - a).count());
VDBG("layer %lld rang\n", (long long) l);
@@ -3262,7 +3263,7 @@ bool Verifier::run(int T, const int32_t* tokens, int64_t pos0, PoolMultiFn pool,
(int64_t) ms_since(b)); // aux: ms the CPU experts took
progress_tick();
std::atomic_thread_fence(std::memory_order_seq_cst);
_mm_sfence();
strata_store_fence();
if (h_bal_ != nullptr) { // set_pcie_balance: the step's plan, its CPU and its PCIe experts
const size_t bi = (size_t) ((k / G) * 2 + grp);
bal_ok_[bi] = *(volatile uint32_t*) h_flagA_ == want;
@@ -3288,7 +3289,7 @@ bool Verifier::run(int T, const int32_t* tokens, int64_t pos0, PoolMultiFn pool,
const Clock::time_point tp = Clock::now();
if (!ss.ple.table->gather_batch(ple_rows, (size_t) T, h_ple_, err)) return false;
std::atomic_thread_fence(std::memory_order_seq_cst);
_mm_sfence();
strata_store_fence();
ms_host += ms_since(tp);
}
if (!(test_stall && k + 1 == steps)) *flag = want;
@@ -3544,7 +3545,7 @@ void Verifier::fetch_dma(void* ctx, const uint8_t* const* src, int n, size_t byt
void Verifier::publish_plan(void* ctx) {
Verifier* v = (Verifier*) ctx;
_mm_sfence();
strata_store_fence();
*(volatile uint32_t*) v->h_flagA_ = v->cur_layer_ + 1;
}
@@ -4172,7 +4173,7 @@ bool Verifier::run_slot_rows(const int* rows, int S, const int32_t* tokens, cons
if (ar_on()) {
if (ss_->ple.ready() && ple_stage()) {
std::atomic_thread_fence(std::memory_order_seq_cst);
_mm_sfence();
strata_store_fence();
*flag = 1;
}
const cudaError_t se = cudaStreamSynchronize(cs_);
@@ -4196,7 +4197,7 @@ bool Verifier::run_slot_rows(const int* rows, int S, const int32_t* tokens, cons
uint32_t spins = 0;
progress_at("verify batch: waiting for the GPU to reach layer", l);
while (*seq < want) {
_mm_pause();
strata_cpu_pause();
if ((++spins & 1023u) != 0) continue;
const auto now = Clock::now();
if (now - last_flush > std::chrono::microseconds(2000)) {
@@ -4213,6 +4214,7 @@ bool Verifier::run_slot_rows(const int* rows, int S, const int32_t* tokens, cons
return false;
}
}
strata_load_fence(); // as above, for the batch loop's wait
const Clock::time_point b = Clock::now();
cur_layer_ = want - 1;
set_plan_slot(0);
@@ -4224,7 +4226,7 @@ bool Verifier::run_slot_rows(const int* rows, int S, const int32_t* tokens, cons
if (remote_opt_) remote_opt_->end();
progress_tick();
std::atomic_thread_fence(std::memory_order_seq_cst);
_mm_sfence();
strata_store_fence();
if (*(volatile uint32_t*) h_flagA_ != want) { // the pool did not publish a plan: an empty one
sink_.counts[0] = 0;
sink_.counts[1] = 0;
@@ -4349,7 +4351,7 @@ int Verifier::batch_serve(PoolMultiFn pool, void* user) {
// run_slot_rows makes). Per-window (ar_on): with a loan in flight the doorbell graph needs the per-layer service.
if (ar_on() && ss_->ple.ready() && ple_stage()) {
std::atomic_thread_fence(std::memory_order_seq_cst);
_mm_sfence();
strata_store_fence();
*h_flag_ = 1;
}
for (;;) {
@@ -4369,7 +4371,7 @@ int Verifier::batch_serve(PoolMultiFn pool, void* user) {
if (remote_opt_) remote_opt_->end();
progress_tick();
std::atomic_thread_fence(std::memory_order_seq_cst);
_mm_sfence();
strata_store_fence();
if (*(volatile uint32_t*) h_flagA_ != want) { // the pool did not publish a plan: an empty one
sink_.counts[0] = 0;
sink_.counts[1] = 0;
@@ -4671,7 +4673,7 @@ int Verifier::service(PoolMultiFn pool, void* user, std::string& err) {
const Clock::time_point tp = Clock::now();
if (!ss.ple.table->gather_batch(pl_ple_rows_.data(), (size_t) T, h_ple_, err)) return false;
std::atomic_thread_fence(std::memory_order_seq_cst);
_mm_sfence();
strata_store_fence();
ms_host += ms_since(tp);
return true;
};
@@ -4722,7 +4724,7 @@ int Verifier::service(PoolMultiFn pool, void* user, std::string& err) {
(int64_t) ms_since(b));
progress_tick();
std::atomic_thread_fence(std::memory_order_seq_cst);
_mm_sfence();
strata_store_fence();
if (*(volatile uint32_t*) h_flagA_ != want) { // the pool did not publish a plan: an empty one
sink_.counts[0] = 0;
sink_.counts[1] = 0;
@@ -4796,7 +4798,7 @@ bool Verifier::pl_commit_async(int n_keep, std::string& err) {
const Clock::time_point t0 = Clock::now();
if (commit_live_) { // its graph reads the words below when it starts: the previous one has (a window ago)
cudaError_t q;
while ((q = cudaEventQuery(ev_commit_)) == cudaErrorNotReady) _mm_pause();
while ((q = cudaEventQuery(ev_commit_)) == cudaErrorNotReady) strata_cpu_pause();
if (q != cudaSuccess) { err = std::string("verify: commit: ") + cudaGetErrorString(q); return false; }
}
h_commit_[0] = n_keep;