Skip to main content

A Triton implementation of greedy submodular algorithms using fused GPU kernels

Project description

Triton Implementation of Greedy Optimization of Submodular Functions

This is a python-only implementation of submodlib and apricot.

This library provides fused kernels for every (function, optimizer) pair available by dynamically generating them.

Installation

pip install triton_submodular

or with uv,

As a package dependency:

uv add triton_submodular

For a venv:

uv pip install triton_submodular

For older GPUs (like pascal), you need to specify the cu126 wheel for pytorch:

uv pip install triton_submodular --torch-backend=cu126

Features

  • Functions:
    • Facility Location
    • Graph Cut
    • Feature Based
    • Max Coverage
  • Optimizers:
    • Naive Greedy
    • Stochastic Greedy
    • Lazy Greedy

Example Usage

import torch
from triton_submodular.functions import FacilityLocation

X = torch.randn(100, 10, device="cuda", dtype=torch.float32)

fn = FacilityLocation(X) # generates euclidean similarity matrix by default

indices, gains = fn.maximize(10, "LazyGreedyTriton")

X_subset = X[indices]

This will take the data (100 points, 10 dimensional) and greedy select 10 points using the lazy greedy optimizer which tries to maximize the facility location function.

Testing

Clone and run uv run -p 3.9 pytest -n auto. Requires a GPU with CUDA support.

Deterministic optimizers are tested to be 1:1 against both apricot and submodlib's implementations. Random algorithms (currently only stochastic greedy) are only tested against apricot, as submodlib uses C's rand() function, making reproduction difficult.

NOTE: The stochastic greedy optimizer with the graphcut function currently does not match 1:1 to apricot's implementation.

Roadmap

  • Benchmarks and optimizations
  • Add more submodular functions
  • Add more optimizers
  • Add more similarity metrics to graph functions that require a similarity matrix
  • Add knapsack constraints
  • Add sparse matrix support (maybe)
  • Add streaming optimization (maybe)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

triton_submodular-0.1.0a1.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

triton_submodular-0.1.0a1-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file triton_submodular-0.1.0a1.tar.gz.

File metadata

  • Download URL: triton_submodular-0.1.0a1.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"21.3","id":"virginia","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for triton_submodular-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 3548f0bbc0d8f7a676ef2f669219caa6e44a83cbeabd4ce28cfd5fc474d5090d
MD5 0a30cfb2aefd7aa4b20556135ad7cf9e
BLAKE2b-256 52305c7b595af7bb2ba1d43b25e0740ddcb5d4f5eee8def4f15785299b053045

See more details on using hashes here.

File details

Details for the file triton_submodular-0.1.0a1-py3-none-any.whl.

File metadata

  • Download URL: triton_submodular-0.1.0a1-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"21.3","id":"virginia","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for triton_submodular-0.1.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 0450f4aa4dde41c40c0928ebf577d4a51e294efd196716feb54ddd08c5f894d8
MD5 b096c0692be8872ced85b22c942589d3
BLAKE2b-256 48119a9fe96923de313b80d097664fd0c00232d4801bea55f23715433c752613

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page