Skip to content

Instantly share code, notes, and snippets.

View rgommers's full-sized avatar

Ralf Gommers rgommers

View GitHub Profile
@rgommers
rgommers / pytorch_stable_abi_marker.md
Created September 16, 2026 22:35
Idea for a way to encode the PyTorch Stable ABI Target into extension modules automatically

PyTorch Stable ABI Target Marker

Goals and constraints

The goal is to make the stable ABI target of a compiled PyTorch extension discoverable from the resulting binary.

The design should have the following properties:

  • No additional work for extension authors. Using the PyTorch stable headers and optionally setting TORCH_TARGET_VERSION should be sufficient. There should be no extra source file, build-system integration, linker flag, or post-processing step.
  • Cross-platform. The mechanism should work with ELF, Mach-O, and PE/COFF rather than relying on a format-specific metadata facility.
@rgommers
rgommers / f2py_wrapper_bug_findings.md
Created August 22, 2026 20:47
A summary of issues surfaced by the experiment of rewriting scipy.linalg's f2py wrappers to Cython (see https://github.com/scipy/scipy/compare/main...rgommers:scipy:f2py-removal)

Pre-existing fblas/flapack wrapper issues surfaced by the f2py-removal experiment

Audit of the f2py-removal branch (46 commits, branched off main at 986b8b3035, Mar 2026), asking: which of the problems found during that effort are defects in the existing wrappers and surrounding scipy code — i.e. still present in main today and never upstreamed?

Sources: all 46 commit messages/bodies, f2py_removal_plan.md, f2py_removal_session_summary.md, the diff against the merge base (the diff against current main is misleading — main has moved on by ~5 months), and verification of each candidate against current main sources. Nothing was executed; all findings are from source reading.

@rgommers
rgommers / pep_825_metadata_consistency.md
Created August 10, 2026 08:38
Metadata consistency in PEP 825: what we require, and why

Metadata consistency in PEP 825: what we require, and why

Intended to answer the request in post 154, that the PEP argue positively that the consistency constraint is valid, and the request in post 172, to be open about the motivation and discuss the trade-offs. The specification text is landing separately in a PR (see peps#5086); this is the reasoning behind it. NOTE: we can summarize this in the PEP later, or add it in whole as a supplementary document.


1. What is actually being required

Metadata consistency has come up in several forms across this thread, and we have been answering each instance separately rather than laying out the whole picture. Before defending the requirement it is worth being precise about how small it is.

@rgommers
rgommers / options-analysis-toml-version-pyproject.md
Last active August 25, 2026 14:28
Options Analysis - TOML Versioning for pyproject.toml

Options Analysis — TOML Versioning for pyproject.toml

Status: Draft for discussion · Decision target: packaging spec update (PyPA specs / possible PEP) · Date: 2026-07-19


Summary

The packaging specifications require pyproject.toml to be written in TOML, but do not pin a TOML version. TOML 1.1.0 has now been released, and the parsers actually deployed

@rgommers
rgommers / numpy_tsan_test_suite_runtime.md
Last active December 19, 2025 20:20
NumPy test suite runtime estimates pytest-run-parallel and TSan

On a macOS arm64 (M1) machine, running the NumPy test suite:

Default build:

  • pixi r test -- --collect-only: 10 s
  • pixi r test (1 thread): 163 s.
  • pixi r test -j2 (pytest-xdist): 116 s.

Free-threaded build (python 3.14):

  • pixi r test-nogil -- --collect-only: 10 s
  • pixi r test-nogil -- --collect-only --parallel-threads=2: 30 s
@rgommers
rgommers / f2py_callback_gees_user_routines.c
Created July 17, 2024 19:54
f2py snippet for a LAPACK function with a callback
/******************* See f2py2e/cb_rules.py: buildcallback *******************/
/********************* cb_cselect_in_gees__user__routines *********************/
typedef struct {
PyObject *capi;
PyTupleObject *args_capi;
int nofargs;
jmp_buf jmpbuf;
} cb_cselect_in_gees__user__routines_t;
@rgommers
rgommers / list_torchdata_deps.txt
Created July 2, 2024 08:18
torchdata dependencies (July 2024)
$ # For top-level dependencies, see the conda-forge metadata browser:
$ # https://conda-metadata-app.streamlit.app/?q=conda-forge%2Flinux-64%2Ftorchdata-0.7.1-py39h02e9b37_5.conda
$ mamba create -n torchdata torchdata # on macOS arm64
$ mamba activate torchdata
$ mamba repoquery depends torchdata
Executing the query torchdata
@rgommers
rgommers / blas_lapack_meson_notes.md
Last active May 31, 2026 10:09
Notes on BLAS/LAPACK library details and conventions

Conda-forge library names and pkg-config output

@rgommers
rgommers / spack-scipy-oneapi-build.log
Created October 13, 2022 13:26
A build for SciPy 1.8.1 with oneAPI compilers (with a build failure)
==> py-scipy: Executing phase: 'install'
==> [2022-10-13-12:45:50.325962] '/home/rgommers/code/spack/opt/spack/linux-endeavourosrolling-skylake_avx512/oneapi-2022.2.0/python-3.9.13-mn4ovd4dkbyg62orinqikrnvaxq6r5tf/bin/python3.9' '-m' 'pip' '-vvv' '--no-input' '--no-cache-dir' '--disable-pip-version-check' 'install' '--no-deps' '--ignore-installed' '--no-build-isolation' '--no-warn-script-location' '--no-index' '--prefix=/home/rgommers/code/spack/opt/spack/linux-endeavourosrolling-skylake_avx512/oneapi-2022.2.0/py-scipy-1.8.1-ww5y2ruckqwn44vypo4e7yl3yzmxiwsh' '.'
Using pip 22.2.2 from /home/rgommers/code/spack/opt/spack/linux-endeavourosrolling-skylake_avx512/oneapi-2022.2.0/py-pip-22.2.2-42kbxmhhxyigyp2224oarapc3o5xxpga/lib/python3.9/site-packages/pip (python 3.9)
Non-user install due to --prefix or --target option
Ignoring indexes: https://pypi.org/simple
Created temporary directory: /tmp/pip-ephem-wheel-cache-vju1m2iu
Created temporary directory: /tmp/pip-build-tracker-h5l54x96
Initialized build tracking at
@rgommers
rgommers / jax_numpy_random_apis.py
Created June 1, 2022 17:40
Comparing JAX and NumPy APIs for random number generation - serial and parallel
"""
Implement `jax.random` APIs with NumPy, and `numpy.random` APIs with JAX.
The purpose of this is to be able to compare APIs more easily, and clarify
where they are and aren't similar.
"""
import secrets
import multiprocessing
import numpy as np