torchspin 0.6.7__tar.gz → 0.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. {torchspin-0.6.7 → torchspin-0.7.0}/CHANGELOG.md +74 -0
  2. {torchspin-0.6.7 → torchspin-0.7.0}/CITATION.cff +1 -1
  3. {torchspin-0.6.7 → torchspin-0.7.0}/PKG-INFO +8 -4
  4. {torchspin-0.6.7 → torchspin-0.7.0}/README.md +4 -3
  5. {torchspin-0.6.7 → torchspin-0.7.0}/pyproject.toml +2 -1
  6. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/__init__.py +1 -1
  7. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/_linalg.py +6 -2
  8. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/esfit.py +434 -225
  9. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/ml.py +32 -12
  10. torchspin-0.7.0/torchspin/parallel.py +135 -0
  11. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin.egg-info/PKG-INFO +8 -4
  12. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin.egg-info/SOURCES.txt +1 -0
  13. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin.egg-info/requires.txt +4 -0
  14. {torchspin-0.6.7 → torchspin-0.7.0}/LICENSE.md +0 -0
  15. {torchspin-0.6.7 → torchspin-0.7.0}/MANIFEST.in +0 -0
  16. {torchspin-0.6.7 → torchspin-0.7.0}/setup.cfg +0 -0
  17. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/_cardamom_istos.py +0 -0
  18. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/_cardamom_propagatedm.py +0 -0
  19. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/_cardamom_utils.py +0 -0
  20. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/_compile.py +0 -0
  21. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/_omp.py +0 -0
  22. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/_resources.py +0 -0
  23. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/_rng.py +0 -0
  24. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/angmom.py +0 -0
  25. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/autograd.py +0 -0
  26. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/autoguess.py +0 -0
  27. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/batch.py +0 -0
  28. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/blochsteady.py +0 -0
  29. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/cardamom.py +0 -0
  30. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/chili.py +0 -0
  31. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/chili_sle.py +0 -0
  32. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/constants.py +0 -0
  33. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/convspec.py +0 -0
  34. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/ctafft.py +0 -0
  35. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/curry.py +0 -0
  36. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/data/FourierSeriesCoefficients.txt +0 -0
  37. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/data/GaussianCascadeCoefficients.txt +0 -0
  38. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/data/isotopedata.txt +0 -0
  39. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/data/spacegroups.txt +0 -0
  40. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/dataproc.py +0 -0
  41. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/dipbackground.py +0 -0
  42. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/dipkernel.py +0 -0
  43. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/diptensor.py +0 -0
  44. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/endorfrq.py +0 -0
  45. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/endorfrq_perturb.py +0 -0
  46. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/eprload.py +0 -0
  47. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/eprsave.py +0 -0
  48. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/evolve.py +0 -0
  49. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/ewrls.py +0 -0
  50. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/excitation.py +0 -0
  51. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/exciteprofile.py +0 -0
  52. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/experiment.py +0 -0
  53. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/exponfit.py +0 -0
  54. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/fastmotion.py +0 -0
  55. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/fdaxis.py +0 -0
  56. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/fitgui.py +0 -0
  57. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/garlic.py +0 -0
  58. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/gridcheck.py +0 -0
  59. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/ham.py +0 -0
  60. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/ham_cf.py +0 -0
  61. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/ham_ee.py +0 -0
  62. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/ham_ez.py +0 -0
  63. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/ham_ezho.py +0 -0
  64. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/ham_hf.py +0 -0
  65. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/ham_nn.py +0 -0
  66. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/ham_nq.py +0 -0
  67. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/ham_nz.py +0 -0
  68. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/ham_oz.py +0 -0
  69. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/ham_so.py +0 -0
  70. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/ham_zf.py +0 -0
  71. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/hamsymm.py +0 -0
  72. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/initstate.py +0 -0
  73. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/isotopologues.py +0 -0
  74. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/levels.py +0 -0
  75. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/levelsplot.py +0 -0
  76. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/lineshape.py +0 -0
  77. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/lpsvd.py +0 -0
  78. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/makespec.py +0 -0
  79. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/mdhmm.py +0 -0
  80. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/mdload.py +0 -0
  81. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/mdtraj2oripot.py +0 -0
  82. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/mlpsvd.py +0 -0
  83. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/nucdata.py +0 -0
  84. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/nucfrq2d.py +0 -0
  85. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/orca2torchspin.py +0 -0
  86. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/ordering.py +0 -0
  87. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/oripotentialplot.py +0 -0
  88. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/orisel.py +0 -0
  89. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/pepper.py +0 -0
  90. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/pepper_autograd.py +0 -0
  91. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/photoselect.py +0 -0
  92. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/plegendre.py +0 -0
  93. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/propint.py +0 -0
  94. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/pulse.py +0 -0
  95. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/py.typed +0 -0
  96. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/rapidscan2spc.py +0 -0
  97. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/resfields.py +0 -0
  98. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/resfields_batch.py +0 -0
  99. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/resfields_eig.py +0 -0
  100. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/resfields_hybrid.py +0 -0
  101. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/resfields_perturb.py +0 -0
  102. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/resfreqs_matrix.py +0 -0
  103. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/resfreqs_perturb.py +0 -0
  104. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/resonator.py +0 -0
  105. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/resonatorprofile.py +0 -0
  106. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/rfmixer.py +0 -0
  107. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/rotations.py +0 -0
  108. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/rotutils.py +0 -0
  109. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/saffron.py +0 -0
  110. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/saffron_pathways.py +0 -0
  111. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/saffron_peaks.py +0 -0
  112. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/saffron_thyme.py +0 -0
  113. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/salt.py +0 -0
  114. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/sigeq.py +0 -0
  115. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/signalprocessing.py +0 -0
  116. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/sitetransforms.py +0 -0
  117. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/sphgrid.py +0 -0
  118. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/spidyan.py +0 -0
  119. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/spinladder.py +0 -0
  120. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/spinops.py +0 -0
  121. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/spinsystem.py +0 -0
  122. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/stackplot.py +0 -0
  123. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/stev.py +0 -0
  124. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/stochtraj_diffusion.py +0 -0
  125. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/stochtraj_jump.py +0 -0
  126. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/strainwidth.py +0 -0
  127. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/transmitter.py +0 -0
  128. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin/utils.py +0 -0
  129. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin.egg-info/dependency_links.txt +0 -0
  130. {torchspin-0.6.7 → torchspin-0.7.0}/torchspin.egg-info/top_level.txt +0 -0
