PYPI PACKAGE AUDIT v0.1.0 Necesita Mejoras

kernelax

Núcleos C y CUDA fusionados, vectorizados y multihilo de JAX

PyPkgScore kernelax
Metodología y Criterios ♥ Donate
430 / 1000
Instalación Rápida
pip install kernelax
1. Gobernanza
0/200
2. Metadatos PEP
150/200
3. Seguridad
160/200
4. Docs y SEO
120/200
5. Ingeniería CI
0/200
📣 Compartir Auditoría: Comparte este informe y la vista previa en el idioma actual
Advertisement
TELEMETRÍA PYPI

Descargas y Adopción en la Comunidad

Últimos 30 días (sin espejos)
Últimos 7 días
134
Últimos 30 días
134
Total (180 días)
134
Métrica / Ecosistema Estado / Valor Fuente
Downloads (30d / 180d) — PyPI Stats (without mirrors)
Trusted Publishing (PEP 740) ✓ Verified OIDC PyPI Integrity / Sigstore
Django Packages — djangopackages.org
PyTech / PyPkgScore 430 / 1000 PyPkgScore Engine

Análisis de Salud e Ingeniería (5 Pilares)

1. Gobernanza y Comunidad0 / 200 ▾
LICENSE✕ 0 pts
SECURITY.md✕ 0 pts
CONTRIBUTING.md✕ 0 pts
CODE_OF_CONDUCT.md✕ 0 pts
2. Metadatos y Empaquetado PEP150 / 200 ▾
Wheel (.whl)✓ 50 pts
pyproject.toml✕ 0 pts
Project URLs✓ 50 pts
Trove Classifiers✓ 50 pts
3. Seguridad y Cadena de Suministro160 / 200 ▾
Cero CVEs (OSV)✓ 60 pts
Trusted Publishing (OIDC)✓ 50 pts
Snyk / Audit Link✕ 0 pts
Repositorio HTTPS✓ 50 pts
4. Documentación, SEO y Ecosistema120 / 200 ▾
README Estructurado✓ 60 pts
Read the Docs✓ 50 pts
Django Packages✕ 0 pts
Sitio Web / Artículos Técnicos✕ 0 pts
5. Ingeniería, CI y Calidad0 / 200 ▾
Pruebas Automatizadas✕ 0 pts
GitHub Actions CI✕ 0 pts
CHANGELOG.md✕ 0 pts
Env & Lockfile (uv/rye/poetry/pdm/hatch)✕ 0 pts
Advertisement
README & DOCS

Documentación Oficial y Guía de Uso — kernelax

PyPI Metadata v0.1.0
Mostrar documentación original completa (README en inglés) ▾

kernelax: fused, vectorized and multithreaded C and CUDA kernels from JAX

kernelax.jit is a drop-in replacement for jax.jit for JAX code that does many small operations per sample: a material law at every integration point, a Newton solve per particle, a 3 x 3 eigenproblem per cell. It compiles such code into fused kernels, C with SIMD and OpenMP on the CPU and CUDA on NVIDIA GPUs.

When it helps

XLA fuses elementwise operations, but it splits a program at reductions, contractions, gathers and scatters, loops and library calls. Every intermediate value that crosses such a boundary is written to memory as an array over the whole batch and read back, and a while loop under jax.vmap runs every step over the whole batch until its slowest sample has converged. When a program consists of many small operations per sample, this memory traffic, not the arithmetic, dominates the run time, and jax.jit often reaches only a few percent of what the hardware can do. kernelax keeps the intermediate values of a sample in registers and runs loops per sample. Typical cases:

  • material laws and their derivatives (jax.grad, jax.jacfwd) at every integration point,
  • local Newton solves, while loops and ODE time steps per sample,
  • small linear algebra per sample (solves, inverses, eigenvalues of matrices up to about 8 x 8),
  • element routines of a finite element assembly, with their gathers and scatter-adds,
  • rollouts of simulators and reinforcement learning environments, one per sample (gymnax, pgx, jumanji, Brax), and simulations per parameter set (Jaxley, diffrax, dynamiqs).

