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

Estimate adapter memory overhead in choose_num_blocks() #346

Merged
merged 6 commits into from
Jul 13, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update src/petals/server/server.py
Co-authored-by: Alexander Borzunov <borzunov.alexander@gmail.com>
  • Loading branch information
justheuristic and borzunov committed Jul 13, 2023
commit d18e2d14fba6a50f66932ed07a0f850469a0a659
10 changes: 7 additions & 3 deletions src/petals/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,13 @@ def _choose_num_blocks(self) -> int:
# Estimate of GPU memory used in rpc_backward (2 GiB for BLOOM, proportional for other models)
autograd_memory = 2 * gib * num_devices / 14336 * self.block_config.hidden_size

adapter_memory_per_block = estimate_adapter_memory_per_block(
self.block_config, self.torch_dtype, self.adapters, self.cache_dir
)
if adapters:
# Delay import of petals.utils.peft to avoid unnecessary import of bitsandbytes
from petals.utils.peft import estimate_adapter_memory_per_block

adapter_memory_per_block = estimate_adapter_memory_per_block(
self.block_config, self.torch_dtype, self.adapters, self.cache_dir
)
total_memory_per_block = block_size + adapter_memory_per_block + self._cache_bytes_per_block

num_blocks = math.floor((total_memory - autograd_memory) / total_memory_per_block)
Expand Down
Loading