Significant FPS drop when using YUV420 input instead of RGB

Hi,

I’m working with a YOLOv8s model and noticed a significant performance difference between two compiled versions.

When I compile the model with RGB input, hailortcli run reports a maximum frame rate of approximately 184 FPS. However, when I add a YUV420-to-RGB conversion layer through my .alls file and recompile the model, the maximum frame rate drops to around 30 FPS.

The reason for adding the YUV conversion layer was to offload the color conversion from the CPU to the Hailo accelerator, reducing CPU usage and improving overall pipeline performance.

Both versions use the same model architecture, with the main difference being the additional YUV conversion layer.

Is this level of performance degradation expected when using the YUV conversion layer? I’m trying to understand whether the conversion itself introduces that much overhead or whether adding the layer affects how the model is mapped and optimized during compilation.

Thanks in advance for any insights!

Hi @Danelis_Garrido

Thank you for the detailed description. It’s very helpful.

The drop from about 184 FPS to about 30 FPS is not what we would typically expect from the color conversion itself. The conversion is a lightweight operation. Moving it onto the Hailo device is a valid and recommended way to offload the host CPU.

The more likely explanation is your second hypothesis: the added layer changed how the compiler mapped the model onto the device. The conversion runs at the full input resolution, so it uses some on-chip resources. If YOLOv8s was already close to the device’s capacity, those extra resources can push the compiler to split the model into several parts (we call these “contexts”). The device then has to switch between those parts for every frame. This switching can reduce throughput significantly, especially when running one frame at a time. A 5–6x drop is consistent with that scenario.

There are a few things we can check quickly to confirm:

  1. Compare the compilation logs or profiler reports of the two HEFs. If the RGB version compiled into a single context and the YUV version into multiple contexts, that explains the difference.
  2. Confirm the exact YUV420 layout from your camera or ISP. “YUV420” can mean NV12 (interleaved chroma) or I420 (planar). NV12 is the most common camera output and the one we generally recommend. Using the conversion that matches your source format directly avoids unnecessary extra steps.
  3. Run hailortcli run with a larger batch size (for example, --batch-size 8) on the YUV version. If the model is multi-context, batching spreads the switching cost over several frames and usually recovers a good part of the throughput.
  4. Recompile with a higher compiler optimization level in your .alls file, which gives the compiler more effort to fit the model efficiently:
    performance_param(compiler_optimization_level=max)

If you can share your .alls file, the compiler logs (or profiler HTML reports) for both versions, the target device, and your Dataflow Compiler version, we’ll be glad to review them and recommend the best configuration for your pipeline. Depending on the results, we can also discuss alternatives. For example, keeping the conversion on the host if your SoC has a hardware color converter or ISP that can do it at no CPU cost.

Thank you for the detailed explanation and insights.

I’m currently using the following input conversion in my .alls file:

i420_to_yuv_layer, yuv_to_rgb_layer = input_conversion(i420_to_rgb)

The camera pipeline provides I420 input, so this conversion matches the source format.

I tested your suggestions and confirmed that the YUV version is indeed being compiled into two contexts, as shown by hailortcli parse-hef:

Architecture HEF was compiled for: HAILO8
Multi Context - Number of contexts: 2

I also tested inference with a batch size of 8, which significantly increased the throughput:

  • Default batch size: 31.01 FPS

  • Batch size 8: 84.67 FPS

This seems to confirm that the multi-context compilation is responsible for the performance drop.

For now, 30 FPS is sufficient for my application. My main concern is whether adding the YUV input conversion could become a limitation if we need to increase the FPS in the future.

I’m using a Raspberry Pi CM4, so multi-context models are a concern due to the limited PCIe bandwidth and the overhead associated with context switching. However, increasing the batch size to 8, as you recommended, helped recover some of the lost throughput.

Thanks again for your insights!