# Wan Video on remote RTX A5000 over Tailscale

Use this when the user has a capable NVIDIA GPU outside the Hermes VM and wants Hermes to drive local/open-source video generation through ComfyUI.

## Recommended baseline for 16 GB VRAM

For an RTX A5000 Laptop GPU with 16 GB VRAM, start conservative:

- ComfyUI local on the GPU host, exposed only through Tailscale.
- `ComfyUI-WanVideoWrapper` custom node.
- Wan 2.1 T2V 1.3B FP8 as first model, not 14B/27B.
- Wan VAE BF16.
- UMT5 XXL FP8 text encoder.
- 480p or smaller smoke tests first; avoid jumping to 720p/long clips.

Model paths used by the wrapper:

- Transformer: `ComfyUI/models/diffusion_models/`
- Text encoder: `ComfyUI/models/text_encoders/`
- VAE: `ComfyUI/models/vae/`
- Clip vision: `ComfyUI/models/clip_vision/` (only needed for image-to-video/reference workflows)

## Current Hugging Face CLI syntax

`huggingface-cli download` may be deprecated. Prefer `hf download`:

```bash
hf download Kijai/WanVideo_comfy \
  Wan2_1-T2V-1_3B_fp8_e4m3fn.safetensors \
  --local-dir ~/ai/ComfyUI/models/diffusion_models

hf download Kijai/WanVideo_comfy \
  Wan2_1_VAE_bf16.safetensors \
  --local-dir ~/ai/ComfyUI/models/vae

hf download Kijai/WanVideo_comfy \
  umt5-xxl-enc-fp8_e4m3fn.safetensors \
  --local-dir ~/ai/ComfyUI/models/text_encoders
```

If access/throttling fails, run `hf auth login` and retry.

## Tailscale launch pattern

Bind ComfyUI to the Tailscale IP rather than a public interface where possible:

```bash
cd ~/ai/ComfyUI
source .venv/bin/activate
TS_IP="$(tailscale ip -4 | head -n1)"
python main.py --listen "$TS_IP" --port 8188 --lowvram
```

If `--lowvram` is not recognized, omit it. If binding to the Tailscale IP fails, use `--listen 0.0.0.0` only with firewall restricted to `tailscale0`.

Health check from Hermes or another Tailscale peer:

```bash
curl "http://TAILSCALE_IP:8188/system_stats"
```

Expected signs:

- `devices[0].type == "cuda"`
- GPU name includes RTX A5000 or target GPU
- VRAM visible/free
- ComfyUI version and PyTorch CUDA build present

## API validation pattern

After connectivity, query `/object_info` before submitting workflows:

- Confirm `WanVideoModelLoader`, `LoadWanVideoT5TextEncoder`, `WanVideoTextEncode`, `WanVideoEmptyEmbeds`, `WanVideoSampler`, `WanVideoVAELoader`, `WanVideoDecode`, `CreateVideo`, and `SaveVideo` exist.
- Inspect model dropdowns in `/object_info` to verify filenames are discovered. This catches wrong model folders before a long job starts.
- Submit a tiny smoke workflow first: e.g. 144x256, 13 frames, 4 steps, then scale up.

## Common failure mode: process disappears during first Wan load

If the API accepts a Wan prompt with `node_errors: {}` but ComfyUI becomes `Connection refused` shortly after, treat it as likely process crash/kill. On 16 GB VRAM systems the cause may be system RAM pressure, especially when UMT5 loads while llama.cpp/Ollama/browser/IDE are also running.

Ask the user on the GPU host to run:

```bash
free -h
ps aux --sort=-%mem | head -20
```

Then stop competing model servers temporarily, e.g.:

```bash
pkill -f llama || true
ollama stop --all 2>/dev/null || true
sudo systemctl stop ollama 2>/dev/null || true
```

Restart ComfyUI with `--lowvram` if supported and retry a smaller smoke workflow. Capture terminal logs or `journalctl -u comfyui -n 120 --no-pager` if run as a service.

## Integration shape for AutoShorts/remote rendering

Use ComfyUI as the GPU video clip generator and keep Hermes/AutoShorts as orchestrator:

1. Generate shot prompts and negative prompts in Hermes.
2. Submit Wan/ComfyUI jobs via Tailscale `/prompt` API.
3. Download outputs from ComfyUI history/view endpoints.
4. Store clips under project import paths like `data/imported_ai_clips/<video_id>/scene_01.mp4`.
5. Let local deterministic renderer add mechanism layers, captions, SFX and final FFmpeg assembly.

Do not make paid provider APIs the default when the user has a capable local GPU and asked for free/local production.