-
Notifications
You must be signed in to change notification settings - Fork 54
[Spyre-Next] Integrated custom attention backend #798
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
Draft
bohnstingl
wants to merge
16
commits into
torch-spyre:main
Choose a base branch
from
bohnstingl:origin/pytorch_paged_attn
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
c97e8db
Integrated custom attention backend
bohnstingl 89ca158
Formatting issues
bohnstingl c75872f
Changed the name of the attention operation
bohnstingl ed004e4
Changed filename
bohnstingl 7a7acd7
Implemented gather to avoid using full KV cache
bohnstingl 1257ef4
Removed .item() calls
bohnstingl 1fcf175
Cleanup and adding of example
bohnstingl abb0663
Lint
bohnstingl 95fb6e1
Added testcase for attention backend
bohnstingl 5780450
Added missing utils file
bohnstingl 2a54dfc
Merge branch 'main' of github.com:vllm-project/vllm-spyre into origin…
bohnstingl 77da1ee
Reformat
bohnstingl 474fc71
Functional update
bohnstingl 8a3ba59
Lint issues
bohnstingl c088f2e
Merge branch 'main' into pytorch_paged_attn_pr
joerunde 32aa78d
:art: linting, vllm compatibility, test integration
joerunde File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| ### TEST 1 - Disable prefix caching | ||
|
|
||
| from vllm import LLM, SamplingParams | ||
| from vllm.v1.attention.backends.registry import AttentionBackendEnum | ||
| from vllm.config import AttentionConfig | ||
|
|
||
|
|
||
| def print_outputs(outputs, engine): | ||
| print("-" * 50) | ||
| for output in outputs: | ||
| generated_text = output.outputs[0].text | ||
| print(f"Generated text: {generated_text!r}") | ||
| print("-" * 50) | ||
| for m in engine.llm_engine.get_metrics(): | ||
| if "cache" in m.name: | ||
| print(m.name, m.value) | ||
|
|
||
|
|
||
| def main(): | ||
| # Configuration | ||
| # MODEL = "ibm-granite/granite-3.0-8b-base" # Tiny model | ||
| MODEL = "ibm-granite/granite-3.3-8b-instruct" # Instruct model | ||
| # MODEL = "ibm-granite/granite-4.0-tiny-preview" # Granite 3 | ||
| # MODEL = "ibm-granite/granite-4.0-h-small" # Granite 4 | ||
| # MODEL = "ibm-granite/granite-4.0-h-tiny" # Granite 4 | ||
| # MODEL = "facebook/opt-125m" # Small model | ||
|
|
||
| # Sampling parameter for the inference process | ||
| sampling_params = SamplingParams( | ||
| max_tokens=5, # Maximum number of tokens to produce | ||
| ) | ||
|
|
||
| # Prompts to use for inference | ||
| prompts = [ | ||
| "What are IBMs main businesses?", | ||
| ] | ||
|
|
||
| engine = LLM( | ||
| model=MODEL, # Model to use for inference. | ||
| # By increasing utilization, you can provide more KV cache space. | ||
| gpu_memory_utilization=0.9, | ||
| # Flag determining whether prefix caching is enabled or disabled. | ||
| enable_prefix_caching=True, | ||
| # # Flag determining whether eager mode or torch.compile should be used. | ||
| # enforce_eager=True, | ||
| # # Datatype of the mamba cache (if any). | ||
| # mamba_ssm_cache_dtype="float32", | ||
| # # Datatype of the model. | ||
| # dtype="float32", | ||
| # # Maximum number of tokens for a prefill before being chunked | ||
| # max_num_batched_tokens=8192, | ||
| # # compliates logic with mamba | ||
| # disable_cascade_attn=True, | ||
| disable_log_stats=False, ## stats | ||
| attention_config=AttentionConfig(backend=AttentionBackendEnum.CUSTOM), | ||
| ) | ||
|
|
||
| # Generate response for prompt 0 | ||
| outputs = engine.generate(prompts[0], sampling_params) | ||
| print_outputs(outputs, engine) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably give this file a descriptive name, also this seems to fail for me with
NotImplementedError: Sliding window not supported yetas is, is this missing a configuration to disable sliding window?