Build a Job Module
How to build your own compute job for Lilypad
Last updated
Was this helpful?
How to build your own compute job for Lilypad
Last updated
Was this helpful?
A Lilypad module is a Git repository that allows you to perform various tasks using predefined templates and inputs. This guide will walk you through creating a Lilypad module, including defining a JSON template, handling inputs, and following best practices.
For a more in-depth look at building modules, refer to this end-to-end guide.
Below are a few examples of modules you can run on Lilypad. From language models to image generators and fun utilities, the network supports a growing list of AI modules.
To view the full list of available modules on Lilypad, please check out the awesome-lilypad repo!
Start by creating a Git repository for your Lilypad module. The module's versions will be represented as Git tags. Below is the basic structure of a Lilypad Module.
Download model files
Handle all dependencies (requirements.txt
)
Implement input/output through environment variables
Write outputs to /outputs
directory
To use a model offline, you first need to download it and store it in a local directory. This guarantees that your code can load the model without requiring an internet connection. Here's a simple process to achieve this:
Install required libraries
Use a script to download the model (eg: python download_model.py
)
Verify that the model files are in your directory
To make sure your Docker image is compatible with Lilypad, you need to define the architecture explicitly during the build process. This is particularly important if you are building the image on a system like macOS, which uses a different architecture (darwin/arm64
) than Lilypad's infrastructure (linux/amd64
).
The examples below are for building, tagging and pushing an image to DockerHub, but you can use any platform you prefer for hosting the image.
For Linux: docker buildx build -t <USERNAME>/<MODULE_NAME>:<MODULE_TAG> --push .
For MacOS:
Format in template:
Usage in CLI:
During development, you will need to use the Git hash to test your module. This allows you to verify that your module functions correctly and produces the expected results.
Below is a working Lilypad module run cmd for reference. (you can use this to run a Lilypad job within the Lilypad CLI):
Use the following command syntax to run your Module on Lilypad Testnet.
If the job run appears to be stuck after a few minutes (sometimes it takes time for the Module to download to the RP node), cancel the job and try again. Open a ticket in Discord with any issues that persist.
Here are some example Lilypad modules for reference:
Cowsay: Lilypad "Hello World" example
Llama2: Text to text
SDXL-turbo pipeline: Text to image generation
Deprecated examples:
lora-training: An example module for LoRa training tasks.
lora-inference: An example module for LoRa inference tasks.
duckdb: An example module related to DuckDB.
These examples can help you understand how to structure your Lilypad modules and follow best practices.
In this guide, we've covered the essential steps to create a Lilypad module, including defining a JSON template, handling inputs, and testing your module. By following these best practices, you can build reliable and reusable modules for Lilypad.
For more information and additional examples, refer to the official Lilypad documentation and the Cowsay example module.
Llama2
An open-source language model, used for generating and understanding text.
Stable Diffusion Turbo Pipeline
A fast, high-performance version of Stable Diffusion XL for generating high-quality images with minimal latency
Cowsay
A playful CLI tool that displays text as if spoken by an ASCII-art cow