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++
gr_parity, ple_parity: wait for the default-stream setup before launching on the test stream
Guillaume PUTIER832b2e4f340e
diff --git a/src/kernels/gr_parity.cpp b/src/kernels/gr_parity.cppindex ce1196786..34d7510bf 100644--- a/src/kernels/gr_parity.cpp+++ b/src/kernels/gr_parity.cpp@@ -190,12 +190,15 @@ int scalar_activation_contract() {};check(cudaMemcpy(d_R, ones, sizeof(ones), cudaMemcpyHostToDevice), "scalar upload R");check(cudaMemcpy(d_weights, weights, sizeof(weights), cudaMemcpyHostToDevice), "scalar upload weights");+ // the uploads run on the legacy stream from pageable memory, which the non-blocking `stream` does not wait for+ check(cudaDeviceSynchronize(), "scalar setup");cudaStream_t stream;check(cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking), "scalar stream");int bad = 0;for (float gamma : {1.0f, 1.00390625f}) {const float gammas[] = {gamma, gamma};check(cudaMemcpy(d_norm, gammas, sizeof(gammas), cudaMemcpyHostToDevice), "scalar upload norm");+ check(cudaDeviceSynchronize(), "scalar norm sync");float mixed_by_mode[3][2] = {}, inject_by_mode[3] = {};for (int mode = 0; mode < 3; ++mode) {select_activation_mode(mode);@@ -243,6 +246,7 @@ int scalar_activation_contract() {const float sentinel = -73.25f;check(cudaMemcpy(d_inject, &sentinel, sizeof(float), cudaMemcpyHostToDevice), "scalar sentinel");+ check(cudaDeviceSynchronize(), "scalar sentinel sync"); // a late sentinel would hide a write to d_injectselect_activation_mode(mode);gr_read(d_R, d_norm, d_weights, d_weights + 4, nullptr, 0.0f,sh, ws, d_mixed, d_inject, stream);@@ -358,6 +362,8 @@ int fused_multi_lds_parity(const float* d_norm, const uint16_t* d_down, const uicudaStream_t stream = nullptr;check(cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking), "multi stream");+ // the uploads above (and the caller's weights) run on the legacy stream, which the non-blocking `stream` does not wait for+ check(cudaDeviceSynchronize(), "multi setup");// Max T forces the HIP kernel's full dynamic-LDS request: 8 * 1280 * sizeof(float) = 40 KiB.fused_gr_read_multi(args.data(), T, d_xn, stream);check(cudaStreamSynchronize(stream), "multi max-T sync");diff --git a/src/kernels/ple_parity.cpp b/src/kernels/ple_parity.cppindex 20da02206..5d42185a8 100644--- a/src/kernels/ple_parity.cpp+++ b/src/kernels/ple_parity.cpp@@ -199,6 +199,8 @@ int history_advance_regression() {float* history = history_storage + guard;float* norm = norm_storage + guard;ck(cudaMemcpy(history, expected.data(), count * sizeof(float), cudaMemcpyHostToDevice), "history initial values");+ // the guard memsets and this upload run on the legacy stream, which the non-blocking `stream` does not wait for+ ck(cudaDeviceSynchronize(), "history setup");cudaStream_t stream;cudaGraph_t graph;cudaGraphExec_t executable;@@ -880,6 +882,9 @@ int main(int argc, char** argv) {ck(cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking), "native PLE key stream");const size_t workspace_bytes = (size_t) k::ple_block_scratch_bytes();ck(cudaMemset(ple_ws, 0xa5, workspace_bytes), "native PLE no-launch sentinel");+ // the guards, the weight upload and the sentinel run on the legacy stream, which the non-blocking+ // `stream` does not wait for+ ck(cudaDeviceSynchronize(), "native PLE key setup");int refused = 0;for (int c = 0; c < 9; ++c) {auto invalid = nw;@@ -905,6 +910,7 @@ int main(int argc, char** argv) {std::vector<float> projected(hcd), normalized(hcd), actual_key(hcd), actual_result(hcd), replay(hcd);for (int p = 0; p < std::min(cap.nt, 2); ++p) {ck(cudaMemcpy(d_emb, cap.emb.data() + (size_t) p * nd, nd * 4, cudaMemcpyHostToDevice), "native PLE key input");+ ck(cudaDeviceSynchronize(), "native PLE key input sync");k::native_q2_0_f32(native_data, d_emb, native_q, raw_projection, k::NG_N_EMBD, k::NG_HC_DIM, 1, stream);ck(cudaStreamSynchronize(stream), "native PLE raw key sync");ck(cudaMemcpy(projected.data(), raw_projection, hcd * 4, cudaMemcpyDeviceToHost), "native PLE raw key read");