Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

multi-GPU: time the helper GPU's staging/launch and wait per request

Niko12214cd2461849e6
diff --git a/include/strata/core/remote_experts.hpp b/include/strata/core/remote_experts.hpp
index 4d0e64854..df2a3b7a4 100644
--- a/include/strata/core/remote_experts.hpp
+++ b/include/strata/core/remote_experts.hpp
@@ -43,6 +43,9 @@ public:
double gib() const { return cache_.gib(); }
uint64_t returned_bytes() const { return returned_bytes_; }
uint64_t full_row_bytes() const { return full_row_bytes_; }
+ /// host time spent in begin() (staging + launches) and in finish() (waiting for this GPU), cumulative
+ double ms_begin() const { return ms_begin_; }
+ double ms_wait() const { return ms_wait_; }
private:
int device_ = -1;
@@ -52,6 +55,7 @@ private:
int64_t launched_layers_ = 0;
uint64_t returned_bytes_ = 0;
uint64_t full_row_bytes_ = 0;
+ double ms_begin_ = 0, ms_wait_ = 0;
ExpertCache cache_;
cudaStream_t stream_ = nullptr;
float* h_x_ = nullptr;
diff --git a/src/core/remote_experts.cpp b/src/core/remote_experts.cpp
index 10b205f0b..ea5e350f2 100644
--- a/src/core/remote_experts.cpp
+++ b/src/core/remote_experts.cpp
@@ -6,6 +6,7 @@
#include "strata/kernels/s2_expert_grouped.hpp"
#include <algorithm>
+#include <chrono>
#include <cstring>
namespace strata::core {
@@ -214,6 +215,9 @@ bool RemoteExperts::open(int device, int slots, int64_t layers, int64_t experts,
bool RemoteExperts::begin(int64_t layer, const float* x, const int32_t* ids, int64_t n_tok,
int64_t k, const int32_t* kind, const int32_t* primary_res,
std::string& err) {
+ // cumulative host time in here (staging and launches), reported per request by the driver
+ struct Timer { double& acc; std::chrono::steady_clock::time_point t0 = std::chrono::steady_clock::now();
+ ~Timer() { acc += std::chrono::duration<double, std::milli>(std::chrono::steady_clock::now() - t0).count(); } } timer{ms_begin_};
const int64_t n = n_tok * k;
if (n <= 0 || n > CAP || n_tok > strata::kernels::cpu::MAXT || k != 10 || layer < 0 ||
(size_t) layer >= layers_present_.size() || device_ < 0) {
@@ -296,7 +300,9 @@ bool RemoteExperts::finish(float* out, std::string& err) {
if (group_id_.empty()) return true;
DeviceScope scope(device_);
if (!scope.ok) { err = scope.error(device_); return false; }
+ const auto w0 = std::chrono::steady_clock::now();
if (!check(cudaStreamSynchronize(stream_), "finish", err, device_)) return false;
+ ms_wait_ += std::chrono::duration<double, std::milli>(std::chrono::steady_clock::now() - w0).count();
for (size_t i = 0; i < original_row_.size(); ++i)
std::memcpy(out + (size_t) original_row_[i] * H, h_out_ + i * H, (size_t) H * sizeof(float));
return true;
diff --git a/src/program/generate.cpp b/src/program/generate.cpp
index ad78ace37..3b3141d2b 100644
--- a/src/program/generate.cpp
+++ b/src/program/generate.cpp
@@ -3520,11 +3520,13 @@ int main(int argc, char** argv) {
(long long) sfx_windows, (long long) sfx_ok, (long long) sfx_drafts);
for (int r = 0; r < 3; ++r) if (o.expert_cache_remote[(size_t) r] > 0)
std::fprintf(stderr, "strata serve: CUDA%d: %lld expert entries, %lld active layer launches, %.1f MiB returned "
- "(%.1f MiB with full rows) in this request\n", r + 1,
+ "(%.1f MiB with full rows) in this request; host %.0f ms staging+launching, %.0f ms "
+ "waiting for it (since start)\n", r + 1,
(long long) (remote_experts[(size_t) r].computed() - remote_before[(size_t) r]),
(long long) (remote_experts[(size_t) r].launched_layers() - launches_before[(size_t) r]),
(double) (remote_experts[(size_t) r].returned_bytes() - compact_before[(size_t) r]) / 1048576.0,
- (double) (remote_experts[(size_t) r].full_row_bytes() - full_before[(size_t) r]) / 1048576.0);
+ (double) (remote_experts[(size_t) r].full_row_bytes() - full_before[(size_t) r]) / 1048576.0,
+ remote_experts[(size_t) r].ms_begin(), remote_experts[(size_t) r].ms_wait());
}
return 0;
}