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

Extend usability of calculate_offload_device_map #768

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

kylesayrs
Copy link
Collaborator

@kylesayrs kylesayrs commented Oct 2, 2024

Purpose

  • Allow calculate_offload_device_map to be used in environments with non-homogenous and/or non-sequential GPUs

Changes

  • Default to using all gpus if num_gpus is not specified
  • Add gpu_ids argument to allow users to choose which devices to use
  • Fix gpu memory calculation in non-homogenous GPU set-ups
    • Previously the calculation assumed that the first GPU's memory was the same for all gpus

Testing

  • Grepped for all uses of function and confirmed that changes are compatible
  • TODO: Test with simulated non-homogenous GPU setup

@kylesayrs kylesayrs changed the title calculate_offload_device_map default to all GPUs [WIP] Increase usability of calculate_offload_device_map Oct 2, 2024
@kylesayrs kylesayrs changed the title [WIP] Increase usability of calculate_offload_device_map [WIP] Extend usability of calculate_offload_device_map Oct 2, 2024
@vllm-project vllm-project deleted a comment from github-actions bot Oct 2, 2024
@kylesayrs kylesayrs changed the title [WIP] Extend usability of calculate_offload_device_map Extend usability of calculate_offload_device_map Oct 4, 2024
@kylesayrs kylesayrs self-assigned this Oct 17, 2024
@kylesayrs kylesayrs removed their assignment Nov 15, 2024
@kylesayrs
Copy link
Collaborator Author

kylesayrs commented Feb 4, 2025

In hindsight, I think I'd prefer to give users helper functions which they can use to compute their own device maps. For example

from llmcompressor import hessian_memory_requirements, quantization_memory_requirements, batch_memory_requirements

model_skeleton = load_model_skeleton(model_stub)
reserved_memory = (
    hessian_memory_requirements(model_skeleton) +
    quantization_memory_requirement(model_skeleton) +
    batch_memory_requirements((bs, seq_len), attention_mask=False) +
    ("whatever junk or padding the user thinks is relevant")
)
device_map = infer_auto_device_map(
    model_skeleton,
    max_memory=get_max_memory(reserved_memory, gpu_ids=[1, 2]),
    no_split_module_classes=model_skeleton._no_split_modules,
)

device_map = get_uniform_device_map(model_skeleton, reserved_memory, gpu_ids=[1, 2])

I believe that this is a preferable user experience as opposed to trying to hide too many things behind a function api which a user has to learn.

Copy link
Collaborator

@dsikka dsikka left a comment

Choose a reason for hiding this comment

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

This is somewhat difficult to review atm.

Can you summarize what each of these helper functions you're suggesting to use and how the interface is expected to change before and after?

Generally speaking, having the helper functions is nice but we should maintain a higher level api that most users can just use/does the necessary memory calculations for them, which for most people right now would not include batching memory (but we could always expand to include this)

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