When building DALI pipelines for inference within PyTriton, keep the following technical constraints in mind:
Prefetching for Inference
While DALI's default prefetch_queue_depth = 2 is ideal for training to overlap data loading with model execution, for inference, it is often better to set prefetch_queue_depth = 1 to minimize latency and process data as quickly as possible.
Layout Conversions (NFCHW to NCHW)
In DALI, the batch dimension is often implicit. When processing video, the pipeline returns data in NFCHW layout (Batch, Frame, Channel, Height, Width). To form a standard batch for inference, this must be flattened to an (N*F)CHW layout.
Video Decoding and Memory Limits
There are two primary ways to decode video in DALI:
fn.decoders.video: Receives an encoded buffer via fn.external_source and decodes the entire video at once. This is the recommended method for PyTriton because it does not require the model to be a decoupled model.fn.inputs.video: Acts as a standalone input and decodes specific portions of a video using the sequence_length operator. This is more memory-efficient for very long videos but requires the DALI model to be configured as a decoupled model to generate multiple responses per request. Note: PyTriton does not currently support decoupled models.