test(config): add comprehensive tests for router config utilities#3349
Open
yurekami wants to merge 1 commit intohuggingface:mainfrom
Open
test(config): add comprehensive tests for router config utilities#3349yurekami wants to merge 1 commit intohuggingface:mainfrom
yurekami wants to merge 1 commit intohuggingface:mainfrom
Conversation
Add 26 new tests to improve coverage of router/src/config.rs, which previously had only 1 test. This is a lightweight maintenance contribution aligned with TGI's maintenance mode guidelines. ## Tests Added ### Utility Function Tests - `test_gcd_basic_cases`: Basic GCD calculations - `test_gcd_edge_cases`: Edge cases (0, 1, equal numbers) - `test_get_factors_basic`: Factor finding for composite numbers - `test_get_factors_prime`: Prime number factor edge case - `test_get_factors_perfect_square`: Perfect square handling - `test_get_factors_one`: Edge case for 1 - `test_select_best_resolution_exact_match`: Exact resolution matching - `test_select_best_resolution_scaling`: Resolution scaling logic - `test_select_best_resolution_empty_returns_original`: Empty list fallback - `test_find_supported_resolutions_basic`: Resolution generation - `test_find_supported_resolutions_includes_expected`: Expected patterns - `test_get_best_fit_upscaling`: Upscaling behavior - `test_get_best_fit_upscaling_max_canvas`: Max canvas mode - `test_get_best_fit_downscaling`: Downscaling behavior ### Model Configuration Tests - `test_idefics2_constant_features`: Idefics2 constant feature count - `test_idefics3_constants`: Idefics3 configuration constants - `test_paligemma_features_from_config`: Paligemma token configuration - `test_qwen2vl_features_calculation`: Qwen2VL feature calculation - `test_qwen2_5vl_features_calculation`: Qwen2.5VL feature calculation - `test_llama4_accessors`: Llama4 config accessors - `test_llama4_aspect_ratios`: Llama4 aspect ratio calculation ### Config Enum Serialization Tests - `test_config_deserialize_simple_variants`: Simple model types - `test_config_deserialize_idefics2`: Idefics2 deserialization - `test_config_deserialize_idefics3`: Idefics3 deserialization - `test_config_deserialize_qwen2vl`: Qwen2VL with vision config - `test_config_deserialize_deepseek_variants`: DeepSeek v2/v3 These tests validate core utility functions (gcd, factors, resolution selection) and model configuration handling without modifying any production behavior. Signed-off-by: Contributor <contributor@example.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds 26 new tests to
router/src/config.rs, improving test coverage for the router's configuration handling. This is a lightweight maintenance contribution aligned with TGI's maintenance mode guidelines.Changes
Tests Added
Utility Function Tests (14 tests)
test_gcd_basic_casestest_gcd_edge_casestest_get_factors_basictest_get_factors_primetest_get_factors_perfect_squaretest_get_factors_onetest_select_best_resolution_*test_find_supported_resolutions_*test_get_best_fit_*Model Configuration Tests (7 tests)
test_idefics2_constant_featurestest_idefics3_constantstest_paligemma_features_from_configtest_qwen2vl_features_calculationtest_qwen2_5vl_features_calculationtest_llama4_accessorstest_llama4_aspect_ratiosConfig Enum Serialization Tests (5 tests)
test_config_deserialize_simple_variantstest_config_deserialize_idefics2test_config_deserialize_idefics3test_config_deserialize_qwen2vltest_config_deserialize_deepseek_variantsMotivation
The
config.rsfile contains critical utility functions for:These functions previously had minimal test coverage (only 1 test for
LlavaNext). This PR ensures correctness of these core utilities without modifying any production behavior.Test Plan
cargo test -p text-generation-router configto verify all tests pass🤖 Generated with Claude Code