Skip to content

Optimized onnx transform class via multithreading #539

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

Closed
wants to merge 12 commits into from

Conversation

abhishek-singh591
Copy link

ONNX Transform Optimization with Thread Pool

Refactored the ONNX transform class to use a thread pool for parallelizing tensor operations, replacing the previous iterative loop. This resulted in a notable performance boost in the FP16Clip transform and a marginal improvement in split_tensor(), which may have further optimization potential.

Performance (LLaMA 3.1 8B)

Operation Without Thread Pool With Thread Pool
FP16 Transform 51.94 sec 38.78 sec
Split Tensor 15.30 sec 13.73 sec

Thread count is hardcoded to os.cpu_count() * 4 to better handle I/O-intensive workloads. Performance may vary depending on the machine's threading capabilities, so results may not be exactly reproducible across environments.

@vbaddi
Copy link
Contributor

vbaddi commented Aug 19, 2025

@abhishek-singh591 this is good start, Can we verify a larger model. Say 70B?
Can you check on this model card: https://huggingface.co/meta-llama/Llama-3.3-70B-Instruct

@vbaddi vbaddi added the enhancement New feature or request label Aug 19, 2025
@abhishek-singh591
Copy link
Author

abhishek-singh591 commented Aug 19, 2025

@vbaddi

LLaMA 3.1 70B Performance Comparison

Without Thread Pooling

  • Execution time for f16: 419.0391 seconds
  • Execution time for Split: 194.3422 seconds

With Thread Pooling

  • Execution time for f16: 302.9838 seconds
  • Execution time for Split: 163.3579 seconds

@abhishek-singh591
Copy link
Author

@vbaddi
Updated the llama 3.1 70B results, hope this suffices for the scalability check.

@abhishek-singh591 abhishek-singh591 force-pushed the optimized_eff branch 2 times, most recently from 3acff3c to ef9f188 Compare August 23, 2025 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants