phi-4-multimodal-instruct mode's forward num_logits_to_keep is None
Author: HERIUN
Pull request: no
Labels: name: bug

I tried phi-4-multimodal-instruct's [example](https://huggingface.co/microsoft/Phi-4-multimodal-instruct)

I got error on ```class Phi4MMForCausalLM's forward()``` method..
In default ```num_logits_to_keep=0``` but None and error happened. i don't know why num_logits_to_keep=None..



### System Info

- `transformers` version: 4.51.3
- Platform: Linux-6.11.0-1013-gcp-x86_64-with-glibc2.39
- Python version: 3.12.9
- Huggingface_hub version: 0.30.2
- Safetensors version: 0.5.3
- Accelerate version: 1.6.0
- Accelerate config:    not found
- DeepSpeed version: not installed
- PyTorch version (GPU?): 2.6.0+cu124 (True)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using distributed or parallel set-up in script?: <fill in>
- Using GPU in script?: <fill in>
- GPU type: NVIDIA L4


### Who can help?

@gante 

### Information

- [ ] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

```python
from huggingface_hub import snapshot_download
import requests
import torch
import os
import io
from PIL import Image
import soundfile as sf
from transformers import AutoModelForCausalLM, AutoProcessor, GenerationConfig
from urllib.request import urlopen

model_path = "microsoft/Phi-4-multimodal-instruct"

# Load model and processor
processor = AutoProcessor.from_pretrained(model_path, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
    model_path, 
    device_map="cuda",
    torch_dtype="auto", 
    trust_remote_code=True,
    # if you do not use Ampere or later GPUs, change attention to "eager"
    _attn_implementation='eager',
).cuda()

# Load generation config
generation_config = GenerationConfig.from_pretrained(model_path)

# Define prompt structure
user_prompt = '
'
assistant_prompt = '
'
prompt_suffix = '
'


#################################################### text-only ####################################################
prompt = f'{user_prompt}what is the answer for 1+1? Explain it.{prompt_suffix}{assistant_prompt}'
print(f'>>> Prompt\n{prompt}')
inputs = processor(prompt, images=None, return_tensors='pt').to('cuda:0')

generate_ids = model.generate(
    **inputs,
    max_new_tokens=1000,
    generation_config=generation_config,
)
generate_ids = generate_ids[:, inputs['input_ids'].shape[1] :]
response = processor.batch_decode(
    generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False
)[0]

print(f'>>> Response\n{response}')

```

### Expected behavior

num_logits_to_keep=0

Comments:
@HERIUN since you are loading the model remote code, that is probably issues with new transformers versions only. Custom code stored on hub is maintained by model authors and thus are not always up-to-date with the latest version

For Phi4 we already have a transformers integration, but the weights are not yet merged on the hub (https://huggingface.co/microsoft/Phi-4-multimodal-instruct/discussions/70). As a workaround until weights are updated, can you try to downgrade transformers to `4.48.2` as suggested in model card?

Oh thanks for kind explaination. i will wait hub to be merged..