Skip to content

Memory access error using md.pair.Table with md.nlist.Tree on GPU #2284

Description

@mphoward

Description

We have run into an issue where we get a memory access error when using a tabulated pair potential with a tree neighbor list on the GPU. With CUDA error checking enabled, we get an error using the reproducer below like:

Traceback (most recent call last):
  File "/home/mphoward/Documents/projects/peg_cg/setup/debug/test/reproducer.py", line 33, in <module>
    sim.run(0)
    ~~~~~~~^^^
  File "/home/mphoward/Documents/projects/peg_cg/setup/debug/env/lib/python3.14/site-packages/hoomd/simulation.py", line 561, in run
    self._cpp_sys.run(steps_int, write_at_start)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: CUDA Error: an illegal memory access was encountered before /hoomd/md/NeighborListGPUTree.cc:442
unknown error
unknown error
unknown error
unknown error
unknown error

We don't get this error if we use md.pair.LJ instead. We also don't get this error if we use fewer points in the table, if we use md.nlist.Cell, or if we run on the CPU. This reproducer should not even have any pair interactions because there is only one particle.

Hence, I suspect something strange is going on between how the tabulated potential is being loaded into memory and how NeighborListGPUTree manages its memory, but I have no idea where to start looking to debug it!

Script

import hoomd
import numpy

# choose whether to use built-in WCA potential (True) or tabulated potential (False)
use_builtin = False

device = hoomd.device.GPU()
device.gpu_error_checking = True
sim = hoomd.Simulation(device=device)
snapshot = hoomd.Snapshot()
if snapshot.communicator.rank == 0:
    snapshot.configuration.box = [10, 10, 10, 0, 0, 0]
    snapshot.particles.types = ["A"]
    snapshot.particles.N = 1
sim.create_state_from_snapshot(snapshot)

nl = hoomd.md.nlist.Tree(buffer=0.4)
if use_builtin:
    wca = hoomd.md.pair.LJ(nlist=nl)
    wca.params[("A", "A")] = dict(epsilon=1.0, sigma=1.0)
else:
    r = numpy.linspace(1e-6, 2 ** (1 / 6), 1000, endpoint=False)
    u_lj = 4 * (numpy.power(r, -12) - numpy.power(r, -6) + 1 / 4)
    f_lj = 48 * (numpy.power(r, -13) - 0.5 * numpy.power(r, -7))
    wca = hoomd.md.pair.Table(nlist=nl)
    wca.params[("A", "A")] = dict(r_min=r[0], U=u_lj, F=f_lj)
wca.r_cut[("A", "A")] = 2 ** (1 / 6)

nve = hoomd.md.methods.ConstantVolume(filter=hoomd.filter.All())
integrator = hoomd.md.Integrator(dt=0.001, forces=[wca], methods=[nve])
sim.operations.integrator = integrator

sim.run(0)

Input files

No response

Output

Traceback (most recent call last):
  File "/home/mphoward/Documents/projects/peg_cg/setup/debug/test/reproducer.py", line 33, in <module>
    sim.run(0)
    ~~~~~~~^^^
  File "/home/mphoward/Documents/projects/peg_cg/setup/debug/env/lib/python3.14/site-packages/hoomd/simulation.py", line 561, in run
    self._cpp_sys.run(steps_int, write_at_start)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: CUDA Error: an illegal memory access was encountered before /hoomd/md/NeighborListGPUTree.cc:442
unknown error
unknown error
unknown error
unknown error
unknown error

Expected output

Run without error.

Platform

Linux

Installation method

Conda-forge package

HOOMD-blue version

7.0.1

Python version

3.14.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions