vllm icon indicating copy to clipboard operation
vllm copied to clipboard

[Model] Jamba support

Open mzusman opened this issue 10 months ago • 3 comments

Add Jamba support to vLLM, This PR comprises two parts: the Jamba modeling file and the Mamba memory handling. Since Jamba is a hybrid model (which alternates between mamba and transformer layers), In the current PR state, we preallocate a "large" Mamba cache buffer per worker. Similarly to how KV cache is preallocated in the CacheEngine, And pass slices of this preallocated buffer into the forward pass according to the required batch size, maintaining this buffer throughout the generation pipeline by keeping track of the occupied slices with a dictionary that is duplicated throughout all of the workers (contrary to how vLLM handles this). Would appreciate your guidance on handling the Mamba cache memory and wrap up the PR

  • [x] Support for sharded Mamba layers (TP).
  • [ ] vLLM way for handling the Mamba cache memory.

PR Checklist (Click to Expand)

Thank you for your contribution to vLLM! Before submitting the pull request, please ensure the PR meets the following criteria. This helps vLLM maintain the code quality and improve the efficiency of the review process.

PR Title and Classification

Only specific types of PRs will be reviewed. The PR title is prefixed appropriately to indicate the type of change. Please use one of the following:

  • [Bugfix] for bug fixes.
  • [CI/Build] for build or continuous integration improvements.
  • [Doc] for documentation fixes and improvements.
  • [Model] for adding a new model or improving an existing model. Model name should appear in the title.
  • [Frontend] For changes on the vLLM frontend (e.g., OpenAI API server, LLM class, etc.)
  • [Kernel] for changes affecting CUDA kernels or other compute kernels.
  • [Core] for changes in the core vLLM logic (e.g., LLMEngine, AsyncLLMEngine, Scheduler, etc.)
  • [Hardware][Vendor] for hardware-specific changes. Vendor name should appear in the prefix (e.g., [Hardware][AMD]).
  • [Misc] for PRs that do not fit the above categories. Please use this sparingly.

Note: If the PR spans more than one category, please include all relevant prefixes.

Code Quality

The PR need to meet the following code quality standards:

  • We adhere to Google Python style guide and Google C++ style guide.
  • Pass all linter checks. Please use format.sh to format your code.
  • The code need to be well-documented to ensure future contributors can easily understand the code.
  • Include sufficient tests to ensure the project to stay correct and robust. This includes both unit tests and integration tests.
  • Please add documentation to docs/source/ if the PR modifies the user-facing behaviors of vLLM. It helps vLLM user understand and utilize the new features or changes.

Notes for Large Changes

Please keep the changes as concise as possible. For major architectural changes (>500 LOC excluding kernel/data/config/test), we would expect a GitHub issue (RFC) discussing the technical design and justification. Otherwise, we will tag it with rfc-required and might not go through the PR.

What to Expect for the Reviews

The goal of the vLLM team is to be a transparent reviewing machine. We would like to make the review process transparent and efficient and make sure no contributor feel confused or frustrated. However, the vLLM team is small, so we need to prioritize some PRs over others. Here is what you can expect from the review process:

  • After the PR is submitted, the PR will be assigned to a reviewer. Every reviewer will pick up the PRs based on their expertise and availability.
  • After the PR is assigned, the reviewer will provide status update every 2-3 days. If the PR is not reviewed within 7 days, please feel free to ping the reviewer or the vLLM team.
  • After the review, the reviewer will put an action-required label on the PR if there are changes required. The contributor should address the comments and ping the reviewer to re-review the PR.
  • Please respond to all comments within a reasonable time frame. If a comment isn't clear or you disagree with a suggestion, feel free to ask for clarification or discuss the suggestion.

Thank You

Finally, thank you for taking the time to read these guidelines and for your interest in contributing to vLLM. Your contributions make vLLM a great tool for everyone!

mzusman avatar Apr 16 '24 12:04 mzusman

Cool!

robertgshaw2-redhat avatar Apr 17 '24 01:04 robertgshaw2-redhat

@zhuohan123 Are you still on this PR?

WoosukKwon avatar Apr 22 '24 07:04 WoosukKwon

@WoosukKwon Yes I am. Still looking!

zhuohan123 avatar Apr 22 '24 17:04 zhuohan123

May I get an update regarding the status of this PR? It seems the author stopped working on it?

zhisbug avatar Jun 20 '24 18:06 zhisbug

May I get an update regarding the status of this PR? It seems the author stopped working on it?

We're currently still working on it, The PR works well, we're just waiting for a more suitable cache blocks manger that will be able to accommodate the Mamba cache (seqlen agnostic cache) instead of just managing it directly inside each worker. We're in direct contact with the vLLM team in that regard.

mzusman avatar Jun 20 '24 22:06 mzusman

AFAIU CI distributed-tests-2-gpus test fails regardless of this PR.

mzusman avatar Jun 30 '24 13:06 mzusman

QQ: Does this PR support parallel sampling (i.e., n > 1 in sampling params)? While I don't think it is not necessary to support parallel sampling in this PR, I'd like to know if this case was considered. Supporting parallel sampling might be a bit hard since it requires implementing copy_blocks for the Mamba cache. If this is not trivial, please leave a comment on the code.

WoosukKwon avatar Jul 01 '24 05:07 WoosukKwon

QQ: Does this PR support parallel sampling (i.e., n > 1 in sampling params)? While I don't think it is not necessary to support parallel sampling in this PR, I'd like to know if this case was considered. Supporting parallel sampling might be a bit hard since it requires implementing copy_blocks for the Mamba cache. If this is not trivial, please leave a comment on the code.

This PR does support parallel sampling, We transfer the seq_ids along with the requests_ids into the Jamba inner state mapping and copy the blocks accordingly, reference in the Jamba code

mzusman avatar Jul 01 '24 08:07 mzusman

Tests failed due to timeouts to HF Ready to be merged

mzusman avatar Jul 02 '24 22:07 mzusman