Skip to content
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
merged 22 commits into from
Nov 27, 2022

Conversation

borzunov
Copy link
Collaborator

@borzunov borzunov commented Nov 26, 2022

In this PR:

  1. 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:

    Screenshot 2022-11-26 at 08 10 49
  2. 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.

  3. 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 than end_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).

  4. 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)
  5. 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

@borzunov borzunov changed the title Make inference fault-tolerant Make inference, foward, and backward more fault-tolerant Nov 26, 2022
@borzunov borzunov changed the title Make inference, foward, and backward more fault-tolerant Make inference, foward, and backward ultimately fault-tolerant Nov 26, 2022
@borzunov borzunov changed the title Make inference, foward, and backward ultimately fault-tolerant Make inference, foward, and backward fully fault-tolerant 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
Copy link
Collaborator Author

@borzunov borzunov Nov 26, 2022

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 borzunov marked this pull request as ready for review November 26, 2022 16:15
@borzunov borzunov changed the title Make inference, foward, and backward fully fault-tolerant Make inference, forward, and backward fully fault-tolerant Nov 26, 2022
Copy link
Collaborator

@justheuristic justheuristic left a 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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants