Skip to main content

lit-deltalake

Build Documentation

Docs with MkDocs uv linting: ruff ty prek security: bandit Semantic Versions Copier SPEC 0 — Minimum Supported Dependencies License

Bring Delta Lake to Pytorch Lightning

Features

  • Stream immutable Delta table snapshots into PyTorch IterableDataset instances.
  • Shard Delta-rs source fragments across initialized DDP ranks and DataLoader workers.
  • Use Delta-rs, an existing PySpark session, or an existing Sail Spark Connect session.
  • Select, filter, transform, decode, and rename columns before training.
  • Pin Delta table versions for reproducible training data.

Installation

Install the default Delta-rs and PyArrow reader:

uv add lit-deltalake

Add an optional reader when needed:

uv add "lit-deltalake[spark]"  # existing PySpark session
uv add "lit-deltalake[sail]"   # existing Sail Spark Connect session

With pip:

python -m pip install lit-deltalake

Usage

from lit_deltalake.dataloaders import create_pytorch_dataloader
from lit_deltalake.readers.types import Filter
import lightning
import torch
from torch import nn
from torch.utils.data import DataLoader


loader = create_pytorch_dataloader(
    "/path/to/training-table",
    columns=("feature_a", "feature_b", "label"),
    filters=(Filter("split", lambda column, value: column == value, "train"),),
    batch_size=128,
    num_workers=4,
    multiprocessing_context="spawn",
)


class EventsDataModule(lightning.LightningDataModule):
    def __init__(self) -> None:
        super().__init__()
        self.loader = loader

    def train_dataloader(self) -> DataLoader:
        return self.loader


class Classifier(lightning.LightningModule):
    def __init__(self, learning_rate: float = 1e-3) -> None:
        super().__init__()
        self.model = nn.Linear(2, 2)
        self.learning_rate = learning_rate
        self.loss_function = nn.CrossEntropyLoss()

    def forward(self, features: torch.Tensor) -> torch.Tensor:
        return self.model(features)

    def training_step(self, batch: dict[str, torch.Tensor], batch_idx: int) -> torch.Tensor:
        del batch_idx
        features = torch.stack((batch["feature_a"], batch["feature_b"]), dim=1).float()
        labels = batch["label"]
        loss = self.loss_function(self(features), labels)
        self.log("train_loss", loss)
        return loss

    def configure_optimizers(self) -> torch.optim.Optimizer:
        return torch.optim.AdamW(self.parameters(), lr=self.learning_rate)


trainer = lightning.Trainer(max_epochs=10)
trainer.fit(Classifier(), datamodule=EventsDataModule())

Examples

See examples and notebooks for more usage examples.

Docs

uv run mkdocs build -f ./mkdocs.yml -d ./_build/

Update template

copier update --trust -A --vcs-ref=HEAD

Credits

This project was generated with 🚀 python project template.

Metadata

Release files for lit-deltalake 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lit-deltalake 0.0.1
File Size Uploaded
lit_deltalake-0.0.1.tar.gz 17.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lit-deltalake 0.0.1
File Interpreter ABI Platform
lit_deltalake-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 41.6 kB

Release files / lit_deltalake-0.0.1.tar.gz

Download URL lit_deltalake-0.0.1.tar.gz
Size 17.7 kB
Tags Source
SHA-256 checksum
How to use checksums
20e1bb6b9cc83a6a41aafbbd27642276a9bf224e5c7ad20dcc458d258f88a3d4
BLAKE2b-256 checksum
How to use checksums
549c158dbd85a37235f718af797986899d8d07ff4b4ca9ae68ac61b6c477af39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.16 {"installer":{"name":"uv","version":"0.12.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / lit_deltalake-0.0.1-py3-none-any.whl

Download URL lit_deltalake-0.0.1-py3-none-any.whl
Size 23.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d835c3bec60128b741165b83a462762df30190a6cd8934cc87af2260036dd0ec
BLAKE2b-256 checksum
How to use checksums
d272952ebdfbb08f5757620bbf9775da04be621936f94ea8b0dca36669a68c9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.16 {"installer":{"name":"uv","version":"0.12.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page