Skip to main content

A Python interace to the GenTen tensor decomposition library

Project description

pygenten: Python bindings for the GenTen package

The python package pygenten provides python bindings for the GenTen package. GenTen is a tool for computing Canonical Polyadic (CP, also called CANDECOMP/PARAFAC) decompositions of tensor data. It is geared towards analysis of extreme-scale data and implements several CP decomposition algorithms that are parallel and scalable, including:

  • CP-ALS: The workhorse algorithm for Gaussian sparse or dense tensor data.
  • CP-OPT: CP decomposition of (sparse or dense) Gaussian data using a quasi-Newton optimization algorithm incorporating possible upper and lower bound constraints.
  • GCP: Generalized CP supporting arbitrary loss functions (Gaussian, Poisson, Bernoulli, ...), solved using quasi-Newton (dense tensors) or stochastic gradient descent (sparse or dense tensors) optimization methods.
  • Streaming GCP: A GCP algorithm that incrementally updates a GCP decomposition as new data is observed, suitable for in situ analysis of streaming data.
  • Federated GCP: A federated learning algorithm for GCP supporting asynchronous parallel communication.

GenTen builds on Kokkos and Kokkos Kernels to support shared memory parallel programming models on a variety of contemporary architectures, including:

  • OpenMP for CPUs.
  • CUDA for NVIDIA GPUs.
  • HIP for AMD GPUs.
  • SYCL for Intel GPUs.

GenTen also supports distributed memory parallelism using MPI.

Installing pygenten

There are two general approaches for building pygenten:

  • Enable python in the generic CMake build process described here.
  • Install using pip which automates the CMake build to some degree.

Installing with pip

pygenten has experimental support for installation using pip from the source distribution on pypi. Furthermore, binary wheels are provided in limited circumstances (currently just linux with OpenMP support only, but more may be provided in the future), enabling immediate installation. The pip installation leverages scikit-build-core to provide a CMake build backend for pip, which allows the user to provide CMake defines that control the pygenten build process and determine which architectures/parallel programming models are enabled. We thus recommend becoming familiar with the CMake build process for GenTen in general as described here before continuing. In particular, the user must have BLAS and LAPACK libraries available in their build environment that can either be automatically discovered by CMake or manually specified through LAPACK_LIBS.

Basic installation

A basic installation of pygenten can be done simply by:

pip install pygenten

This will install the binary wheel if it is available, and if it isn't, build GenTen and pygenten for a CPU architecture using OpenMP parallelism using a default compiler from the user's path. During the build of pygenten, CMake will attempt to locate valid BLAS and LAPACK libraries in the user environment. If these cannot be found, the user can customize the build by specifying LAPACK_LIBS as described below.

Note that when installing pygenten from a binary wheel, the repairwheel step that makes the wheel usable on a wide variety of architectures seems to make the included genten and related executables unusable. If you want to use GenTen outside of python, you should install it from source as described below.

Customized installation

To customize the GenTen/pygenten build, you must first instruct pip to compile from source by adding the --no-binary pygenten command-line argument. The can then be customized by passing CMake defines to specify compilers, BLAS/LAPACK libraries, host/device architectures, and enabled programming models. This is done by adding command-line arguments to pip of the form

--config-settings=cmake.define.SOME_DEFINE=value

Any CMake define accepted by GenTen/Kokkos/KokkosKernels can be passed this way. Since this is fairly verbose and GenTen can require several defines, several meta-options are provided to enable supported parallel programming models:

CMake Define What it enables
PYGENTEN_MPI Enable distributed parallelism with MPI. Sets the execution space to Serial by default.
PYGENTEN_OPENMP Enable shared memory host parallelism using OpenMP
PYGENTEN_SERIAL No host shared memory parallelism. Useful for builds targeting GPU architectures or distributed memory parallelism
PYGENTEN_CUDA Enable CUDA parallelism for NVIDIA GPU architectures
PYGENTEN_HIP Enable HIP parallelism for AMD GPU architectures
PYGENTEN_SYCL Enable SYCL parallelism for Intel GPU architectures

When enabling GPU architectures, one also needs to specify the corresponding architecture via Kokkos_ARCH_* defines described here.

For example, an MPI+CUDA build for a Volta V100 GPU architecture can be obtained with

pip install -v --no-binary pygenten --config-settings=cmake.define.PYGENTEN_CUDA=ON --config-settings=cmake.define.Kokkos_ARCH_VOLTA70=ON --config-settings=cmake.define.PYGENTEN_MPI=ON pygenten

For MPI builds, pygenten assumes the MPI compiler wrappers mpicxx and mpicc are available in the user's path. If this is not correct, the user can specify the appropriate compiler by setting the appropriate CMake define, e.g., CMAKE_CXX_COMPILER. Furthermore, for CUDA builds, pygenten will build with the nvcc_wrapper script as the compiler as required by Kokkos, which calls g++ as the host compiler by default. This can be changed by setting the NVCC_WRAPPER_DEFAULT_COMPILER environment variable. Moreover, for MPI+CUDA, pygenten will set environment variables to override the compiler wrapped by mpicxx to use nvcc_wrapper, which currently works only with OpenMPI and MPICH. Finally, for MPI+HIP or MPI+SYCL builds, pygenten assumes the compiler wrappers call the appropriate device-enabled compiler, e.g., hipcc for AMD and icpx for Intel.

Installing numpy

pygenten relies on numpy, both of which are compiled extension libraries leveraging OpenMP and BLAS/LAPACK. Therefore, module import errors can occur if pygenten and numpy are compiled in very different environments, due to, e.g., symbol conflicts in libstdc++. This typically happens when pygenten is compiled with a much newer compiler than what was used to compile the numpy wheel. Futhermore, we have observed slower performance in pygenten in some cases when numpy is imported before pygenten, which we believe is due to inconsistent OpenMP and/or BLAS/LAPACK libraries between the two packages. Thus, the most robust way to use pygenten is to also install numpy from source, using the same build environment as pygenten. This can be done in a similar manner as pygenten by providing configure options to numpy through pip, e.g.,

pip install --no-binary numpy -Csetup-args=-Dblas=my_blas -Csetup-args=-Dlapack=my_lapack numpy

to specify the appropriate BLAS and LAPACK libraries (called my_blas and my_lapack in this case). Compilers can be specified through the CC, CXX, and FC environment variables. More details can be found here. However, we only recommend doing this if you see errors when importing pygenten or you observe slower performance than what would be observed with the genten command-line tool.

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

pygenten-0.1.1.tar.gz (17.0 MB view details)

Uploaded Source

Built Distributions

pygenten-0.1.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (21.6 MB view details)

Uploaded CPython 3.13 manylinux: glibc 2.17+ x86-64

pygenten-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (21.6 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

pygenten-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (21.6 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pygenten-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (21.6 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pygenten-0.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (21.6 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pygenten-0.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (21.6 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pygenten-0.1.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (21.6 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

File details

Details for the file pygenten-0.1.1.tar.gz.

File metadata

  • Download URL: pygenten-0.1.1.tar.gz
  • Upload date:
  • Size: 17.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for pygenten-0.1.1.tar.gz
Algorithm Hash digest
SHA256 38b0790c61b5d3a4a5e855fdc98bdb0f3cf6211cc7c3505bf5e4759d11cb9b59
MD5 cef1ff230ea96aa6808a7fe3c97ed524
BLAKE2b-256 5c99916241fffd7008192f3343f5efbb5cc2591676577252393e5cfb3f6151e6

See more details on using hashes here.

File details

Details for the file pygenten-0.1.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pygenten-0.1.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3089af834d5123f3af1db486174bf00d7176a6c9df929f51dc02dba85aa7558d
MD5 83413653b5c36f6857f2d8c16b6b256c
BLAKE2b-256 8dd7353838ef954eee84e2733a733aa6789c6d650ffc50c293c3eb939fd935a0

See more details on using hashes here.

File details

Details for the file pygenten-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pygenten-0.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d0f3159a515a1c87d83561348f0109ec08a4c95cb966d72fc9477e0156416ecc
MD5 e0d4b5f93ed5549393c943b0a64999d7
BLAKE2b-256 ba8b8dcea41fa11365c4b09957c6c7942b703ca8c3a88ddbe6a92078fc8c070e

See more details on using hashes here.

File details

Details for the file pygenten-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pygenten-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 32ead36e762c32c27877d608050251a45a6358554237facdf9346fb81a59aeb1
MD5 14f741d616cd0e77d401f82c70d37bdc
BLAKE2b-256 4ea8173a0478f6b31a2ed96bd5f25c28cd3138a167549a1e8d29f132eeb32ee0

See more details on using hashes here.

File details

Details for the file pygenten-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pygenten-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 10d9a8035dbb3f99cd845e5b173c5bfe6f9064ea8cea106e4b6d3a7f859b55b8
MD5 3d887349b9190d6dcf4a2b06e3297e12
BLAKE2b-256 db00178f389b70f9334d87ca9d83de98ce3f11054ee5e27f2883fdbcae513e2f

See more details on using hashes here.

File details

Details for the file pygenten-0.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pygenten-0.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3d33dd2cb62726394d6d34b150dcb00396f943add95c3ba4af98fd5184720bf5
MD5 5c8e24e9df3c739c3688f199ba15536e
BLAKE2b-256 5be82371bce3db850bd1fa59044ccc7bc155552b027973874845c4b63ad2a632

See more details on using hashes here.

File details

Details for the file pygenten-0.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pygenten-0.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8bb7d38803b2df98ad42bf0ad9c75e7ade6032749d6d1600d07a13177d5112d2
MD5 d3ff6cbcfab84a1b6faa2603fdd13b8a
BLAKE2b-256 32cd5f29018493e91184c93ccc55573351b5919c88855be5e5d2eed63af51ccf

See more details on using hashes here.

File details

Details for the file pygenten-0.1.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pygenten-0.1.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e5a735c0c8a0ba4629df2db8aa8e5938c2e912bf67585084867de3b62d6aaba5
MD5 21e86e9b46fb7673c09188371b257553
BLAKE2b-256 5c653f9dd65b34a7e8e8b0b3b210084281a25184faa37dc44f05856f620a8572

See more details on using hashes here.

Supported by

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