File size: 3,158 Bytes
eac3bc2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# syntax=docker/dockerfile:1.7
# ZOMBIE-WEIGHTS L4 image: two isolated uv/Python-3.12 environments sharing one HF cache.
#
#   /opt/venv_core       torch 2.13 (from base), transformers <5.22, trl <1.15,
#                        transformer-lens==3.8.0, bnb, CuratorKIT, CircuitKIT,
#                        SafeTune, AuditKIT — NO torchao
#   /opt/venv_aligntune  aligntune 0.1.35, trl==1.7.1, torchao 0.18, torchvision 0.28
#
# Build:
#   docker build -f docker/Dockerfile.l4 -t ghcr.io/divyanshu-kumar14/zombie-weights-l4:latest .
FROM pytorch/pytorch:2.13.0-cuda12.6-cudnn9-runtime

ENV DEBIAN_FRONTEND=noninteractive \
    HF_HOME=/root/.cache/huggingface \
    HF_HUB_ENABLE_HF_TRANSFER=1 \
    PYTHONUNBUFFERED=1 \
    TOKENIZERS_PARALLELISM=false \
    ALIGNTUNE_ENABLE_VLLM=0 \
    UV_LINK_MODE=copy

RUN apt-get update && apt-get install -y --no-install-recommends \
        git curl ca-certificates build-essential \
    && rm -rf /var/lib/apt/lists/*

# uv (pinned standalone binary; avoids PEP 668 system-pip restrictions)
COPY --from=ghcr.io/astral-sh/uv:0.12.17 /uv /usr/local/bin/uv

# ---------------------------------------------------------------------------
# Core environment (base image Python 3.12.3 + system torch 2.13.0)
# uv creates the venv; pip resolves against system-site-packages so torch is
# reused instead of downloading a second CUDA stack.
# ---------------------------------------------------------------------------
RUN uv venv --system-site-packages --seed /opt/venv_core
RUN /opt/venv_core/bin/pip install --no-cache-dir \
        "transformers>=5.15,<5.22" \
        "trl>=0.12,<1.15" \
        "peft>=0.18,<1" \
        "huggingface-hub>=1.5,<2" \
        "transformer-lens==3.8.0" \
        "bitsandbytes>=0.41" \
        "datasets>=3.0" \
        "accelerate>=1.4" \
        "sentencepiece" \
        "protobuf" \
        "scikit-learn" \
        "hf_transfer" \
        "curatorkit[hf,connectors]" \
        "circuitkit==0.2.3" \
        "safetune==0.1.18" \
        "auditkit==1.1.11"

# ---------------------------------------------------------------------------
# AlignTune environment (isolated; torchao only lives here)
# ---------------------------------------------------------------------------
RUN uv venv --system-site-packages --seed /opt/venv_aligntune
RUN /opt/venv_aligntune/bin/pip install --no-cache-dir \
        "torchvision==0.28.0" \
        "transformers>=5.15,<5.22" \
        "peft>=0.18,<1" \
        "datasets>=4.7.0" \
        "accelerate>=1.6" \
        "trl==1.7.1" \
        "torchao==0.18.0" \
        "aligntune==0.1.35"

# ---------------------------------------------------------------------------
# Project code + hard import gates
# ---------------------------------------------------------------------------
COPY docker/verify_imports.py /opt/zombie-weights/docker/verify_imports.py
COPY src/ /opt/zombie-weights/src/
COPY scripts/ /opt/zombie-weights/scripts/

RUN /opt/venv_core/bin/python /opt/zombie-weights/docker/verify_imports.py core \
 && /opt/venv_aligntune/bin/python /opt/zombie-weights/docker/verify_imports.py aligntune

WORKDIR /opt/zombie-weights
CMD ["bash"]