[BUG] Runtime configuration validation is bypassed under python -O
Bug: Runtime configuration validation is bypassed under python -O
deepspeed/runtime/config.py uses Python assert statements for several runtime configuration validation checks.
When Python is executed with optimization enabled (python -O), assertion statements are removed. As a result, invalid DeepSpeed configurations can bypass validation.
Minimal reproduction
python -O -c 'from deepspeed.runtime.config import DeepSpeedConfig; DeepSpeedConfig({"train_batch_size": 0})'With normal Python execution, the invalid configuration triggers the existing validation error. With python -O, the assertion is removed and the invalid configuration can be accepted.
The same issue affects other validation paths in DeepSpeedConfig, including:
- invalid batch-size values
- inconsistent batch-size arithmetic
- simultaneously enabling fp16 and bf16
- missing batch-size configuration
- invalid ZeRO stages
- invalid fp16/bf16 ZeRO-related configuration
Proposed fix
Replace the affected runtime assert statements with explicit condition checks and exceptions so that configuration validation is enforced regardless of Python optimization mode.
The existing validation conditions and error messages should be preserved where practical.
Regression tests should verify the affected validation paths and ensure they remain active when running with python -O.
Related work
Related configuration-validation discussions/issues include #3982, #7852, and #8260, as well as PR #8336. These address different validation problems but provide related context for explicit configuration validation.
I did not find an existing issue describing this specific python -O assertion-removal problem.
Source: deepspeedai/DeepSpeed