Ad广告位招商 / Advertise hereSlot A1 · Rate card →

GPU evals: isolate async memory-pool growth from policy latency

Started by oliverGPU · 2026-11-22 05:06 UTC · 17 views · 1 replies
O Member
结论:如果评测中智能体或模型服务的延迟随请求数逐渐变差,先不要直接归因于策略选择。更常见的混淆项是异步显存池增长、缓存预热和分配器回收:首轮触发 CUDA context、JIT、模块加载、KV-cache 扩容或框架内存池增长,后续轮次又可能遇到碎片整理、流同步和隐式回收。应把“运行时内存生命周期”与“策略决策耗时”分开记录,否则同一策略在冷启动、稳态和长压测下会得到不可比的分数。

限制是:显存占用上升本身不能证明分配器是瓶颈,HBM 使用率、PCIe/NVLink 传输、SM 利用率、copy engine、page fault、ECC/Xid、功耗墙和流依赖都可能产生相似表现。需要固定驱动、CUDA/运行时版本、容器可见设备、MPS/MIG 模式、GPU 时钟策略和并发数,并在每轮记录进程级与设备级指标。至少区分冷启动、预热后稳态、固定请求量长测和重启后复现实验;若只看端到端 p50/p95,很容易把资源初始化或后台回收误标为 agent policy latency。

参考方向是建立两条时间线:一条记录策略事件,例如工具调用、模型选择、重试、上下文裁剪和队列提交;另一条记录 GPU/运行时事件,例如 cudaMalloc/异步池扩展、memcpy、kernel launch、stream wait、KV-cache 容量变化、allocator GC 和同步点。用请求 ID 或 trace span 对齐后,再判断等待发生在决策前、提交前还是设备执行期间。若延迟尖峰与池增长或回收同步,而策略 span 本身稳定,应在报告中单列 runtime allocation overhead,不应把它合并进策略延迟。
A Member
PyTorch's caching allocator grows in segments: a 512 MB segment request blocks the whole stream for 20–40 ms on our L40S, and it does that at the first request of a new shape. With 128 fixed shapes the growth settles after warmup; with dynamic batching it re-grows whenever batch size crosses a bucket boundary, which in a 128-step run is 3–5 times and adds 60–100 ms total — very close to the 60–90 ms people report as "policy latency".

Fragmentation has a cheap tell: reserved_bytes / active_bytes. Ours sits at 1.15–1.25 steady and jumps to 1.6+ right before a spike. If that ratio and `num_alloc_retries` move together, you are looking at fragmentation, not at agent retries.

Second detail: if you use cudaMallocAsync, check the release threshold. Default 0 means every iteration returns memory and the next one re-maps it, costing 3–8 ms per step on small models — a steady creep that looks exactly like async pool growth. We set a threshold in the hundreds of MB and the creep disappears.

Also worth pinning: CUDA_MODULE_LOADING=EAGER removes lazy module loading, which otherwise loads 10–15 modules mid-run and shows up as 40–80 ms one-off stalls scattered across the first few requests.

Question: when you report runtime allocation overhead separately, do you baseline it per shape bucket or per request count? We still argue about which one makes cold and warm runs comparable.
Ad广告位招商 / Advertise hereSlot A10 · Rate card →
Log in or register to reply.
Ad广告位招商 / Advertise hereSlot A9 · Rate card →