Skip to content

GPU-accelerate dI/dV (no tilting)#54

Open
GianmarcoMidena wants to merge 17 commits into
masterfrom
44-enable-gpu-acceleration
Open

GPU-accelerate dI/dV (no tilting)#54
GianmarcoMidena wants to merge 17 commits into
masterfrom
44-enable-gpu-acceleration

Conversation

@GianmarcoMidena

@GianmarcoMidena GianmarcoMidena commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

GPU Acceleration Support for dI/dV (no tilting) with Multiple Backend Options

This PR enables GPU acceleration of dI/dV calculations via OpenCL or PyTorch and provides alternative computational backends. The changes include comprehensive test coverage and improved development environment configuration.

Key Changes

Backend Support

  • Add OpenCL and PyTorch backends for GPU-accelerated dI/dV calculations (parallel and sequential modes)
  • Add NumPy backend for dI/dV calculations as a pure Python fallback
  • Introduce DidvBackend enum for runtime backend selection
  • Update dIdV(), STM(), and MSTM() to support backend parameter

Development Environment

  • Add development environment environment_dev_gpu_intel.yml with Intel GPU support
  • Add Intel Compute Runtime
  • Add PyOpenCL and PyTorch configurations
  • Add PYOPENCL_COMPILER_OUTPUT environment variable for debugging

Testing Infrastructure

  • Restructure tests into unit/ and integration/ directories
  • Add comprehensive dI/dV backend consistency tests (unit and integration)
  • Add dI/dV core property tests (determinism, batching, symmetry)
  • Add pytest configuration for backend parametrization
  • Implement shared test utilities for code reuse

Examples & Benchmarking

  • Add orbitals test configurations: s_sp.toml, pxy_sp.toml, pz_sp.toml
  • Add benchmark infrastructure for Si(111) 7×7 system with multiple backends
  • Add benchmarking script with execution time measurement
  • Add tilting coronene examples with pxy and dz2 tip orbitals
  • Improve example test harness with additional test cases

Bug Fixes & Improvements

  • Fix dxz orbital coefficient formula in cpp/MatOrb.cpp
  • Improve precision of eta formatting (.1f → .7f) in output file names
  • Improve test coverage by renaming and refactoring existing IO tests
  • Update documentation with test running instructions and coverage reporting

Testing

  • All backends tested for consistency against C++ reference implementation
  • Unit tests with synthetic tip positions (51×51×51 grid)
  • Integration tests with STM-generated real tip positions
  • Symmetry tests verifying even-symmetric behavior
  • Core property tests validating determinism and batching

Extras

  • Validate config argument in ppstm_run.py

Closes

#44, #55

@GianmarcoMidena GianmarcoMidena linked an issue Jul 9, 2026 that may be closed by this pull request
35 tasks
@GianmarcoMidena
GianmarcoMidena force-pushed the 44-enable-gpu-acceleration branch 10 times, most recently from 910b6f8 to 39c797f Compare July 14, 2026 08:21
Add environment_dev_gpu_intel.yml with PYOPENCL_COMPILER_OUTPUT=1 to show PyOpenCL compiler messages during builds on Intel GPU systems.
Add environment_dev_icd_system.yml with PYOPENCL_COMPILER_OUTPUT=1 to show PyOpenCL compiler messages during builds on Intel GPU systems.
@GianmarcoMidena
GianmarcoMidena force-pushed the 44-enable-gpu-acceleration branch 7 times, most recently from ceb104b to 3b3d040 Compare July 16, 2026 05:28
Core functionality:
- Ensure single scalar output per tip position
- Verify tip position effects on dI/dV output
- Support diagonal and non-diagonal LCAO coefficients
- Use backend-specific tolerances for numerical comparison

Test coverage:
- Single and multiple sample positions
- s, pz, pxy, dz2, dxzyz, CO tip orbitals for sp sample orbital combinations
- s, pz, pxy, CO tip orbitals for spd sample orbital combinations

Symmetry verification:
- Verify dI/dV even-symmetry at tip center for s tip orbital

Backend consistency:
- Ensure consistency between batch and individual processing modes
- Verify consistency across multiple executions
- Validate parity between C++ and OpenCL backends (parallel and sequential)
- Validate parity between C++ and NumPy backends (reference: Krejčí et al. 2017)
- Validate parity between C++ and PyTorch backends (reference: Krejčí et al. 2017)
- Add integration tests with real tip positions
…rbitals

Fix incorrect s sample orbital conductance computation in C++ for dxz tip orbitals interacting with sp sample orbitals.
Implement OpenCL kernels for dI/dV calculations with:
- Parallel and sequential execution modes
- spd samples: s, pz, px, py tip orbitals
- sp samples: s, pz, px, py, dz2, dxz, dyz tip orbitals

Ensure arrays are contiguous (C order) before kernel execution via np.ascontiguousarray().
Implement dI/dV calculations in NumPy backend with support for:
- spd samples: s, pz, px, py tip orbitals
- sp samples: s, pz, px, py, dz2, dxz, dyz tip orbitals

Based on Krejčí et al. (2017) and existing C++ implementation.
Avoid allocating too big intermediate arrays during dI/dV computation so
large examples such as Si_7x7 can complete without exhausting
available memory.
@GianmarcoMidena
GianmarcoMidena force-pushed the 44-enable-gpu-acceleration branch from 3b3d040 to 22b910a Compare July 16, 2026 07:51
Implement dI/dV calculations in PyTorch backend with support for:
- spd samples: s, pz, px, py tip orbitals
- sp samples: s, pz, px, py, dz2, dxz, dyz tip orbitals

Improve efficiency of orbital conductance computation.

Based on Krejčí et al. (2017) and existing C++ implementation.
Add a benchmark suite for measuring dI/dV calculation runtime across
C++, OpenCL, NumPy, and PyTorch backends on both local and Slurm cluster
environments.
Use argparse to parse the PP-STM config file path instead of reading
sys.argv directly. Validate the provided path before loading the TOML
configuration.
@GianmarcoMidena
GianmarcoMidena force-pushed the 44-enable-gpu-acceleration branch from 22b910a to c92f16f Compare July 16, 2026 10:55
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.

GPU-accelerate dIdV (no tilt)

2 participants