Commit c2ec21e
[Serve] Add default autoscaling params for custom policies (#58857)
## Description
Currently, custom autoscaling policies bypass all standard autoscaling
configuration parameters - they must manually implement delay logic,
scaling factors, and bounds checking themselves. This PR adds an
`apply_autoscaling_config` decorator that enables custom autoscaling
policies to automatically benefit from Ray Serve's standard autoscaling
parameters that are embedded in the default policy (`upscale_delay_s,`
`downscale_delay_s`, `downscale_to_zero_delay_s`, `upscaling_factor`,
`downscaling_factor`, `min_replicas`, `max_replicas`).
## Related issues
Fixes #58622
## Implementation Details
- Core implementation (python/ray/serve/autoscaling_policy.py):
- Added `apply_autoscaling_config decorator`
- Refactored delay logic into `_apply_delay_logic()` helper function
- Added scaling factor logic for custom
policies`_apply_scaling_factors()` helper function
- Refactored bounds checking into` _apply_bounds()` helper function
- Updated replica_queue_length_autoscaling_policy to use
`_apply_delay_logic` function
- Tests (python/ray/serve/tests/test_autoscaling_policy.py and
python/ray/tests/unit/test_autoscaling_policy.py)
- End-to-end tests verifying delay enforcement for decorated custom
policies
- Tests for scaling factor moderation (upscaling and downscaling)
- Unit tests for checking each helper function
Added documentation for usage with example
---------
Signed-off-by: Vaishnavi Panchavati <vaishdho10@gmail.com>
Co-authored-by: harshit-anyscale <harshit@anyscale.com>1 parent 4f1ce10 commit c2ec21e
File tree
10 files changed
+1171
-511
lines changed- ci/lint
- doc/source/serve
- advanced-guides
- api
- doc_code
- python/ray/serve
- _private
- tests
- unit
10 files changed
+1171
-511
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1609 | 1609 | | |
1610 | 1610 | | |
1611 | 1611 | | |
1612 | | - | |
1613 | | - | |
1614 | | - | |
1615 | | - | |
1616 | | - | |
1617 | 1612 | | |
1618 | 1613 | | |
1619 | 1614 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
637 | 637 | | |
638 | 638 | | |
639 | 639 | | |
| 640 | + | |
| 641 | + | |
640 | 642 | | |
641 | 643 | | |
642 | 644 | | |
643 | 645 | | |
644 | 646 | | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
645 | 675 | | |
646 | 676 | | |
647 | 677 | | |
| |||
681 | 711 | | |
682 | 712 | | |
683 | 713 | | |
684 | | - | |
| 714 | + | |
| 715 | + | |
685 | 716 | | |
686 | | - | |
| 717 | + | |
687 | 718 | | |
688 | 719 | | |
689 | 720 | | |
| |||
728 | 759 | | |
729 | 760 | | |
730 | 761 | | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
731 | 775 | | |
732 | 776 | | |
733 | 777 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
| |||
Lines changed: 20 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | | - | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
31 | 36 | | |
32 | 37 | | |
33 | 38 | | |
| |||
52 | 57 | | |
53 | 58 | | |
54 | 59 | | |
55 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
56 | 63 | | |
57 | 64 | | |
58 | 65 | | |
| |||
113 | 120 | | |
114 | 121 | | |
115 | 122 | | |
116 | | - | |
| 123 | + | |
| 124 | + | |
117 | 125 | | |
118 | 126 | | |
119 | 127 | | |
| |||
305 | 313 | | |
306 | 314 | | |
307 | 315 | | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
308 | 319 | | |
309 | 320 | | |
310 | 321 | | |
| |||
815 | 826 | | |
816 | 827 | | |
817 | 828 | | |
818 | | - | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
819 | 833 | | |
820 | 834 | | |
821 | 835 | | |
| |||
837 | 851 | | |
838 | 852 | | |
839 | 853 | | |
840 | | - | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
841 | 858 | | |
842 | 859 | | |
843 | 860 | | |
| |||
974 | 991 | | |
975 | 992 | | |
976 | 993 | | |
977 | | - | |
| 994 | + | |
978 | 995 | | |
979 | 996 | | |
980 | | - | |
| 997 | + | |
981 | 998 | | |
982 | 999 | | |
983 | 1000 | | |
| |||
0 commit comments