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.

feat: add SEO keyword plan

nirholas48bcf756a5e3
diff --git a/docs/ops/gcp-credits-plan.md b/docs/ops/gcp-credits-plan.md
index 0aec3d0c6..8db06e32c 100644
--- a/docs/ops/gcp-credits-plan.md
+++ b/docs/ops/gcp-credits-plan.md
@@ -16,11 +16,29 @@ Six GPU services share those 3 GPUs:
| model-triposg | image-to-3D | 0 | 2 |
| unirig | auto-rigging | 1 | 2 |
| avatar-reconstruction | photo-to-avatar | 1 | 3 |
+| model-hunyuan3d-21 | PBR realism lane, L4 fallback build (min 0 since 2026-07-17; a pinned min 1 here starved every other rollout) | 0 | 1 |
+
+`model-hunyuan3d-21-rtx` (same 2.1 PBR lane, warm min 1 / max 4) does NOT draw
+from this pool; it runs on the RTX PRO 6000 quota below.
Four warm instances against a quota of 3 means the fleet is permanently at its ceiling: any concurrent generation forces failover to lower-quality lanes or queues. **This quota, not model parameters, is the current cap on 3D output quality and reliability.**
-- A quota preference exists: `l4-no-zonal-us-central1-8`, raised to **preferred 16** on 2026-07-16 (was 8). Google reviews asynchronously; check with:
+- A quota preference exists: `l4-no-zonal-us-central1-8`, raised to **preferred 16** on 2026-07-16 (was 8). Still reconciling as of 2026-07-17. Google reviews asynchronously; check with:
`gcloud alpha quotas preferences list --project=aerial-vehicle-466722-p5`
+
+### The escape hatch that is ALREADY GRANTED: RTX PRO 6000
+
+`NvidiaRtxPro6000GpuAllocNoZonalRedundancyPerProjectRegion` is granted at
+**1000** for us-central1 (preference `rtx-pro-6000-uscentral1-3dpbr`). Cloud
+Run deploys with `--gpu-type=nvidia-rtx-pro-6000` there today (validated
+2026-07-17 with a live probe service); platform minimums for the type are
+**20 CPU / 80 Gi memory** per instance. Blackwell is compute capability 12.0,
+so images built for the L4 (cu121/cu124 stacks) do NOT run on it; a worker
+needs a CUDA 12.8 + torch 2.7 (cu128) rebuild. First mover:
+`workers/model-hunyuan3d/Dockerfile.hunyuan21rtx` (service
+`model-hunyuan3d-21-rtx`, warm min 1 / max 4). When an L4 lane needs headroom
+before the L4 grant lands, port it the same way rather than parking work on
+the quota.
- **When granted ≥ 8, execute immediately (no owner input needed):**
```sh
gcloud run services update model-trellis --region us-central1 --max-instances=3
diff --git a/docs/ops/seo-keyword-plan.md b/docs/ops/seo-keyword-plan.md
new file mode 100644
index 000000000..1178030d9
--- /dev/null
+++ b/docs/ops/seo-keyword-plan.md
@@ -0,0 +1,109 @@
+# SEO keyword plan
+
+Verified keyword landscape and content calendar for three.ws across its product clusters: 3D generation, AI agents/MCP, Solana/x402/crypto, and enterprise AI (watsonx/Granite). Built 2026-07-17 from a deep-research pass (24 sources fetched, 25 claims adversarially verified, 23 confirmed) plus a live audit of the IBM Community publishing surface. Every SERP observation is dated 2026-07-17; re-verify before acting on this doc more than a quarter later.
+
+Related: [page-audit.md](./page-audit.md) covers on-site quality; this doc covers what to write and where to publish it.
+
+---
+
+## The two publishing surfaces
+
+### three.ws (own domain)
+
+331 indexable pages across 10 sections (crypto 113, learn 68, build 47, blog 31, main 29, others 43). The blog at `/blog` already carries partnership and feature posts. Every page gets a per-page OG card from `/api/page-og` (the `?v=carbon` variant renders an IBM-adjacent light card for content shared into IBM contexts).
+
+### IBM Community user group
+
+three.ws runs a user group at [community.ibm.com](https://community.ibm.com/community/user/usergroup?CommunityKey=e71510cc-d953-408f-9a1c-019f5c0a7016). Verified properties of its blog posts (live HTML audit, 2026-07-17):
+
+- Outbound links carry `rel="noopener"` only: no `nofollow`, no `ugc`. They are ordinary editorial links.
+- Posts get self-canonical, keyword-slugged URLs and are indexable (no `noindex`).
+- The editor exposes Meta Title, Meta Description, Featured Image, Canonical Url, and Additional Meta fields per post.
+
+### The authority-inheritance caveat (verified, load-bearing)
+
+Do NOT plan around "publish on ibm.com, inherit DA 92." Two Google policies, both verified against Google's own documentation ([site reputation abuse](https://developers.google.com/search/blog/2024/11/site-reputation-abuse), effective 2024-11-19):
+
+1. Third-party content published mainly to exploit a host's ranking signals is classified as spam, and no business arrangement (white-label, licensing, formal contributor status) exempts it.
+2. Google runs systems that detect site sections independent from the host and measures them as standalone sites, so a community.ibm.com post does not automatically inherit ibm.com's domain-level authority.
+
+What this means in practice: IBM Community posts are worth writing when they are genuinely on-topic for IBM's audience (watsonx, Granite, MCP, enterprise AI) and valuable independent of any ranking inheritance. The durable value channels are the referral audience, dofollow editorial links earned by genuinely useful content, SERP presence the post earns on its own merits, and AI-search citation (assistants cite ibm.com-hosted content heavily). Off-topic content (pump.fun, token launches, generic 3D marketing) does not belong there: it would be the exact pattern the spam policy targets, and it would burn the IBM partnership. Publish crypto-cluster content on three.ws/blog instead.
+
+Cadence: one post per week maximum on IBM Community, tutorials only, each useful to an IBM developer who never clicks through to three.ws.
+
+---
+
+## Verified cluster landscape
+
+Confidence labels are from the adversarial-verification pass (3-vote refutation panels per claim).
+
+### 1. 3D generation (text-to-3D, image-to-3D, GLB)
+
+- **Head terms are unwinnable.** "Text to 3D" is owned by Meshy: year-stamped title ("Free Text to 3D AI Generator 2026"), 10M+ claimed creators (~$30M ARR corroborated), and an on-page FAQ that captures the question-style long-tail (generation time, ownership, export formats, engine compatibility). Incumbents also defend "X vs Y" comparison SERPs with dedicated /compare/ pages. High confidence.
+- **Winnable long-tails** are the queries Meshy's page does not serve: rigged/animation-ready avatars from text, embeddable 3D agents, free-no-account generation.
+- **Unexamined:** Tripo, Luma, Spline SERPs and the image-to-3D cluster were not directly verified. Treat the 3D map as Meshy-centric and incomplete.
+
+### 2. AI agents and MCP
+
+- **"Build an MCP server" is anchored by modelcontextprotocol.io** (weather-server quickstart, Claude Desktop host, eight languages as tabs on one page). High confidence.
+- **Two verified gaps:** (a) dedicated per-language tutorials; the SERP for "MCP server in Rust tutorial" is exclusively third-party blogs (shuttle.dev, oneuptime.com, dev.to), no official page; (b) use-case-differentiated tutorials (an MCP server for 3D generation, an MCP server with paid tools). three.ws ships real packages for both (`packages/ibm-watsonx-mcp`, `packages/x402-mcp`, `packages/avatar-agent-mcp`).
+- High-DA educational publishers (freeCodeCamp, Baeldung) are actively entering the generic MCP tutorial space; the generic quickstart lane is closing.
+
+### 3. Solana, x402, agent payments (strongest opportunity)
+
+- **Definitional head terms are protocol-owned:** x402.org #1 and solana.com #2 for "what is x402", with Coinbase/Ledger/Crossmint/QuickNode/Cloudflare filling page one. Do not target definitional queries. High confidence.
+- **The co-ranking tooling ecosystem is thin:** solana.com's own agentic-payments doc names pay.sh, Corbits, MCPay.tech, PayAI, ACK, and Google's A2A x402 as the ecosystem. That is a small enough set for tutorial and tooling content to rank. High confidence.
+- **Citable adoption stats:** 35M+ Solana x402 transactions and $10M+ volume per solana.com (conservative floor; third parties report 45M+ Solana transactions and 165M/~$50M ecosystem-wide via Coinbase, April 2026). Medium confidence; pair the solana.com figure with the fresher third-party numbers and re-check before citing.
+- **Unexamined:** pump.fun/token-launch and agent-wallet keyword clusters have no verified findings yet; Virtuals Protocol and ai16z/Eliza SERPs were never checked.
+
+### 4. Enterprise AI (watsonx, Granite, Guardian)
+
+- **IBM first-party content saturates Granite tutorial head terms** ("Granite agentic RAG", "Granite function calling"): developer.ibm.com tutorials plus official cookbooks hold multiple top-10 positions across four IBM properties. Two presumed gaps were REFUTED in verification: IBM already publishes MCP-with-Granite content, so "Granite + MCP" broadly is NOT open. High confidence.
+- **The one verified open angle is host surface:** IBM's official MCP+watsonx tutorial (ranks #1 for its head query) demonstrates only Claude Desktop as the MCP host. Nothing IBM publishes covers embedding a watsonx/Granite-backed agent in a web page or a 3D embeddable agent. That is precisely three.ws's product. High confidence.
+- **Guardian bridge:** Granite Guardian 4.1's documented agent-specific capabilities (function-calling hallucination detection, RAG/tool-call hallucination detection) make "agent guardrails" and "guardrails for MCP servers" legitimate extension topics; IBM's four Guardian cookbooks cover none of that applied angle. High confidence.
+
+### Methodology note
+
+No quantitative keyword data was collected (volumes, KD, CPC). Winnability here is inferred from SERP composition, which is the better signal anyway: Ahrefs KD is computed solely from referring-domain counts of the current top-10, so it understates difficulty against entrenched incumbents and overstates it on thin long-tails. When a SERP's top ten is third-party blog posts, that is the green light.
+
+---
+
+## Content calendar
+
+Ordered by expected impact. "Host" is where the canonical piece lives. IBM Community posts must stand alone as useful to IBM developers; three.ws posts can sell harder.
+
+| # | Piece (working title) | Target query cluster | Host | Why winnable (verified basis) |
+|---|---|---|---|---|
+| 1 | Text to 3D with AI: prompt to embeddable GLB, free, no account | "generate 3D model from text free no account", "embeddable 3D model" | IBM Community + cross-post summary on /blog | Long-tail Meshy's page does not serve; "free, no account" differentiator |
+| 2 | Build an MCP server with paid tools (x402 agent payments) | "MCP server payments", "monetize MCP server", "x402 MCP" | three.ws /blog or docs tutorial | Use-case MCP gap plus thin x402 tooling SERP; we ship `packages/x402-mcp` |
+| 3 | Embed a watsonx/Granite-backed agent in any web page | "embed watsonx agent website", "Granite web agent" | IBM Community | The one verified IBM content gap (host surface beyond Claude Desktop); perfectly on-topic for the host |
+| 4 | Agent payments on Solana: x402 in production (with adoption numbers) | "x402 Solana", "agent payments Solana" | three.ws /blog | Thin co-ranking set (PayAI, Corbits, MCPay.tech); we run x402 rails in production |
+| 5 | Granite Guardian for autonomous agents: allow, review, block | "agent guardrails", "function calling hallucination detection" | IBM Community | Extends (not duplicates) IBM's four Guardian cookbooks with the applied agent/MCP angle. BLOCKED until WATSONX_* env vars are set on Cloud Run and the /ibm showcase decision lands |
+| 6 | MCP server in Rust (or Go): a complete walkthrough | "MCP server Rust tutorial", "MCP server Go example" | three.ws /blog or docs | Verified per-language gap; SERP is all third-party blogs today |
+| 7 | Rigged, animation-ready avatars from a text prompt | "text to 3D avatar rigged", "animation-ready avatar generator" | three.ws /blog | Meshy FAQ territory ends at static models; rigging is our differentiator |
+| 8 | Launch directory / pump.fun cluster piece | TBD | three.ws only, never IBM Community | Cluster unverified; research volumes first. Commit gate applies to any non-$THREE coin references |
+
+Per-post mechanics (IBM Community): keyword front-loaded in the title (it becomes the slug), Meta Title/Description filled, Featured Image = `/api/page-og?v=carbon&...` card, Canonical blank for original posts, canonical to the three.ws original when syndicating. 3-5 deep links per post with descriptive anchors to the specific matching three.ws page.
+
+---
+
+## Open questions (from the research pass, unresolved)
+
+1. Actual volumes/difficulty for the chosen long-tails; nothing tool-measured yet. Worth a Semrush/Ahrefs pull if we get access.
+2. The unexamined competitor SERPs: Tripo/Luma/Spline (3D), ElevenLabs (embeddable agents), Virtuals/ai16z (Solana agent frameworks).
+3. Whether IBM Community posts measurably rank today (i.e. whether Google's independent-section detection fires on community.ibm.com in practice). Test empirically: publish posts 1 and 3, track their SERP positions for their target queries over 4-6 weeks.
+4. Conversion: does traffic from per-language MCP tutorials or x402 tooling queries reach product surfaces? Wire UTM params on deep links (`?utm_source=ibm-community`) so the answer is measurable.
+
+## Verified sources (primary)
+
+- https://www.meshy.ai/features/text-to-3d
+- https://modelcontextprotocol.io/docs/develop/build-server
+- https://solana.com/x402/what-is-x402
+- https://solana.com/docs/payments/agentic-payments
+- https://developer.ibm.com/tutorials/mcp-watsonx/
+- https://developer.ibm.com/components/granite-models/tutorials/
+- https://www.ibm.com/granite/docs/use-cases/all-cookbooks
+- https://www.ibm.com/granite/docs/models/guardian
+- https://github.com/ibm-granite/granite-guardian
+- https://developers.google.com/search/blog/2024/11/site-reputation-abuse
+- https://ahrefs.com/blog/keyword-difficulty/
diff --git a/examples/monicas-apartment/README.md b/examples/monicas-apartment/README.md
new file mode 100644
index 000000000..2a1dda782
--- /dev/null
+++ b/examples/monicas-apartment/README.md
@@ -0,0 +1,31 @@
+# Monica's Apartment (Friends) - first-person Three.js scene
+
+A single, self-contained HTML file that rebuilds the iconic Monica Geller apartment set from Friends as a walkable first-person 3D scene: purple walls, the purple front door with the yellow peephole frame, teal kitchen cabinets, the mismatched dining chairs, the big living-room window onto a lit-up night skyline with balcony and fire-escape railing, all under warm evening lighting.
+
+It answers the community "single HTML apartment" benchmark that has been going around for coding models: one file, no build step, no assets. Every texture (wood floor, oriental rug, city skyline) is generated procedurally on a canvas at load, so the file has zero external dependencies beyond the Three.js module itself.
+
+## Run it
+
+Open the file directly in a browser; no server needed:
+
+```
+open examples/monicas-apartment/index.html
+```
+
+Or from the repo dev server (`npm run dev`, port 3000): `http://localhost:3000/examples/monicas-apartment/index.html`.
+
+Three.js 0.184 loads from the jsDelivr CDN via an import map, so the page needs network access on first load.
+
+## Controls
+
+- Click to enter (pointer lock)
+- WASD or arrow keys to walk, mouse to look
+- Shift to run, Esc to release the pointer
+
+## What's inside (for readers of the code)
+
+- First-person rig: a yaw object containing a pitch object containing the camera; no external controls addon.
+- Movement: axis-separated AABB collision so you slide along furniture instead of sticking to it, with a subtle head-bob.
+- Walls with openings are assembled from box segments (`wallWithOpenings`), which is how the two windows punch through the north wall.
+- Lighting: warm ambient plus five point lights (dining pendant and floor lamp cast shadows) and a cool bluish directional as moonlight through the big window; ACES tone mapping.
+- A `window.__scene.snap(x, y, z, yaw, pitch)` hook exists so headless browsers can position the camera for screenshot verification.
diff --git a/examples/monicas-apartment/index.html b/examples/monicas-apartment/index.html
index 72b000e3d..fa971e678 100644
--- a/examples/monicas-apartment/index.html
+++ b/examples/monicas-apartment/index.html
@@ -71,7 +71,7 @@ const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
-renderer.shadowMap.type = THREE.PCFSoftShadowMap;
+renderer.shadowMap.type = THREE.PCFShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.18;
@@ -89,7 +89,7 @@ pitchRig.add(camera);
const yawRig = new THREE.Object3D();
yawRig.add(pitchRig);
yawRig.position.set(0, 1.62, 3.1);
-yawRig.rotation.y = Math.PI; // face the kitchen and the big window
+yawRig.rotation.y = 0; // face north: kitchen and the big window
scene.add(yawRig);
/* ------------------------------------------------------------------ */
@@ -207,7 +207,7 @@ const M = {
steel: new THREE.MeshStandardMaterial({ color: 0x9aa0a6, roughness: 0.35, metalness: 0.8 }),
woodDark: new THREE.MeshStandardMaterial({ color: 0x5a3a22, roughness: 0.6 }),
woodMid: new THREE.MeshStandardMaterial({ color: 0x8a5c34, roughness: 0.6 }),
- doorPurple:new THREE.MeshStandardMaterial({ color: 0x6b4a86, roughness: 0.7 }),
+ doorPurple:new THREE.MeshStandardMaterial({ color: 0x5c3b7e, roughness: 0.7 }),
doorWood: new THREE.MeshStandardMaterial({ color: 0xcfbfa2, roughness: 0.75 }),
frameYellow:new THREE.MeshStandardMaterial({ color: 0xe8b84b, roughness: 0.5 }),
sofa: new THREE.MeshStandardMaterial({ color: 0xb5806a, roughness: 0.95 }), // dusty rose-tan
@@ -456,10 +456,10 @@ door('z', -HX, 1.2, M.doorWood); // Rachel's room
}
// open shelves with dishes on west wall
for (let s = 0; s < 2; s++) {
- box(0.9, 0.03, 0.26, M.woodMid, -HX + WT / 2 + 0.14, 1.6 + s * 0.42, -1.4, { shadow: false, ry: 0 });
+ box(0.26, 0.03, 0.7, M.woodMid, -HX + WT / 2 + 0.14, 1.6 + s * 0.42, -0.95, { shadow: false });
for (let p = 0; p < 3; p++) {
const plate = new THREE.Mesh(new THREE.CylinderGeometry(0.085, 0.085, 0.09, 14), M.appliance);
- plate.position.set(-HX + WT / 2 + 0.14, 1.67 + s * 0.42, -1.68 + p * 0.28);
+ plate.position.set(-HX + WT / 2 + 0.14, 1.67 + s * 0.42, -1.2 + p * 0.25);
scene.add(plate);
}
}
@@ -591,14 +591,14 @@ function chair(x, z, ry, seatMat) {
const shadeS = new THREE.Mesh(new THREE.CylinderGeometry(0.11, 0.16, 0.2, 16, 1, true), M.lampShade);
shadeS.position.set(3.15, 0.98, -0.6); scene.add(shadeS);
- // floor lamp near the green chair
+ // floor lamp behind the green chair
const stem = new THREE.Mesh(new THREE.CylinderGeometry(0.022, 0.03, 1.45, 10), M.black);
- stem.position.set(-0.5, 0.73, 2.5); scene.add(stem);
+ stem.position.set(-1.25, 0.73, 1.9); scene.add(stem);
const base = new THREE.Mesh(new THREE.CylinderGeometry(0.16, 0.18, 0.04, 16), M.black);
- base.position.set(-0.5, 0.02, 2.5); scene.add(base);
+ base.position.set(-1.25, 0.02, 1.9); scene.add(base);
const shade = new THREE.Mesh(new THREE.CylinderGeometry(0.14, 0.2, 0.28, 16, 1, true), M.lampShade);
- shade.position.set(-0.5, 1.56, 2.5); scene.add(shade);
- addCollider(-0.68, -0.32, 2.32, 2.68);
+ shade.position.set(-1.25, 1.56, 1.9); scene.add(shade);
+ addCollider(-1.43, -1.07, 1.72, 2.08);
}
/* ------------------------------------------------------------------ */
@@ -668,7 +668,7 @@ function chair(x, z, ry, seatMat) {
// floor lamp light
const fl = new THREE.PointLight(0xffb46e, 26, 10, 2);
- fl.position.set(-0.5, 1.6, 2.5);
+ fl.position.set(-1.25, 1.6, 1.9);
fl.castShadow = true;
fl.shadow.mapSize.set(1024, 1024);
fl.shadow.bias = -0.004;
@@ -728,11 +728,12 @@ function blocked(x, z) {
return false;
}
-const clock = new THREE.Clock();
+const timer = new THREE.Timer();
let bobT = 0;
function tick() {
- const dt = Math.min(clock.getDelta(), 0.05);
+ timer.update();
+ const dt = Math.min(timer.getDelta(), 0.05);
if (playing) {
const run = keys['ShiftLeft'] || keys['ShiftRight'];
diff --git a/workers/model-hunyuan3d/Dockerfile.hunyuan21rtx b/workers/model-hunyuan3d/Dockerfile.hunyuan21rtx
new file mode 100644
index 000000000..9816366bd
--- /dev/null
+++ b/workers/model-hunyuan3d/Dockerfile.hunyuan21rtx
@@ -0,0 +1,98 @@
+# Hunyuan3D-2.1 PBR worker, RTX PRO 6000 (Blackwell) build.
+#
+# Same application as Dockerfile.hunyuan21 (app21.py), rebuilt for the
+# NVIDIA RTX PRO 6000 lane on Cloud Run: Blackwell is compute capability 12.0,
+# which the cu124 stack in the L4 image cannot target (CUDA gained sm_120 in
+# 12.8). This variant moves the base to CUDA 12.8 and torch to 2.7.1/cu128,
+# whose wheels ship native sm_120 kernels. TORCH_CUDA_ARCH_LIST compiles the
+# in-tree extensions for BOTH 8.9 (L4) and 12.0 (RTX PRO 6000) so one image
+# can serve either GPU type.
+FROM nvidia/cuda:12.8.1-devel-ubuntu22.04
+
+ENV PYTHONDONTWRITEBYTECODE=1 \
+ PYTHONUNBUFFERED=1 \
+ PIP_NO_CACHE_DIR=1 \
+ DEBIAN_FRONTEND=noninteractive \
+ TORCH_CUDA_ARCH_LIST="8.9;12.0+PTX" \
+ CUDA_NVCC_FLAGS="-allow-unsupported-compiler" \
+ CUDA_HOME=/usr/local/cuda \
+ PYOPENGL_PLATFORM=egl
+
+# System libs: build toolchain for the extensions, plus the GL/EGL/X stack that
+# headless Blender (bpy, imported by DifferentiableRenderer.mesh_utils) and the
+# EGL rasterizer link against at import/runtime.
+RUN apt-get update && apt-get install -y --no-install-recommends \
+ python3.10 python3.10-dev python3-pip \
+ git curl wget build-essential ninja-build cmake pkg-config \
+ libeigen3-dev \
+ libgl1 libglib2.0-0 libegl1 libgles2 libglvnd0 libglvnd-dev \
+ libgl1-mesa-dev libegl1-mesa-dev libgles2-mesa-dev \
+ libxrender1 libxi6 libsm6 libxext6 libxkbcommon0 libxfixes3 \
+ && rm -rf /var/lib/apt/lists/* \
+ && ln -sf /usr/bin/python3.10 /usr/bin/python3 \
+ && ln -sf /usr/bin/python3.10 /usr/bin/python \
+ && pip install --upgrade pip setuptools wheel
+
+# torch first (cached layer), from the CUDA 12.8 wheel index to match the base.
+# 2.7.1/cu128 is the first stable torch line with native sm_120 (Blackwell).
+RUN pip install torch==2.7.1 torchvision==0.22.1 torchaudio==2.7.1 \
+ --index-url https://download.pytorch.org/whl/cu128
+
+COPY requirements.hunyuan21.txt /app/requirements.txt
+RUN pip install -r /app/requirements.txt
+
+# Blender's `bpy` has no cp310 PyPI wheel and is only reached through the unused
+# save_glb OBJ->GLB exporter in DifferentiableRenderer.mesh_utils. Drop a tiny
+# stub module so the top-level `import bpy` in that file resolves; this worker
+# assembles the PBR GLB with pygltflib and never calls a bpy function.
+RUN python - <<'PY'
+import os, sysconfig
+dest = os.path.join(sysconfig.get_paths()["purelib"], "bpy.py")
+with open(dest, "w") as f:
+ f.write("# stub: real Blender bpy is only needed for the unused save_glb "
+ "OBJ->GLB exporter. This worker builds the PBR GLB with pygltflib.\n")
+print("wrote bpy stub to", dest)
+PY
+
+# The 2.1 code (hy3dshape + hy3dpaint packages) is cloned in-tree from a pinned
+# Tencent-Hunyuan/Hunyuan3D-2.1 commit: the texgen extensions must be compiled
+# from this tree, and a moving `main` breaks the reproducibility bar. Build the
+# CUDA rasterizer (editable, so its .so lives in-tree) and the pybind11 mesh
+# inpaint processor, then fetch the RealESRGAN super-res checkpoint the paint
+# pass upscales its PBR views with.
+RUN git clone https://github.com/Tencent-Hunyuan/Hunyuan3D-2.1.git /opt/hunyuan3d21 \
+ && cd /opt/hunyuan3d21 \
+ && git checkout 82920d643c0dc2f7bfd7255f45f62d386edfe60c \
+ && cd hy3dpaint/custom_rasterizer \
+ && pip install --no-build-isolation -e . \
+ && cd ../DifferentiableRenderer \
+ && bash compile_mesh_painter.sh \
+ && cd /opt/hunyuan3d21/hy3dpaint \
+ && mkdir -p ckpt \
+ && wget -q https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth -P ckpt
+
+# Fail the BUILD (not a live deploy) if the dependency stack drifts: every
+# import the loader pulls before it touches the GPU must resolve. CUDA is not
+# initialised here (no GPU at build), so the smoke test stays to pure-python +
+# .so loads and skips modules that init CUDA on import.
+RUN cd /opt/hunyuan3d21 && python -c "\
+import sys; sys.path.insert(0,'.'); sys.path.insert(0,'hy3dshape'); sys.path.insert(0,'hy3dpaint'); \
+import torch, torchvision, transformers, diffusers, trimesh, bpy, cv2, pygltflib, custom_rasterizer; \
+from torchvision_fix import apply_fix; apply_fix(); \
+from hy3dshape.pipelines import Hunyuan3DDiTFlowMatchingPipeline; \
+from hy3dpaint.convert_utils import create_glb_with_pbr_materials; \
+print('deps ok:', torch.__version__, torchvision.__version__, transformers.__version__, diffusers.__version__)"
+
+# The worker runs from the repo root: the paint config references cfg/ckpt files
+# by repo-relative path, so cwd must be /opt/hunyuan3d21.
+WORKDIR /opt/hunyuan3d21
+COPY worker_security.py /opt/hunyuan3d21/worker_security.py
+COPY app21.py /opt/hunyuan3d21/app21.py
+
+EXPOSE 8080
+
+CMD ["uvicorn", "app21:app", \
+ "--host", "0.0.0.0", \
+ "--port", "8080", \
+ "--workers", "1", \
+ "--timeout-keep-alive", "300"]
diff --git a/workers/model-hunyuan3d/README.md b/workers/model-hunyuan3d/README.md
index f357edf3b..122b61eb1 100644
--- a/workers/model-hunyuan3d/README.md
+++ b/workers/model-hunyuan3d/README.md
@@ -10,6 +10,7 @@ Cloud Run services**, because their Python stacks are mutually incompatible
|---|---|---|---|---|
| `model-hunyuan3d` | Hunyuan3D-2.0 | [`main.py`](./main.py) | [`Dockerfile`](./Dockerfile) | single baked diffuse texture |
| `model-hunyuan3d-21` | **Hunyuan3D-2.1** | [`app21.py`](./app21.py) | [`Dockerfile.hunyuan21`](./Dockerfile.hunyuan21) | **PBR: baseColor + metallicRoughness + normal** |
+| `model-hunyuan3d-21-rtx` | **Hunyuan3D-2.1** | [`app21.py`](./app21.py) | [`Dockerfile.hunyuan21rtx`](./Dockerfile.hunyuan21rtx) | same PBR set, on **RTX PRO 6000 (Blackwell)** |
**2.1 is the realism lane.** It runs the `hy3dshape` shape DiT, then the
`hy3dpaint` PBR paint pass (multiview PBR diffusion → RealESRGAN super-res →
@@ -20,9 +21,21 @@ in the platform's own GPU fleet. 2.0 remains deployed and untouched as the
instant fallback lane: to roll back, repoint `GCP_HUNYUAN3D_URL` at the
`model-hunyuan3d` service URL — no rebuild.
-Both services speak the **same wire contract**, so either URL drops straight
+All three services speak the **same wire contract**, so any URL drops straight
into the platform's `GCP_HUNYUAN3D_URL` env.
+**Why an RTX build exists.** All L4 services in us-central1 share one quota of
+3 GPUs, and the fleet is permanently at that ceiling; the RTX PRO 6000 quota in
+the same region is granted at 1000. `Dockerfile.hunyuan21rtx` is the same
+app21.py on a CUDA 12.8 / torch 2.7.1 (cu128) stack, because Blackwell is
+compute capability 12.0 and the cu124 wheels in the L4 image ship no sm_120
+kernels. Its extensions compile for both 8.9 and 12.0, so the RTX image also
+runs on an L4 if ever needed. Deploy with
+[`cloudbuild.hunyuan21rtx.yaml`](./cloudbuild.hunyuan21rtx.yaml) (BuildKit,
+inline layer cache); platform minimums for the GPU type are 20 CPU / 80 Gi. The
+RTX service runs warm (min 1, max 4) as the 2.1 primary; the L4 build stays
+deployed at min 0 as the instant fallback.
+
## License
Hunyuan3D-2.1 is released under the **TENCENT HUNYUAN NON-COMMERCIAL LICENSE
diff --git a/workers/model-hunyuan3d/app21.py b/workers/model-hunyuan3d/app21.py
index b5bb73344..024791c01 100644
--- a/workers/model-hunyuan3d/app21.py
+++ b/workers/model-hunyuan3d/app21.py
@@ -71,7 +71,6 @@ from concurrent.futures import ThreadPoolExecutor
from contextlib import asynccontextmanager
from typing import Optional
-import torch
from fastapi import FastAPI, HTTPException, Header, BackgroundTasks
from google.api_core.exceptions import NotFound
from google.cloud import storage
@@ -200,6 +199,13 @@ def _quality_for(tier: str | None) -> dict:
def _load_pipeline():
global _pipeline
+ # torch is imported HERE, not at module scope: importing it cold reads
+ # multi-GiB CUDA libraries off the streamed image filesystem and can eat
+ # most of Cloud Run's hard 240s startup-probe ceiling. Keeping module
+ # import light means uvicorn binds the port in seconds, deterministically;
+ # this loader already runs off the request path in a worker thread.
+ import torch # noqa: F401 (heavyweight import deferred to the load thread)
+
# The 2.1 repo is cloned to REPO_ROOT in the image and expects its two
# package dirs on sys.path plus cwd==REPO_ROOT (the paint config references
# cfg/ckpt files by repo-relative path). The Dockerfile sets WORKDIR there.
@@ -503,11 +509,15 @@ async def get_task(task_id: str, authorization: str = Header(...)) -> dict:
@app.get("/health")
async def health() -> dict:
+ # torch imports lazily in the loader thread; before it lands, report the
+ # GPU as unknown rather than blocking the health endpoint on the import.
+ torch = sys.modules.get("torch")
+ gpu = bool(torch and torch.cuda.is_available())
return {
"ok": True,
"model": MODEL_LABEL,
- "gpu_available": torch.cuda.is_available(),
- "gpu_name": torch.cuda.get_device_name(0) if torch.cuda.is_available() else None,
+ "gpu_available": gpu if torch else None,
+ "gpu_name": torch.cuda.get_device_name(0) if gpu else None,
"pipeline_loaded": _pipeline is not None,
"ready": bool(_ready and _ready.is_set()),
"load_error": _load_error,
diff --git a/workers/model-hunyuan3d/cloudbuild.hunyuan21.yaml b/workers/model-hunyuan3d/cloudbuild.hunyuan21.yaml
index 9ff3536dd..6ff4a97ec 100644
--- a/workers/model-hunyuan3d/cloudbuild.hunyuan21.yaml
+++ b/workers/model-hunyuan3d/cloudbuild.hunyuan21.yaml
@@ -5,11 +5,12 @@ substitutions:
_REPO: model-hunyuan3d-21
_GCS_BUCKET: three-ws-avatar-reconstructions
_WEIGHTS_BUCKET: three-ws-model-weights
- # min=1: the 2.1 shape DiT (6.9 GiB .ckpt) + paint UNet (3.7 GiB) + DINOv2
- # stage ~18 GiB from GCS and load in minutes; keep one instance warm so no
- # request ever pays that. GCP credit budget covers the always-on GPU-hour.
+ # min=0: this L4 build is the FALLBACK for the 2.1 lane; the warm primary is
+ # model-hunyuan3d-21-rtx (see cloudbuild.hunyuan21rtx.yaml), which runs on
+ # RTX PRO 6000 where the project quota is 1000 GPUs vs 3 L4s. A pinned L4
+ # here starved trellis/unirig/triposg rollouts of the 3-GPU regional budget.
# max=1: one L4 fits exactly one in-flight generation.
- _MIN_INSTANCES: "1"
+ _MIN_INSTANCES: "0"
_MAX_INSTANCES: "1"
steps:
diff --git a/workers/model-hunyuan3d/cloudbuild.hunyuan21rtx.yaml b/workers/model-hunyuan3d/cloudbuild.hunyuan21rtx.yaml
new file mode 100644
index 000000000..15edada90
--- /dev/null
+++ b/workers/model-hunyuan3d/cloudbuild.hunyuan21rtx.yaml
@@ -0,0 +1,97 @@
+substitutions:
+ _REGION: us-central1
+ _RUN_SA: avatar-reconstruction-sa@aerial-vehicle-466722-p5.iam.gserviceaccount.com
+ _SERVICE: model-hunyuan3d-21-rtx
+ _REPO: model-hunyuan3d-21
+ _GCS_BUCKET: three-ws-avatar-reconstructions
+ _WEIGHTS_BUCKET: three-ws-model-weights
+ # The RTX PRO 6000 lane: Cloud Run's Blackwell GPU tier, where the project's
+ # quota is granted at 1000 (vs 3 for L4). Platform minimums for this GPU type
+ # are 20 CPU / 80Gi memory. min=1 keeps one instance warm so no request pays
+ # the ~18 GiB weight stage; max=4 gives real parallel PBR capacity.
+ _MIN_INSTANCES: "1"
+ _MAX_INSTANCES: "4"
+
+steps:
+ # Warm the layer cache: --cache-from only consults images already present on
+ # the builder, so pull rtx-latest first (tolerating its absence on the very
+ # first build) or every rebuild recompiles the CUDA extensions from scratch.
+ - id: pull-cache
+ name: gcr.io/cloud-builders/docker
+ entrypoint: bash
+ args:
+ - -c
+ - docker pull ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/server:rtx-latest || exit 0
+
+ - id: build
+ name: gcr.io/cloud-builders/docker
+ dir: workers/model-hunyuan3d
+ env:
+ # The bpy-stub step uses a heredoc (RUN python - <<'PY'), which only the
+ # BuildKit frontend parses; the legacy builder dies on it.
+ - DOCKER_BUILDKIT=1
+ args:
+ - build
+ - --file
+ - Dockerfile.hunyuan21rtx
+ # Embed cache metadata so the NEXT build's --cache-from can reuse layers
+ # (BuildKit images carry no cache manifest without this).
+ - --build-arg
+ - BUILDKIT_INLINE_CACHE=1
+ - --tag
+ - ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/server:rtx-$SHORT_SHA
+ - --tag
+ - ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/server:rtx-latest
+ - --cache-from
+ - ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/server:rtx-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:rtx-$SHORT_SHA
+ - --region=${_REGION}
+ - --service-account=${_RUN_SA}
+ - --platform=managed
+ - --port=8080
+ - --gpu=1
+ - --gpu-type=nvidia-rtx-pro-6000
+ - --no-gpu-zonal-redundancy
+ - --no-cpu-throttling
+ - --cpu=20
+ - --memory=80Gi
+ - --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};HUNYUAN3D_MODEL=2.1;WEIGHTS_DIR=/weights/hunyuan3d-2.1;WEIGHTS_GCS_URI=gs://${_WEIGHTS_BUCKET}/hunyuan3d-2.1;WEIGHTS_LOCAL_DIR=/tmp/hunyuan3d-2.1;DINO_DIR=/weights/dinov2-giant;DINO_GCS_URI=gs://${_WEIGHTS_BUCKET}/dinov2-giant;DINO_LOCAL_DIR=/tmp/dinov2-giant;MAX_CONCURRENT=1
+ - --set-secrets=API_KEY=avatar-reconstruction-key:latest
+
+images:
+ - ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/server:rtx-$SHORT_SHA
+ - ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_REPO}/server:rtx-latest
+
+options:
+ machineType: E2_HIGHCPU_32
+ logging: CLOUD_LOGGING_ONLY
+
+# The project's default compute service account was deleted (see
+# docs/ops/gcp-production.md): every Cloud Build must pin the build SA
+# explicitly or the submit fails with "Unknown service account".
+serviceAccount: projects/aerial-vehicle-466722-p5/serviceAccounts/[email protected]
+
+# Full cold build compiles torch extensions for two CUDA archs; give it room.
+timeout: 7200s