Port https://github.com/NovaSky-AI/SkyRL/pull/1120 to skyrl folder#1130
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors the StackedDecoderLayers to simplify how sharding metadata is handled. The new approach uses nnx.spmd.add_axis to create a treedef that includes the necessary sharding information for the stacked layers. This is a significant improvement as it removes a manual, imperative synchronization loop, making the code more robust and declarative. I have one suggestion to ensure the code is resilient against potential AttributeErrors.
|
|
||
| # Build a treedef with stacked partition metadata so tree_unflatten | ||
| # reconstructs Variables with the correct leading-layer sharding axis. | ||
| stacked_first_state = nnx.spmd.add_axis(first_state, 0, {nnx.PARTITION_NAME: None}) |
Contributor
There was a problem hiding this comment.
For consistency with nnx.spmd.add_axis and to prevent a potential AttributeError if PARTITION_NAME is not exposed at the top-level nnx module, it's safer to qualify it with the spmd submodule.
Suggested change
| stacked_first_state = nnx.spmd.add_axis(first_state, 0, {nnx.PARTITION_NAME: None}) | |
| stacked_first_state = nnx.spmd.add_axis(first_state, 0, {nnx.spmd.PARTITION_NAME: None}) |
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.
See #1120