mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-05 15:58:53 +00:00
When cudaGraphInstantiate (pdl::instantiate) fails for lack of memory, the capture code falls back to eager mode. The graph handle was already destroyed right after the
instantiate call, and the failure branch destroyed it a second time: cudaGraphDestroy on the dangling handle returns cudaErrorInvalidValue and leaves it as the last error.
Nothing cleared it after that (the cudaGetLastError() of the branch ran before the second destroy), so the next code that reads the last error took it for its own:
InkTopkScratch::run() ("CUDA error 1 at ink_cuda_backend.cu:1314: invalid argument", the first top-k after the fallback) and ended the engine. It hit the shipped default path too.
Fix, at the five graph sites of ink_runner.cuh (the M-row decode graph, the tree-verify graph, the 5060 Ti prefix+core graph, the batched multi-slot graph and the batched chain-verify graph: GraphKey modes 0, 2, 200+, 10 and 30): gr = nullptr after the first destroy, and
(void)cudaGetLastError() after the failure branch's destroy, so the eager fallback starts with a clean error state. The same pattern was searched for in the whole engine
(a scan for a graph handle destroyed twice on one path): the DSpark / DFlash 2 graphs (ink_dspark.cuh, core/dflash2.cpp), core/mtp.cpp, core/session.cpp, core/verify.cpp,
the HIP backends and hy4 destroy once per path; only these five sites had it.
Test (RTX 3090, SQ-20 v2, DFlash 2, default path, the late-ballast shim of NV-ADA-AMPERE: all but 20 / 60 MiB of the free VRAM taken right before the first stream capture):
the old binary dies at 20 MiB after "Tree CUDA Graph capture unavailable (err=2)", the fixed binary completes (decode 86.7 against 87.4 normal tok/s); with 60 MiB (capture
succeeds) and without the shim both binaries are token-identical with the same speed; FASTQ math on the fixed build 88/90 with no fatal line.