algenta-graph

Graph, network and automata kernels. Compiled Mojo, loaded in-process.

23 modules · 252 functions · CPU

Get started

pip install kernels torch
from kernels import get_kernel

kernel = get_kernel(
    "thyn-ai/algenta-graph",
    version=1,
    backend="cpu",
    trust_remote_code=["thyn-ai/algenta-graph"],
)
kernel.topology.euler_characteristic(4, 6, 4)  # -> 2  Euler characteristic V - E + F

backend="cpu" selects the CPU build. On a Mac the loader otherwise looks for a Metal build, which this family does not ship. trust_remote_code names the repositories you allow; Hugging Face's trusted publishers load without it.

Plain Python in, plain Python out. Lists, tuples, buffers and tensors are accepted wherever the contract expects a list; structured results are dictionaries. Some functions take a list and the number of elements to use from it, which may not exceed the list's length; multi-dimensional data is passed flattened, row-major, with its dimensions. Functions that update an argument do so in place, as help() says. Every call is checked against the published contract before it reaches native code. An invalid call raises KernelError with a stable code, never a crash. Engine kernels report shape and finiteness problems as a status; the wrapper raises KernelError named after it.

Any function can also be called by name, with args as a list or a dict of parameter names:

kernel.execute("graph.algorithms", "bfs", [...])

What's inside

Module Functions What it does
autograd_graph 10 Autodiff step formulas: gradient accumulation, JVP and VJP terms, loss scaling, norm clipping
cartography 12 Map scale and representative fraction, UTM zone, Mercator and equirectangular, great circles
cellular_automata 10 Cellular automata: Wolfram elementary rules, Game of Life, totalistic rules, Langton's ant
chromatography 10 Chromatography: retention factor, selectivity, plate count, resolution, van Deemter, Kovats
crystallography 12 Crystallography: Bragg angle, cubic d-spacing, cell volumes, packing factors, Scherrer size
demographics 12 Demographic rates: crude birth and death, fertility, infant mortality, dependency, doubling
graph.algorithms 8 Adjacency-list graphs: Dijkstra, BFS, DFS, Kahn topological sort, connected components, paths
graph.weighted 9 Weighted edge lists: Kruskal spanning tree, Floyd-Warshall, Bellman-Ford, Dijkstra, union-find
graph_algorithms 10 Per-step network formulas: edge relaxation, PageRank step, centralities, clustering, density
graph_analytics.adjacency 35 Compressed sparse row graphs: build, validate, degrees, reverse, dedupe, Dijkstra, BFS levels
graph_analytics.centrality 9 Centrality on sparse graphs: Brandes betweenness, closeness, harmonic, eigenvector, PageRank
graph_analytics.community 19 Community detection: multi-level Louvain, label propagation, Newman-Girvan modularity
graph_analytics.temporal 16 Time-stamped graphs: earliest-arrival and fastest journeys, reachability, windows, burstiness
graph_compiler 10 Computation-graph optimization scores: fusion benefit, dead ops, constant folding, broadcasting
graph_decision 10 Routing and flow arithmetic: weighted relaxation, residual capacity, decayed weights, utility
heap 13 Min and max heaps: heapify, push, pop, k smallest and largest, k-way merge, running median
oceanography 10 Ocean physics: seawater density, buoyancy frequency, geostrophic velocity, Ekman depth, waves
rag_retrieval 10 Retrieval scoring: reciprocal rank fusion, BM25 and vector blend, cross-encoder logit, MMR
retrieval.fuse 2 Reciprocal rank fusion across any number of ranked lists, with per-list rank attribution
retrieval.score 8 Ranking over candidate lists: hybrid dense-sparse scores, greedy MMR selection, quality ratios
stratigraphy 10 Rock layers and dating: sedimentation rate, radiometric and radiocarbon ages, isotope delta
topology 7 Topological data analysis: Vietoris-Rips edges, Betti 0, persistence and bottleneck distance
trie 0 Prefix trie over strings: insert, exact search, prefix test, word and node counts, word listing

kernel.CONTRACT holds every signature, including the length rules for list arguments; help(kernel.autograd_graph) documents each function.

Not included

  • topology.filtration_values — requires a consistent distance/simplex structure; not expressible as a length rule.
  • topology.persistence_diagram_0 — requires a consistent distance/simplex structure; not expressible as a length rule.
  • topology.vietoris_rips_edges — requires a square distance matrix; a non-square nested list is not expressible as a length rule.
  • trie.* — the trie functions take a Trie structure that a plain in-process call cannot build; use the SDK for tries.

Requirements

  • Apple silicon: macOS 15 or later for the CPU build.
  • Linux arm64 and x86-64, glibc 2.35 or later.
  • kernels 0.17 or later and PyTorch 2.5 to 2.14. PyTorch has to be installed: the loader picks the build for your PyTorch version. The kernel itself never imports it.

Windows is not supported.

Notes

Calls into one kernel instance run one at a time; use processes for parallelism. Runtime state does not survive fork(); start worker processes with spawn.

License

Algenta Community License 1.1 (LICENSE). Free for personal, research and open-source use, and for internal use at organizations with fewer than 50 employees and under $5M in annual revenue. Beyond that, a commercial license is required: https://algenta.ai/pricing.

Enforced in the compiled library, not just in this text: one concurrent native worker per device (ABI §9). A second process, family or thread waits its turn rather than running in parallel. That is the Community licence's worker floor made real; parallel execution comes with a commercial license.

Support

Generally Available on the platforms listed under Requirements. Within v1, functions are only added; removals or signature changes ship as v2. Platforms, accelerators and PyTorch releases not listed are not supported. Documentation: https://docs.algenta.ai (the kernels guide: https://docs.algenta.ai/guides/kernels-on-hugging-face). Community: https://discord.gg/w8NDsph9an or this repository's Community tab. Commercial licences and support: https://algenta.ai/pricing.

Downloads last month
2
algenta
mojo
cpu
other
Torch
2.14
OS
macoslinux
Arch
x86_64aarch64