@@ -6,6 +6,80 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.7.0] — 2026-11-09
10
+
11
+ CPU-parallel fitting and data generation. Default behavior (`n_workers=1`,
12
+ `simulate_batch(workers=0)`) is unchanged; no physics code changed.
13
+
14
+ ### Changed — behavior differs from 0.6.7
15
+
16
+ - **`FitOptions.n_workers` now also applies to levmar, trf, lbfgsb and the
17
+ uncertainty estimate of every method**, not only to the population methods.
18
+ A script that already set `n_workers='auto'` (or an integer > 1) for one of
19
+ these methods used to get no parallelism; it now starts spawned worker
20
+ processes, which needs the usual `if __name__ == '__main__':` guard around
21
+ the code that runs the fit.
22
+
23
+ ### Added
24
+
25
+ - **Parallel finite differences in esfit.** With `FitOptions(n_workers > 1)`
26
+ or `'auto'`, the independent finite-difference probes run in the worker pool:
27
+ levmar's initial Jacobian (n + 1 calls), every trf Jacobian and L-BFGS-B
28
+ gradient (n calls each, through SciPy's `workers=`, SciPy ≥ 1.16; older SciPy
29
+ runs them sequentially with a warning) and the uncertainty Jacobian (2n
30
+ calls). Probe points, recording order and evaluation counts are unchanged, so
31
+ a model with deterministic output gives the same fit. For trf and lbfgsb,
32
+ SciPy evaluates the base point in the main process and the probes in workers
33
+ with fewer threads; torch round-off then differs at ~1e-14, which shows up as
34
+ a ~1e-6 relative Jacobian difference, far below what changes a fit. Measured
35
+ on a 224-core cluster node (4-parameter pepper fit, 8–64 threads): levmar
36
+ 1.6–1.7×, trf 2.6–3.2× faster. The uncertainty Jacobian no longer evaluates
37
+ an unused base point.
38
+ - **`FitOptions.devices`**, e.g. `['cuda:0', 'cuda:1']`: process workers are
39
+ pinned to these GPUs round-robin (`CUDA_VISIBLE_DEVICES` per worker), so a
40
+ model with `device='cuda'` runs on its own GPU.
41
+ - **`torchspin.ml.simulate_batch` reuses its worker pool** (shared with esfit)
42
+ instead of starting one per call, sends rows in chunks, and accepts
43
+ `workers='auto'`. Cu(II) on a 64-core node: 197 → 1473 spectra/s with 64
44
+ workers (one process: 42; one A100 GPU: 76). An interrupted batch terminates
45
+ the pool.
46
+ - **`torchspin.parallel`** (public): `cpu_budget()` (CPU affinity, then SLURM,
47
+ then the machine), `inner_threads()`, the `thread_budget(n)` context manager
48
+ (caps torchspin's inner pools, and BLAS with `blas=True` when `threadpoolctl`
49
+ is installed) and `native_thread_env(n)` for spawned workers (also passes
50
+ `OMP_WAIT_POLICY=PASSIVE`).
51
+ - Optional extra `[hpc]` (`threadpoolctl`, `cloudpickle`).
52
+ - Docs: `docs/pitfalls.md`, "Training sets of large spin systems" (orientation
53
+ symmetry and `Options.Threshold`: for Cu(II) with two ¹⁴N, `Threshold=1e-2`
54
+ was 3.6× faster with a 0.4 % spectrum change).
55
+ - Benchmarks:
56
+ - end-to-end esfit workloads (levmar and trf, sequential and with process
57
+ workers; swarm with process and thread backends; a nested-parallelism case);
58
+ - `benchmarks/workloads/ml_throughput.py` (spectra per second of
59
+ `simulate_batch`);
60
+ - `benchmarks/analysis/compare_baseline.py`, which saves host-free baselines
61
+ and flags regressions;
62
+ - a generic SLURM job-array template, `benchmarks/cluster/slurm_array_template.sbatch`;
63
+ - `run_workloads.py --save-outputs`;
64
+ - `docs/v1_acceleration/`: the acceleration review and roadmap with the
65
+ measurement log.
66
+
67
+ ### Fixed
68
+
69
+ - `benchmarks/workloads/run_workloads.py`:
70
+ - `--threads N` now overwrites the native thread variables. With an
71
+ inherited `OMP_NUM_THREADS` (as batch scripts set it), "1-thread" runs used
72
+ to keep every core in the native pools.
73
+ - It also caps Apple Accelerate (`VECLIB_MAXIMUM_THREADS`).
74
+ - `--procs` starts its process pool once, outside the timed replicates.
75
+ - A failing workload is recorded instead of aborting the run.
76
+ - It imports torchspin before torch and records `OMP_WAIT_POLICY`.
77
+
78
+ ### Removed
79
+
80
+ - `benchmarks/cluster/slurm_cpu.sh` and `slurm_gpu.sh`, replaced by the
81
+ array template. The CPU script's thread sweep was mislabeled (see Fixed).
82
+
9
83
  ## [0.6.7] — 2026-11-09
