Skip to content

Commit 0bbc0ef

Browse files
committed
Reject invalid ZenFlow top-k ratio endpoints
Signed-off-by: tandede <1090179959@qq.com>
1 parent 24402c3 commit 0bbc0ef

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

deepspeed/runtime/zenflow/zenflow_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
class ZenFlowConfig(DeepSpeedConfigModel):
1313
"""Configuration options for ZenFlow optimization module."""
1414

15-
topk_ratio: float = Field(0.1, ge=0.0, le=1.0)
16-
"""Ratio of top-k important gradient columns to retain (range: 0.0 to 1.0)."""
15+
topk_ratio: float = Field(0.1, gt=0.0, lt=1.0)
16+
"""Ratio of top-k important gradient columns to retain (must be greater than 0.0 and less than 1.0)."""
1717

1818
select_strategy: str = "auto"
1919
"""Strategy for selecting important gradient indices.

tests/unit/runtime/zenflow/test_zf_config.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ def test_invalid_zenflow_type_raises():
5959
DeepSpeedZeroConfig(zenflow=123)
6060

6161

62+
@pytest.mark.parametrize("topk_ratio", [0.0, 1.0])
63+
def test_topk_ratio_excludes_endpoints(topk_ratio):
64+
with pytest.raises(ValidationError):
65+
ZenFlowConfig(topk_ratio=topk_ratio)
66+
67+
6268
def test_offload_and_zenflow_combined():
6369
"""
6470
offload_optimizer and zenflow can be used together under stage 2

0 commit comments

Comments
 (0)