Repository navigation
add parallelism to prepacking/weight loading - #31691
Conversation
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
|
Copilot fix lint |
|
Copilot fix lint |
|
Copilot fix lint again |
|
Copilot resolve the merge conflicts in this pull request |
# Conflicts: # onnxruntime/core/framework/session_state.cc Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
Resolved in 7a47e69 — merged origin/main and fixed the conflict in |
There was a problem hiding this comment.
Pull request overview
Adds opt-in parallel weight prepacking during session initialization to reduce model-loading latency.
Changes:
- Introduces
session.prepack.enable_parallel. - Dispatches per-node prepacking through the intra-op thread pool.
- Adds MatMulNBits coverage for the option.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
onnxruntime/core/framework/session_state.cc |
Implements parallel prepacking and synchronization. |
include/onnxruntime/core/session/onnxruntime_session_options_config_keys.h |
Defines and documents the option. |
onnxruntime/test/contrib_ops/matmul_4bits_test.cc |
Adds option-based MatMulNBits tests. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: xadupre <22452781+xadupre@users.noreply.github.com>
Description
Prepacking was not fully parallelized during session initialization. Memory-mapped weights were retrieved sequentially before each kernel processed them, so data retrieval did not overlap with the expensive
PrePack()work.This PR:
OpKernel::PrePack()calls across the session intra-op thread pool;MatMulNBits;Performance
Measured with a ModelBuilder-generated Qwen3.6-27B model quantized to INT4 on an Intel Xeon Platinum 8480C.
Before:
After:
Android minimal binary size
With the outer prepack path included, the GitHub Actions Android minimal baseline on the current merge commit measured 1,594,365 bytes. Its threshold is raised from 1,590,272 to 1,595,392 bytes, retaining approximately 1 KiB of headroom. The independent Azure
MinimalBaselinethreshold remains unchanged at 1,306,224 bytes pending an Azure-specific artifact measurement.Validation
onnxruntime_test_all.SessionStateTestSharedInitalizersWithPrePacking.ParallelPrepackConvertsExceptionsToStatus.