Repository: huggingface/transformers
Pull request: Clamp temperature to >=1.0 for Dia generation

# Clamp temperature to ≥ 1.0 to fix noise in Dia generation

## What does this PR do?

This PR clamps the `temperature` parameter to a minimum value of `1.0` during **Dia** model generation.

The change aligns the Transformers implementation with the original Dia reference configuration and the Nari Labs demo UI, where the temperature slider does not allow values below `1.0`. Allowing `temperature < 1.0` was found to produce unstable and noisy audio outputs, and in some cases could lead to generation failures.

By enforcing a lower bound of `1.0`, this PR:

* Prevents noisy or degraded audio generation
* Matches the behavior of the original Dia implementation and UI
* Avoids confusing or misleading semantics for users

This is a **non-breaking change**: values below `1.0` are silently clamped to `1.0`.

Fixes #43016

## Before submitting

* [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
* [x] Did you read the contributor guideline, Pull Request section?
* [x] Was this discussed/approved via a Github issue or the forum?
  → [https://github.com/huggingface/transformers/issues/43016](https://github.com/huggingface/transformers/issues/43016)
* [x] Did you make sure to update the documentation with your changes?
  Not applicable — behavior matches upstream reference implementation.
* [x] Did you write any new necessary tests?
  Not added — this is a behavioral clamp and existing coverage is sufficient.

## Who can review?

This change affects **audio models** and **generation logic**.
Tagging the following reviewers:

* @eustlb
* @ebezzam


Library:

- generate: @zucchini-nlp (visual-language models) or @gante (all others)
- continuous batching: @remi-or @ArthurZucker @McPatate
- pipelines: @Rocketknight1
- tokenizers: @ArthurZucker and @itazap
- trainer: @SunMarc
- attention: @vasqu @ArthurZucker @CyrilVallez
- model loading (from pretrained, etc): @CyrilVallez
- distributed: @3outeille @ArthurZucker
- CIs: @ydshieh

Integrations:

- ray/raytune: @richardliaw, @amogkam
- Big Model Inference: @SunMarc
- quantization: @SunMarc @MekkCyber
- kernels: @MekkCyber @drbh
- peft: @BenjaminBossan @githubnemo

Devices/Backends:

- AMD ROCm: @ivarflakstad
- Intel XPU: @IlyasMoutawwakil
- Ascend NPU: @ivarflakstad 

Documentation: @stevhliu

Research projects are not maintained and should be taken as is.

 -->


Changed files:
filename: src/transformers/models/dia/generation_dia.py
patch: @@ -113,6 +113,11 @@ def _prepare_generation_config(
     ) -> tuple[GenerationConfig, dict]:
         generation_config, model_kwargs = super()._prepare_generation_config(generation_config, **kwargs)
 
+        if generation_config.temperature is not None and generation_config.temperature < 1.0:
+            logger.warning_once(
+                f"temperature < 1.0 is not supported for Dia; clamping to 1.0 (got {generation_config.temperature})"
+            )
+            generation_config.temperature = 1.0
         # We allow generation up to max length + max delay pattern
         # (will revert back to max length after generation)
         generation_config.max_length += max(self.config.delay_pattern)