Portable BGMN threading/parallelism + fit-aware intensity-order pruning - #35
Merged
Andrea-gm merged 2 commits intoJul 31, 2026
Merged
Conversation
Change 1 — Bound BGMN threads, keep worker parallelism (portable): - New src/dara/hardware.py detects usable cores (SLURM env vars → os.sched_getaffinity → os.cpu_count). - settings.py adds BGMN_N_THREADS (default 1, env DARA_BGMN_N_THREADS) and RAY_NUM_CPUS (default = detected cores, env DARA_RAY_NUM_CPUS). - BGMN now runs 1 thread per refinement instead of 8, avoiding cores×8 OS-thread oversubscription. ray.init pins num_cpus=RAY_NUM_CPUS (SLURM-safe); the inner BGMN task uses .options(num_cpus=BGMN_N_THREADS); the outer orchestration task uses num_cpus=0 so it no longer pins a core while blocked, freeing all cores for BGMN refinements (concurrency ≈ cores/threads). - generate_control_file default n_threads now sourced from BGMN_N_THREADS. Change 2 — Don't discard a better-fitting branch on the intensity-order heuristic: - Existing intensity-order / low-weight-fraction detection is unchanged. - A flagged branch is now pruned only if it did NOT improve Rwp by at least 8% vs its parent (MATERIAL_RWP_IMPROVEMENT = 0.08), via the pure helper keep_branch_despite_intensity_order, guarded against missing/zero parent Rwp. - New tests/test_search_tree.py covers the helper and integration paths.
Reorders type-union members in result.py (parse_values) and utils.py (get_number) so None comes last, resolving the RUF036 errors flagged by CI's ruff. Purely a lint fix — no behavior change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change 1 — Bound BGMN threads, keep worker parallelism (portable):
Change 2 — Don't discard a better-fitting branch on the intensity-order heuristic:
Summary
Major changes:
Todos
If this is work in progress, what else needs to be done?
Checklist
Tip: Install
pre-commithooks to auto-check types and linting before every commit: