transformers.generation.utils.GenerationMixin.generate() got multiple values for keyword argument 'generation_config'
Author: rectalogic
Pull request: no
Labels: name: bug

name: Generation

### System Info

- `transformers` version: 4.46.0.dev0
- Platform: macOS-14.6.1-arm64-arm-64bit
- Python version: 3.12.5
- Huggingface_hub version: 0.25.1
- Safetensors version: 0.4.5
- Accelerate version: not installed
- Accelerate config: not found
- PyTorch version (GPU?): 2.4.1 (False)
- 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?: no



### Who can help?

@Rocketknight1

### Information

- [ ] The official example scripts
- [X] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [X] My own task or dataset (give details below)

### Reproduction

Using a pipeline with the `text-to-audio` task fails:
```python
from transformers import pipeline

pipe = pipeline(task="text-to-audio")
pipe("Hello world")
```
Fails with this exception:
```
No model was supplied, defaulted to suno/bark-small and revision 1dbd7a1 (https://huggingface.co/suno/bark-small).
Using a pipeline without specifying a model name and revision in production is not recommended.
/Users/aw/Projects/rectalogic/llm-transformers/venv/lib/python3.12/site-packages/transformers/models/encodec/modeling_encodec.py:124: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
  self.register_buffer("padding_total", torch.tensor(kernel_size - stride, dtype=torch.int64), persistent=False)
Hardware accelerator e.g. GPU is available in the environment, but no `device` argument is passed to the `Pipeline` object. Model will be on CPU.
Traceback (most recent call last):
  File "/Users/aw/Projects/rectalogic/llm-transformers/a.py", line 4, in <module>
    pipe("Hello world")
  File "/Users/aw/Projects/rectalogic/llm-transformers/venv/lib/python3.12/site-packages/transformers/pipelines/text_to_audio.py", line 186, in __call__
    return super().__call__(text_inputs, **forward_params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aw/Projects/rectalogic/llm-transformers/venv/lib/python3.12/site-packages/transformers/pipelines/base.py", line 1268, in __call__
    return self.run_single(inputs, preprocess_params, forward_params, postprocess_params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aw/Projects/rectalogic/llm-transformers/venv/lib/python3.12/site-packages/transformers/pipelines/base.py", line 1275, in run_single
    model_outputs = self.forward(model_inputs, **forward_params)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aw/Projects/rectalogic/llm-transformers/venv/lib/python3.12/site-packages/transformers/pipelines/base.py", line 1175, in forward
    model_outputs = self._forward(model_inputs, **forward_params)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aw/Projects/rectalogic/llm-transformers/venv/lib/python3.12/site-packages/transformers/pipelines/text_to_audio.py", line 147, in _forward
    output = self.model.generate(**model_inputs, **forward_params)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aw/Projects/rectalogic/llm-transformers/venv/lib/python3.12/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aw/Projects/rectalogic/llm-transformers/venv/lib/python3.12/site-packages/transformers/models/bark/modeling_bark.py", line 1724, in generate
    semantic_output = self.semantic.generate(
                      ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aw/Projects/rectalogic/llm-transformers/venv/lib/python3.12/site-packages/transformers/models/bark/modeling_bark.py", line 900, in generate
    semantic_output = super().generate(
                      ^^^^^^^^^^^^^^^^^
TypeError: transformers.generation.utils.GenerationMixin.generate() got multiple values for keyword argument 'generation_config'
```

### Expected behavior

Should not raise an exception.

Comments:
Confirmed the issue here - this is quite serious! Investigating ASAP

cc @gante - I did a `git bisect` and the cause is #33480

@rectalogic this should now be fixed on `main` - please let us know if you encounter any other issues with the pipeline!

I still get the issue on a MAC.

Transformers: 4.45.2 'TypeError: transformers.generation.utils.GenerationMixin.generate() got multiple values for keyword argument 'generation_config'

I can see the updates in the utils.py regarding the config args but still getting the error. 




@dea13 does the same short script from above reproduce the issue, or did you have to do something else to trigger it?

> @dea13 does the same short script from above reproduce the issue, or did you have to do something else to trigger it?

Same short script - and I tried other ways to call the package but it always outputs the same issue.

@dea13 can you try installing from main with `pip install git+https://github.com/huggingface/transformers.git` ?

> `pip install git+https://github.com/huggingface/transformers.git` ?

Yes it worked! What would be different?

@dea13 the fix in #33824 hasn't been included in a release yet, so it's only accessible on `main`. The next release is due quite soon, at which point it will be included and you can go back to just `pip install transformers`.

Closing this issue for now, since I think it's resolved!