我不會用 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。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM