From 3decb3ca1340caa836f628ba56bcd82bbf88bcf4 Mon Sep 17 00:00:00 2001 From: fl0l0u Date: Fri, 30 Oct 2026 16:05:10 +0000 Subject: [PATCH] qwen4exp: the pinned window copy survives its model's reset declare() resets the rank's Model with Model{} on every re-declare -- every rebuild, every sizing probe, every test case -- and the reset drops pipe_cu_h, the once-made pinned copy of the window bounds, on the floor: the pointer is overwritten and the pin leaks. arch_test flags it under the asan tier (qsa_a_widened_step...: 8 bytes, calloc, pipe_bounds), and the leak grows one pin per re-declare of a rank. Free the copy where it is dropped. The copy is read only by a widened step's memcpys, and no step runs across a declare. --- arch/qwen4exp_fp8/qwen4exp_fp8.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/qwen4exp_fp8/qwen4exp_fp8.cpp b/arch/qwen4exp_fp8/qwen4exp_fp8.cpp index 27ef3467..d5cca086 100644 --- a/arch/qwen4exp_fp8/qwen4exp_fp8.cpp +++ b/arch/qwen4exp_fp8/qwen4exp_fp8.cpp @@ -273,6 +273,10 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c * real max_tok (RadBuildCtx::shape_probe). */ static thread_local Model probe_model; Model& m = ctx->shape_probe ? probe_model : g_model[ctx->rank]; + /* The reset drops the pinned window copy (pipe_bounds); free it first -- a re-declare of the + * same rank (every rebuild, every test case) otherwise overwrites the pointer and leaks the + * pin. The copy is read only by a step's memcpys, and no step runs across a declare. */ + if (m.pipe_cu_h) rad_dev_free(m.pipe_cu_h, RAD_MEM_HOST_PINNED); m = Model{}; m.nm = Names(ctx->scope ? ctx->scope : ""); Names& nm = m.nm;