# Large Image Embedding E2E Suite

End-to-end tests for running a base64-image decoding + ViT inference pipeline on
Geneva. This suite is adapted from Ray's nightly benchmark: [large_image_embedding](https://github.com/ray-project/ray/tree/master/release/nightly_tests/multimodal_inference_benchmarks/large_image_embedding).

## Pipeline (Geneva)

1. Decode base64 image bytes and extract width/height → `decoded` (pa.struct)
2. ViT preprocessing (resize/rescale/normalize) → `preprocessed` (3x224x224 float32)
3. Run ViT inference → `vit_logits` (1000-dim)

UDF implementations live in `src/geneva/udfs/image/vit_image.py`.
The suite-level uploader `upload_manifests.py` uses the `udfs/vit_image`
profile env/manifest factory and uploads `large-image-embedding-udfs-v1`.

## Running Tests

From the workspace root:

```bash
uv sync --all-groups --all-extras --locked
make -f e2e/Makefile test-e2e-large-image-embedding-gcp SLUG=myrun NUM_LARGE_IMAGES=20 BATCH_SIZE=4
```

Or directly from the suite directory:

```bash
cd e2e/large_image_embedding
RAY_ENABLE_UV_RUN_RUNTIME_ENV=0 uv run -m pytest -c ../pytest.ini test_drivers \
  --csp=gcp --num-images=20 --batch-size=4 -v
```

## Running Benchmark (geneva_main)

This runs the benchmark driver used by the GitHub Actions workflow
`E2E Bench - Large Image Embedding`.

From the workspace root:

```bash
uv sync --all-groups --all-extras --locked
make bench-e2e-large-image-embedding-gcp SLUG=myrun NUM_BENCH_IMAGES=300
```

Key knobs:
- `NUM_BENCH_IMAGES`: total prompts/images to process (clamped to 7358)
- `MIN_CHECKPOINT_SIZE` / `MAX_CHECKPOINT_SIZE`: adaptive checkpoint sizing bounds (defaults 1/512)
- `NUM_WORKERS`: Ray worker replicas (default 5)
- `INTRA_APPLIER_CONCURRENCY`: threads per worker process (default 1)
- `DATASET_PATH`: use an existing `gs://.../table` or `s3://.../table`
- `FRESH_RUN=0`: do not delete checkpoints (default is fresh)

Notes:
- Backfill uses `num_frags = max(1, num_images // 300)` (with `300 = PROMPT_FRAG_ROWS`).
- If `DATASET_PATH` is set, existing derived columns are dropped before backfill.
