From a6702f8db52e11e364257ec008f549a1baab7941 Mon Sep 17 00:00:00 2001 From: Constantin Date: Sun, 25 Oct 2026 06:57:16 -0400 Subject: [PATCH] Fix test fixture lifetimes for sanitizer validation Avoid empty-payload fwrite, retain the JSON embedding value during iteration, and release fake pinned allocations between Flash-Next redeclarations. Test-only fixes used by the HYV3 sanitizer run. --- tests/arch_test.cpp | 6 +++++- tests/checkpoint_test.cpp | 3 ++- tests/server_test.cpp | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/arch_test.cpp b/tests/arch_test.cpp index 9985a922..d8eee1b1 100644 --- a/tests/arch_test.cpp +++ b/tests/arch_test.cpp @@ -9520,7 +9520,7 @@ TEST(flashnext_a_spanned_prefill_runs_a_pass_at_a_time_with_its_all_reduces_besi ctx.max_mixed_tok = 2048; REQUIRE_EQ(stderr_of_rc([&] { return qwen4exp_fp8::declare(&b, &meta, &ctx); }), RAD_OK); - const qwen4exp_fp8::Model& m = qwen4exp_fp8::g_model[rank]; + qwen4exp_fp8::Model& m = qwen4exp_fp8::g_model[rank]; CHECK(m.span_on); CHECK_EQ(m.pipe_on, world > 2); CHECK_EQ(m.qsacfg.plane_rows, 2048); @@ -9556,6 +9556,10 @@ TEST(flashnext_a_spanned_prefill_runs_a_pass_at_a_time_with_its_all_reduces_besi CHECK(score > 0); CHECK_EQ(wide_score, 0); CHECK(conv > 0); + /* This fake runtime has no engine teardown between model redeclarations. */ + rad_dev_free(m.pipe_cu_h, RAD_MEM_HOST_PINNED); + m.pipe_cu_h = nullptr; + m.pipe_cu_tried = false; if (world < 4) { CHECK_EQ(ar, world > 1 ? 1 : 0); CHECK_EQ(ar_lane0, ar); diff --git a/tests/checkpoint_test.cpp b/tests/checkpoint_test.cpp index 88ccbc51..b7562c68 100644 --- a/tests/checkpoint_test.cpp +++ b/tests/checkpoint_test.cpp @@ -60,7 +60,8 @@ void write_shard(const std::string& path, const std::vector& ts) { const uint64_t n = hdr.size(); std::fwrite(&n, 8, 1, f); std::fwrite(hdr.data(), 1, hdr.size(), f); - for (const T& t : ts) std::fwrite(t.bytes.data(), 1, t.bytes.size(), f); + for (const T& t : ts) + if (!t.bytes.empty()) std::fwrite(t.bytes.data(), 1, t.bytes.size(), f); std::fclose(f); } diff --git a/tests/server_test.cpp b/tests/server_test.cpp index b9a5fda5..f046f719 100644 --- a/tests/server_test.cpp +++ b/tests/server_test.cpp @@ -5143,8 +5143,8 @@ TEST(embeddings_are_truncated_then_normalised_and_failures_named) { } { f.sched.embedding = std::vector(8, 0.0f); - for (const json& x : vectors(R"({"input":"a"})")["data"][0]["embedding"]) - CHECK_EQ(x.get(), 0.0f); + const json embedding = vectors(R"({"input":"a"})")["data"][0]["embedding"]; + for (const json& x : embedding) CHECK_EQ(x.get(), 0.0f); } f.sched.embedding = { 3, 4, 0, 12, 0, 0, 0, 0 }; {