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

Use updated Triton stateful backend behavior for streaming states #3

Closed
alecgunny opened this issue Jun 27, 2022 · 0 comments · Fixed by #21
Closed

Use updated Triton stateful backend behavior for streaming states #3

alecgunny opened this issue Jun 27, 2022 · 0 comments · Fixed by #21
Labels
enhancement New feature or request quiver Issue with hermes.quiver

Comments

@alecgunny
Copy link
Contributor

Triton's documentation now contains a description of a state management feature which should help to improve the efficiency of the stateful models in hermes.quiver by removing the need for updating the snapshot weight in the model itself. This in turn makes it unnecessary to implement the stateful models in TensorFlow. A simple implementation of this for the snapshotter might look like:

import torch
from typing import Sequence, Tuple

class Snapshotter(torch.nn.Module):
    def __init__(self, snapshot_size: int, channels: Sequence) -> None:
        super().__init__()
        self.snapshot_size = snapshot_size
        self.channels = channels

    def forward(self, update: torch.Tensor, snapshot: torch.Tensor) -> Tuple[torch.tensor, ...]:
        snapshot = torch.cat([update, snapshot[len(update):]], axis=2)
        snapshots = torch.split(snapshot, list(self.channels))
        return tuple(snapshots) + (snapshot,)

And the model config would include a section that looks something like

sequence_batching {
  state [
    {
      input_name: "old_snapshot"
      output_name: "new_snapshot"
      data_type: TYPE_INT32
      dims: [ -1 ]
      initial_state: {
       data_type: TYPE_INT32
       dims: [ 1 ]
       zero_data: true
       name: "initial state"
      }
    }
  ]
}

With the actual state naming mechanism needing to be worked out.

This will require adding functionality to the Exporter classes to be able to mark certain inputs as states.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request quiver Issue with hermes.quiver
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant