GraphBLAS

{{short description|API for graph data and graph operations}}

{{Orphan|date=September 2023}}

{{Infobox technology standard

| title = GraphBLAS Specification

| long_name =

| native_name =

| native_name_lang =

| image = File:GraphBLAS_logo.png

| caption = The logo of the GraphBLAS API

| status = Released

| year_started =

| first_published = {{Start date|2017|05|29}}

| version = 2.1.0

| version_date = {{Start date|2023|12|22}}

| preview =

| preview_date =

| organization =

| committee =

| editors =

| authors =

| base_standards =

| related_standards =

| abbreviation =

| domain = Graph algorithms

| license = Creative Commons Attribution (CC BY) 4.0

| website = {{URL|https://graphblas.org}}

}}

GraphBLAS ({{IPAc-en|audio=GraphBLAS.ogg|'|g|r|æ|f|,|b|l|ɑː|z|}}) is an API specification that defines standard building blocks for graph algorithms in the language of linear algebra.{{Cite web|url=https://graphblas.org/|title=GraphBLAS|website=graphblas.org|access-date=2021-12-04}}{{Cite web|url=https://www.sei.cmu.edu/research-capabilities/all-work/display.cfm?customel_datapageid_4050=6501|title=GraphBLAS: A Programming Specification for Graph Analysis|website=www.sei.cmu.edu|access-date=2019-11-08}} GraphBLAS is built upon the notion that a sparse matrix can be used to represent graphs as either an adjacency matrix or an incidence matrix. The GraphBLAS specification describes how graph operations (e.g. traversing and transforming graphs) can be efficiently implemented via linear algebraic methods (e.g. matrix multiplication) over different semirings.{{cite web |last1=Pereira |first1=Juliana |title=High-Performance Graph Algorithms Using Linear Algebra |url=https://networkdatascience.ceu.edu/article/2020-01-15/high-performance-graph-algorithms-using-linear-algebra |publisher=Central European University, Department of Network and Data Science |accessdate=13 February 2020}}

The development of GraphBLAS and its various implementations is an ongoing community effort, including representatives from industry, academia, and government research labs.{{cite web |title=People of ACM - Tim Davis |url=https://www.acm.org/articles/people-of-acm/2019/tim-davis |website=acm.org |publisher=Association for Computing Machinery |accessdate=8 November 2019}}{{cite web |last1=Mattson |first1=Tim |last2=Gabb |first2=Henry |title=Graph Analytics: A Foundational Building Block for the Data Analytics World |url=https://techdecoded.intel.io/big-picture/graph-analytics-a-foundational-building-block-for-the-data-analytics-world/#gs.watx6b |website=Tech.Decoded |publisher=Intel |accessdate=14 February 2020}}

Background

Graph algorithms have long taken advantage of the idea that a graph can be represented as a matrix, and graph operations can be performed as linear transformations and other linear algebraic operations on sparse matrices.{{cite book |last1=Kepner |first1=Jeremy |last2=Gilbert |first2=John |title=Graph Algorithms in the Language of Linear Algebra |date=2011 |publisher=Society for Industrial and Applied Mathematics |location=Philadelphia, PA, USA |isbn=9780898719901 |url=https://dl.acm.org/citation.cfm?id=2039367 |accessdate=8 November 2019}}{{rp|section=Preface |pages=xxv-xxvi}} For example, matrix-vector multiplication can be used to perform a step in a breadth-first search.{{rp|section=4.3.1 Breadth-first search |pages=32–33}}

The GraphBLAS specification (and the various libraries that implement it) provides data structures and functions to compute these linear algebraic operations. In particular, GraphBLAS specifies sparse matrix objects which map well to graphs where vertices are likely connected to relatively few neighbors (i.e. the degree of a vertex is significantly smaller than the total number of vertices in the graph). The specification also allows for the use of different semirings to accomplish operations in a variety of mathematical contexts.

Originally motivated by the need for standardization in graph analytics, similar to its namesake BLAS,{{cite web |title=GraphBLAS: Building Blocks for High Performance Graph Analytics |url=https://crd.lbl.gov/news-and-publications/news/2017/graphblas-building-blocks-for-high-performance-graph-analytics/ |website=crd.lbl.gov |first1=Linda |last1=Vu |accessdate=8 November 2019 |quote="In subsequent years, various research collaborations created a variety of BLAS libraries for different tasks. Realizing the benefits to users, vendors also worked with researchers to optimize these building blocks to run on their hardware. GraphBLAS is essentially a continuation of this BLAS heritage."}} the GraphBLAS standard has also begun to interest people outside the graph community, including researchers in machine learning,{{cite book |date=12–14 September 2017 |doi=10.1109/HPEC.2017.8091098 |first1=Jeremy |last1=Kepner |first2=Manoj |last2=Kumar |first3=José |last3=Moreira |first4=Pratap |last4=Pattnaik |first5=Mauricio |last5=Serrano |first6=Henry |last6=Tufo |title=2017 IEEE High Performance Extreme Computing Conference (HPEC) |chapter=Enabling massive deep neural networks with the GraphBLAS |pages=1–10 |quote="In this paper we have shown that the key [deep neural network] computations can be represented in GraphBLAS, a library interface defined for sparse matrix algebra. Furthermore, we have shown that the key step of forward propagation, with ReLU as the nonlinearity, can be performed much more efficiently with GraphBLAS implementation as compared to BLAS implementation when the weight matrices are sparse."|arxiv=1708.02937 |bibcode=2017arXiv170802937K |isbn=978-1-5386-3472-1 |s2cid=3632940 }} and bioinformatics.{{cite news |last1=Vu |first1=Linda |title=A Game Changer: Metagenomic Clustering Powered by Supercomputers |url=https://newscenter.lbl.gov/2018/03/12/metagenomic-clustering-powered-by-supercomputers/ |accessdate=10 November 2019 |agency=Lawrence Berkeley National Laboratory News Center |date=12 March 2018}} GraphBLAS implementations have also been used in high-performance graph database applications such as RedisGraph.{{cite web |title=RedisGraph |url=https://redislabs.com/redis-enterprise/redis-modules/redis-enterprise-modules/redisgraph/ |website=Redis Labs |accessdate=11 November 2019}}{{cite news |last1=Anadiotis |first1=George |title=Redis Labs goes Google Cloud, Graph, and other interesting places |url=https://www.zdnet.com/article/redis-labs-goes-google-cloud-graph-and-other-interesting-places/ |accessdate=8 November 2019 |work=ZDNet |date=24 October 2019}}{{cite news |title=Redis Labs Introduces RedisGraph and Streams to Support a Zero Latency Future |url=https://devops.com/redis-labs-introduces-redisgraph-and-streams-to-support-a-zero-latency-future/ |accessdate=10 November 2019 |work=DevOps.com |date=16 November 2018 |quote="Built on GraphBLAS, an open-source library that employs linear algebra including matrix multiplication, RedisGraph can complete calculations up to 600 times faster than any alternate graph solution according to benchmark results."}}{{cite news |last1=Woodie |first1=Alex |title=Redis Speeds Towards a Multi-Model Future |url=https://www.datanami.com/2018/09/28/redis-speeds-towards-a-multi-model-future/ |accessdate=10 November 2019 |work=Datanami |date=28 September 2018 |quote="One of the newest modules to emerge from Redis Labs turns the key value store into a graph database. The module, called RedisGraph, will be based on the GraphBLAS technology that emerged out of academia and industry."}}{{cite news |last1=Dsouza |first1=Melisha |title=RedisGraph v1.0 released, benchmarking proves its 6-600 times faster than existing graph databases |url=https://hub.packtpub.com/redisgraph-v1-0-released-benchmarking-proves-its-6-600-times-faster-than-existing-graph-databases/ |accessdate=10 November 2019 |work=Packt |date=20 November 2018 |quote="RedisGraph is a Redis module that adds a graph database functionality to Redis. RedisGraph delivers a fast and efficient way to store, manage and process graphs, around 6 to 600 times faster than existing graph databases. RedisGraph represents connected data as adjacency matrices and employs the power of GraphBLAS which is a highly optimized library for sparse matrix operations."}}

=Specification=

The GraphBLAS specification has been in development since 2013,{{cite book |date=10–12 September 2013 |doi=10.1109/HPEC.2013.6670338 |first1=Tim |last1=Mattson |first2=David |last2=Bader |first3=Jon |last3=Berry |first4=Aydin |last4=Buluç |first5=Jack |last5=Dongarra |first6=Christos |last6=Faloutsos |first7=John |last7=Feo |first8=John |last8=Gilbert |first9=Joseph |last9=Gonzalez |first10=Bruce |last10=Hendrickson |first11=Jeremy |last11=Kepner |first12=Charles |last12=Leiserson |first13=Andrew |last13=Lumsdaine |first14=David |last14=Padua |first15=Stephen |last15=Poole |first16=Steve |last16=Reinhardt |first17=Mike |last17=Stonebraker |first18=Steve |last18=Wallach |first19=Andrew |last19=Yoo |title=2013 IEEE High Performance Extreme Computing Conference (HPEC) |chapter=Standards for graph algorithm primitives |pages=1–2 |quote="It is our view that the state of the art in constructing a large collection of graph algorithms in terms of linear algebraic operations is mature enough to support the emergence of a standard set of primitive building blocks. This paper is a position paper defining the problem and announcing our intention to launch an open effort to define this standard."|arxiv=1408.0393 |isbn=978-1-4799-1365-7 |s2cid=12099965 }} and has reached version 2.1.0 as of December 2023.{{cite web |title=The GraphBLAS C API Specification: Version 2.1.0 |url=https://graphblas.org/docs/GraphBLAS_API_C_v2.1.0.pdf |first1=Benjamin |last1=Brock |first2=Aydın |last2=Buluç |first3=Raye |last3=Kimmerer |first4=Jim |last4=Kitchen |first5=Manoj |last5=Kumar |first6=Timothy |last6=Mattson |first7=Scott |last7=McMillan |first8=José |last8=Moreira |first9=Michel |last9=Pelletier |first10=Erik |last10=Welch |accessdate=22 December 2023}} While formally a specification for the C programming language, a variety of programming languages have been used to develop implementations in the spirit of GraphBLAS, including C++,{{cite web |title=GraphBLAS Template Library (GBTL) |url=https://github.com/cmu-sei/gbtl |website=GitHub.com |accessdate=8 November 2019}} Java,{{cite web |title=Graphulo: Graph Processing on Accumulo |url=http://graphulo.mit.edu |website=graphulo.mit.edu |accessdate=8 November 2019}} and Nvidia CUDA.{{cite web |title=GraphBLAST |url=https://github.com/gunrock/graphblast |website=GitHub.com |accessdate=8 November 2019}}

=Compliant implementations and language bindings=

There are currently two fully-compliant reference implementations of the GraphBLAS specification.{{cite web |last1=Davis |first1=Timothy |title=SuiteSparse:GraphBLAS |url=http://faculty.cse.tamu.edu/davis/GraphBLAS.html |accessdate=11 November 2019 |quote="SuiteSparse:GraphBLAS is a full implementation of the GraphBLAS standard (graphblas.org), which defines a set of sparse matrix operations on an extended algebra of semirings using an almost unlimited variety of operators and types."}}{{cite web |last1=Moreira |first1=Jose |last2=Horn |first2=Bill |title=ibmgraphblas |url=https://github.com/IBM/ibmgraphblas |website=GitHub.com |accessdate=19 November 2019}} Bindings assuming a compliant specification exist for the Python,{{cite web |last1=Pelletier |first1=Michel |title=GraphBLAS for Python |url=https://github.com/michelp/pygraphblas |website=GitHub.com |accessdate=11 November 2019}} MATLAB,{{cite web |last1=Davis |first1=Timothy |title=SuiteSparse:GraphBLAS |url=http://faculty.cse.tamu.edu/davis/GraphBLAS.html |accessdate=11 November 2019 |quote="Now with OpenMP parallelism and a MATLAB interface"}} and Julia{{cite web |last1=Mehndiratta |first1=Abhinav |title=GraphBLAS Implementation |url=https://summerofcode.withgoogle.com/archive/2019/projects/5106075190165504/ |website=Google Summer of Code Archive |accessdate=11 November 2019}}{{cite web |last1=Mehndiratta |first1=Abhinav |title=An introduction to GraphBLAS |date=7 June 2019 |url=https://abhinavmehndiratta.github.io/2019-06-07/an-introduction-to-graphblas |website=GSoC'19 Blog |accessdate=11 November 2019}} programming languages.

Linear algebraic foundations

File:AdjacencyMatrixGraphBLASBFS.png

The mathematical foundations of GraphBLAS are based in linear algebra and the duality between matrices and graphs.{{cite book |date=13–15 September 2016 |doi=10.1109/HPEC.2016.7761646 |first1=Jeremy |last1=Kepner |first2=Peter |last2=Aaltonen |first3=David |last3=Bader |first4=Aydın |last4=Buluç |first5=Franz |last5=Franchetti |first6=John |last6=Gilbert |first7=Dylan |last7=Hutchison |first8=Manoj |last8=Kumar |first9=Andrew |last9=Lumsdaine |first10=Henning |last10=Meyerhenke |first11=Scott |last11=McMillan |first12=José |last12=Moreira |first13=John D. |last13=Owens |first14=Carl |last14=Yang |first15=Marcin |last15=Zalewski |first16=Timothy |last16=Mattson |title=2016 IEEE High Performance Extreme Computing Conference (HPEC) |chapter=Mathematical foundations of the GraphBLAS |pages=1–9 |arxiv=1606.05790 |bibcode=2016arXiv160605790K |isbn=978-1-5090-3525-0 |s2cid=3654505 }}For additional mathematical background, see {{cite book |last1=Kepner |first1=Jeremy |last2=Jananthan |first2=Hayden |title=Mathematics of Big Data: Spreadsheets, Databases, Matrices, and Graphs |date=17 July 2018 |publisher=The MIT Press |isbn=978-0262038393 |pages=81–168 |url=https://mitpress.mit.edu/books/mathematics-big-data |accessdate=10 November 2019}}

Each graph operation in GraphBLAS operates on a semiring, which is made up of the following elements:

Note that the zero element (i.e. the element that represents the absence of an edge in the graph) can also be reinterpreted.{{rp|at="VII. 0-Element: No Graph Edge" |quote="In most cases, the 0 element is standard arithmetic 0, but in other cases it can be a different value. Nonstandard 0 values can be helpful when combined with different ⊕ and ⊗ operations."}} For example, the following algebras can be implemented in GraphBLAS:

class="wikitable" style="text-align: center;"
Algebra\oplus\otimesDomainZero Element
Standard arithmetic+\times\R0
Max–plus algebra\max+\{-\infty\} \cup \R-\infty
Min–plus algebra\min+\{+\infty\} \cup \R+\infty
Max–min algebra\max\min[0, +\infty)0
Min–max algebra\min\max(-\infty, 0]0
Galois fieldXORAND\{0,1\}0

All the examples above satisfy the following two conditions in their respective domains:

For instance, a user can specify the min-plus algebra over the domain of double-precision floating point numbers with GrB_Semiring_new(&min_plus_semiring, GrB_MIN_FP64, GrB_PLUS_FP64).

Functionality

While the GraphBLAS specification generally allows significant flexibility in implementation, some functionality and implementation details are explicitly described:

  • GraphBLAS objects, including matrices and vectors, are opaque data structures.{{rp|at=2.4 GraphBLAS Opaque Objects}}
  • Non-blocking execution mode, which permits lazy or asynchronous evaluation of certain operations.{{rp|at=2.5.1 Execution modes}}
  • Masked assignment, denoted A\langle M \rangle = B, which assigns elements of matrix B to matrix A only in positions where the mask matrix M is non-zero.{{rp|at=3.5.4 Masks}}

The GraphBLAS specification also prescribes that library implementations be thread-safe.{{rp|at=2.5.2 Multi-threaded execution}}

Example code

The following is a GraphBLAS 2.1-compliant example of a breadth-first search in the C programming language.{{rp|page=294}}

  1. include
  2. include
  3. include
  4. include
  5. include "GraphBLAS.h"

/*

* Given a boolean n x n adjacency matrix A and a source vertex s, performs a BFS traversal

* of the graph and sets v[i] to the level in which vertex i is visited (v[s] == 1).

* If i is not reachable from s, then v[i] = 0 does not have a stored element.

* Vector v should be uninitialized on input.

*/

GrB_Info BFS(GrB_Vector *v, GrB_Matrix A, GrB_Index s)

{

GrB_Index n;

GrB_Matrix_nrows(&n,A); // n = # of rows of A

GrB_Vector_new(v,GrB_INT32,n); // Vector v(n)

GrB_Vector q; // vertices visited in each level

GrB_Vector_new(&q, GrB_BOOL, n); // Vector q(n)

GrB_Vector_setElement(q, (bool)true, s); // q[s] = true, false everywhere else

/*

* BFS traversal and label the vertices.

*/

int32_t level = 0; // level = depth in BFS traversal

GrB_Index nvals;

do {

++level; // next level (start with 1)

GrB_apply(*v, GrB_NULL, GrB_PLUS_INT32,

GrB_SECOND_INT32, q, level, GrB_NULL); // v[q] = level

GrB_vxm(q, *v, GrB_NULL, GrB_LOR_LAND_SEMIRING_BOOL,

q, A, GrB_DESC_RC); // q[!v] = q ||.&& A; finds all the

// unvisited successors from current q

GrB_Vector_nvals(&nvals, q);

} while (nvals); // if there is no successor in q, we are done.

GrB_free(&q); // q vector no longer needed

return GrB_SUCCESS;

}

See also

References

{{reflist}}