add explicit CC parameters to DeviceKernel.compile_and_load#45
Open
hgt312 wants to merge 1 commit intoaws-neuron:mainfrom
Open
add explicit CC parameters to DeviceKernel.compile_and_load#45hgt312 wants to merge 1 commit intoaws-neuron:mainfrom
hgt312 wants to merge 1 commit intoaws-neuron:mainfrom
Conversation
…ile_and_load Support MPMD workloads and non-torch-distributed runtimes by allowing callers to pass CC parameters explicitly. When cc_enabled is set, every rank traces and compiles independently (no rank-0 broadcast or barrier). Build directories are namespaced by rank to avoid concurrent write collisions. - cc_enabled=None (default): auto-detect from torch.distributed (SPMD) - cc_enabled=True: explicit CC with per-rank compilation (MPMD) - cc_enabled=False: disable CC even in distributed settings Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
vgene
requested changes
Mar 20, 2026
Contributor
vgene
left a comment
There was a problem hiding this comment.
See the idea in the function signature. It's just an idea, open to discussion
| else: | ||
| mpmd_build_dir = build_dir | ||
|
|
||
| if distributed and cc_enabled is None: |
Contributor
There was a problem hiding this comment.
Is cc_enabled the best name here? Can be confusing since it's for controlling MPMD?
| if distributed: | ||
| # Resolve CC parameters: explicit args take priority, then torch.distributed. | ||
| if cc_enabled is None and distributed: | ||
| cc_enabled = True |
Contributor
There was a problem hiding this comment.
This assignment is quite confusing.
| use_cached_if_exists=True, | ||
| build_dir=None, | ||
| target=CompilationTarget.DEFAULT, | ||
| cc_enabled=None, |
Contributor
There was a problem hiding this comment.
One idea to make the usage more explicit:
- change the
rank_id, andworld_sizetorank_id_overrideandworld_size_override. - change
cc_enabledtoenable_cc_override? - add another
is_mpmdflag which default to False
Then, in the main logic
cc_enabled = enable_cc_override or distributed
rank_id = rank_id_override or dist.get_rank()
world_size = dist.get_world_size()
The above controls which core the NEFF is loaded to.
Whether all cores compile different NEFF or all using rank 0's NEFF is only controled by is_mpmd.
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.
Description:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.