10
84
 
11
85
  ### Fixed
@@ -2,7 +2,7 @@ cff-version: 1.2.0
2
2
  message: "If you use torchspin in your research, please cite both torchspin and the upstream EasySpin paper."
3
3
  title: "torchspin: Differentiable PyTorch port of EasySpin for EPR spectroscopy"
4
4
  type: software
5
- version: "0.6.7"
5
+ version: "0.7.0"
6
6
  date-released: "2026-11-09"
7
7
  license: MIT
8
8
  authors:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: torchspin
3
- Version: 0.6.7
3
+ Version: 0.7.0
4
4
  Summary: Differentiable PyTorch port of EasySpin - EPR/ESR spin Hamiltonian and spectrum simulation
5
5
  Author-email: Alec Follmer <ahfollmer@ucdavis.edu>
6
6
  Maintainer-email: Alec Follmer <ahfollmer@ucdavis.edu>
@@ -31,6 +31,9 @@ Provides-Extra: plot
31
31
  Requires-Dist: matplotlib>=3.6; extra == "plot"
32
32
  Provides-Extra: fit
33
33
  Requires-Dist: cloudpickle>=2.0; extra == "fit"
34
+ Provides-Extra: hpc
35
+ Requires-Dist: threadpoolctl>=3.1; extra == "hpc"
36
+ Requires-Dist: cloudpickle>=2.0; extra == "hpc"
34
37
  Provides-Extra: gui
35
38
  Requires-Dist: ipywidgets>=7.6; extra == "gui"
36
39
  Requires-Dist: matplotlib>=3.6; extra == "gui"
@@ -153,9 +156,10 @@ print('Best-fit g:', result.pfit)
153
156
  `progress='text'` prints RMSD, evaluation count and ETA as it runs, and
154
157
  interrupting the kernel returns the best fit so far.
155
158
 
156
- Population methods (swarm, genetic, grid, montecarlo, global) can evaluate each
157
- generation in parallel worker processes with `FitOptions(n_workers='auto')`. This
158
- is off by default. Each worker is a separate Python process with its own torch
159
+ With `FitOptions(n_workers='auto')`, model evaluations run in parallel worker
160
+ processes: each generation of the population methods (swarm, genetic, grid,
161
+ montecarlo, global), and the finite-difference probes of each levmar, trf and
162
+ lbfgsb Jacobian (1.5–3× faster for a 4-parameter pepper fit). This is off by default. Each worker is a separate Python process with its own torch
159
163
  (about 0.3–0.5 GB), so `'auto'` uses the cores you were allocated, at most 32, and
