-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[FSDP()][9/N] Refactor ctor (continued) #87923
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
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/87923
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 Failures, 3 PendingAs of commit 5a5cd73: The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
[ghstack-poisoned]
[ghstack-poisoned]
This PR makes a second pass over the constructor. The logic has been grouped into `_init_<...>` functions based on intent (e.g. `_init_prefetching_state()` or `_init_runtime_state()`). This makes the initialization code for composable FSDP much cleaner than having to re-write the same sequences of lower-level helper calls. This PR also moves `_ExecOrderData` into its own file `_exec_order_utils.py`. [ghstack-poisoned]
This PR makes a second pass over the constructor. The logic has been grouped into `_init_<...>` functions based on intent (e.g. `_init_prefetching_state()` or `_init_runtime_state()`). This makes the initialization code for composable FSDP much cleaner than having to re-write the same sequences of lower-level helper calls. This PR also moves `_ExecOrderData` into its own file `_exec_order_utils.py`. [ghstack-poisoned]
ghstack-source-id: fa1f6c7 Pull Request resolved: pytorch#87923
This PR makes a second pass over the constructor. The logic has been grouped into `_init_<...>` functions based on intent (e.g. `_init_prefetching_state()` or `_init_runtime_state()`). This makes the initialization code for composable FSDP much cleaner than having to re-write the same sequences of lower-level helper calls. This PR also moves `_ExecOrderData` into its own file `_exec_order_utils.py`. [ghstack-poisoned]
ghstack-source-id: 1b0ac6e Pull Request resolved: pytorch#87923
| FSDP_SYNCED = "_fsdp_synced" | ||
|
|
||
| # TODO (awgu): Refactor this later | ||
| SHARDING_STRATEGY_MAP = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curious why it needs this map if the key and value are the same?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Key is public facing ShardingStrategy. Value is private/internal HandleShardingStrategy. I think we should be able to refactor later to only use the public facing ShardingStrategy. I had two separate ones to avoid the circular import issues a while ago, but now that ShardingStrategy is in its own file api.py, hopefully this should be resolved.
|
ideally we still want to run the basic FSDP benchmarks to sanity check no crash, no regression before landing the PRs as it has huge changes to the core codes |
This PR makes a second pass over the constructor. The logic has been grouped into `_init_<...>` functions based on intent (e.g. `_init_prefetching_state()` or `_init_runtime_state()`). This makes the initialization code for composable FSDP much cleaner than having to re-write the same sequences of lower-level helper calls. This PR also moves `_ExecOrderData` into its own file `_exec_order_utils.py`. Pull Request resolved: pytorch#87923 Approved by: https://github.com/mrshenli
This PR makes a second pass over the constructor. The logic has been grouped into `_init_<...>` functions based on intent (e.g. `_init_prefetching_state()` or `_init_runtime_state()`). This makes the initialization code for composable FSDP much cleaner than having to re-write the same sequences of lower-level helper calls. This PR also moves `_ExecOrderData` into its own file `_exec_order_utils.py`. Pull Request resolved: pytorch#87923 Approved by: https://github.com/mrshenli
Stack from ghstack:
unflat_param_name->fqnfor consistency #88123 [FSDP] Renameunflat_param_name->fqnfor consistency_get_buffer_names()#88122 [FSDP] Simplify_get_buffer_names()torch.no_grad()context when offloading to CPU #88121 [FSDP] Remove unneededtorch.no_grad()context when offloading to CPU_lazy_init()into_fsdp_root_pre_forward()#87941 [FSDP()][26/N] Move_lazy_init()into_fsdp_root_pre_forward()_post_forward_reshard()#87940 [FSDP()][25/N] Add_post_forward_reshard()_lazy_init()#87939 [FSDP()][24/N] Refactor_lazy_init()_reset_lazy_init()#87937 [FSDP] Simplify_reset_lazy_init()_cast_buffers()in_lazy_init()#87936 [FSDP()][22/N] Refactor_cast_buffers()in_lazy_init()_cast_buffers()#87935 [FSDP()][21/N] Refactor_buffer_name_to_orig_dtypecomputationdtypetobuffer_name_to_dtype#87934 [FSDP] Renamedtypetobuffer_name_to_dtypedevicearg from_cast_buffers()#87933 [FSDP] Removedevicearg from_cast_buffers()pre_forward_unshard()#87931 [FSDP()][18/N] Refactorpre_forward_unshard()_fsdp_root_pre_forward()#87930 [FSDP()][17/N] Refactor_fsdp_root_pre_forward()_init_streams()#87928 [FSDP()][15/N] Refactor_init_streams()This PR makes a second pass over the constructor. The logic has been grouped into
_init_<...>functions based on intent (e.g._init_prefetching_state()or_init_runtime_state()). This makes the initialization code for composable FSDP much cleaner than having to re-write the same sequences of lower-level helper calls.This PR also moves
_ExecOrderDatainto its own file_exec_order_utils.py.