Skip to content

small tensor parallelism optimization #796

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Alex-GZ
Copy link

@Alex-GZ Alex-GZ commented Jun 14, 2025

Just two small changes in tensor parallelism:

  • Removed an unnecessary (in my opinion) cross gpu barrier in tp_broadcast, so the GPU that had finished the transfer earlier can start its work sooner. Maybe instead, there should be a synchronization done before the CPU->GPU transfer, in the 'src_dev>=0' branch.
  • Rewrote the barrier to make it cost 2n-2 event wait calls instead of n(n-1), while preserving its function.

This PR had improved generation T/s in my setup by about 20% in the zone of CUDA API queueing bottleneck (at <20k context, 123B 4.5bpw model, 6 mostly different GPU, CPU with rather slow single-threaded performance and Linux) The impact may be a bit higher on Windows, probably.

@Ph0rk0z
Copy link

Ph0rk0z commented Jun 21, 2025

Tested it, and appears to work. Splitting 123b over 4x3090 I go from high 16/17t/s to 19.x t/s. Went back and forth a few times. Almost as good as splitting over 3 only. Should try that next and see if I get a speedup too.

@Ph0rk0z
Copy link

Ph0rk0z commented Jun 21, 2025

Some more tests. 4gpu, there is gain, 3 gpu there is about a .5t/s drop.

Can you check on your setup for odd/even gpu? Maybe there is a way to use both ways depending on device count.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants