Skip to content

Allow passing a lamda to from_alloc to set env vars based on MonarchContext #622

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 1 commit into from

Conversation

jayasi
Copy link
Contributor

@jayasi jayasi commented Jul 22, 2025

Summary:
The from_alloc method now takes an optional Callable

At a high level:

def setup_defined_in_user_code(ctx: MonarchCtx) -> None
   """
   user code logic which sets up env vars 
   """
   ... 

allocator = MastAllocator(my_job)
alloc = allocator.allocate(spec)
proc_mesh = await ProcMesh.from_alloc(alloc, setup_defined_in_user_code)
// this will call the SetupActor behind the scenes which takes the setup_defined_in_user_code method

user_code_actor = await proc_mesh.spawn(UserCodeActor) 
....

Differential Revision: D78602523


@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 22, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78602523

@jayasi jayasi force-pushed the export-D78602523 branch from 1c19b3e to c53f28e Compare July 22, 2025 17:53
jayasi added a commit to jayasi/monarch that referenced this pull request Jul 22, 2025
…ontext (pytorch-labs#622)

Summary:

The from_alloc method now takes an optional Callable 

At a high level:
```
def setup_defined_in_user_code(ctx: MonarchCtx) -> None
   """
   user code logic which sets up env vars 
   """
   ... 

allocator = MastAllocator(my_job)
alloc = allocator.allocate(spec)
proc_mesh = await ProcMesh.from_alloc(alloc, setup_defined_in_user_code)
// this will call the SetupActor behind the scenes which takes the setup_defined_in_user_code method

user_code_actor = await proc_mesh.spawn(UserCodeActor) 
....

Differential Revision: D78602523
jayasi added a commit to jayasi/monarch that referenced this pull request Jul 22, 2025
…ontext (pytorch-labs#622)

Summary:

The from_alloc method now takes an optional Callable 

At a high level:
```
def setup_defined_in_user_code(ctx: MonarchCtx) -> None
   """
   user code logic which sets up env vars 
   """
   ... 

allocator = MastAllocator(my_job)
alloc = allocator.allocate(spec)
proc_mesh = await ProcMesh.from_alloc(alloc, setup_defined_in_user_code)
// this will call the SetupActor behind the scenes which takes the setup_defined_in_user_code method

user_code_actor = await proc_mesh.spawn(UserCodeActor) 
....

Differential Revision: D78602523
@jayasi jayasi force-pushed the export-D78602523 branch from c53f28e to 66be7b3 Compare July 22, 2025 18:39
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78602523

@jayasi jayasi force-pushed the export-D78602523 branch from 66be7b3 to a3a39aa Compare July 23, 2025 01:15
jayasi added a commit to jayasi/monarch that referenced this pull request Jul 23, 2025
…ontext (pytorch-labs#622)

Summary:

The from_alloc method now takes an optional Callable 

At a high level:
```
def setup_defined_in_user_code(ctx: MonarchCtx) -> None
   """
   user code logic which sets up env vars 
   """
   ... 

allocator = MastAllocator(my_job)
alloc = allocator.allocate(spec)
proc_mesh = await ProcMesh.from_alloc(alloc, setup_defined_in_user_code)
// this will call the SetupActor behind the scenes which takes the setup_defined_in_user_code method

user_code_actor = await proc_mesh.spawn(UserCodeActor) 
....

Differential Revision: D78602523
jayasi added a commit to jayasi/monarch that referenced this pull request Jul 23, 2025
…ontext (pytorch-labs#622)

Summary:

The from_alloc method now takes an optional Callable 

At a high level:
```
def setup_defined_in_user_code(ctx: MonarchCtx) -> None
   """
   user code logic which sets up env vars 
   """
   ... 

allocator = MastAllocator(my_job)
alloc = allocator.allocate(spec)
proc_mesh = await ProcMesh.from_alloc(alloc, setup_defined_in_user_code)
// this will call the SetupActor behind the scenes which takes the setup_defined_in_user_code method

user_code_actor = await proc_mesh.spawn(UserCodeActor) 
....

Differential Revision: D78602523
@jayasi jayasi force-pushed the export-D78602523 branch from a3a39aa to 2935b30 Compare July 23, 2025 01:15
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78602523

1 similar comment
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78602523

jayasi added a commit to jayasi/monarch that referenced this pull request Jul 23, 2025
…ontext (pytorch-labs#622)

Summary:
Pull Request resolved: pytorch-labs#622

The from_alloc method now takes an optional Callable

At a high level:
```
def setup_defined_in_user_code(ctx: MonarchCtx) -> None
   """
   user code logic which sets up env vars
   """
   ...

allocator = MastAllocator(my_job)
alloc = allocator.allocate(spec)
proc_mesh = await ProcMesh.from_alloc(alloc, setup_defined_in_user_code)
// this will call the SetupActor behind the scenes which takes the setup_defined_in_user_code method

user_code_actor = await proc_mesh.spawn(UserCodeActor)
....

Differential Revision: D78602523
@jayasi jayasi force-pushed the export-D78602523 branch from 2935b30 to 5ebafd6 Compare July 23, 2025 01:19
…ontext (pytorch-labs#622)

Summary:

The from_alloc method now takes an optional Callable 

At a high level:
```
def setup_defined_in_user_code(ctx: MonarchCtx) -> None
   """
   user code logic which sets up env vars 
   """
   ... 

allocator = MastAllocator(my_job)
alloc = allocator.allocate(spec)
proc_mesh = await ProcMesh.from_alloc(alloc, setup_defined_in_user_code)
// this will call the SetupActor behind the scenes which takes the setup_defined_in_user_code method

user_code_actor = await proc_mesh.spawn(UserCodeActor) 
....

Reviewed By: highker

Differential Revision: D78602523
@jayasi jayasi force-pushed the export-D78602523 branch from 5ebafd6 to e9985d9 Compare July 24, 2025 00:49
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78602523

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in ee55be1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Meta Open Source bot. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants