Skip to content

Add an RPC mechanism to Lightning App #13637

@tchaton

Description

@tchaton

🚀 Feature

As a user, I would like to build an app that can act as a platform. Once the app is running in the cloud, I would like my users to be able to connect to the app and execute commands (RPC) calls to launch dynamically jobs.

Ideally, I would like to be able to execute some python code on the user client side, so more complex RPC calls can be implemented.

Example

Imagine you want to build a simplified application version of Grid.ai.

Using Grid, users can log in with grid login.

Once logged in, a user can execute their PyTorch Lightning scripts in the cloud with the following command:

grid run train.py --trainer.max_epochs=uniform(10, 100)

In order to create the same functionality with an app, we need a RPC API. Let's assume it exposes a sweep command.

lightning run app simplified_grid_app.py

Once running, users of the app could run the following command.

lightning connect app_id/url/app_name
lightning sweep script.py --trainer.max_epochs=uniform(10, 100) --compute="fast-gpu"

Here are the steps behind the sweep command:

  • [user machine] Enter the sweep command
  • [user machine] Upload the local source code to s3, send a request to the App RestAPI with all information to know where the code is, etc...
  • [Rest API] Receives the request and passes the payload to the flow.
  • [Flow] Execute the associated method with the payload.

Here is an example of the Sweep Method:

def sweep(self, request):
    self.flows.append(
        HPOCodeRunner(**request)
    )

Motivation

Pitch

Alternatives

Additional context


If you enjoy Lightning, check out our other projects! ⚡

  • Metrics: Machine learning metrics for distributed, scalable PyTorch applications.

  • Lite: enables pure PyTorch users to scale their existing code on any kind of device while retaining full control over their own loops and optimization logic.

  • Flash: The fastest way to get a Lightning baseline! A collection of tasks for fast prototyping, baselining, fine-tuning, and solving problems with deep learning.

  • Bolts: Pretrained SOTA Deep Learning models, callbacks, and more for research and production with PyTorch Lightning and PyTorch.

  • Lightning Transformers: Flexible interface for high-performance research using SOTA Transformers leveraging Pytorch Lightning, Transformers, and Hydra.

cc @Borda @tchaton @justusschock @awaelchli

Metadata

Metadata

Assignees

No one assigned

    Labels

    app (removed)Generic label for Lightning App packagedesignIncludes a design discussionfeatureIs an improvement or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions