- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 10.9k
[Hybrid Allocator] Support KV cache groups with different block_size #24949
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
          
     Open
      
      
            heheda12345
  wants to merge
  20
  commits into
  vllm-project:main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
heheda12345:two_dtype_kv_cache
  
      
      
   
  
    
  
  
  
 
  
      
    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.
          
          
  
     Open
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            20 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      23530a4
              
                support different block size
              
              
                heheda12345 4b3acea
              
                fix bug
              
              
                heheda12345 f03bb61
              
                fix tests
              
              
                heheda12345 f061d83
              
                revert
              
              
                heheda12345 48a70ae
              
                rename BlockHashListWithBlockSize
              
              
                heheda12345 286aeac
              
                fix comments
              
              
                heheda12345 5be0625
              
                fix comments
              
              
                heheda12345 4ad6559
              
                fix comments
              
              
                heheda12345 10df50e
              
                remove unnecessary logic
              
              
                heheda12345 aaf8bc9
              
                support block_size alignment
              
              
                heheda12345 bab0be5
              
                add test
              
              
                heheda12345 20a96f5
              
                Merge commit '17edd8a' into two_dtype_kv_cache
              
              
                heheda12345 ff3a21b
              
                ruff
              
              
                heheda12345 f988a71
              
                Merge commit 'd6953be' into two_dtype_kv_cache
              
              
                heheda12345 2ea1cca
              
                Merge branch 'main' of github.com:vllm-project/vllm into two_dtype_kv…
              
              
                heheda12345 b8d368f
              
                fix test
              
              
                heheda12345 0d4fad3
              
                remove yapf tag
              
              
                heheda12345 856cc74
              
                support block_size alignment
              
              
                heheda12345 0c20bc2
              
                reduce diff
              
              
                heheda12345 1fe5821
              
                tmp fix on dcp
              
              
                heheda12345 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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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 | 
|---|---|---|
|  | @@ -167,6 +167,10 @@ def __init__( | |
| f"num_heads ({num_heads}) is not divisible by num_kv_heads ({num_kv_heads})" | ||
| ) | ||
|  | ||
| # TODO in this PR: only for testing now. remove this hardcode later | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. self reminder: remove this | ||
| if sliding_window is None: | ||
| print("set kv_cache_dtype to fp8_e4m3 for layer", prefix) | ||
| kv_cache_dtype = "fp8_e4m3" | ||
| # The default k/v_scale is set to 1.0. This is ignored | ||
| # when kv-cache is not fp8, and should be used with | ||
| # kv-cache in fp8_e5m2. For kv-cache in fp8_e4m3, we | ||
|  | ||
      
      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.
Would you mind adding a test for the mixed dtype case?
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.
similarly could use
new_kv_cache_spec, as it is nothing speficif tonew_sliding_window_specI'd say.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.
I think there is no difference on mixed dtype & mixed head size from the view of this PR. Feel free to add tests when you are working on mixed dtype support.
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.
For models only with full attention, we can have a much simpler path because we don't need to ensure all layers have the same
page_size_bytes. I'm working on it in another PR.