Skip to content

Update Dockerfile for uv and pyproject.toml migration - #260

Merged
natolambert merged 21 commits into
mainfrom
fix/dockerfile-uv-migration
Jan 31, 2026
Merged

Update Dockerfile for uv and pyproject.toml migration#260
natolambert merged 21 commits into
mainfrom
fix/dockerfile-uv-migration

Conversation

@natolambert

@natolambert natolambert commented Jan 30, 2026

Copy link
Copy Markdown

Summary

  • Replace setup.py with pyproject.toml (removed in Migrate to UV and pyproject.toml, fix transformers compatibility #259)
  • Use uv instead of pip for faster, more reliable package management
  • Install all optional dependencies [generative,v1] in a single command
  • Remove redundant manual pip installs (anthropic, openai, together, google-generativeai are now in the [generative] extra)
  • Update workflow to trigger on pyproject.toml changes instead of setup.py
  • Enable workflow_dispatch for manual builds

Test plan

  • Docker image builds successfully in CI
  • rewardbench --help works in the container
  • rewardbench-gen --help works in the container

Generated with Claude Code

- Replace setup.py with pyproject.toml
- Use uv instead of pip for faster, more reliable package management
- Install all optional dependencies [generative,v1]
- Remove redundant manual pip installs (now in pyproject.toml extras)
- Update workflow to trigger on pyproject.toml changes
- Enable workflow_dispatch for manual builds

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 169b955f0d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Dockerfile Outdated
Nathan Lambert and others added 20 commits January 30, 2026 10:40
The rewardbench-gen entry point uses rewardbench/generative.py which
imports google.generativeai (old SDK), not google.genai (new SDK).
Both packages are needed for full compatibility.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update rewardbench/generative.py to use the modern google-genai SDK
instead of the legacy google-generativeai. This aligns it with
generative_v2.py and simplifies dependencies.

Move google-generativeai to [v1] extra for any legacy code that
still needs the old SDK.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Pin torch>=2.1,<=2.8 in pyproject.toml for compatibility with
  prebuilt flash-attn wheels
- Add torchvision and torchaudio to dependencies
- Remove separate torch install from Dockerfile (now in pyproject.toml)
- Use prebuilt flash-attn 2.8.3 wheel from GitHub releases instead of
  building from source (significantly faster Docker builds)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
vllm 0.13.0 requires torch==2.9.0, but flash-attn prebuilt wheels
only exist up to torch 2.8. Since we need vllm 0.13.0, we must
build flash-attn from source (slower Docker builds).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
flash-attn cannot be installed because:
1. vllm 0.13.0 requires torch 2.9, but prebuilt wheels only exist up to torch 2.8
2. Building from source requires excessive memory and is very slow

vllm has its own optimized attention kernels, so this is fine for inference.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
GitHub Actions has sufficient memory to build flash-attn from source.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
vllm is CUDA-only and doesn't support macOS. Adding sys_platform == 'linux'
marker allows Mac users to run uv sync --all-extras and still get all
the API-based providers (openai, anthropic, google-genai, together).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Pin vllm==0.13.0 on all Linux platforms (prevents torch version floating)
- Add MAX_JOBS=4 to flash-attn build to limit parallelism and avoid OOM

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
GitHub Actions has sufficient memory; MAX_JOBS was only needed locally.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Copy dependency manifests (pyproject.toml, uv.lock) first for caching
- Use uv sync --frozen --no-install-project to install deps (cached layer)
- Copy source code after deps (only invalidates later layers)
- Use uv sync --frozen --no-editable for deployment-style install
- flash-attn installed last after torch is finalized

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Move flash-attn install BEFORE source code copy so it's cached
  unless dependencies change (not on every code change)
- Add docker/build-push-action with GHA layer caching (cache-from/to)
- This should dramatically speed up subsequent builds

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Base image (Dockerfile):
- Uses api + v1 extras (no vllm)
- Pins torch <=2.8
- Uses prebuilt flash-attn wheel (~5-10 min build)
- For: reward models, API-based judges (OpenAI, Anthropic, etc.)

vLLM image (Dockerfile.vllm):
- Uses generative + v1 extras (includes vllm)
- vllm pins torch 2.9
- Builds flash-attn from source (~45 min build)
- For: local LLM inference judges

Also split extras in pyproject.toml:
- api: API clients only (openai, anthropic, google-genai, together)
- vllm: vllm only (pins torch)
- generative: api + vllm (backwards compatible)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Document api, vllm, generative extras in CLAUDE.md
- Add Docker images table to both CLAUDE.md and README.md
- Update build instructions for both images

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add --system flag to uv pip install commands in Dockerfiles
  (required when no venv is present in Docker)
- Fix black formatting in rewardbench.py

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
vLLM 0.13.0 includes its own flash attention implementation,
so we do not need to build flash-attn from source. This saves
~30 minutes of build time.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- uv sync uses lockfile which has torch 2.9, so we need to downgrade after
- Update flash-attn to v2.8.3 which has prebuilt wheels for torch 2.8

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- openjdk: no Java code in project
- git-lfs: hf_transfer downloads models via HTTP
- parallel: code uses Python threads, not GNU parallel

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Caching adds ~5-10 min upload overhead per build. With infrequent
builds and fast base image (prebuilt flash-attn), caching overhead
isn't worth it.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@natolambert
natolambert merged commit 05a9005 into main Jan 31, 2026
5 checks passed
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.

1 participant