-
Notifications
You must be signed in to change notification settings - Fork 516
Lightening studio orchestrator #2931
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
Merged
Merged
Changes from all commits
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
d28ad6e
add lightening studio orchestrator
safoinme 263eca7
update
safoinme 9eb0834
fix installing write zenml branch
safoinme 6d2d75e
update the orchestrator
safoinme ccb7dde
fix pip install
safoinme 086addc
fix req
safoinme c7f459e
update mypy
safoinme 1d293c4
fix machine usage
safoinme 7d79c3d
update setting
safoinme 23a7274
update setting
safoinme b9da88a
fix deploy
safoinme a341c12
fix get settings
safoinme 55e47f2
add uv
safoinme 1e0fa17
add async
safoinme 6db55d6
updated code
safoinme ab2d295
update env setting
safoinme eb576bd
remove breakpoints
safoinme 7f1a1ef
fixes
safoinme 4143ead
run using a job
safoinme 0662fb3
update
safoinme 6f165bf
fix skypilot change
safoinme 0d32f0c
Auto-update of NLP template
actions-user 48f5dee
Merge branch 'develop' into feature/lightening-studio-orchestrator
safoinme 41bdf70
update lightning
safoinme 5b94454
Auto-update of Starter template
actions-user 4611b17
update code
safoinme 711184a
Merge branch 'feature/lightening-studio-orchestrator' of https://gith…
safoinme c84aae5
update lighning orchestrator
safoinme 50e62e4
remove old wheel code
safoinme e658018
cleanup imports
safoinme 0787ee5
fix async mode
safoinme f42c2a2
update async mode
safoinme feed527
update lightning
safoinme cf49329
format
safoinme b7ebd97
chore: Upload code to main studio in lightning orchestrator entrypoint
safoinme 40d3d39
chore: Update lightning orchestrator entrypoint to upload code to mai…
safoinme 73a407f
update ligning
safoinme a2fa55d
update docs
safoinme 65f4e8b
update async
safoinme fd99ec6
fix provisoning
safoinme 03a42fc
add a cat logs for async
safoinme 6b58e91
ready lightning studio
safoinme ecca17d
Merge branch 'develop' into feature/lightening-studio-orchestrator
safoinme 2654946
update based on reviews
safoinme c46e11d
Merge branch 'feature/lightening-studio-orchestrator' of https://gith…
safoinme d314973
update docs and toc and init
safoinme 805f06a
spell check
safoinme 1dc4889
Merge branch 'develop' into feature/lightening-studio-orchestrator
safoinme 359e112
add screenshots
safoinme 9467b5f
Merge branch 'feature/lightening-studio-orchestrator' of https://gith…
safoinme 6da6a9e
Optimised images with calibre/image-actions
github-actions[bot] 0801f9d
Merge branch 'develop' into feature/lightening-studio-orchestrator
schustmi 1cb7877
Refactor code utils
schustmi 69b41d0
Linting
schustmi 39b627c
More linting
schustmi 64c19b4
Merge branch 'develop' into feature/lightening-studio-orchestrator
schustmi 0644044
Add mocked lib for api docs
schustmi b496e48
Some small fixes
schustmi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,205 @@ | ||
|
||
--- | ||
description: Orchestrating your pipelines to run on Lightning AI. | ||
--- | ||
|
||
|
||
# Lightning AI Orchestrator | ||
|
||
[Lightning AI Studio](https://lightning.ai/) is a platform that simplifies the development and deployment of AI applications. The Lightning AI orchestrator is an integration provided by ZenML that allows you to run your pipelines on Lightning AI's infrastructure, leveraging its scalable compute resources and managed environment. | ||
|
||
|
||
{% hint style="warning" %} | ||
This component is only meant to be used within the context of a [remote ZenML deployment scenario](../../getting-started/deploying-zenml/README.md). Usage with a local ZenML deployment may lead to unexpected behavior! | ||
{% endhint %} | ||
|
||
|
||
## When to use it | ||
|
||
* You are looking for a fast and easy way to run your pipelines on GPU instances. | ||
|
||
* you're already using Lightning AI for your machine learning projects. | ||
|
||
* you want to leverage Lightning AI's managed infrastructure for running your pipelines. | ||
|
||
* you're looking for a solution that simplifies the deployment and scaling of your ML workflows. | ||
|
||
* you want to take advantage of Lightning AI's optimizations for machine learning workloads. | ||
|
||
|
||
## How to deploy it | ||
|
||
To use the [Lightning AI Studio](https://lightning.ai/) orchestrator, you need to have a Lightning AI account and the necessary credentials. You don't need to deploy any additional infrastructure, as the orchestrator will use Lightning AI's managed resources. | ||
|
||
|
||
## How it works | ||
|
||
The Lightning AI orchestrator is a ZenML orchestrator that runs your pipelines on Lightning AI's infrastructure. When you run a pipeline with the Lightning AI orchestrator, ZenML will archive your current ZenML repository and upload it to the Lightning AI studio. Once the code is archived, using `lightning-sdk`, ZenML will create a new stduio in Lightning AI and upload the code to it. Then ZenML runs list of commands via `studio.run()` to prepare for the pipeline run (e.g. installing dependencies, setting up the environment). Finally, ZenML will run the pipeline on Lightning AI's infrastructure. | ||
|
||
* You can always use an already existing studio by specifying the `main_studio_name` in the `LightningOrchestratorSettings`. | ||
* The orchestartor supports a async mode, which means that the pipeline will be run in the background and you can check the status of the run in the ZenML Dashboard or the Lightning AI Studio. | ||
* You can specify a list of custom commands that will be executed before running the pipeline. This can be useful for installing dependencies or setting up the environment. | ||
* The orchestrator supports both CPU and GPU machine types. You can specify the machine type in the `LightningOrchestratorSettings`. | ||
|
||
## How to use it | ||
|
||
To use the Lightning AI orchestrator, you need: | ||
|
||
* The ZenML `lightning` integration installed. If you haven't done so, run | ||
|
||
```shell | ||
pip install lightning-sdk | ||
``` | ||
|
||
* A [remote artifact store](../artifact-stores/artifact-stores.md) as part of your stack. | ||
|
||
|
||
* [Lightning AI credentials](#lightning-ai-credentials) | ||
|
||
|
||
### Lightning AI credentials | ||
|
||
* `LIGHTNING_USER_ID`: Your Lightning AI user ID | ||
|
||
* `LIGHTNING_API_KEY`: Your Lightning AI API key | ||
|
||
* `LIGHTNING_USERNAME`: Your Lightning AI username (optional) | ||
|
||
* `LIGHTNING_TEAMSPACE`: Your Lightning AI teamspace (optional) | ||
|
||
* `LIGHTNING_ORG`: Your Lightning AI organization (optional) | ||
|
||
|
||
Alternatively, you can configure these credentials when registering the orchestrator. | ||
|
||
|
||
We can then register the orchestrator and use it in our active stack: | ||
|
||
```shell | ||
zenml orchestrator register lightning_orchestrator \ | ||
--flavor=lightning \ | ||
--user_id=<YOUR_LIGHTNING_USER_ID> \ | ||
--api_key=<YOUR_LIGHTNING_API_KEY> \ | ||
--username=<YOUR_LIGHTNING_USERNAME> \ | ||
--teamspace=<YOUR_LIGHTNING_TEAMSPACE> \ | ||
--organization=<YOUR_LIGHTNING_ORGANIZATION> | ||
|
||
# Register and activate a stack with the new orchestrator | ||
zenml stack register lightning_stack -o lightning_orchestrator ... --set | ||
``` | ||
|
||
You can also configure the orchestrator at pipeline level, using the `orchestrator` parameter. | ||
|
||
|
||
```python | ||
from zenml.integrations.lightning.flavors.lightning_orchestrator_flavor import LightningOrchestratorSettings | ||
|
||
|
||
lightning_settings = LightningOrchestratorSettings( | ||
main_studio_name="my_studio", | ||
machine_type="cpu", | ||
async_mode=True, | ||
custom_commands=["pip install -r requirements.txt", "do something else"] | ||
) | ||
|
||
@pipeline( | ||
settings={ | ||
"orchestrator.lightning": lightning_settings | ||
} | ||
) | ||
def my_pipeline(): | ||
... | ||
``` | ||
|
||
|
||
{% hint style="info" %} | ||
ZenML will archive the current zenml repository (The code within the path where you run `zenml init`) and upload it to the Lightning AI studio. | ||
For this reason you need make sure that you are running `zenml init` in the same directory where you are running your pipeline. | ||
{% endhint %} | ||
|
||
 | ||
|
||
{% hint style="info" %} | ||
The `custom_commands` attribute allows you to specify a list of shell commands that will be executed before running the pipeline. This can be useful for installing dependencies or setting up the environment, The commands will be executed in the root directory of the uploaded and extracted ZenML repository. | ||
{% endhint %} | ||
|
||
|
||
You can now run any ZenML pipeline using the Lightning AI orchestrator: | ||
|
||
```shell | ||
python file_that_runs_a_zenml_pipeline.py | ||
``` | ||
|
||
|
||
### Lightning AI UI | ||
|
||
Lightning AI provides its own UI where you can monitor and manage your running applications, including the pipelines orchestrated by ZenML. | ||
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. screenshots? |
||
 | ||
|
||
|
||
For any runs executed on Lightning AI, you can get the URL to the Lightning AI UI in Python using the following code snippet: | ||
|
||
```python | ||
from zenml.client import Client | ||
|
||
pipeline_run = Client().get_pipeline_run("<PIPELINE_RUN_NAME>") | ||
orchestrator_url = pipeline_run.run_metadata["orchestrator_url"].value | ||
``` | ||
|
||
safoinme marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Additional configuration | ||
|
||
For additional configuration of the Lightning AI orchestrator, you can pass `LightningOrchestratorSettings` which allows you to configure various aspects of the Lightning AI execution environment: | ||
|
||
```python | ||
from zenml.integrations.lightning.flavors.lightning_orchestrator_flavor import LightningOrchestratorSettings | ||
|
||
lightning_settings = LightningOrchestratorSettings( | ||
main_studio_name="my_studio", | ||
machine_type="cpu", | ||
async_mode=True, | ||
custom_commands=["pip install -r requirements.txt", "do something else"] | ||
) | ||
``` | ||
|
||
|
||
|
||
|
||
These settings can then be specified on either pipeline-level or step-level: | ||
|
||
```python | ||
# Either specify on pipeline-level | ||
@pipeline( | ||
settings={ | ||
"orchestrator.lightning": lightning_settings | ||
} | ||
) | ||
def my_pipeline(): | ||
... | ||
|
||
# OR specify settings on step-level | ||
@step( | ||
settings={ | ||
"orchestrator.lightning": lightning_settings | ||
} | ||
) | ||
def my_step(): | ||
... | ||
``` | ||
|
||
Check out the [SDK docs](https://sdkdocs.zenml.io/latest/integration_code_docs/integrations-lightning/#zenml.integrations.lightning.flavors.lightning_orchestrator_flavor.LightningOrchestratorSettings) for a full list of available attributes and [this docs page](../../how-to/use-configuration-files/runtime-configuration.md) for more information on how to specify settings. | ||
|
||
|
||
To use GPUs with the Lightning AI orchestrator, you need to specify a GPU-enabled machine type in your settings: | ||
|
||
```python | ||
lightning_settings = LightningOrchestratorSettings( | ||
machine_type="gpu", # or | ||
) | ||
``` | ||
|
||
|
||
Make sure to check Lightning AI's documentation for the available GPU-enabled machine types and their specifications. | ||
|
||
|
||
<figure><img src="https://static.scarf.sh/a.png?x-pxid=f0b4f458-0a54-4fcd-aa95-d5ee424815bc" alt="ZenML Scarf"><figcaption></figcaption></figure> |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,3 +73,4 @@ | |
VERTEX = "vertex" | ||
XGBOOST = "xgboost" | ||
VAULT = "vault" | ||
LIGHTNING = "lightning" |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Copyright (c) ZenML GmbH 2024. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at: | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
# or implied. See the License for the specific language governing | ||
# permissions and limitations under the License. | ||
"""Initialization of the Lightning integration for ZenML.""" | ||
|
||
from typing import List, Type | ||
|
||
from zenml.integrations.constants import ( | ||
LIGHTNING, | ||
) | ||
from zenml.integrations.integration import Integration | ||
from zenml.stack import Flavor | ||
|
||
LIGHTNING_ORCHESTRATOR_FLAVOR = "lightning" | ||
|
||
|
||
class LightningIntegration(Integration): | ||
"""Definition of Lightning Integration for ZenML.""" | ||
|
||
NAME = LIGHTNING | ||
REQUIREMENTS = ["lightning-sdk"] | ||
|
||
@classmethod | ||
def flavors(cls) -> List[Type[Flavor]]: | ||
"""Declare the stack component flavors for the Lightning integration. | ||
|
||
Returns: | ||
List of stack component flavors for this integration. | ||
""" | ||
from zenml.integrations.lightning.flavors import ( | ||
LightningOrchestratorFlavor, | ||
) | ||
|
||
return [ | ||
LightningOrchestratorFlavor, | ||
] | ||
|
||
LightningIntegration.check_installation() |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright (c) ZenML GmbH 2024. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at: | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
# or implied. See the License for the specific language governing | ||
# permissions and limitations under the License. | ||
"""Lightning integration flavors.""" | ||
|
||
from zenml.integrations.lightning.flavors.lightning_orchestrator_flavor import ( | ||
LightningOrchestratorConfig, | ||
LightningOrchestratorFlavor, | ||
) | ||
__all__ = [ | ||
"LightningOrchestratorFlavor", | ||
"LightningOrchestratorConfig", | ||
] |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.