Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
jsun-m committed Oct 30, 2024
2 parents b292ced + f5ea4c9 commit b7d7b0c
Show file tree
Hide file tree
Showing 44 changed files with 868 additions and 247 deletions.
35 changes: 30 additions & 5 deletions .github/workflows/release-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,29 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['py38', 'py39', 'py310', 'py311', 'py312']
include:
# Python versions
- version: '3.8'
target: 'py38'
- version: '3.9'
target: 'py39'
- version: '3.10'
target: 'py310'
- version: '3.11'
target: 'py311'
- version: '3.12'
target: 'py312'
# Micromamba versions
- version: '3.8'
target: 'micromamba'
- version: '3.9'
target: 'micromamba'
- version: '3.10'
target: 'micromamba'
- version: '3.11'
target: 'micromamba'
- version: '3.12'
target: 'micromamba'

steps:
- name: Checkout code
Expand All @@ -34,16 +56,19 @@ jobs:
- name: Extract tag name
run: echo "RUNNER_TAG=${GITHUB_REF#refs/tags/runner-}" >> $GITHUB_ENV

- name: Build and push Docker image for ${{ matrix.python-version }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./docker/Dockerfile.runner
push: true
tags: ${{ secrets.ECR_REGISTRY }}/beta9-runner:${{ matrix.python-version }}-${{ env.RUNNER_TAG }},${{ secrets.ECR_REGISTRY }}/beta9-runner:${{ matrix.python-version }}-latest
target: ${{ matrix.python-version }}
tags: ${{ secrets.ECR_REGISTRY }}/beta9-runner:${{ matrix.target == 'micromamba' && format('micromamba{0}', matrix.version) || matrix.target }}-${{ env.RUNNER_TAG }},${{ secrets.ECR_REGISTRY }}/beta9-runner:${{ matrix.target == 'micromamba' && format('micromamba{0}', matrix.version) || matrix.target }}-latest
target: ${{ matrix.target }}
build-args: |
${{ matrix.target == 'micromamba' && format('PYTHON_VERSION={0}', matrix.version) || '' }}
platforms: linux/amd64
load: false
registry: ${{ steps.login-ecr.outputs.registry }}
repository: ${{ steps.login-ecr.outputs.registry }}/beta9-runner
add_git_labels: true
tag_with_ref: true
tag_with_ref: true
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@ proxy:

runner:
for target in py312 py311 py310 py39 py38; do \
docker build . --no-cache --target $$target --platform=linux/amd64 -f ./docker/Dockerfile.runner -t localhost:5001/beta9-runner:$$target-$(runnerTag); \
docker build . --target $$target --platform=linux/amd64 -f ./docker/Dockerfile.runner -t localhost:5001/beta9-runner:$$target-$(runnerTag); \
docker push localhost:5001/beta9-runner:$$target-$(runnerTag); \
done
for version in "3.12" "3.11" "3.10" "3.9" "3.8"; do \
docker build . --build-arg PYTHON_VERSION=$$version --target micromamba --platform=linux/amd64 -f ./docker/Dockerfile.runner -t localhost:5001/beta9-runner:micromamba$$version-$(runnerTag); \
docker push localhost:5001/beta9-runner:micromamba$$version-$(runnerTag); \
done

start:
cd hack && okteto up --file okteto.yaml
Expand Down
77 changes: 44 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

---

### Run GPU Workloads Across Multiple Clouds
### Cross-Cloud Serverless Engine

Run serverless workloads with fast cold starts on bare-metal servers, anywhere in the world

<p align="center">
<a href="https://docs.beam.cloud">
Expand All @@ -30,26 +32,55 @@

</div>

## What is Beta9?

Beta9 is an open source container orchestrator, designed for running GPU workloads across different cloud environments in different regions.
## Features

- Connect VMs to your cluster with a single cURL command
- Run serverless workloads using a friendly Python interface
- Autoscaling and automatic scale-to-zero
- Read large files at the edge using distributed, cross-region storage
- Manage your fleet of GPUs using a Tailscale-powered service mesh
- Connect bare-metal nodes to your cluster with a single cURL command
- Manage your fleet of servers using a Tailscale-powered service mesh
- Securely run workloads with end-to-end encryption through WireGuard
- Run workloads using a friendly Python interface

## How does it work?
## How Does It Work?

### Run Serverless Workloads in Pure Python

Add an `endpoint` decorator to your code, and you'll get a load-balanced HTTP endpoint (with auth!) to invoke your code.

### Provision GPUs Anywhere
You can also run long-running functions with `@function`, deploy task queues using `@task_queue`, and schedule jobs with `@schedule`:

```python
from beta9 import endpoint


# This will run on a remote A100-40 in your cluster
@endpoint(cpu=1, memory=128, gpu="A100-40")
def square(i: int):
return i**2
```

Deploy with a single command:

```
$ beta9 deploy app.py:square --name inference
=> Building image
=> Using cached image
=> Deployed 🎉
curl -X POST 'https://inference.beam.cloud/v1' \
-H 'Authorization: Bearer [YOUR_AUTH_TOKEN]' \
-H 'Content-Type: application/json' \
-d '{}'
```

### Run on Bare-Metal Servers Around the World

Connect any GPU to your cluster with one CLI command and a cURL.

```sh
$ beta9 machine create --pool lambda-a100-40

=> Created machine with ID: '9541cbd2'. Use the following command to setup the node:
=> Created machine with ID: '9541cbd2'. Use the following command to set up the node:

#!/bin/bash
sudo curl -L -o agent https://release.beam.cloud/agent/agent && \
Expand All @@ -64,9 +95,9 @@ sudo ./agent --token "AUTH_TOKEN" \

You can run this install script on your VM to connect it to your cluster.

### Manage Your GPU Fleet
### Manage Your CPU or GPU Fleet

Manage your distributed cross-region GPU cluster using a centralized control plane.
Manage your distributed cross-region cluster using a centralized control plane.

```sh
$ beta9 machine list
Expand All @@ -78,20 +109,6 @@ $ beta9 machine list

```

### Run Workloads in Python

Offload any workload to your remote machines by adding a Python decorator to your code.

```python
from beta9 import function


# This will run on a remote A100-40 in your cluster
@function(cpu=1, memory=128, gpu="A100-40")
def square(i: int):
return i**2
```

# Local Installation

You can run Beta9 locally, or in an existing Kubernetes cluster using our [Helm chart](https://github.com/beam-cloud/beta9/tree/main/deploy/charts/beta9).
Expand All @@ -102,9 +119,6 @@ k3d is used for local development. You'll need Docker to get started.

To use our fully automated setup, run the `setup` make target.

> [!NOTE]
> This will overwrite some of the tools you may already have installed. Review the [setup.sh](bin/setup.sh) to learn more.
```bash
make setup
```
Expand All @@ -113,9 +127,6 @@ make setup

The SDK is written in Python. You'll need Python 3.8 or higher. Use the `setup-sdk` make target to get started.

> [!NOTE]
> This will install the Poetry package manager.
```bash
make setup-sdk
```
Expand All @@ -137,7 +148,7 @@ If you need support, you can reach out through any of these channels:

- [Slack](https://join.slack.com/t/beam-cloud/shared_invite/zt-2f16bwiiq-oP8weCLWNrf_9lJZIDf0Fg) \(Chat live with maintainers and community members\)
- [GitHub issues](https://github.com/beam-cloud/issues) \(Bug reports, feature requests, and anything roadmap related)
- [Twitter](https://twitter.com/beam_cloud) \(Updates on releases and stuff)
- [Twitter](https://twitter.com/beam_cloud) \(Updates on releases and more)

## Thanks to Our Contributors

Expand Down
73 changes: 73 additions & 0 deletions docker/Dockerfile.runner
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,76 @@ rm -rf /usr/lib/python2.7 && rm -rf /usr/lib/python3.6
EOT

VOLUME ["/volumes", "/snapshot"]

# Micromamba-base
# ========================
FROM base as micromamba-base

WORKDIR /workspace

ENV DEBIAN_FRONTEND=noninteractive \
NVIDIA_VISIBLE_DEVICES=all \
PATH=/micromamba/bin:$PATH \
MAMBA_ROOT_PREFIX=/micromamba \
MAMBA_EXE=/bin/micromamba \
SHELL=/bin/bash

COPY ./pkg/abstractions/image/base_requirements.txt /workspace/requirements.txt

SHELL ["/bin/bash", "-c"]
RUN <<EOT
set -eux

VERSION="2.0.2"
ARCH=$(uname -m)
if [ "$ARCH" = "x86_64" ]; then
MAMBA_ARCH="64"
elif [ "$ARCH" = "aarch64" ]; then
MAMBA_ARCH="aarch64"
else
echo "Unsupported architecture: $ARCH"
exit 1
fi

curl -L "https://micro.mamba.pm/api/micromamba/linux-${MAMBA_ARCH}/${VERSION}" \
| tar -xj -C "/" "bin/micromamba"

mkdir -p /micromamba

sh -c 'echo "#!/bin/sh\nexec micromamba run -n beta9 python3 \"\$@\""' > /micromamba/mpy
chmod +x /micromamba/mpy

apt-get clean -y
apt-get autoremove -y
rm -rf /var/lib/apt/lists/*
rm -rf /usr/share/doc
rm -rf /usr/share/man
rm -rf /usr/share/locale
rm -rf /root/.cache/*
rm -rf /tmp/*
EOT


VOLUME ["/volumes", "/snapshot"]

# Micromamba final
# ========================
ARG PYTHON_VERSION=3.10
FROM micromamba-base as micromamba

WORKDIR /workspace

COPY --from=micromamba-base /micromamba /micromamba

RUN <<EOT
set -eux

/bin/micromamba create -n beta9 python=${PYTHON_VERSION} -y
/bin/micromamba run -n beta9 pip install -r /workspace/requirements.txt

ln -sf /micromamba/mpy /usr/bin/micromamba${PYTHON_VERSION}

/bin/micromamba clean --all --yes
EOT

VOLUME ["/volumes", "/snapshot"]
9 changes: 5 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ require (
github.com/lib/pq v1.10.9
github.com/mholt/archiver/v3 v3.5.1
github.com/mitchellh/hashstructure/v2 v2.0.2
github.com/opencontainers/runtime-spec v1.1.0
github.com/opencontainers/runtime-spec v1.2.0
github.com/opencontainers/umoci v0.4.7
github.com/openmeterio/openmeter v1.0.0-beta.47
github.com/oracle/oci-go-sdk v24.3.0+incompatible
Expand All @@ -65,7 +65,7 @@ require (
go.opentelemetry.io/otel/sdk/log v0.7.0
go.opentelemetry.io/otel/sdk/metric v1.31.0
go.opentelemetry.io/otel/trace v1.31.0
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c
golang.org/x/net v0.30.0
golang.org/x/sync v0.8.0
golang.org/x/sys v0.26.0
Expand Down Expand Up @@ -110,6 +110,7 @@ require (
github.com/briandowns/spinner v1.23.0 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cilium/ebpf v0.16.0 // indirect
github.com/coder/websocket v1.8.12 // indirect
github.com/containerd/console v1.0.3 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect
Expand Down Expand Up @@ -242,12 +243,12 @@ require (
go4.org/mem v0.0.0-20220726221520-4f986261bf13 // indirect
go4.org/netipx v0.0.0-20231129151722-fdeea329fbba // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/mod v0.19.0 // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
golang.org/x/term v0.25.0 // indirect
golang.org/x/text v0.19.0 // indirect
golang.org/x/time v0.7.0 // indirect
golang.org/x/tools v0.23.0 // indirect
golang.org/x/tools v0.26.0 // indirect
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect
golang.zx2c4.com/wireguard/windows v0.5.3 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect
Expand Down
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/cilium/ebpf v0.15.0 h1:7NxJhNiBT3NG8pZJ3c+yfrVdHY8ScgKD27sScgjLMMk=
github.com/cilium/ebpf v0.15.0/go.mod h1:DHp1WyrLeiBh19Cf/tfiSMhqheEiK8fXFZ4No0P1Hso=
github.com/cilium/ebpf v0.16.0 h1:+BiEnHL6Z7lXnlGUsXQPPAE7+kenAd4ES8MQ5min0Ok=
github.com/cilium/ebpf v0.16.0/go.mod h1:L7u2Blt2jMM/vLAVgjxluxtBKlz3/GWjB0dMOEngfwE=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cloudevents/sdk-go/v2 v2.15.1 h1:EZxXQFkzk8TSsxDBx8v18+KGwTYsGRyHNwtzZiHUk4E=
github.com/cloudevents/sdk-go/v2 v2.15.1/go.mod h1:lL7kSWAE/V8VI4Wh0jbL2v/jvqsm6tjmaQBSvxcv4uE=
Expand Down Expand Up @@ -499,8 +499,8 @@ github.com/opencontainers/runc v1.0.0-rc90/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2r
github.com/opencontainers/runc v1.1.10 h1:EaL5WeO9lv9wmS6SASjszOeQdSctvpbu0DdBQBizE40=
github.com/opencontainers/runc v1.1.10/go.mod h1:+/R6+KmDlh+hOO8NkjmgkG9Qzvypzk0yXxAPYYR65+M=
github.com/opencontainers/runtime-spec v1.0.2/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/opencontainers/runtime-spec v1.1.0 h1:HHUyrt9mwHUjtasSbXSMvs4cyFxh+Bll4AjJ9odEGpg=
github.com/opencontainers/runtime-spec v1.1.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/opencontainers/runtime-spec v1.2.0 h1:z97+pHb3uELt/yiAWD691HNHQIF07bE7dzrbT927iTk=
github.com/opencontainers/runtime-spec v1.2.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/opencontainers/umoci v0.4.7 h1:mbIbtMpZ3v9oMpKaLopnWoLykgmnixeLzq51EzAX5nQ=
github.com/opencontainers/umoci v0.4.7/go.mod h1:lgJ4bnwJezsN1o/5d7t/xdRPvmf8TvBko5kKYJsYvgo=
github.com/openmeterio/openmeter v1.0.0-beta.47 h1:tZR4QiKLiJMAhPUsA/FXrskYF65wQ/23QNbxeFzWRA0=
Expand Down Expand Up @@ -725,8 +725,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a h1:Q8/wZp0KX97QFTc2ywcOE0YRjZPVIx+MXInMzdvQqcA=
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08=
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c h1:7dEasQXItcW1xKJ2+gg5VOiBnqWrJc+rq0DPKyvvdbY=
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c/go.mod h1:NQtJDoLvd6faHhE7m4T/1IY708gDefGGjR/iUW8yQQ8=
golang.org/x/exp/typeparams v0.0.0-20240119083558-1b970713d09a h1:8qmSSA8Gz/1kTrCe0nqR0R3Gb/NDhykzWw2q2mWZydM=
golang.org/x/exp/typeparams v0.0.0-20240119083558-1b970713d09a/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
golang.org/x/image v0.18.0 h1:jGzIakQa/ZXI1I0Fxvaa9W7yP25TqT6cHIHn+6CqvSQ=
Expand All @@ -736,8 +736,8 @@ golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvx
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8=
golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0=
golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -810,8 +810,8 @@ golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBn
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg=
golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI=
golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ=
golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
5 changes: 2 additions & 3 deletions pkg/abstractions/common/autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ type IAutoscaler interface {
}

const (
MaxReplicas uint = 10 // Maximum number of desired replicas that can be returned
windowSize int = 60 // Number of samples in the sampling window
sampleRate time.Duration = time.Duration(1000) * time.Millisecond // Time between samples
windowSize int = 60 // Number of samples in the sampling window
sampleRate time.Duration = time.Duration(1000) * time.Millisecond // Time between samples
)

type AutoscalerSample interface{}
Expand Down
Loading

0 comments on commit b7d7b0c

Please sign in to comment.