Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

4.3 KB
Raw Blame
substitutions:
  _REGION: us-central1
  _RUN_SA: avatar-reconstruction-sa@aerial-vehicle-466722-p5.iam.gserviceaccount.com
  _SERVICE: model-trellis
  _REPO: model-trellis
  _GCS_BUCKET: three-ws-avatar-reconstructions
  _WEIGHTS_BUCKET: three-ws-model-weights
  _MIN_INSTANCES: "1"
  # One warm instance for latency; burst to 3 under load. The two conditions the
  # old max=1 note gated on are both met now: task state is persisted to GCS
  # (polls resolve on any instance) and the region's L4 quota is 8 (verified
  # 2026-07-16), so extra instances schedule instead of starving siblings. Each
  # instance serializes its own GPU at MAX_CONCURRENT=1, so instance count IS
  # the concurrent-generation count — at the raised quality budgets (25-45
  # sampler steps) a single instance would queue user-visibly under load.
  _MAX_INSTANCES: "3"
  _WEIGHTS_BUCKET_PREFIX: trellis-large
  # Sibling background-removal worker. Set so the MAX tier (and any matte=true
  # request) mattes the subject before reconstruction. Shares this worker's
  # bearer secret and GCS bucket. Optional: unset degrades to TRELLIS's own
  # internal background removal, never a failure.
  _REMBG_SERVICE_URL: https://rembg-service-lp642k3kpa-uc.a.run.app

steps:
  - id: build
    name: gcr.io/cloud-builders/docker
    dir: workers/model-trellis
    args:
      - build
      - --tag
      - ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/server:$SHORT_SHA
      - --tag
      - ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/server:latest
      - --cache-from
      - ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/server:latest
      - .

  - id: push
    name: gcr.io/cloud-builders/docker
    args:
      - push
      - --all-tags
      - ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/server

  - id: deploy
    name: gcr.io/google.com/cloudsdktool/cloud-sdk:slim
    entrypoint: gcloud
    args:
      - run
      - deploy
      - ${_SERVICE}
      - --image=${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/server:$SHORT_SHA
      - --region=${_REGION}
      - --service-account=${_RUN_SA}
      - --platform=managed
      - --port=8080
      - --gpu=1
      - --gpu-type=nvidia-l4
      - --no-gpu-zonal-redundancy
      - --no-cpu-throttling
      - --cpu=8
      - --memory=32Gi
      - --min-instances=${_MIN_INSTANCES}
      - --max-instances=${_MAX_INSTANCES}
      - --timeout=900
      - --allow-unauthenticated
      - --add-volume=name=weights,type=cloud-storage,bucket=${_WEIGHTS_BUCKET}
      - --add-volume-mount=volume=weights,mount-path=/weights
      - --set-env-vars=GCS_BUCKET=${_GCS_BUCKET},WEIGHTS_DIR=/weights/trellis-large,MAX_CONCURRENT=1,WEIGHTS_GCS_URI=gs://${_WEIGHTS_BUCKET}/${_WEIGHTS_BUCKET_PREFIX},WEIGHTS_LOCAL_DIR=/tmp/trellis-weights,REMBG_SERVICE_URL=${_REMBG_SERVICE_URL}
      - --set-secrets=API_KEY=avatar-reconstruction-key:latest
      # Recycle an instance whose model load is permanently dead. The startup
      # probe is a TCP check, and the port opens immediately because the ~3 GB
      # load is backgrounded, so nothing here ever noticed a load that failed:
      # with min-instances=1 the failed instance stayed resident and answered
      # every job with "pipeline unavailable" until somebody redeployed. That is
      # the 2026-09-02 outage. main.py answers /health with 503 only once the
      # whole retry budget is spent, so an ordinary cold load (200 while
      # loading) is never killed mid-load, and a genuinely dead container is
      # replaced within ~3 minutes. Inference runs in a thread executor, so
      # /health stays responsive while the GPU is busy.
      - --liveness-probe=httpGet.path=/health,initialDelaySeconds=60,periodSeconds=60,timeoutSeconds=10,failureThreshold=3

images:
  - ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/server:$SHORT_SHA
  - ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/server:latest

options:
  machineType: E2_HIGHCPU_32
  logging: CLOUD_LOGGING_ONLY

# CUDA extension compiles (nvdiffrast / diffoctreerast / diff-gaussian-rasterization)
# push the image build well past Cloud Build's 10-minute default. Give it an hour.
timeout: 3600s

# The project's default compute SA was deleted — builds must pin the dedicated
# build account (same as the other worker configs) or submits fail with
# "Unknown service account".
serviceAccount: projects/aerial-vehicle-466722-p5/serviceAccounts/[email protected]