fix(model): wire openai_compatible configuration across trainer, eval, and config pipeline by RohithPariki · Pull Request #262 · microsoft/SkillOpt · GitHub
Skip to content

fix(model): wire openai_compatible configuration across trainer, eval, and config pipeline - #262

Open
RohithPariki wants to merge 4 commits into
microsoft:mainfrom
RohithPariki:fix/openai-compatible-config-pipeline
Open

fix(model): wire openai_compatible configuration across trainer, eval, and config pipeline#262
RohithPariki wants to merge 4 commits into
microsoft:mainfrom
RohithPariki:fix/openai-compatible-config-pipeline

Conversation

@RohithPariki

Copy link
Copy Markdown
Contributor

Description

This PR connects the generic openai_compatible backend across the configuration, trainer, and evaluation pipelines so that models served via OpenAI-compatible endpoints (such as DeepSeek, Groq, Together AI, vLLM, Ollama, LiteLLM, or local servers) can be fully configured via YAML configs, --cfg-options, or CLI flags and properly initialized during training and evaluation runs.

Key Changes

  1. Config pipeline (skillopt/config.py): Added all 18 model.openai_compatible_* mappings to _FLATTEN_MAP so YAML configs retain general and per-role (optimizer_ / target_) settings during flattening.
  2. Backend runtime configuration (skillopt/model/openai_compatible_backend.py & skillopt/model/__init__.py): Extended configure_openai_compatible to support per-role overrides for temperature, timeout_seconds, and max_tokens across OPTIMIZER_CONFIG and TARGET_CONFIG.
  3. Trainer initialization (skillopt/engine/trainer.py): Added configure_openai_compatible(...) call during ReflACTTrainer.train() initialization so parameters configured via YAML or CLI take effect during training and episode rollouts.
  4. Standalone evaluation harness (scripts/eval_only.py): Added "openai_compatible", "qwen", and "qwen_chat" to --backend choices, added CLI flags, mapped them to structured keys in load_config, and invoked configure_openai_compatible in main().
  5. Training CLI (scripts/train.py): Added CLI arguments for openai_compatible_*, mapped them in _LEGACY_TO_STRUCTURED, and added environment variable guidance (OPENAI_COMPATIBLE_API_KEY) for secure credential passing.
  6. Unit Tests (tests/test_openai_compatible_config.py & tests/test_openai_compatible_backend.py): Added comprehensive test coverage for YAML config flattening, CLI overrides, role separation, trainer initialization, credential warnings, and eval_only script parsing.

Verification

  • Ran test suite across config and backend modules (pytest tests/test_openai_compatible_config.py tests/test_openai_compatible_backend.py tests/test_azure_openai_compat.py tests/test_minimax_backend.py tests/test_minimax_region.py tests/test_qwen_backend.py tests/test_role_backend_resolution.py tests/test_codex_config_aliases.py tests/test_retired_cli_options.py tests/test_env_section_survives_dedup.py). All 175 tests passed.

@RohithPariki
RohithPariki marked this pull request as ready for review August 29, 2026 00:21
@Yif-Yang

Copy link
Copy Markdown
Contributor

@RohithPariki

Copy link
Copy Markdown
Contributor Author

Thanks Yifan Yang (@Yif-Yang) for the detailed review! I have addressed all 4 points in commit 451f2e8:

  1. train.py --backend choices: Added "openai_compatible" to the argument choices in scripts/train.py.
  2. eval_only.py Qwen routing & model normalization: Added the qwen_chat role routing branch (optimizer_backend = "openai_chat", target_backend = "qwen_chat") and model-default normalization for qwen_chat roles to resolve the target model to Qwen/Qwen3.5-4B.
  3. eval_only.py optimizer Qwen kwargs: Updated the configure_qwen_chat(...) invocation to forward all optimizer_qwen_chat_* options.
  4. OpenAI-compatible model fallback & precedence: Added normalization in both train.py and eval_only.py so that unoverridden base gpt-5.5 sentinels fall back to --openai_compatible_model / per-role compatible models or the declared default gpt-4o-mini, while strictly preserving explicit per-role model overrides (--optimizer_model / --target_model).
  5. Regressions: Added unit tests in tests/test_openai_compatible_config.py covering train CLI backend selection, eval-only Qwen role and model resolution, optimizer Qwen kwargs forwarding, and OpenAI-compatible fallback / explicit-model precedence.

@Yif-Yang

Copy link
Copy Markdown
Contributor

Thanks for wiring the previously missing entry points. Re-reviewing d1ed2f2da738, one model-precedence gap remains after configuration parsing: the actual runtime overwrites explicit role models with the shared compatible-model fallback.

Offline reproduction, stopping the trainer immediately after model configuration (no provider request):

--backend openai_compatible
--openai_compatible_model fallback-shared
--optimizer_model explicit-optimizer
--target_model explicit-target

load_config(): optimizer_model=explicit-optimizer, target_model=explicit-target
actual OPTIMIZER_CONFIG.deployment: fallback-shared
actual TARGET_CONFIG.deployment: fallback-shared

trainer.py:779-780 applies the resolved deployments first, then configure_openai_compatible(model=...) at line 836 replaces them. Eval has the same ordering (eval_only.py:642-643, then line 700). The new precedence tests stop at load_config(), while the trainer wiring test replaces the configurator with a recorder, so neither checks the final wire configuration.

Please establish precedence once and preserve the resolved explicit per-role model through runtime setup; add trainer and eval regressions that inspect the real compatible configs or a fake client's request payload after all configuration calls.

There is also the same new order-dependent MiniMax default assertion as in #255: running tests/test_codex_optimizer_backend.py before tests/test_minimax_backend.py leaves TARGET_DEPLOYMENT="target-model" and fails the new default check. Please coordinate that overlapping test/implementation change with #255 and fix fixture isolation before merge.

@RohithPariki

RohithPariki commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

@RohithPariki
RohithPariki force-pushed the fix/openai-compatible-config-pipeline branch from d3c3b81 to 0e88e38 Compare September 6, 2026 00:51
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.

2 participants