Skip to content
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

Make context builder / base images arm64 compatible #1490

Merged
merged 1 commit into from
Mar 24, 2025

Conversation

nnarayen
Copy link
Contributor

@nnarayen nnarayen commented Mar 21, 2025

🚀 What

Changes our context builder + base images to be arm64 compatible. Modified a unit test that now runs locally on mac:

$ poetry run pytest truss/tests/test_model_inference.py::test_requirements_file_truss

And verified in local dev/staging via context builder 0.9.71rc008 that models can still build + run.

Before multi stage
image

After multi stage
image

💻 How

🔬 Testing

@nnarayen nnarayen force-pushed the nikhil/update-context-builder-arm branch 6 times, most recently from e679265 to 24f86e6 Compare March 21, 2025 22:36
@@ -2,6 +2,16 @@ name: Build Context Builder Image

on:
workflow_dispatch:
inputs:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Building arm64 images on a github runner is slow, so I wanted to keep the option of just building for amd64 fast for now

@@ -59,6 +59,7 @@ jobs:
push: ${{ github.event_name != 'pull_request' }}
tags: baseten/truss-context-builder:v${{ needs.detect-version-changed.outputs.new_version }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Production context builders ideally are built for both, and since nobody is really waiting on these it's ok to be slower

@@ -2,21 +2,32 @@
# for creating docker build context out of a Truss.
# Build that image as:
# docker buildx build . -f context_builder.Dockerfile --platform=linux/amd64 -t baseten/truss-context-builder
FROM python:3.9-slim
FROM python:3.9-slim AS builder
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making this a multi stage build takes it from ~500mb to ~100mb

@@ -1 +1,3 @@
torch>=2.0.1
blake3>=0.3.3
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without the changes made in this PR (specifically to truss/templates/base.Dockerfile.jinja), this test would now fail on Macbooks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What part inside the truss model exactly needs blake now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this test nothing, but I just put it here as an example of a dependency that is trickier to build on arm64. In 'real' models, I believe it's the control patching flow


RUN apt-get update \
&& apt-get install --yes --no-install-recommends curl tar \
&& apt-get install --yes --no-install-recommends curl build-essential golang-go \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We add the tooling needing for arm64 images unconditionally, but since it's a multi stage image, these deps aren't needed in the final image

@nnarayen nnarayen requested a review from marius-baseten March 21, 2025 22:50
@nnarayen nnarayen force-pushed the nikhil/update-context-builder-arm branch from 24f86e6 to 619c1a0 Compare March 24, 2025 04:48
@@ -1 +1,3 @@
torch>=2.0.1
blake3>=0.3.3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What part inside the truss model exactly needs blake now?

@nnarayen nnarayen force-pushed the nikhil/update-context-builder-arm branch from 619c1a0 to ba7efb5 Compare March 24, 2025 18:47
@nnarayen nnarayen merged commit ed1596c into main Mar 24, 2025
5 checks passed
@nnarayen nnarayen deleted the nikhil/update-context-builder-arm branch March 24, 2025 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants