Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup CPU predict function. #11139

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

trivialfis
Copy link
Member

@trivialfis trivialfis commented Jan 2, 2025

  • Remove predict instance. It's dead code as we can't use it outside of XGBoost even with C++ include.
  • Remove unroll. No performance benefit.
  • Optimize dense QDM inference.
  • optimize data loading by directly copying data to feature vector instead of going through a workspace.

Partially address #10793

The optimization mostly focuses on dense data and the result varies between CPUs:

| Xeon(R) Gold 6128 |            DMatrix |    QuantileDMatrix |
|-------------------+--------------------+--------------------|
| Master            | 27.980122327804565 | 55.665775775909424 |
| PR                |  23.63674759864807 | 30.158272981643677 |

| Ryzen 9 7900X3D |            DMatrix |    QuantileDMatrix |
|-----------------+--------------------+--------------------|
| Master          | 24.764960527420044 | 31.460495710372925 |
| PR              | 22.532921314239502 | 21.412014961242676 |

@trivialfis
Copy link
Member Author

trivialfis commented Jan 6, 2025

@razdoburdin Could you please help take a look into the optimization?

I'm not an expert in CPU optimization. The changes in the predictor affects the Xeon much more significantly than the Ryzen. If I remove the dense optimization, it adds about 3 seconds to Ryzen, but 20 seconds to the Xeon.

Looking at some profiling results on Ryzen, the bottleneck seems to be in data loading (movss/movl). Would love to get some opinions.

@razdoburdin
Copy link
Contributor

@razdoburdin Could you please help take a look into the optimization?

I'm not an expert in CPU optimization. The changes in the predictor affects the Xeon much more significantly than the Ryzen. If I remove the dense optimization, it adds about 3 seconds to Ryzen, but 20 seconds to the Xeon.

Looking at some profiling results on Ryzen, the bottleneck seems to be in data loading (movss/movl). Would love to get some opinions.

It is hard to give the exact answer without deep investigation of the changes. My hypothesis are:

  1. Xeon benefits more from vectorization due to AVX512 support
  2. Xeon has much smaller L3 cache, that makes memory access optimizations more critical.

@trivialfis
Copy link
Member Author

@razdoburdin Thank you for sharing, could you please help review the changes in the CPU predictor when you are available?

It is hard to give the exact answer without deep investigation of the changes

Currently, the evaluation might be even more expensive than training for some datasets. Would be great if we could get some help on that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants