我不会用 Triton 系列:Dynamic batching 学习笔记

Q&A

问题:按照下面配置 Preferred Batch Sizes,如果此时 requests 有 7 个,那么会发送多少个给 backend 呢?

dynamic_batching {
  preferred_batch_size: [ 4, 8 ]
}

回答:看文档中的表述,应该是 4。如果可以形成 preferred batch size,那么就会尽可能组成一个最大的 batch size。
When a model instance becomes available for inferencing, the dynamic batcher will attempt to create batches from the requests that are available in the scheduler. Requests are added to the batch in the order the requests were received. If the dynamic batcher can form a batch of a preferred size(s) it will create a batch of the largest possible preferred size and send it for inferencing. If the dynamic batcher cannot form a batch of a preferred size (or if the dynamic batcher is not configured with any preferred batch sizes), it will send a batch of the largest size possible that is less than the maximum batch size allowed by the model (but see the following section for the delay option that changes this behavior).

问题:max_batch_size 缺省的情况下,request 拿到的 shape 是怎么样的?max_batch_size 不为 0 的情况下,又是怎么样的?客户端在请求的时候,输入的 shape 有什么样的要求?

回答:如果 max_batch_size 为 0,那么将不支持 dynamic batching,这时后端拿到的就是 config.pbtxt 中的 dims 的形状。如果 max_batch_size 不为 0,那么将开启 dynamic batching,请求的时候第一维只要小于 max_batch_size 即可,假设只有一个请求,那么后端拿到的就是 max_batch_size + dims 组成的 shape。如果有多个请求,需要后端自己做好处理。客户端请求的时候,输入的 shape 需要满足形式为 [-1, dims] 的格式,第一维度需要是 batch size 才行,即使当前 batch 只有一个样本,也不可以使用 dims,必须要 [1, dims]。

问题:allow_ragged_batch 选项的作用?

回答:允许一个 batch 中的样本具有不同形状。比如两个请求的输入形状不一样,但是仍然可以组成一个 batch。

posted @ 2022-10-15 09:16  楷哥  阅读(1097)  评论(1编辑  收藏  举报