Update modeling_phi4mm.py to avoid `TypeError: unsupported operand type(s) for *: 'int' and 'NoneType' `
Browse filesEnsure 'num_logits_to_keep' has always a valid numeric value before the slice is computed to avoid `TypeError: unsupported operand type(s) for *: 'int' and 'NoneType' `
- modeling_phi4mm.py +3 -0
    	
        modeling_phi4mm.py
    CHANGED
    
    | @@ -2143,6 +2143,9 @@ class Phi4MMForCausalLM(Phi4MMPreTrainedModel, GenerationMixin): | |
| 2143 |  | 
| 2144 | 
             
                    hidden_states = outputs[0]
         | 
| 2145 | 
             
                    # Only compute necessary logits, and do not upcast them to float if we are not computing the loss
         | 
|  | |
|  | |
|  | |
| 2146 | 
             
                    logits = self.lm_head(hidden_states[:, -num_logits_to_keep:, :])
         | 
| 2147 |  | 
| 2148 | 
             
                    loss = None
         | 
|  | |
| 2143 |  | 
| 2144 | 
             
                    hidden_states = outputs[0]
         | 
| 2145 | 
             
                    # Only compute necessary logits, and do not upcast them to float if we are not computing the loss
         | 
| 2146 | 
            +
                    if num_logits_to_keep is None:
         | 
| 2147 | 
            +
                        num_logits_to_keep = hidden_states.size(1)
         | 
| 2148 | 
            +
             | 
| 2149 | 
             
                    logits = self.lm_head(hidden_states[:, -num_logits_to_keep:, :])
         | 
| 2150 |  | 
| 2151 | 
             
                    loss = None
         | 

