This came up while building the GPU engine for an open-source quantum chemistry app, and it may save someone a debugging session.
Libxc is the exchange-correlation functional library that most DFT codes use, and GPU4PySCF ships a CUDA build of Libxc 7.1.2 (gpu4pyscf-libxc-cuda12x 0.9.0). That build keeps functional parameter data in CUDA managed memory, and the host reads it between kernel launches. On a GPU where concurrentManagedAccess is 0, which includes GPUs under WSL2 and on native Windows, the host can't touch managed memory while kernels are in flight. GPU DFT then segfaults, and it only runs with CUDA_LAUNCH_BLOCKING=1, at about half speed.
The patch keeps that data in host memory and allocates the device buffers with cudaMalloc. The engine tests check that the patched libxc.so never calls cudaMallocManaged.
Measured on an RTX 3070 under WSL2 (driver 610.88), B3LYP-D3(BJ)/def2-SVP optimisation plus frequencies, median of three runs:
- Unpatched with synchronous launches: water 46.1 s, ethanol 101.3 s
- Patched with normal launches: water 22.9 s, ethanol 46.1 s
- Energies match the CPU to within 1e-10 Eh
The cause and fix are reported to Libxc (https://gitlab.com/libxc/libxc/-/issues/647) and GPU4PySCF (https://github.com/pyscf/gpu4pyscf/issues/1067). Libxc's maintainer replied that Libxc 8 rewrites GPU support as templated C++, so a 7.x fix is unlikely, and the engine carries the patch until a Libxc 8 build passes its tests.
The patch, the build stage and the measurements are in the repo: https://github.com/quachem/quachem-workbench/tree/main/docs/evidence/2026-11-26-libxc-engine-patch
This was debugged and written up with a lot of help from Claude.