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

Add local tensor-parallel fwd/bwd #143

Merged
merged 146 commits into from
Jan 3, 2023
Merged

Add local tensor-parallel fwd/bwd #143

merged 146 commits into from
Jan 3, 2023

Conversation

justheuristic
Copy link
Collaborator

@justheuristic justheuristic commented Dec 9, 2022

This pull request adds an option to run Petals server on multiple local GPUs. It uses https://github.com/BlackSamorez/tensor_parallel

  • tensor_parallel works with forward/backward
  • tensor_parallel works with inference (use_cache=True)
  • exact match output, grad w.r.t. input, inference caches
  • works with odd numbers of GPUs
  • del block frees memory from all GPUs (for rebalancing)
  • stability tests
  • add to CI tests
  • determine num_blocks
  • measure throughput correctly

Benchmark

https://gist.github.com/justheuristic/149ccfbf903a847cbaa09dbe59965bd9

Overnight sanity checks:

  • 8bit approximation error same as in main (mean~=2% q0.9~=5%)
    • TP=1, 2, 3 (see screenshots above)
  • forward, grad w.r.t. input and inference exact match with main with TP=1
  • >=80% GPU utilization with 3x 1080ti, batch = 8 tokens
  • throughput measured with and without TP
  • TP on 1080Tis has near-linear speedup comparable to the benchmarks (see first message)

@borzunov borzunov changed the title [donotmerege] empty test [do not merge] empty test Dec 9, 2022
justheuristic and others added 15 commits December 10, 2022 21:55
Co-authored-by: Iaroslav Lisniak <48571134+IaroslavLisniak@users.noreply.github.com>
Co-authored-by: Iaroslav Lisniak <yalisnyak@nes.ru>
Co-authored-by: Andrei Panferov <andrei@blacksamorez.ru>
Co-authored-by: Andrei Panferov <andrei.panferov@eqvilent.com>
Co-authored-by: Iaroslav Lisniak <48571134+IaroslavLisniak@users.noreply.github.com>
Co-authored-by: Iaroslav Lisniak <yalisnyak@nes.ru>
Co-authored-by: Andrei Panferov <andrei@blacksamorez.ru>
Co-authored-by: Andrei Panferov <andrei.panferov@eqvilent.com>
Co-authored-by: Iaroslav Lisniak <48571134+IaroslavLisniak@users.noreply.github.com>
Co-authored-by: Iaroslav Lisniak <yalisnyak@nes.ru>
Co-authored-by: Andrei Panferov <andrei@blacksamorez.ru>
Co-authored-by: Andrei Panferov <andrei.panferov@eqvilent.com>
Co-authored-by: Iaroslav Lisniak <48571134+IaroslavLisniak@users.noreply.github.com>
Co-authored-by: Iaroslav Lisniak <yalisnyak@nes.ru>
Co-authored-by: Andrei Panferov <andrei@blacksamorez.ru>
Co-authored-by: Andrei Panferov <andrei.panferov@eqvilent.com>
Co-authored-by: Iaroslav Lisniak <48571134+IaroslavLisniak@users.noreply.github.com>
Co-authored-by: Iaroslav Lisniak <yalisnyak@nes.ru>
Co-authored-by: Andrei Panferov <andrei@blacksamorez.ru>
Co-authored-by: Andrei Panferov <andrei.panferov@eqvilent.com>
Co-authored-by: Iaroslav Lisniak <48571134+IaroslavLisniak@users.noreply.github.com>
Co-authored-by: Iaroslav Lisniak <yalisnyak@nes.ru>
Co-authored-by: Andrei Panferov <andrei@blacksamorez.ru>
Co-authored-by: Andrei Panferov <andrei.panferov@eqvilent.com>
@justheuristic justheuristic changed the title [do not merge] empty test Added tensor-parallel fwd/bwd Dec 12, 2022
@justheuristic justheuristic changed the title Added tensor-parallel fwd/bwd Added local tensor-parallel fwd/bwd Dec 12, 2022
@@ -48,44 +64,60 @@ def __init__(self, *args, memory_cache: MemoryCache, backend_dtype: torch.dtype,
self.kwargs_schema,
)

def get_inference_cache_descriptors(self, batch_size: int, max_length: int) -> Tuple[TensorDescriptor, ...]:
Copy link
Collaborator Author

@justheuristic justheuristic Jan 3, 2023

Choose a reason for hiding this comment

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

This can be more than 2 tuples if TP > 1

justheuristic and others added 2 commits January 3, 2023 17:21
Co-authored-by: Alexander Borzunov <borzunov.alexander@gmail.com>
@justheuristic justheuristic merged commit ae9e71f into main Jan 3, 2023
@justheuristic justheuristic deleted the empty branch January 3, 2023 15:35
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.

None yet

2 participants