Skip to content
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

[LoweringContext] Support an optimized parameter mapping for SPMD #8453

Closed
wants to merge 5 commits into from

Conversation

rpsilva-aws
Copy link
Contributor

Currently, the existing parameter mapping for the lowering context is not well suited for SPMD. In case of large models, it will cause a large synchronous bottleneck when transferring all device data to the host. This is caused by each ReplicateShardedData computation that gathers and reassembles each sharded data across multiple devices. This is by design, since it is expected to collect all parameters regardless of their allocation.

In this PR, we introduce a new mapping that does not invoke the sharded replication, but instead uses references to the device data. This is generally sufficient and preferred in most cases, where the user only wants to access the validate parameters (those that are not returned as -1 from tensor_parameter_id, as 'fake' parameters).

@rpsilva-aws rpsilva-aws marked this pull request as ready for review December 4, 2024 21:42
@rpsilva-aws
Copy link
Contributor Author

Note: Conflicts with #8418. Will handle rebase order based on merge timing.

@rpsilva-aws
Copy link
Contributor Author

@JackCaoG @tengyifei

@miladm miladm requested review from tengyifei and bhavya01 December 5, 2024 00:04
Copy link
Collaborator

@tengyifei tengyifei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

test/test_operations.py Show resolved Hide resolved
test/test_operations.py Show resolved Hide resolved
test/run_tests.sh Show resolved Hide resolved
torch_xla/csrc/init_python_bindings.cpp Show resolved Hide resolved
torch_xla/csrc/init_python_bindings.cpp Outdated Show resolved Hide resolved
torch_xla/csrc/init_python_bindings.cpp Outdated Show resolved Hide resolved
test/test_operations.py Show resolved Hide resolved
@tengyifei tengyifei added the tpuci label Dec 5, 2024
@tengyifei tengyifei self-requested a review December 5, 2024 23:14
@rpsilva-aws
Copy link
Contributor Author

Replacing with #8460 to fix the merge commit, wrong local branch.

@rpsilva-aws rpsilva-aws closed this Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants