feat(inference): 引入串行/行并行/树并行推理后端并按后端拆分 CI#12
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c3a6008de6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let chunk_count = usize::min(rayon::current_num_threads(), trees.len()); | ||
| let chunk_ranges = tree_chunk_ranges(trees.len(), chunk_count); |
There was a problem hiding this comment.
Decouple tree chunking from Rayon thread count
predict_dense_scalar_tree_parallel derives chunk_count from rayon::current_num_threads(), so the chunk boundaries (and therefore floating-point summation order) change when the pool size changes, e.g. different RAYON_NUM_THREADS values or custom pool sizes across environments. Because IEEE-754 addition is non-associative, the same model/input can produce different predictions across deployments, which conflicts with the deterministic backend goal and can flip multi:softmax decisions near ties. Use a chunking strategy that is stable for a given model (or make the thread-count dependency explicit and tested) to keep outputs reproducible.
Useful? React with 👍 / 👎.
Summary
infer-serial(默认)infer-row-parallelinfer-tree-parallelXgbModel::predict_dense公共 API 保持不变。--all-features改为按后端矩阵分别执行 clippy/test,并同步更新 README、CONTRIBUTING、PR 模板和 CHANGELOG。Motivation
面向低延迟/微批推理场景,需要在吞吐与稳定性之间提供可控选择。
通过编译期特性切换后端,可避免运行时策略分支开销,并确保部署形态可预测。
Validation
cargo fmt --allcargo clippy --all-targets -- -D warningscargo test --all-targetscargo clippy --all-targets --no-default-features --features infer-row-parallel -- -D warningscargo test --all-targets --no-default-features --features infer-row-parallelcargo clippy --all-targets --no-default-features --features infer-tree-parallel -- -D warningscargo test --all-targets --no-default-features --features infer-tree-parallelNotes
predict_dense对外接口未变,更改集中在内部后端实现与构建特性。--all-features。