Spark GPU Backend¶
Configuration¶
geoembed.backends.spark.config
¶
Configuration for the full-image GPU embedding pipeline.
EmbeddingsConfig(chip_size=224, batch_size=256, mixed_precision=True, model_name='dofa')
dataclass
¶
Configuration for the full-image GPU embedding pipeline.
The pipeline reads entire COGs, tiles on GPU via torch.unfold(), and runs batched inference — no per-chip I/O.
Attributes:
| Name | Type | Description |
|---|---|---|
chip_size |
int
|
Square chip dimension in pixels (224 for DOFA). |
batch_size |
int
|
Inference batch size within each image (tune for VRAM). |
mixed_precision |
bool
|
Use FP16 autocasting for faster inference. |
model_name |
str
|
Registered model name (default "dofa"). |
Pipeline Orchestrator¶
geoembed.backends.spark.orchestrator
¶
Spark-based full-image GPU embedding pipeline.
Distributes COG images across GPU workers via Spark mapInPandas. Each worker reads a full image, tiles on GPU via torch.unfold(), runs batched inference, and returns embeddings + spatial bounds.
Double-buffered I/O within each worker hides read latency behind GPU compute. Uses Spark's native GPU resource scheduling (spark.task.resource.gpu.amount).
EmbeddingsPipeline(config, input_storage, output_storage)
¶
Full-image GPU embedding pipeline distributed via Spark mapInPandas.
Each Spark task: 1. Receives a batch of image paths 2. Reads full COGs, tiles on GPU, runs inference (with double-buffering) 3. Returns embeddings + spatial bounds
Spark handles multi-node GPU distribution via spark.task.resource.gpu.amount = 1.
Usage
from geoembed.backends.spark.config import EmbeddingsConfig from geoembed.backends.spark.orchestrator import EmbeddingsPipeline from geoembed.core.config import StorageConfig
config = EmbeddingsConfig(chip_size=224, batch_size=256, mixed_precision=True) pipeline = EmbeddingsPipeline( config=config, input_storage=StorageConfig(backend="delta", path="catalog.schema.metadata"), output_storage=StorageConfig(backend="delta", path="catalog.schema.embeddings"), ) pipeline.run()
Source code in src/geoembed/backends/spark/orchestrator.py
run()
¶
Execute the full-image GPU embedding pipeline via Spark.
Source code in src/geoembed/backends/spark/orchestrator.py
GPU Worker¶
geoembed.backends.spark.worker
¶
Full-image GPU worker — reads COG, tiles on GPU, runs inference.
Single Ray actor that processes one image at a time: 1. Read full COG to CPU (via rasterio) — in background thread for double-buffering 2. Transfer to GPU as float32 tensor 3. Tile via torch.unfold() (zero-copy views, ~0ms) 4. Batch inference with DOFA (mixed precision) 5. Compute spatial bounds from affine transform (pure arithmetic) 6. Return Arrow table with embeddings + spatial metadata
Double-buffering: reads the next image while GPU processes the current one, hiding ~2.7s I/O latency behind ~3.2s GPU compute.
FullImageGPUWorker(chip_size=224, batch_size=256, mixed_precision=True, model_name='dofa')
¶
Ray MapBatches actor: full-image read → GPU tile → inference → Arrow output.
Processes images one at a time with double-buffered I/O. Each call receives a batch of image paths and returns an Arrow table with all chip embeddings and spatial bounds.
Source code in src/geoembed/backends/spark/worker.py
__call__(batch)
¶
Entry point for Ray map_batches.
Receives a batch of image paths, processes each with double-buffered I/O, returns a combined Arrow table with all chip embeddings + spatial metadata.