[SPARK-58360][ML][CONNECT] Avoid nested parent overcount in RFormulaModel size estimate - #57552
Closed
zhengruifeng wants to merge 7 commits into
Closed
[SPARK-58360][ML][CONNECT] Avoid nested parent overcount in RFormulaModel size estimate#57552zhengruifeng wants to merge 7 commits into
zhengruifeng wants to merge 7 commits into
Conversation
zhengruifeng
marked this pull request as ready for review
July 27, 2026 07:47
uros-b
reviewed
Jul 27, 2026
| assert( | ||
| model.estimatedSize < maxSize, | ||
| s"Estimation (${model.estimatedSize}) should be less than $maxSize") | ||
| } |
Member
There was a problem hiding this comment.
The new test asserts only an upper bound (estimatedSize < 16KiB). It genuinely fails without the fix (the default walk blows past 16KiB via SparkSession), so it is a real regression guard, but a buggy implementation returning 0 or a too-small value would also pass. Please add a lower bound to match that standard from predecessor PRs.
uros-b
approved these changes
Jul 27, 2026
uros-b
left a comment
Member
There was a problem hiding this comment.
Thank you @zhengruifeng, LGTM after addressing!
zhengruifeng
added a commit
that referenced
this pull request
Jul 28, 2026
…odel size estimate ### What changes were proposed in this pull request? This PR adds a specialized `RFormulaModel.estimatedSize` implementation. It counts the model metadata, the resolved formula, and the nested `PipelineModel` through its parent-safe estimate. ### Why are the changes needed? The default model-size estimate clears only the outer model parent. `RFormulaModel` retains its nested pipeline, whose stages can otherwise retain estimator-parent graphs and overcount Spark session or context state in ML Connect cache accounting. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Added `RFormulaSuite` coverage that fits a categorical R formula and verifies that the fitted model estimate stays below the expected upper bound. Also ran `git diff --check`, ASCII, and source-line-length checks. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Codex (GPT-5) Closes #57552 from zhengruifeng/rformula-size-estimate-dev3. Authored-by: Ruifeng Zheng <ruifengz@apache.org> Signed-off-by: Ruifeng Zheng <ruifengz@apache.org> (cherry picked from commit 6f12573) Signed-off-by: Ruifeng Zheng <ruifengz@apache.org>
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
This PR adds a specialized
RFormulaModel.estimatedSizeimplementation. It counts the model metadata, the resolved formula, and the nestedPipelineModelthrough its parent-safe estimate.Why are the changes needed?
The default model-size estimate clears only the outer model parent.
RFormulaModelretains its nested pipeline, whose stages can otherwise retain estimator-parent graphs and overcount Spark session or context state in ML Connect cache accounting.Does this PR introduce any user-facing change?
No.
How was this patch tested?
Added
RFormulaSuitecoverage that fits a categorical R formula and verifies that the fitted model estimate stays below the expected upper bound.Also ran
git diff --check, ASCII, and source-line-length checks.Was this patch authored or co-authored using generative AI tooling?
Generated-by: Codex (GPT-5)