Skip to content

fix: serialize ContinuousBatchingConfig properly instead of null (#47039)#47415

Closed
webtecnica wants to merge 1 commit into
huggingface:mainfrom
webtecnica:fix/47039-genconfig-serialize
Closed

fix: serialize ContinuousBatchingConfig properly instead of null (#47039)#47415
webtecnica wants to merge 1 commit into
huggingface:mainfrom
webtecnica:fix/47039-genconfig-serialize

Conversation

@webtecnica

@webtecnica webtecnica commented Jul 19, 2026

Copy link
Copy Markdown

CI

What does this PR do?

Fixes #47039ContinuousBatchingConfig was serializing as null in GenerationConfig.to_json_string() because it lacked a to_dict() method and its nested CompileConfig fields weren't being rehydrated after JSON round-trip.

Changes

src/transformers/generation/configuration_utils.py

  1. ContinuousBatchingConfig.to_dict() — New method that serializes the instance to a dict, properly calling to_dict() on nested CompileConfig fields (varlen_compile_config, decode_compile_config).

  2. ContinuousBatchingConfig.__post_init__() — Added rehydration of nested CompileConfig from dicts (handles the deserialization path after JSON round-trip).

  3. GenerationConfig.__init__() — Added rehydration of ContinuousBatchingConfig from dict when a plain dict is passed (e.g., from from_pretrained after JSON deserialization).

tests/generation/test_configuration_utils.py

  • Added test_serialize_generation_continuous_batching_config — Verifies:
    • Round-trip save/load preserves ContinuousBatchingConfig type and values
    • Nested CompileConfig fields are properly rehydrated
    • JSON output does not contain continuous_batching_config: null
    • _compile_all_devices is not leaked through CompileConfig serialization

Who can review?

@Rocketknight1 @remi-or

@github-actions

Copy link
Copy Markdown
Contributor

CI recap

Dashboard: View test results in Grafana
Latest run: 29689479036:2
Result: success | Jobs: 15 | Tests: 171,597 | Failures: 0 | Duration: 13h 54m

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GenerationConfig serializes ContinuousBatchingConfig as null

2 participants