There is no transformers version that can run DeepSeek V3 generate
Author: pbelevich
Pull request: no
Labels: name: bug

### System Info

DeepSeek V3 generate uses get_max_length(removed in 4.49.0) and fp8 quantization(introduced in 4.49.0)

1. DeepSeek 671B models use: past_key_values.get_max_length:
https://huggingface.co/deepseek-ai/DeepSeek-V3/blob/main/modeling_deepseek.py#L1654
https://huggingface.co/deepseek-ai/DeepSeek-R1/blob/main/modeling_deepseek.py#L1654

It was removed in 4.49.0: https://github.com/huggingface/transformers/commit/80dbbd103c217f422de91a3265bf6d8e8bc414f7

2. DeepSeek 671B models use FP8 quantization:
https://huggingface.co/deepseek-ai/DeepSeek-V3/blob/main/config.json#L40
https://huggingface.co/deepseek-ai/DeepSeek-R1/blob/main/config.json#L40

It was introduced in 4.49.0: https://github.com/huggingface/transformers/commit/efe72fe21f4292e4f3a74344c0a065dc69480b3b

cc @ArthurZucker 

### Who can help?

< 4.49.0:
```
  File "/opt/miniconda3/lib/python3.12/site-packages/transformers/models/auto/auto_factory.py", line 559, in from_pretrained
    return model_class.from_pretrained(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/lib/python3.12/site-packages/transformers/modeling_utils.py", line 3647, in from_pretrained
    config.quantization_config = AutoHfQuantizer.merge_quantization_configs(
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/lib/python3.12/site-packages/transformers/quantizers/auto.py", line 173, in merge_quantization_configs
    quantization_config = AutoQuantizationConfig.from_dict(quantization_config)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/lib/python3.12/site-packages/transformers/quantizers/auto.py", line 97, in from_dict
    raise ValueError(
ValueError: Unknown quantization type, got fp8 - supported types are: ['awq', 'bitsandbytes_4bit', 'bitsandbytes_8bit', 'gptq', 'aqlm', 'quanto', 'eetq', 'hqq', 'compressed-tensors', 'fbgemm_fp8', 'torchao', 'bitnet']
``` 

>= 4.49.0:
```
  File "/opt/miniconda3/lib/python3.12/site-packages/transformers/generation/utils.py", line 3550, in _sample
    model_inputs = self.prepare_inputs_for_generation(input_ids, **model_kwargs)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/fsxl/belevich/.cache/huggingface/modules/transformers_modules/deepseek-ai/DeepSeek-R1/56d4cbbb4d29f4355bab4b9a39ccb717a14ad5ad/modeling_deepseek.py", line 1654, in prepare_inputs_for_generation
    max_cache_length = past_key_values.get_max_length()
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'DynamicCache' object has no attribute 'get_max_length'. Did you mean: 'get_seq_length'?
```

### 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

call model.generate()

### Expected behavior

have transformers version that can run deepseek v3 generate

Comments:
cc @gante @zucchini-nlp, maybe we can make a PR to update the custom code in the Deepseek repos?

I found a PR already open in DeepSeek repo [here](https://huggingface.co/deepseek-ai/DeepSeek-V3/discussions/88), I will ping the authors so it gets merged soon

Also interesting that it doesn't work with versions `<v4.49` because I suppose there models should have been working previously. The DeepSeek repo suggests to use `v4.46.3`, so maybe with that version it will work

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.

The model is merged in transformers as well, why not remove the `trust_remote_code=True`? 
Plus we cannot control what gets merged as said above!