Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 401
infra: update aggregation mode deployment#2278
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
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
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,46 @@ | ||
| name: "Start Aggregation Mode Server" | ||
| # Starts the Paperspace GPU server that runs the aggregation mode. | ||
| # | ||
| # The server is kept powered off to avoid 24/7 billing. This workflow boots it | ||
| # once a day; on boot the machine runs `aggregation_mode.service`, which executes | ||
| # the SP1 aggregations and then powers the machine off again | ||
| # (see infra/aggregation_mode/run.sh). | ||
| on: | ||
| schedule: | ||
| # 15:00 UTC == 12:00 GMT-3, every day. GitHub Actions cron is always in UTC. | ||
| - cron: "0 15 * * *" | ||
| workflow_dispatch: | ||
| jobs: | ||
| start-server: | ||
| name: Start Paperspace aggregation server | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Start Paperspace machine | ||
| env: | ||
| PAPERSPACE_API_KEY: ${{ secrets.PAPERSPACE_API_KEY }} | ||
| MACHINE_ID: ${{ secrets.PAPERSPACE_MACHINE_ID }} | ||
| run: | | ||
| set -euo pipefail | ||
| if [ -z "${PAPERSPACE_API_KEY}" ] || [ -z "${MACHINE_ID}" ]; then | ||
| echo "::error::PAPERSPACE_API_KEY and PAPERSPACE_MACHINE_ID secrets must be set." | ||
| exit 1 | ||
| fi | ||
| echo "Starting Paperspace machine ${MACHINE_ID}..." | ||
| http_code=$(curl -sS -o response.json -w "%{http_code}" \ | ||
| -X PATCH "https://api.paperspace.com/v1/machines/${MACHINE_ID}/start" \ | ||
| -H "Authorization: Bearer ${PAPERSPACE_API_KEY}") | ||
| echo "Paperspace API responded with HTTP ${http_code}" | ||
| cat response.json || true | ||
| # 2xx means the start request was accepted. | ||
| if [ "${http_code}" -lt 200 ] || [ "${http_code}" -ge 300 ]; then | ||
| echo "::error::Failed to start Paperspace machine (HTTP ${http_code})." | ||
| exit 1 | ||
| fi | ||
| echo "Start request accepted. The machine will run the aggregation on boot and shut itself down afterwards." |
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 |
|---|---|---|
| @@ -9,4 +9,4 @@ ExecStartPre=sleep 60 | ||
| ExecStart=/home/user/run.sh | ||
| [Install] | ||
| WantedBy=multi-user.target | ||
| WantedBy=default.target | ||
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 |
|---|---|---|
| @@ -24,7 +24,8 @@ done | ||
| sudo loginctl enable-linger user | ||
| # Install other dependencies | ||
| sudo apt install -y gcc pkg-config libssl-dev build-essential apt-transport-https ca-certificates curl software-properties-common nvtop | ||
| sudo apt install -y gcc pkg-config libssl-dev build-essential apt-transport-https ca-certificates curl software-properties-common nvtop clang | ||
| sudo apt-get install -y protobuf-compiler | ||
| # Install docker | ||
| sudo apt-get update | ||
| @@ -52,14 +53,24 @@ sudo tailscale up --ssh --advertise-tags=tag:server && sudo tailscale set --auto | ||
| # Install CUDA | ||
| sudo add-apt-repository ppa:graphics-drivers/ppa | ||
| sudo apt update | ||
| sudo apt install nvidia-driver-570 | ||
| sudo apt install -y nvidia-driver-580 | ||
| # If see errors | ||
| sudo apt-mark unhold cuda-drivers cuda-toolkit-12-6 nvidia-dkms-565-server nvidia-fabricmanager-565 nvidia-headless-565-server nvidia-utils-565-server | ||
| sudo apt update | ||
| sudo apt install nvidia-driver-570 | ||
| sudo apt autoremove | ||
| sudo apt autoclean | ||
| wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb | ||
| sudo dpkg -i cuda-keyring_1.1-1_all.deb | ||
| sudo apt update | ||
| sudo apt install -y cuda-toolkit-12-9 | ||
| ## Add to ~/.bashrc | ||
| export PATH=/usr/local/cuda-12.9/bin${PATH:+:${PATH}} | ||
| export LD_LIBRARY_PATH=/usr/local/cuda-12.9/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} | ||
| # If see errors | ||
| #sudo apt-mark unhold cuda-drivers cuda-toolkit-12-6 nvidia-dkms-565-server nvidia-fabricmanager-565 nvidia-headless-565-server nvidia-utils-565-server | ||
| #sudo apt update | ||
| #sudo apt install nvidia-driver-570 | ||
| #sudo apt autoremove | ||
| #sudo apt autoclean | ||
| sudo reboot | ||
| nvidia-smi # To check if the driver is installed correctly | ||
| @@ -108,26 +119,33 @@ read -p "Enter a block number for SP1 (last_aggregated_block): " num && echo "{\ | ||
| ./infra/aggregation_mode/config_file.sh ./infra/aggregation_mode/config-proof-aggregator-risc0.template.yaml $HOME/config/config-proof-aggregator-risc0.yaml | ||
| read -p "Enter a block number for Risc0 (last_aggregated_block): " num && echo "{\"last_aggregated_block\":$num}" > $HOME/config/proof-aggregator-risc0.last_aggregated_block.json | ||
| mkdir -p $HOME/repos/aggregation_mode/mainnet | ||
| cd $HOME/repos/aggregation_mode/mainnet | ||
| git clone https://github.com/yetanotherco/aligned_layer.git | ||
| cd aligned_layer # Subsequent relative paths (cargo --path, ./infra/...) resolve from the repo root | ||
| # Build the proof_aggregator | ||
| make proof_aggregator_install | ||
| #make proof_aggregator_install | ||
| cargo install --path aggregation_mode/proof_aggregator --features prove,gpu --bin proof_aggregator_gpu --locked | ||
| cargo install --path aggregation_mode/proof_aggregator --features prove --bin proof_aggregator_cpu --locked # This builds risc0 with CPU but sp1 is runnable with GPU | ||
FlagonSA marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| # Copy run script | ||
| cp ./infra/aggregation_mode/run.sh $HOME/run.sh | ||
| chmod 744 $HOME/run.sh | ||
| # Setup systemd service | ||
| # The service is enabled to run on every boot (no timer). The machine is started | ||
| # once a day by the GitHub Actions workflow (.github/workflows/aggregation_mode.yml), | ||
| # runs the aggregation on startup and then shuts itself down (see run.sh). | ||
| cp ./infra/aggregation_mode/aggregation_mode.service $HOME/.config/systemd/user/aggregation_mode.service | ||
| cp ./infra/aggregation_mode/aggregation_mode.timer $HOME/.config/systemd/user/aggregation_mode.timer | ||
| #sudo systemctl enable aggregation_mode.service | ||
| systemctl --user enable aggregation_mode.timer | ||
| systemctl --user start aggregation_mode.timer | ||
| systemctl --user daemon-reload | ||
| systemctl --user enable aggregation_mode.service | ||
| # Run the proof_aggregator manually if you want | ||
| systemctl --user start aggregation_mode.service | ||
| # Check timer status | ||
| systemctl --user status aggregation_mode.timer | ||
| # Check service status | ||
| systemctl --user status aggregation_mode.service | ||
| # Check logs | ||
| journalctl -xfeu aggregation_mode.service --user -n10 | ||
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 |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| #!/bin/bash | ||
| SLEEP=5 | ||
| SLEEP=60 | ||
| echo "Starting Aggregation Mode in $SLEEP seconds..." | ||
| sleep $SLEEP | ||
| @@ -13,3 +13,11 @@ echo "SP1 Aggregation Mode finished" | ||
| echo "Starting Risc0 Aggregation Mode..." | ||
| AGGREGATOR=risc0 /home/user/.cargo/bin/proof_aggregator_gpu /home/user/config/config-proof-aggregator-risc0.yaml | ||
| echo "Risc0 Aggregation Mode finished" | ||
| # Aggregation finished: power off the machine so Paperspace stops billing it. | ||
| # The GitHub Actions workflow (.github/workflows/aggregation_mode.yml) starts the | ||
| # machine again on the next scheduled run, and aggregation_mode.service runs this | ||
| # script automatically on boot. | ||
FlagonSA marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| echo "Aggregation finished, shutting down the machine in 1 minute..." | ||
| sleep $SLEEP | ||
| sudo shutdown -h now | ||
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.