- 
                Notifications
    
You must be signed in to change notification settings  - Fork 276
 
[GPTQ] Fix actorder resolution, add sentinel #1453
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
          
     Merged
      
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            7 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      7769942
              
                fix resolution, add sentinel
              
              
                kylesayrs a5f693d
              
                make sentinel validatable
              
              
                kylesayrs 7a2b417
              
                add sentinel test
              
              
                kylesayrs 42257cd
              
                reduce validation, update docstring
              
              
                kylesayrs 1410992
              
                Merge branch 'main' into kylesayrs/fix-default-actorder
              
              
                dsikka bc6e66c
              
                delowercase
              
              
                kylesayrs c3de27e
              
                Merge branch 'main' into kylesayrs/fix-default-actorder
              
              
                kylesayrs 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
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import inspect | ||
| 
     | 
||
| from pydantic_core import core_schema | ||
| 
     | 
||
| _registry = {} | ||
| 
     | 
||
| 
     | 
||
| class Sentinel: | ||
| """ | ||
| Unique sentinel values. Implements https://peps.python.org/pep-0661/ | ||
                
      
                  kylesayrs marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| with dummy pydantic validation | ||
| """ | ||
| 
     | 
||
| def __new__(cls, name, module_name=None): | ||
| name = str(name) | ||
| 
     | 
||
| if module_name is None: | ||
| module_name = inspect.currentframe().f_globals.get("__file__") | ||
| if module_name is None: | ||
| module_name = __name__ | ||
| 
     | 
||
| registry_key = f"{module_name}-{name}" | ||
| 
     | 
||
| sentinel = _registry.get(registry_key, None) | ||
| if sentinel is not None: | ||
| return sentinel | ||
| 
     | 
||
| sentinel = super().__new__(cls) | ||
| sentinel._name = name | ||
| sentinel._module_name = module_name | ||
| 
     | 
||
| return _registry.setdefault(registry_key, sentinel) | ||
| 
     | 
||
| def __repr__(self): | ||
| return self._name | ||
| 
     | 
||
| def __reduce__(self): | ||
| return ( | ||
| self.__class__, | ||
| ( | ||
| self._name, | ||
| self._module_name, | ||
| ), | ||
| ) | ||
| 
     | 
||
| @classmethod | ||
| def __get_pydantic_core_schema__(cls, _source_type, _handler): | ||
| return core_schema.no_info_plain_validator_function(cls.validate) | ||
| 
     | 
||
| @classmethod | ||
| def validate(cls, value: "Sentinel") -> "Sentinel": | ||
| return value | ||
  
    
      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,6 @@ | ||
| from llmcompressor.sentinel import Sentinel | ||
| 
     | 
||
| 
     | 
||
| def test_sentinel(): | ||
| assert Sentinel("MISSING") == Sentinel("MISSING") | ||
| assert Sentinel("MISSING", "module_one") != Sentinel("MISSING", "module_two") | 
  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.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.