Skip to content

[SPARK-51974][CONNECT][ML] Limit model size and per-session model cache size #50751

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 25 commits into from

Conversation

WeichenXu123
Copy link
Contributor

@WeichenXu123 WeichenXu123 commented Apr 29, 2025

What changes were proposed in this pull request?

Limit model size and per-session model cache size.

Configurations:

spark.connect.session.connectML.mlCache.memoryControl.enabled
spark.connect.session.connectML.mlCache.memoryControl.maxInMemorySize
spark.connect.session.connectML.mlCache.memoryControl.offloadingTimeout
spark.connect.session.connectML.mlCache.memoryControl.maxModelSize
spark.connect.session.connectML.mlCache.memoryControl.maxSize

Only when spark.connect.session.connectML.mlCache.memoryControl.enabled is true, the rest configures can work.

Why are the changes needed?

Motivation: This is for ML cache management, to avoid huge ML cache affecting Spark driver availability.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

UT.

Was this patch authored or co-authored using generative AI tooling?

No.

Signed-off-by: Weichen Xu <[email protected]>
Signed-off-by: Weichen Xu <[email protected]>
Signed-off-by: Weichen Xu <[email protected]>
@WeichenXu123 WeichenXu123 marked this pull request as draft April 29, 2025 09:09
Signed-off-by: Weichen Xu <[email protected]>
@WeichenXu123 WeichenXu123 changed the title [draft] Tree training early stop capped by model size Tree training early stop capped by model size May 1, 2025
@WeichenXu123 WeichenXu123 changed the title Tree training early stop capped by model size [SPARK-51974][CONNECT][ML] Limit model size and per-session model cache size May 1, 2025
@WeichenXu123 WeichenXu123 marked this pull request as ready for review May 1, 2025 14:29
@@ -61,6 +61,31 @@ private[connect] class MLCache(sessionHolder: SessionHolder) extends Logging {

private[ml] val totalSizeBytes: AtomicLong = new AtomicLong(0)

private[ml] val totalModelCacheSizeBytes: AtomicLong = new AtomicLong(0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "totalSizeBytes" above is tracking the total size in memory. Why do we need to use a different totalModelCacheSizeBytes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

totalModelCacheSizeBytes is for counting in-memory + offloaded data size
totalSizeBytes is for counting in-memory size, I will rename it to totalInMemorySizeBytes

Copy link
Contributor

@zhengruifeng zhengruifeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to reformat the error classes, otherwise LGTM

Signed-off-by: Weichen Xu <[email protected]>
Signed-off-by: Weichen Xu <[email protected]>
Signed-off-by: Weichen Xu <[email protected]>
Signed-off-by: Weichen Xu <[email protected]>
@github-actions github-actions bot added the PYTHON label May 5, 2025
@WeichenXu123
Copy link
Contributor Author

Refactored configurations: @zhengruifeng @xi-db

  • spark.connect.session.connectML.mlCache.memoryControl.enabled
  • spark.connect.session.connectML.mlCache.memoryControl.maxInMemorySize
  • spark.connect.session.connectML.mlCache.memoryControl.offloadingTimeout
  • spark.connect.session.connectML.mlCache.memoryControl.maxModelSize
  • spark.connect.session.connectML.mlCache.memoryControl.maxSize

Only when spark.connect.session.connectML.mlCache.memoryControl.enabled is true, the rest configures can work.

Signed-off-by: Weichen Xu <[email protected]>
@zhengruifeng
Copy link
Contributor

LGTM pending CI

Signed-off-by: Weichen Xu <[email protected]>
Signed-off-by: Weichen Xu <[email protected]>
Signed-off-by: Weichen Xu <[email protected]>
Signed-off-by: Weichen Xu <[email protected]>
Signed-off-by: Weichen Xu <[email protected]>
Signed-off-by: Weichen Xu <[email protected]>
Signed-off-by: Weichen Xu <[email protected]>
Signed-off-by: Weichen Xu <[email protected]>
@WeichenXu123
Copy link
Contributor Author

merged to master

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

Successfully merging this pull request may close these issues.

3 participants