[Test][V1] Add sleep/wake correctness regression test for hybrid GDN/… (#44972)

Signed-off-by: chun-wan <chun-wan@amd.com>
This commit is contained in:
chun-wan
2026-08-02 22:02:42 +00:00
committed by GitHub
parent 0055b8bfa3
commit 0033211c0b
2 changed files with 100 additions and 0 deletions
+23
View File
@@ -212,6 +212,29 @@ void create_and_map(unsigned long long device, ssize_t size, CUdeviceptr d_mem,
if (error_code != 0) {
return;
}
#ifdef USE_ROCM
// ROCm-only: zero the freshly (re)mapped region.
//
// On some amdgpu driver versions the physical VRAM backing a buffer is not
// scrubbed on release, so the pages handed back here (e.g. on wake_up after a
// sleep that discarded a tag) can still contain stale data from a previously
// freed allocation -- possibly from another process. Callers of the device
// allocator expect newly mapped memory to be well defined; in particular
// hybrid Mamba / gated-delta-net (GDN) models keep a persisted conv/recurrent
// state cache, and a new sequence that reads an unzeroed slot will propagate
// garbage/NaN, collapsing generation to token id 0 (decoded as "!").
//
// This is scoped to the ROCm path on purpose: the CUDA path is unchanged.
// Use CUDA_CHECK so a failure sets the global error_code; the Python caller
// (python_create_and_map) only inspects error_code, so returning without
// setting it would make a failed memset look successful and still hand back
// unzeroed memory.
CUDA_CHECK((CUresult)hipMemset(reinterpret_cast<void*>(d_mem), 0, size));
if (error_code != 0) {
return;
}
#endif
// std::cout << "create_and_map: device=" << device << ", size=" << size << ",
// d_mem=" << d_mem << ", p_memHandle=" << p_memHandle << std::endl;
}