Example

import jax, jax.numpy as jnp
import kernelax

jax.config.update("jax_enable_x64", True)


def psi(F):  # strain energy of a Neo-Hooke material at one point (shear modulus 1, Lame constant 10)
    J = jnp.linalg.det(F)
    return 0.5 * (jnp.sum(F * F) - 3) - jnp.log(J) + 5.0 * jnp.log(J) ** 2


stress = jax.vmap(jax.jacrev(psi))  # first Piola-Kirchhoff stress P = dpsi/dF at every point

F = jnp.eye(3) + 0.1 * jax.random.normal(jax.random.key(0), (1_000_000, 3, 3))  # a million points
P_xla = jax.jit(stress)(F)
P = kernelax.jit(stress)(F)  # the first call compiles the kernel (seconds; later processes load it from disk)

A call takes 3.9 ms with kernelax.jit and 420 ms with jax.jit on 8 cores of an AMD EPYC 9474F, and 0.27 ms against 4.1 ms on an NVIDIA L40S.

With common libraries

In these examples the only change is kernelax.jit in place of jax.jit. Seconds on 8 cores of an AMD EPYC 9474F, each run in a fresh process; the first call includes tracing and compilation, for kernelax.jit the build of its kernels (empty cache).

Example First call, jax.jit kernelax.jit Later calls, jax.jit kernelax.jit
diffrax: stiff kinetics (Kvaerno5) for 16 384 sets of rate constants 14.3 3.9 14.5 0.12 (120×)
optimistix: BFGS for 2 million parameter sets 6.6 2.8 6.2 0.059 (105×)
e3nn: equivariant messages on 4 million edges (float32) 1.3 2.8 1.6 0.10 (15×)
Jaxley: the branched neuron of Jaxley's tutorial on jit and vmap for 4096 pairs of conductances 3.1 4.9 2.3 0.088 (27×)

Installation

pip install kernelax

Requirements: Linux on x86-64 with AVX2 or AVX-512, Python >= 3.12, JAX 0.12 (>= 0.12.1), gcc and g++ >= 12 with OpenMP, glibc >= 2.35. GPU kernels also need an NVIDIA GPU, JAX with CUDA (jax[cuda12] or jax[cuda13]) and the CUDA toolkit's nvcc.

Further API

kernelax.kernel compiles a function of one sample explicitly: under jax.vmap it runs as one kernel over the batch, and its derivatives run as kernels too. With psi and F from the example above:

stress = kernelax.kernel(jax.grad(psi))  # the stress at one point, as a kernel
P = jax.vmap(stress)(F)  # one kernel call over all points
A = jax.vmap(jax.jacfwd(stress))(F)  # its derivative, the tangent dP/dF, is a kernel too

kernelax.export writes a function of one sample as a C library with Fortran and Java interfaces, e.g. a material law with its tangent for a finite element code:

import numpy as np

kernelax.export(lambda F: (jax.grad(psi)(F), jax.hessian(psi)(F)), (np.eye(3),), name="neo_hooke", out_dir="neo_hooke")
# then make -C neo_hooke: libneo_hooke.so with neo_hooke_batch(nt, n, F, P, A) for n points on nt threads and
# neo_hooke_point(F, P, A) for one point

The reference covers the options, report(), environment variables, numerics (results are close to, but not bitwise equal to, XLA's) and limits.

AI usage

Parts of the code, tests and documentation were developed with AI assistance.

Citation

If you use kernelax in your work, please cite it as given in CITATION.cff:

@software{kernelax,
  author  = {Bode, Tobias},
  title   = {kernelax: fused, vectorized and multithreaded C and CUDA kernels from JAX},
  year    = {2026},
  version = {0.1.0},
  url     = {https://github.com/BodeTobias/kernelax},
}

License

MIT, see LICENSE.