feat: Run dataset and model initializers in parallel#313
Conversation
|
🎉 Welcome to the Kubeflow SDK! 🎉 Thanks for opening your first PR! We're happy to have you as part of our community 🚀 Here's what happens next:
Join the community:
Feel free to ask questions in the comments if you need any help or clarification! |
There was a problem hiding this comment.
Pull request overview
This PR refactors the ContainerBackend to run dataset and model initializers in parallel using Python's ThreadPoolExecutor, reducing total initialization time from sequential (sum of both downloads) to parallel (duration of the longest download). This is particularly beneficial for LLM fine-tuning workloads with large datasets and models.
Changes:
- Refactored
_run_initializersto useconcurrent.futures.ThreadPoolExecutorwith max_workers=2 - Updated method documentation to reflect parallel execution
- Modified logging messages to indicate queueing and parallel completion
af5276e to
be3c0a8
Compare
|
I wanted to know this issue is Open right i submitted PR but I had issue for PR Title can anyone can help me as I didn't get the format for PR Title issue |
|
/retitle feat: Run dataset and model initializers in parallel |
…ow#290) Signed-off-by: priyank <[email protected]>
bb80231 to
c05ed89
Compare
|
@astefanutti E2E Test are solved here |
Fiona-Waters
left a comment
There was a problem hiding this comment.
Thanks @priyank766 this looks good. Just a couple of suggestions.
Signed-off-by: priyank <[email protected]>
Signed-off-by: priyank <[email protected]>
|
Thanks for the feedback! Addressed both points:
|
Fiona-Waters
left a comment
There was a problem hiding this comment.
@priyank766 This looks great now. I would like to test it on my machine, will do that as soon as I can and will get back to you. Thanks
|
Sure I would love to hear your feedback and thoughts |
Fiona-Waters
left a comment
There was a problem hiding this comment.
Was able to run this successfully on my local machine using Docker. Thanks @priyank766
/lgtm
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andreyvelich The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/hold cancel |
Add docs/source/train/initializers.rst documenting the dataset and model initializer types (HuggingFaceDatasetInitializer, S3DatasetInitializer, DataCacheInitializer, HuggingFaceModelInitializer, S3ModelInitializer) that were added to the container backend in PRs kubeflow#188 and kubeflow#313. The guide covers: concept overview, per-initializer code examples, combined usage, ContainerBackendConfig options (images, timeout), log-based debugging, and backend limitations. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Add docs/source/train/initializers.rst covering dataset and model initializers for the container backend (added in kubeflow#188, parallelised in kubeflow#313). Includes per-type code examples, combined usage, ContainerBackendConfig options, and debugging via get_job_logs().
Add docs/source/train/initializers.rst covering dataset and model initializers for the container backend (added in kubeflow#188, parallelised in kubeflow#313). Includes per-type code examples, combined usage, ContainerBackendConfig options, and debugging via get_job_logs().
Add docs/source/train/initializers.rst covering dataset and model initializers for the container backend (added in kubeflow#188, parallelised in kubeflow#313). Includes per-type code examples, combined usage, ContainerBackendConfig options, and debugging via get_job_logs(). Signed-off-by: Ayush Petwal <[email protected]>
Add docs/source/train/initializers.rst covering dataset and model initializers for the container backend (added in kubeflow#188, parallelised in kubeflow#313). Includes per-type code examples, combined usage, ContainerBackendConfig options, and debugging via get_job_logs(). Signed-off-by: Ayush Petwal <[email protected]>
Add docs/source/train/initializers.rst covering dataset and model initializers for the container backend (added in kubeflow#188, parallelised in kubeflow#313). Includes per-type code examples, combined usage, ContainerBackendConfig options, and debugging via get_job_logs(). Signed-off-by: Ayush Petwal <[email protected]>
* chore(trainer): add data and model initializers guide Add docs/source/train/initializers.rst covering dataset and model initializers for the container backend (added in #188, parallelised in #313). Includes per-type code examples, combined usage, ContainerBackendConfig options, and debugging via get_job_logs(). Signed-off-by: Ayush Petwal <[email protected]> * docs(trainer): address PR review comments on initializers guide - Fix model output path from /workspace/model-weights to /workspace/model to match the MODEL_PATH constant in constants.py - Clarify DataCacheInitializer is Kubernetes-only in the backend note and annotate the Available Initializers table row accordingly - Add DataCacheInitializer usage example with required fields (storage_uri, metadata_loc, num_data_nodes) and backend constraint note Signed-off-by: 1Ayush-Petwal <[email protected]> * docs(trainer): use latest tag for initializer images in guide Signed-off-by: 1Ayush-Petwal <[email protected]> --------- Signed-off-by: Ayush Petwal <[email protected]> Signed-off-by: 1Ayush-Petwal <[email protected]>
What this PR does / why we need it:
Currently, the ContainerBackend (Docker/Podman) runs dataset and model initializers sequentially. For Large Language Model (LLM) fine-tuning or heavy data workloads, downloading both a massive dataset and a base model separately can add significant overhead to the job startup time.
This PR refactors the _run_initializers logic to use
concurrent.futures.ThreadPoolExecutor. If both a dataset and a model are configured, they are now initialized in parallel threads. This reduces the total initialization time to the duration of the longest single download, rather than the sum of both.Key technical changes:
import concurrent.futuresto the backend.Which issue(s) this PR fixes:
Fixes #290
Checklist:
uv run pytest kubeflow/trainer/backends/container/backend_test.pymake verify.Verification Results:
Ran the specific backend tests to confirm the threading logic works as expected without race conditions:
uv run pytest kubeflow/trainer/backends/container/backend_test.py # Result: 19 passed