Skip to content

Opt-in device or pinned memory for tuning backups; less host overhead in the HISQ tests - #1671

Open
weinbe2 wants to merge 8 commits into
developfrom
feature/tune-backup-memory
Open

weinbe2 wants to merge 8 commits into
developfrom
feature/tune-backup-memory

Conversation

@weinbe2

@weinbe2 weinbe2 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

This PR was motivated by hisq force auto-tuning taking forever... and finding out that a lot of the time was actually spent in the copies for backing up and restoring fields.

New features

  • QUDA_TUNE_BACKUP_MEMORY=host|pinned|device selects the memory for the backups that device GaugeField, ColorSpinorField and CloverField objects make in preTune() and restore in postTune():
    • host (default): a fresh pageable host allocation per backup, as before.
    • pinned: pooled pinned host memory.
    • device: device memory, allocated outside QUDA's device memory pool.
  • Host fields always back up to host memory.
  • An unknown value is an error. With device, running out of device memory errors as any device allocation does.
  • This is opt-in only b/c it can lead to functionality regressions, i.e., runs with tuning now failing... this can be pretty chunky with the extra pool memory it allocates, especially with MG, etc.

Performance

  • hisq_stencil_test and hisq_stencil_ctest: the CPU reference fat and long links are built on the first verify() instead of in setup. The ctest still builds its reference with the Naik term.
  • unitarizeLinksCPU and fermion_force::unitarizeForceCPU: the loop over sites is parallelized with OpenMP.

Bug fixes

  • hisq_paths_force_test: when tuning, each force kernel is first called untimed, so the reported times exclude tuning.
  • hisq_stencil_test and hisq_stencil_ctest: destroy() frees only the buffers that were allocated. Previously the Naik reference buffers were freed only if the last test used the Naik term.
  • CloverField::backup() / restore(): the inverse is backed up only if the field holds one at backup time, and restore() restores exactly what was backed up. Previously a second buffer was always allocated, and the inverse was restored whenever the field held one at restore time.

Testing

Build: STRICT, sm_100, MPI, OpenMP, staggered. Single rank on one B200 (x86 host).

  • hisq_paths_force_test --partition 14 --prec single --recon 13 --verify false, empty tunecache:

    Local volume host pinned device
    18×18×36×72 161 s 34 s 26 s
    144×18×36×72 1,237 s 205 s 142 s
  • 2.8 GiB copy rates on the same node:

    Copy Rate
    Device to host, fresh pageable malloc 2.0 GB/s
    Device to host, pageable already touched 18.5 GB/s
    Device to host, pinned 55 GB/s
    Device to device ~3,200 GB/s
  • hisq_paths_force_test --verify true (8×8×8×16, --partition 14, empty tunecache): passes in all three modes, single and double precision.

  • clover_force_test (ctest arguments, --compute-clover true, empty tunecache, QUDA_CLOVER_DYNAMIC=ON, so CloverInvert tunes and backs up the clover field): 16 of 16 pass in all three modes.

  • blas_test (ctest arguments, --nsrc 8 --msrc 9, empty tunecache, which backs up sets of color-spinor fields): 480 of 480 pass in all three modes.

  • Device backups outside the pool: 1/8 volume, device, 25.7 s, against 26.3 s with pooled device backups. An unpooled cudaMalloc + cudaFree costs about 0.7× the device-to-device backup and restore copies (1.3 ms against 1.8 ms at 2.75 GiB).

  • hisq_stencil_test, 24⁴: setup 6.8 s → 0.25 s with --verify false. Passes with --verify true, with and without the Naik term.

  • hisq_stencil_ctest: 64 passed; the 64 skipped are partition settings that are off by default.

  • unitarize_link_test and hisq_unitarize_force_test: pass in single and double precision.

  • hisq_paths_force_test with an empty tunecache now reports a staples time of 61.7 ms instead of 131,238 ms; with a filled tunecache it reports 45.6 ms.

  • git clang-format --diff origin/develop: no changes.

  • Multi-rank, with ranks sharing one GPU (QUDA_ENABLE_MPS=1), empty tunecaches:

    • 1 1 1 2: hisq_paths_force_test --verify true (2 of 2), clover_force_test (16 of 16) and blas_test (480 of 480) pass in all three modes.
    • 1 1 2 2: hisq_paths_force_test --verify true passes with host and device.

…that device gauge, color-spinor and clover fields make while tuning in pinned host or device memory instead of fresh pageable host memory, the default
…and long links only when verifying, on the first verify(), instead of in every run's setup
…ol, with a LatticeField::BackupMemPool helper
@mathiaswagner

Copy link
Copy Markdown
Member

Thinking out loud and might need more plumbing: Could we use managed ? Should go to device by default but could spill to host - probably slow but might not matter so much when tuning is slow to begin with.

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants