-
Notifications
You must be signed in to change notification settings - Fork 497
fix(infra): correct staleness capacity inflation after recovery #1345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -368,6 +368,17 @@ def __init__( | |
| weight_update_meta=self.weight_update_meta, | ||
| ) | ||
|
|
||
| # After recovery, sync the staleness manager so its capacity formula | ||
| # stays bounded despite the version jumping from 0 to recovery_version. | ||
| if self.recover_info is not None: | ||
| recovery_version = self.recover_info.last_step_info.global_step + 1 | ||
| if is_single_controller(): | ||
| sm = self.rollout._staleness_manager | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggestion: sm = self.rollout.staleness_managerAccessing |
||
| else: | ||
| sm = self.rollout.workflow_executor._staleness_manager | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This reaches through two layers of private attributes from the trainer. Consider adding a public This would keep the SPMD path consistent with the single-controller path and avoid breaking if |
||
| if sm is not None: | ||
| sm.on_version_recovered(recovery_version) | ||
|
|
||
| self._config_perf_tracer() | ||
| self._apply_initial_offload_policy() | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -766,6 +766,27 @@ def test_parametrized_version_progression(version): | |
| assert capacity == min(1000, expected_staleness_capacity) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("recovered_version", [5, 10, 50]) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Consider adding @pytest.mark.parametrize("recovered_version", [0, 5, 10, 50])Also worth adding a case where |
||
| def test_on_version_recovered(recovered_version): | ||
| """Test that on_version_recovered adjusts accepted so capacity stays bounded.""" | ||
| version_provider = MockVersionProvider(0) | ||
| manager = StalenessManager( | ||
| version_provider=version_provider, | ||
| max_concurrent_rollouts=1000, | ||
| consumer_batch_size=16, | ||
| max_staleness=2, | ||
| ) | ||
|
|
||
| # Simulate recovery: version jumps to recovered_version | ||
| version_provider.set_version(recovered_version) | ||
| manager.on_version_recovered(recovered_version) | ||
|
|
||
| # After recovery, capacity should be (max_staleness + 1) * consumer_batch_size | ||
| # regardless of the recovered version value. | ||
| capacity = manager.get_capacity() | ||
| assert capacity == (2 + 1) * 16 | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| # Run tests with pytest | ||
| pytest.main([__file__, "-v"]) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic is correct. Minor note: if
running > 0at recovery time (unlikely but theoretically possible), the resulting capacity would be(max_staleness + 1) * consumer_bs - running, which is still bounded — so this is safe. A brief assertion or comment noting thatrunningis expected to be 0 at recovery time could help future readers.