160
164
  no more workers than fit in half the free memory. A script that uses it needs the
161
165
  usual `if __name__ == '__main__':` guard around the code that runs the fit.
@@ -98,9 +98,10 @@ print('Best-fit g:', result.pfit)
98
98
  `progress='text'` prints RMSD, evaluation count and ETA as it runs, and
99
99
  interrupting the kernel returns the best fit so far.
100
100
 
101
- Population methods (swarm, genetic, grid, montecarlo, global) can evaluate each
102
- generation in parallel worker processes with `FitOptions(n_workers='auto')`. This
103
- is off by default. Each worker is a separate Python process with its own torch
101
+ With `FitOptions(n_workers='auto')`, model evaluations run in parallel worker
102
+ processes: each generation of the population methods (swarm, genetic, grid,
103
+ montecarlo, global), and the finite-difference probes of each levmar, trf and
104
+ lbfgsb Jacobian (1.5–3× faster for a 4-parameter pepper fit). This is off by default. Each worker is a separate Python process with its own torch
104
105
  (about 0.3–0.5 GB), so `'auto'` uses the cores you were allocated, at most 32, and
105
106
  no more workers than fit in half the free memory. A script that uses it needs the
106
107
  usual `if __name__ == '__main__':` guard around the code that runs the fit.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "torchspin"
7
- version = "0.6.7"
7
+ version = "0.7.0"
8
8
  description = "Differentiable PyTorch port of EasySpin - EPR/ESR spin Hamiltonian and spectrum simulation"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -49,6 +49,7 @@ Issues = "https://github.com/follmerlab/torchspin/issues"
49
49
  [project.optional-dependencies]
50
50
  plot = ["matplotlib>=3.6"]
51
51
  fit = ["cloudpickle>=2.0"] # process-pool esfit with notebook-defined models
52
+ hpc = ["threadpoolctl>=3.1", "cloudpickle>=2.0"] # BLAS thread caps (torchspin.parallel.thread_budget(blas=True)), process pools
52
53
  gui = ["ipywidgets>=7.6", "matplotlib>=3.6", "ipympl>=0.9", "ipython>=7", "cloudpickle>=2.0"] # interactive fitting panel (torchspin.fitgui)
53
54
  test = ["pytest>=7", "pytest-cov", "matplotlib>=3.6", "cloudpickle>=2.0", "ipywidgets>=7.6"]
54
55
  dev = ["pytest>=7", "pytest-cov", "build", "twine", "matplotlib>=3.6", "cloudpickle>=2.0", "ipywidgets>=7.6"]
@@ -25,7 +25,7 @@ try:
25
25
  __version__ = _pkg_version("torchspin")
26
26
  except _PkgNotFound:
27
27
  # Editable install during development, or version metadata unavailable.
28
- __version__ = "0.6.7+dev"
28
+ __version__ = "0.7.0+dev"
29
29
 
30
30
  # Idle OpenMP threads must sleep, not spin-wait (see torchspin/_omp.py and
31
31
  # docs/pitfalls.md, "Threads and performance"). This has to run before anything
@@ -24,6 +24,8 @@ from concurrent.futures import ThreadPoolExecutor
24
24
  import numpy as np
25
25
  import torch
26
26
 
27
+ from torchspin.parallel import inner_threads
28
+
27
29
  _MIN_BATCH = 32 # below this the pool overhead is not worth it
28
30
  _CUSOLVER_BATCHED_MAX = 32 # syevjBatched limit
29
31
  # Workspace the batched CUDA solver reserves per matrix. Measured on torch 2.14 / CUDA 13:
@@ -55,7 +57,9 @@ def _executor(w: int) -> ThreadPoolExecutor:
55
57
 
56
58
 
57
59
  def _pool_size(nb: int) -> int:
58
- return max(1, min(torch.get_num_threads(), nb // 8))
60
+ # inner_threads() is torch.get_num_threads(), or less inside a
61
+ # torchspin.parallel.thread_budget (e.g. in an esfit worker)
62
+ return max(1, min(inner_threads(), nb // 8))
59
63
 
60
64
 
61
65
  def _one(fn, np_fn, A: torch.Tensor, allow_numpy: bool = True):
@@ -236,7 +240,7 @@ def pool_map(fn, items: list):
236
240
  concurrently instead of contending. Falls back to a plain map for one item
237
241
  or one thread.
238
242
  """
239
- w = min(torch.get_num_threads(), len(items))
243
+ w = min(inner_threads(), len(items))
240
244
  if w <= 1:
241
245
  return [fn(it) for it in items]
242
246
  with _threads_lock: