Skip to content

gpu#1

Open
vlladyg wants to merge 6 commits intomainfrom
VVCORE_gpu
Open

gpu#1
vlladyg wants to merge 6 commits intomainfrom
VVCORE_gpu

Conversation

@vlladyg
Copy link
Owner

@vlladyg vlladyg commented Jan 23, 2025

GPU modules for the VVCORE library


Note

Introduce a CuPy/MPI-based GPU pipeline for current/density computations with GPU-aware I/O and memory management, and remove the previous MPI/C-extension implementation.

  • Core GPU implementation
    • Add signals.py with CuPy-based computation of dens, cur, cur_L, cur_T, including longitudinal/transverse projections and VRAM-aware partitioning.
    • Add trajectory_reader.py that reads HDF5 (H5MD) directly to GPU arrays (cupy) and slices frames per-rank.
    • Add VVCORE.py entrypoint orchestrating MPI ranks, NVML GPU assignment, GPU memory queries, compute, gather, and HDF5 output.
    • Add utils.py helpers updated for CuPy arrays: index loading from ind.h5, device-to-host transfer (dict_from_device), stacking, saving, and memory splitting (signal_mem).
    • Add qgrids.py GPU-branch generators for FCC/BCC/SC and optional file-based grids.
  • Tests/Tooling
    • Add GPU/MPI test scripts (device_count_test.py, test-cuda-aware-mpi4py.py, test_parallel_h5py.py, memory_*_test.py) and run.sh (SLURM example).
    • Add example data path data/NaBr_T300K.h5.
  • Documentation
    • Overhaul README.md for the GPU branch: setup, usage, MPI multi-GPU, configuration, API, and troubleshooting.
  • Removals (legacy MPI/C implementation)
    • Remove VVCORElib_mpi package, CLI scripts (VVCORE_mpi*), C extensions (src/_rho_j_k.c), and setup.py.

Written by Cursor Bugbot for commit bf42977. This will update automatically on new commits. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is being reviewed by Cursor Bugbot

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

"""Initializes computations for signal"""
traj = trajectory_h5(traj_file, vel_flag = not (len(opts) == 1 and opts[0] == 'dens'))

if os.path.exists(f"qrid.h5"):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Typo in file check prevents loading custom Q-grid

The file existence check uses "qrid.h5" but the correct filename is "qgrid.h5" (missing 'g'). This causes the code to never detect a user's custom Q-grid file even when it exists. The from_file() function in qgrids.py opens "qgrid.h5", and the documentation also references qgrid.h5. Users who create custom Q-grid files following the documentation will find their files silently ignored, with the code falling back to lattice-based grid generation instead.

Fix in Cursor Fix in Web


start_time_init = time.time()

mem = info.free/2**20/(comm.size//num_of_devices)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Division by zero when fewer processes than GPUs

The memory calculation mem = info.free/2**20/(comm.size//num_of_devices) causes a ZeroDivisionError when the number of MPI processes is less than the number of GPUs. For example, running with 2 processes on a 4-GPU system results in comm.size//num_of_devices = 2//4 = 0. This is a common scenario when testing or running quick analyses on multi-GPU systems.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant