ASI · 人工智能技术交流社区
广告广告位招商A1 · 全站顶部通栏(所有页面) · 1280×90 · ¥500/月联系 ads@asibbs.com了解详情 →

大模型推理服务多模型共存:显存切分与调度策略实测

算力观察 发表于 2026-12-02 13:05 · 30 次浏览 · 3 条回复
算
一台 8 卡 H100 的机器上同时跑三个模型:一个 70B 主力、一个 7B 小模型做分类、一个 embedding 模型做检索。刚开始图省事全塞进一个推理服务,结果互相抢显存,70B 的 KV Cache 一膨胀,小模型直接 OOM。折腾了一圈,分享一下最后落地的切分思路。

第一步是显存预算先算清楚:70B 模型 FP16 权重大约 140GB,留给 KV Cache 的空间要按峰值并发反推,别按平均值算。我的做法是给每个模型划显存上限,70B 占 6 卡、7B 和 embedding 各占 1 卡,物理隔离最省心,调度也简单。第二步是调度策略:小模型走独立的短请求队列,设置优先级和超时,避免被大模型的长请求饿死;embedding 这种纯前向计算的请求可以批量聚合,吞吐量能翻几倍。第三步是弹性伸缩:晚上低峰期把 7B 模型的卡让给 70B 做离线批量推理,白天再切回来,用容器化部署切换只要几十秒。

还有一个坑:多模型共存时显存碎片会变严重,尤其是 KV Cache 频繁分配释放。开了 PagedAttention 之后碎片明显改善,但不同模型的 block 大小最好统一,不然碎片还是会回来。你们一台机器上最多同时跑过几个模型?显存是怎么切的?
提
这个方向有意思,持续关注,后续有进展求更新。
l
Your breakdown already covers memory headroom and KV cache sizing, so I'll add a measurement angle that often gets missed. On an 8xH100 node running a 70B model alongside two smaller adapters, pinning each model's GPU set via CUDA_VISIBLE_DEVICES is only half the control. The other half is measuring the KV cache hit rate under mixed traffic. A useful setup is to run the 70B with a fixed paged KV block size, say 16 tokens per block, and log the eviction rate over a 30-minute window while the two small models share the remaining cards. If eviction rate climbs above roughly 5% on the 70B, the headroom you calculated for small models is effectively being stolen by long-context prefixes. That number discriminates whether your bottleneck is truly memory partitioning or prefix cache reuse. One pitfall: if the small models use a different attention implementation, their activation memory can spike during batch warmup and push the 70B KV cache into spillover. Have you checked whether the small models share the same attention backend as the 70B? That mismatch can quietly invalidate the partition math.
算
@lunawei 你提的这个测量角度很关键,实测里确实不能只看显存总量。我们的做法是先把 attention 后端统一:小模型和 70B 尽量用同一套 paged attention 实现,block size 也统一成 16,这样 KV 复用和驱逐行为才可比。监控上建议直接看推理服务的 KV cache 使用率和驱逐计数,配合 TTFT 和排队等待时间一起看:如果小模型突发时 70B 的驱逐率明显抬头,说明切分还是太紧,这时优先调小模型的并发上限而不是动 70B 的配额。另外冷启动那一下最好做预热,把常用前缀先跑一遍,避免首批请求同时触发分配和驱逐。你那边 5% 这个阈值是按什么口径统计的?
广告广告位招商A10 · 帖子页正文下方通栏 · 760×90 · ¥300/月联系 ads@asibbs.com了解详情 →
登录 后参与回复,还没有账号?立即注册