-
Notifications
You must be signed in to change notification settings - Fork 524
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
Make inference, forward, and backward fully fault-tolerant #91
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
borzunov
force-pushed
the
fault-tolerant-inference
branch
from
November 26, 2022 02:18
ea91607
to
a58a8b9
Compare
borzunov
changed the title
Make inference fault-tolerant
Make inference, foward, and backward more fault-tolerant
Nov 26, 2022
borzunov
changed the title
Make inference, foward, and backward more fault-tolerant
Make inference, foward, and backward ultimately fault-tolerant
Nov 26, 2022
borzunov
changed the title
Make inference, foward, and backward ultimately fault-tolerant
Make inference, foward, and backward fully fault-tolerant
Nov 26, 2022
borzunov
commented
Nov 26, 2022
max_length: int, | ||
points: int = 0, | ||
): | ||
self.uid, self.rpc_info = uid, rpc_info | ||
self.num_blocks = uid.count(CHAIN_DELIMITER) + 1 | ||
# warning: this code manages async objects that are only usable inside RemoteExpertWorker's background thread; | ||
# using them in any other EventLoop may cause side-effects including, headaches, diarrhea, and loss of sleep |
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.
This important message is now sent by starting the class name from _
.
borzunov
changed the title
Make inference, foward, and backward fully fault-tolerant
Make inference, forward, and backward fully fault-tolerant
Nov 26, 2022
justheuristic
approved these changes
Nov 26, 2022
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.
Great work!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In this PR:
The inference session is made fully fault-tolerant. If a server fails (or doesn't respond within timeout), it will be replaced by one (or more) servers, and the lost attention caches will be regenerated. See the screenshot of how it works below.
Here, the 24-layer model is spread across 3 servers, then the intermediate one (holding blocks 8-14) leaves, then a new large server joins and decides to host layers 6-24 (thus closing the gap). The inference session is able to recover the span 8-14 through the new server and successfully continues inference. The results are identical to the ones without failures:
Forward and backward are made "gap-tolerant". If some servers leave and a gap arises in the swarm (i.e., some blocks are not handled by anyone), the forward and backward pass will not fail anymore. Instead, they will keep retrying until a new path through the model is available. I have checked that the activations/gradients calculated after failure recovery are equal to the ones calculated without failures.
Fixed an important bug in forward/backward. Sometimes,
make_sequence()
returns a sequence that is longer than requested (since the last server hosts blocks further thanend_index
). Before this PR, the code actually run the inputs through these extra blocks leading to incorrect results. This affected partial forward passes and partial/full backward passes (since they re-run partial forward passes in case of failures).minor: Renamed classes:
RemoteTransformerBlockInferenceSession
->_ServerInferenceSession
(since (a) it actually handles the whole span instead of a single block and (b) it is not designed to be used outside Petals internals)RemoteSequentialInferenceSession
->InferenceSession
(since the previous name is too long and hardly readable)While working on this PR, I have also discovered a bug in hivemind that leads to an error in Petals. As soon as it is fixed, we should update
requirements.txt
to point to a new hivemind version. See Fix MPFuture failing outside inference mode learning-at-home/hivemind#521