Skip to content

Conversation

@yurekami
Copy link

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

  • +296 lines of tests added
  • 0 changes to production code
  • Increases config.rs test count from 1 to 27

Tests Added

Utility Function Tests (14 tests)

Test Description
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_* Resolution selection logic (3 tests)
test_find_supported_resolutions_* Resolution generation (2 tests)
test_get_best_fit_* Best fit calculation (3 tests)

Model Configuration Tests (7 tests)

Test Description
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 (5 tests)

Test Description
test_config_deserialize_simple_variants Simple model types (Mistral, Llama, Gemma2)
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

Motivation

The config.rs file contains critical utility functions for:

  • Image resolution selection and scaling
  • Vision model feature calculation
  • Model configuration deserialization

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

  • Run cargo test -p text-generation-router config to verify all tests pass
  • Verify no production code changes

🤖 Generated with Claude Code

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 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant