Skip to content

fix(inference): Synchronize cpu_threads configuration for HPI predictors#4972

Open
SankaraVenkatRam wants to merge 1 commit intoPaddlePaddle:developfrom
SankaraVenkatRam:fix/hpi-cpu-threads-sync
Open

fix(inference): Synchronize cpu_threads configuration for HPI predictors#4972
SankaraVenkatRam wants to merge 1 commit intoPaddlePaddle:developfrom
SankaraVenkatRam:fix/hpi-cpu-threads-sync

Conversation

@SankaraVenkatRam
Copy link

Summary

This PR fixes an issue where user-defined CPU thread settings (e.g. cpu_threads=2) were ignored when using the High Performance Inference (HPI) backend.

Although the value was correctly set in the legacy PaddlePredictorOption, it was never propagated to HPI, which instead used its own default (usually 10 threads). This could lead to unexpected CPU overuse, especially in containers or limited environments.


What changed

  • Synced CPU thread settings between PaddlePredictorOption and HPIConfig via a new sync_threads step in BasePredictor
  • Added support for the CPU_NUM_THREADS environment variable in:
    • OpenVINO and ONNX Runtime HPI configs
    • Default CPU thread handling in pp_option.py

Result

  • Explicit cpu_threads values are now respected by the HPI backend
  • CPU_NUM_THREADS provides a simple global override when no value is set in code
  • More predictable and resource-friendly CPU usage

Why it matters

This aligns user intent with actual runtime behavior and avoids silent over-allocation of CPU resources.

@paddle-bot
Copy link

paddle-bot bot commented Feb 4, 2026

Thanks for your contribution!

@paddle-bot paddle-bot bot added the contributor External developers label Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant