GenerationConfig serializes ContinuousBatchingConfig as null
Author: VectorPeak
Pull request: no

### System Info

Observed on the local development checkout used for PR #47038:

```text
transformers main branch at 9d011e8375ab802f1b9ada2d488af35232f6dd3e
Python 3.12 in a local conda environment on Windows
```

Relevant local validation for the proposed fix has passed:

```text
python -m pytest tests/generation/test_configuration_utils.py::GenerationConfigSerializationTest::test_serialize_generation_continuous_batching_config -q
python -m pytest tests/generation/test_configuration_utils.py::GenerationConfigSerializationTest::test_serialize_generation_watermarking_config -q
python -m ruff format --check src/transformers/generation/configuration_utils.py tests/generation/test_configuration_utils.py
python -m ruff check src/transformers/generation/configuration_utils.py tests/generation/test_configuration_utils.py
git diff --check
```

### Who can help?

Continuous batching / generation config maintainers may be the right reviewers. I opened this issue to coordinate before moving the linked draft PR out of draft.

### Information

The problem arises when using generation config serialization / deserialization, especially `GenerationConfig.save_pretrained()` and `GenerationConfig.from_pretrained()` with `ContinuousBatchingConfig`.

### Reproduction

`GenerationConfig.to_json_string()` serializes nested dataclasses through a helper that calls `to_dict()` when available. `ContinuousBatchingConfig` is a dataclass but does not currently define `to_dict()`, so it can fall through as `None` and be written as JSON `null`.

A minimal shape of the failing case is:

```python
import json
import tempfile
from pathlib import Path

from transformers import GenerationConfig
from transformers.generation.configuration_utils import CompileConfig, ContinuousBatchingConfig

with tempfile.TemporaryDirectory() as tmpdir:
    config = GenerationConfig(
        continuous_batching_config=ContinuousBatchingConfig(
            block_size=2,
            varlen_compile_config=CompileConfig(dynamic=True),
            decode_compile_config=CompileConfig(dynamic=False),
        )
    )
    config.save_pretrained(tmpdir)

    raw = Path(tmpdir, generation_config.json).read_text(encoding=utf-8)
    data = json.loads(raw)
    loaded = GenerationConfig.from_pretrained(tmpdir)

print('contains null:', 'continuous_batching_config: null' in raw)
print('contains block_size:', block_size in data.get(continuous_batching_config, {}))
print(type(loaded.continuous_batching_config).__name__)
print(type(loaded.continuous_batching_config.varlen_compile_config).__name__)
```

Without the fix, the continuous batching config can be serialized as:

```json
continuous_batching_config: null
```

which loses parameters such as `block_size`, `default_compile_level`, and nested compile config settings after a save/load round trip.

I opened draft PR #47038 with a narrow proposed fix:

- add `ContinuousBatchingConfig.to_dict()`
- rehydrate `continuous_batching_config` dictionaries back into `ContinuousBatchingConfig`
- rehydrate nested `varlen_compile_config` / `decode_compile_config` dictionaries back into `CompileConfig`
- add a regression test for the save/load round trip

Draft PR: https://github.com/huggingface/transformers/pull/47038

AI assistance was used for diagnosis, patch drafting, validation planning, and PR text preparation. The linked PR is intentionally kept as a draft pending coordination here.

### Expected behavior

`GenerationConfig.save_pretrained()` should preserve `ContinuousBatchingConfig` as structured JSON instead of serializing it as `null`.

A subsequent `GenerationConfig.from_pretrained()` should restore:

- `continuous_batching_config` as a `ContinuousBatchingConfig`
- nested `varlen_compile_config` / `decode_compile_config` values as `CompileConfig`
- public continuous batching parameters such as `block_size` and `default_compile_level`

The proposed fix in PR #47038 produces this local behavior proof:

```text
contains null: False
contains block_size: True
ContinuousBatchingConfig
CompileConfig
False
```

The final `False` verifies that `_compile_all_devices` is not leaked through nested `CompileConfig.to_dict()` serialization.

Comments:
cc @remi-or @mcpatate for continuous batching