Skip to content

Self Energy Calculation Acceleration: Optimizing the parallelization logic - #49

Merged
AsymmetryChou merged 30 commits into
deepmodeling:mainfrom
AsymmetryChou:se_acc
Nov 1, 2026
Merged

AsymmetryChou merged 30 commits into
deepmodeling:mainfrom
AsymmetryChou:se_acc

Conversation

@AsymmetryChou

Copy link
Copy Markdown
Collaborator

This pull request significantly improves the parallelization logic and documentation for the self-energy calculation in dpnegf/negf/lead_property.py. The main focus is on making CPU and memory budget handling more robust, clarifying and enforcing input parameter validation, and introducing per-batch, adaptive BLAS threading strategies for better performance and resource safety. Documentation for these options is also updated for clarity and accuracy.

Parallelization and resource management improvements:

  • Introduced _resolve_cpu_budget to consistently interpret and validate cpu_budget, defaulting to a safe value if unspecified or invalid. Now used throughout worker and BLAS thread selection. [1] [2]
  • Improved _get_safe_n_workers to handle n_workers=None as auto, validate types more strictly, and always cap by the resolved CPU budget. [1] [2]
  • Enhanced input validation in compute_all_self_energy for n_workers, blas_threads, and ek_batch_size, raising clear errors for invalid values.

Per-batch BLAS threading and scheduling:

  • Reworked BLAS threading logic: each batch now determines its own optimal thread count based on batch size, CPU budget, and problem size, caching choices by concurrency level. Short batches and small systems skip autotuning for efficiency; longer or larger batches use sample-based autotuning with a soft time budget. [1] [2] [3]
  • Each batch logs its scheduling and threading decisions for transparency and debugging.

Documentation updates:

  • Updated run_options.rst to clarify the meaning, default, and validation rules for n_workers, cpu_budget, blas_threads, and ek_batch_size, reflecting the new logic and constraints.
  • Improved docstrings in code to match the new behavior and clarify parameter effects and error handling. [1] [2] [3]

Code quality and safety:

  • Replaced loose type checks with numbers.Integral for robust integer validation, and added explicit checks to prevent boolean values from being interpreted as integers. [1] [2] [3]
  • Ensured all parameter handling and scheduling decisions are safe and predictable, with clear fallbacks and warnings for edge cases. [1] [2] [3]

These changes collectively make parallel execution safer, more efficient, and easier to configure and debug.

@AsymmetryChou AsymmetryChou changed the title Self energy Calculation Acceleration: Optimizing the parallelization logic Self Energy Calculation Acceleration: Optimizing the parallelization logic Nov 1, 2026
@AsymmetryChou
AsymmetryChou merged commit 343184c into deepmodeling:main Nov 1, 2026
1 check passed
@AsymmetryChou
AsymmetryChou deleted the se_acc branch November 1, 2026 07:19
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