Repository navigation
refactor(python): async-native fleet, and handle release semantics - #88
Open
Sunny (sunnylovestiramisu) wants to merge 1 commit into
Open
Sunny (sunnylovestiramisu) wants to merge 1 commit into
Sunny (sunnylovestiramisu) wants to merge 1 commit into
Conversation
Sunny (sunnylovestiramisu)
requested a review
from Tomer Glottmann (tomergee)
October 14, 2026 00:39
Sunny (sunnylovestiramisu)
force-pushed
the
pr2
branch
from
October 14, 2026 16:55
e8e8e65 to
34776c2
Compare
…R 2) Introduce AsyncSandboxFleet as an asyncio-native pool manager and refine handle lifecycle semantics: - Introduce AsyncSandboxFleet using pure asyncio queues, locks, and tasks for non-blocking concurrent rollout acquisition. - Support async setup(tasks=None) to pre-warm the pool from a task list. - Standardize SandboxHandle.exec() and exec_async() to return ExecResult. - Add SandboxHandle.release_async() and recycle_async(), documenting that recycling suspends the actor without resetting in-guest filesystem or memory state. - Change SandboxHandle context manager (__exit__ / __aexit__) to default to release() rather than teardown/destroy. - Export AsyncSandboxFleet in ate_env top-level module. - Add test_async_fleet.py covering concurrency, timeouts, and batch acquisition. - Resolve task images to (template, rootfs_image) for Substrate backends and pass rootfs_image to Client.create.
Sunny (sunnylovestiramisu)
force-pushed
the
pr2
branch
from
October 14, 2026 17:28
34776c2 to
8716da2
Compare
Collaborator
Author
|
Addressed the nit pick in PR #89 (review) |
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.
Summary
This PR introduces
AsyncSandboxFleet, anasyncio-native orchestrator designed for high-concurrency workloads (such as reinforcement learning rollouts with VeRL, TorchRL, and Ray), standardizes sandbox handle lifecycle semantics, and integrates rootfs image resolution for unmodified container images via Substrate's derived template mechanism (#70).Key Changes
1.
AsyncSandboxFleetAsyncSandboxFleetusingasynciotasks, semaphores, and thread pools to enable non-blocking batch acquisition and warm-pool sizing without blocking the caller's event loop.await fleet.setup(tasks=None)to run pre-flight, compute aFleetPlan, and warm actor pools concurrently across task images.warm_images()andunwarm_image()to support rolling or sliding-window allocation strategies for bounded footprint execution.AsyncSandboxFleetfromate_env.2. Handle Lifecycle & Release Semantics
SandboxHandle.exec()andexec_async()to returnExecResult.SandboxHandle.release_async()andrecycle_async(), explicitly documenting that recycling suspends the actor without resetting in-guest filesystem or memory state.SandboxHandlecontext manager (__exit__/__aexit__) to default torelease()(terminate) rather than destroying the entire fleet run.3. Task Image & Rootfs Resolution (Addressing Review Feedback)
_ensure_template_for_imageResolution: Returns(template, rootfs_image):config.image_templatesresolve to(mapped_template, None).(config.template or "default-template", image), passing the task image through asrootfs_imagewhile using the configured template as base.BackendDriverSignature Updates: Addedrootfs_image: Optional[str] = Noneparameter acrossacquire,acquire_async,warm_pool,warm_pool_async, andunwarm_poolinBackendDriver,SubstrateBackendDriver, andMockBackendDriver.Client.createPropagation: Passedrootfs_image=rootfs_imageat bothclient.createinvocations inSubstrateBackendDriver(on-demand creation in_acquire_internaland pre-warm inwarm_pool_async).(template, image): Keyed_warm_paused_poolby(template, image)tuple to prevent warm pool collisions between environments sharing a base template with distinct rootfs images, while retaining transparent string key normalization for backwards compatibility.rootfs_imageontoRawSandboxInstanceandPlanEntry, and correctly preserved the pool key uponrelease_async(..., recycle=True).Task.imagebehavior detailing lookup inimage_templatesversus propagation asrootfs_image.Review Feedback Addressed
FleetConfigwithTask(image="...")senttemplate.name == "default-template"and emptyrootfs_image, ignoring the task container image.Client.create(rootfs_image=...)introduced in Run unmodified rootfs images: guest injected as an OCI image volume, plus second-runtime layers #70 so the Substrate server derives actor templates per digest on the fly._warm_paused_poolby(template, image).Verification
Unit Tests:
test_substrate_rootfs_image_sent_to_serverintest_substrate_driver.pyverifying that:FleetConfigsendstemplate.name == "default-template"andlast_create_request.rootfs_image == image.AsyncSandboxFleetcorrectly propagatesrootfs_imageduring async acquisition.driver.warm_pool_async(..., rootfs_image=image)passesrootfs_imageand keys_warm_paused_pool[("custom-base", image)].image_templatessendrootfs_image == ""and use the mapped template.test_async_fleet.pycovering concurrency, timeouts, and batch acquisition.End to End