Validate positive inference and HybridEngine max output tokens (#8343)
## Description
Reject zero and negative `max_out_tokens` during initial configuration
validation. These values previously passed parsing and failed later
during generation or model conversion.
Both `DeepSpeedInferenceConfig` (including its `max_tokens` alias) and
`HybridEngineConfig` now require a positive value. HybridEngine
therefore rejects invalid values when parsing the top-level
`DeepSpeedConfig`, before constructing an inference configuration during
model conversion. The defaults remain 1024 for inference and 512 for
HybridEngine.
Regression coverage is included in the existing inference and runtime
configuration test files. Inference tests reject -1 and 0 through both
field names. HybridEngine tests construct the top-level
`DeepSpeedConfig` with HybridEngine enabled, reject -1 and 0, accept
1/512/1024, and preserve the default of 512. This covers the parsed
configuration consumed by
`DeepSpeedHybridEngine.new_inference_container`.
Fixes #8339.
## Testing
- `python -m pytest -q -m 'inference or not inference'
tests/unit/runtime/test_ds_config_model.py
tests/unit/inference/test_inference_config.py --tb=short`: **25
passed**, including the regression coverage and existing CUDA Graph
test. Executed on an NVIDIA RTX A1000 Laptop GPU (4 GiB, driver 595.84),
Python 3.12.13, PyTorch 2.13.0+cu130.
- Confirmed that the HybridEngine -1/0 rejection tests fail without the
new constraint and pass with it.
- `pre-commit run --files deepspeed/inference/config.py
deepspeed/runtime/config.py
tests/unit/inference/test_inference_config.py
tests/unit/runtime/test_ds_config_model.py`: passed.
- `python ci/tests_fetcher.py --base origin/master`: selects the full
`tests/unit/v1` scope because `deepspeed/runtime/config.py` is shared
runtime configuration.
No full HybridEngine model conversion or generation run was performed.
---------
Signed-off-by: taking-lying-flat <1615405@qq.com>
Co-authored-by: Masahiro Tanaka <81312776+tohtana@users.noreply.github.com>