From 728097fb6f0e76343aedaff26f48d96318ca070b Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Tue, 13 Oct 2026 04:49:15 +0200 Subject: [PATCH] HIP: STRATA_COPY_HIP_PRIO=1 (opt-in) creates the verifier's copy stream at high priority ROCm gives out hardware queues per priority. Sharing one with the window's stream, --pcie-mode dma's expert copies and the host function that raises flag B queue behind the window graph that spins on that flag: on an R9700 every dma-mode request timed out at layer 1. With its own queue dma mode runs (copies overlap the VRAM-hit compute). --- src/core/verify.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/core/verify.cpp b/src/core/verify.cpp index f4cc7497..272ecbeb 100644 --- a/src/core/verify.cpp +++ b/src/core/verify.cpp @@ -727,7 +727,20 @@ bool Verifier::init(const WeightTable& wt, const ModelGeometry& g, SessionState& sink_.staging = (unsigned long long) staging_; sink_.staging_cap = kStagingBlobs; (void) TS; - if (cudaStreamCreateWithFlags(©_, cudaStreamNonBlocking) != cudaSuccess) { + bool copy_made = false; +#if defined(STRATA_USE_HIP) && !defined(STRATA_HIP_GFX906) + // engine-latency, STRATA_COPY_HIP_PRIO=1 (opt-in): the copy stream at high priority, so it gets a hardware queue of + // its own (ROCm hands queues out per priority). Sharing one with the window's stream, --pcie-mode dma's copies and + // their host function queue behind the window's graph, which spins on the flag they raise (a timeout at layer 1). + { + static const bool cp = [] { const char* v = std::getenv("STRATA_COPY_HIP_PRIO"); return v != nullptr && std::atoi(v) != 0; }(); + int lo = 0, hi = 0; + if (cp && hipDeviceGetStreamPriorityRange(&lo, &hi) == hipSuccess) + copy_made = hipStreamCreateWithPriority(©_, hipStreamNonBlocking, hi) == hipSuccess; + (void) cudaGetLastError(); + } +#endif + if (!copy_made && cudaStreamCreateWithFlags(©_, cudaStreamNonBlocking) != cudaSuccess) { err = "verify: copy stream create failed"; return false; }