faster-diffbloch 0.2.0__tar.gz → 0.2.2__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.
- {faster_diffbloch-0.2.0 → faster_diffbloch-0.2.2}/PKG-INFO +13 -7
- {faster_diffbloch-0.2.0 → faster_diffbloch-0.2.2}/README.md +10 -3
- {faster_diffbloch-0.2.0 → faster_diffbloch-0.2.2}/pyproject.toml +4 -7
- {faster_diffbloch-0.2.0 → faster_diffbloch-0.2.2}/src/faster_diffbloch/__init__.py +1 -1
- {faster_diffbloch-0.2.0 → faster_diffbloch-0.2.2}/src/faster_diffbloch/cli.py +21 -4
- {faster_diffbloch-0.2.0 → faster_diffbloch-0.2.2}/.gitignore +0 -0
- {faster_diffbloch-0.2.0 → faster_diffbloch-0.2.2}/LICENSE +0 -0
- {faster_diffbloch-0.2.0 → faster_diffbloch-0.2.2}/hatch_build.py +0 -0
- {faster_diffbloch-0.2.0 → faster_diffbloch-0.2.2}/src/faster_diffbloch/backend.py +0 -0
- {faster_diffbloch-0.2.0 → faster_diffbloch-0.2.2}/src/faster_diffbloch/builder.py +0 -0
- {faster_diffbloch-0.2.0 → faster_diffbloch-0.2.2}/src/faster_diffbloch/native/batch_cgemm.c +0 -0
- {faster_diffbloch-0.2.0 → faster_diffbloch-0.2.2}/src/faster_diffbloch/native/batch_cgemm.h +0 -0
- {faster_diffbloch-0.2.0 → faster_diffbloch-0.2.2}/src/faster_diffbloch/native/batch_cgemm.metal +0 -0
- {faster_diffbloch-0.2.0 → faster_diffbloch-0.2.2}/src/faster_diffbloch/native/bridge_lib.c +0 -0
- {faster_diffbloch-0.2.0 → faster_diffbloch-0.2.2}/src/faster_diffbloch/native/metal_batch_cgemm.m +0 -0
- {faster_diffbloch-0.2.0 → faster_diffbloch-0.2.2}/src/faster_diffbloch/native/native_scattering.c +0 -0
- {faster_diffbloch-0.2.0 → faster_diffbloch-0.2.2}/src/faster_diffbloch/native/native_scattering.h +0 -0
- {faster_diffbloch-0.2.0 → faster_diffbloch-0.2.2}/src/faster_diffbloch/scattering.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: faster-diffbloch
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Drop-in Metal GPU (macOS) and optimized CPU (macOS/Linux) acceleration for diffBloch
|
|
5
5
|
Project-URL: Homepage, https://godofecht.github.io/diffFlow/
|
|
6
6
|
Project-URL: Documentation, https://godofecht.github.io/diffFlow/
|
|
@@ -24,11 +24,10 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
24
24
|
Classifier: Programming Language :: Python :: 3.11
|
|
25
25
|
Classifier: Programming Language :: Python :: 3.12
|
|
26
26
|
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
27
|
-
Requires-Python: >=3.
|
|
27
|
+
Requires-Python: >=3.12
|
|
28
|
+
Requires-Dist: diffbloch>=0.2.0rc1
|
|
28
29
|
Requires-Dist: numpy>=1.24
|
|
29
30
|
Requires-Dist: torch>=2.0
|
|
30
|
-
Provides-Extra: diffbloch
|
|
31
|
-
Requires-Dist: diffbloch; extra == 'diffbloch'
|
|
32
31
|
Description-Content-Type: text/markdown
|
|
33
32
|
|
|
34
33
|
# faster-diffbloch
|
|
@@ -132,19 +131,26 @@ configurations and beam counts will differ.
|
|
|
132
131
|
pip install faster-diffbloch
|
|
133
132
|
```
|
|
134
133
|
|
|
134
|
+
This installs the compatible `diffBloch` release and provides the same `diffbloch` command. The
|
|
135
|
+
accelerated backend is enabled automatically. The `faster-diffbloch` and `diffbloch-fast` commands
|
|
136
|
+
remain available as aliases.
|
|
137
|
+
|
|
135
138
|
---
|
|
136
139
|
|
|
137
140
|
## Usage
|
|
138
141
|
|
|
139
142
|
### 1. Drop-in CLI
|
|
140
143
|
|
|
141
|
-
Use
|
|
144
|
+
Use the normal `diffbloch` command:
|
|
142
145
|
|
|
143
146
|
```bash
|
|
144
|
-
diffbloch
|
|
145
|
-
diffbloch
|
|
147
|
+
diffbloch infer examples/Colmey_et_al_2026/data/quartz-no-abs
|
|
148
|
+
diffbloch refine examples/Colmey_et_al_2026/data/quartz-no-abs
|
|
146
149
|
```
|
|
147
150
|
|
|
151
|
+
The wrapper uses CPU tensors by default. The native backend selects Metal on Apple Silicon and the
|
|
152
|
+
optimized CPU path elsewhere. Pass `--device` to preserve an explicit diffBloch device choice.
|
|
153
|
+
|
|
148
154
|
### 2. Python API Injection
|
|
149
155
|
|
|
150
156
|
Enable acceleration inside any existing diffBloch script:
|
|
@@ -99,19 +99,26 @@ configurations and beam counts will differ.
|
|
|
99
99
|
pip install faster-diffbloch
|
|
100
100
|
```
|
|
101
101
|
|
|
102
|
+
This installs the compatible `diffBloch` release and provides the same `diffbloch` command. The
|
|
103
|
+
accelerated backend is enabled automatically. The `faster-diffbloch` and `diffbloch-fast` commands
|
|
104
|
+
remain available as aliases.
|
|
105
|
+
|
|
102
106
|
---
|
|
103
107
|
|
|
104
108
|
## Usage
|
|
105
109
|
|
|
106
110
|
### 1. Drop-in CLI
|
|
107
111
|
|
|
108
|
-
Use
|
|
112
|
+
Use the normal `diffbloch` command:
|
|
109
113
|
|
|
110
114
|
```bash
|
|
111
|
-
diffbloch
|
|
112
|
-
diffbloch
|
|
115
|
+
diffbloch infer examples/Colmey_et_al_2026/data/quartz-no-abs
|
|
116
|
+
diffbloch refine examples/Colmey_et_al_2026/data/quartz-no-abs
|
|
113
117
|
```
|
|
114
118
|
|
|
119
|
+
The wrapper uses CPU tensors by default. The native backend selects Metal on Apple Silicon and the
|
|
120
|
+
optimized CPU path elsewhere. Pass `--device` to preserve an explicit diffBloch device choice.
|
|
121
|
+
|
|
115
122
|
### 2. Python API Injection
|
|
116
123
|
|
|
117
124
|
Enable acceleration inside any existing diffBloch script:
|
|
@@ -4,10 +4,10 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "faster-diffbloch"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.2"
|
|
8
8
|
description = "Drop-in Metal GPU (macOS) and optimized CPU (macOS/Linux) acceleration for diffBloch"
|
|
9
9
|
readme = "README.md"
|
|
10
|
-
requires-python = ">=3.
|
|
10
|
+
requires-python = ">=3.12"
|
|
11
11
|
keywords = ["diffBloch", "electron diffraction", "electron crystallography", "structure refinement", "PyTorch acceleration", "Metal GPU"]
|
|
12
12
|
license = "MIT"
|
|
13
13
|
authors = [
|
|
@@ -27,16 +27,13 @@ classifiers = [
|
|
|
27
27
|
"Topic :: Scientific/Engineering :: Physics",
|
|
28
28
|
]
|
|
29
29
|
dependencies = [
|
|
30
|
+
"diffbloch>=0.2.0rc1",
|
|
30
31
|
"numpy>=1.24",
|
|
31
32
|
"torch>=2.0",
|
|
32
33
|
]
|
|
33
34
|
|
|
34
|
-
[project.optional-dependencies]
|
|
35
|
-
diffbloch = [
|
|
36
|
-
"diffbloch",
|
|
37
|
-
]
|
|
38
|
-
|
|
39
35
|
[project.scripts]
|
|
36
|
+
diffbloch = "faster_diffbloch.cli:main"
|
|
40
37
|
faster-diffbloch = "faster_diffbloch.cli:main"
|
|
41
38
|
diffbloch-fast = "faster_diffbloch.cli:main"
|
|
42
39
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
"""CLI wrapper enabling faster-diffbloch before running diffbloch commands.
|
|
1
|
+
"""Drop-in CLI wrapper enabling faster-diffbloch before running diffbloch commands.
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
diffbloch <diffbloch command ...> Metal GPU acceleration, then diffBloch
|
|
4
|
+
faster-diffbloch <diffbloch command ...> Alias for the drop-in command
|
|
4
5
|
faster-diffbloch refine --exact <experiment> diffBloch's refinement run in Flow,
|
|
5
6
|
bit for bit with `diffbloch refine`
|
|
6
7
|
|
|
@@ -11,6 +12,22 @@ from __future__ import annotations
|
|
|
11
12
|
|
|
12
13
|
import sys
|
|
13
14
|
|
|
15
|
+
|
|
16
|
+
def _default_device(argv: list[str]) -> list[str]:
|
|
17
|
+
"""Keep the stock command line while avoiding diffBloch's CUDA default on this path.
|
|
18
|
+
|
|
19
|
+
The accelerated backend owns the native GPU choice. A CPU torch tensor is the portable
|
|
20
|
+
transport for the native Metal and CPU paths, and it also avoids MPS float64 restrictions.
|
|
21
|
+
An explicit ``--device`` remains authoritative for callers that need another torch device.
|
|
22
|
+
"""
|
|
23
|
+
if not argv or argv[0] not in {
|
|
24
|
+
"infer", "preprocess", "refine", "converge", "convergence-test"
|
|
25
|
+
}:
|
|
26
|
+
return argv
|
|
27
|
+
if any(arg == "--device" or arg.startswith("--device=") for arg in argv):
|
|
28
|
+
return argv
|
|
29
|
+
return [argv[0], "--device", "cpu", *argv[1:]]
|
|
30
|
+
|
|
14
31
|
# The versions --exact was checked against, bit for bit, on an M4 Max under macOS 26.
|
|
15
32
|
EXACT_TORCH = "2.14."
|
|
16
33
|
EXACT_DIFFBLOCH = ("https://github.com/Differentiable-Electron-Crystallography/diffBloch",
|
|
@@ -42,12 +59,12 @@ def main() -> None:
|
|
|
42
59
|
if argv[:1] == ["refine"] and "--exact" in argv:
|
|
43
60
|
# Exact mode runs diffBloch untouched apart from its optimizer loop: no acceleration.
|
|
44
61
|
sys.exit(_exact([a for a in argv if a != "--exact"]))
|
|
45
|
-
# Enable
|
|
62
|
+
# Enable the native backend by default. The backend selects Metal on Apple Silicon.
|
|
46
63
|
from .backend import enable
|
|
47
64
|
enable(device="gpu")
|
|
48
65
|
try:
|
|
49
66
|
from diffBloch.app.cli import main as diffbloch_main
|
|
50
|
-
diffbloch_main()
|
|
67
|
+
raise SystemExit(diffbloch_main(_default_device(argv)))
|
|
51
68
|
except ImportError:
|
|
52
69
|
print("Error: diffbloch is not installed. Install diffbloch or run 'pip install diffbloch'.", file=sys.stderr)
|
|
53
70
|
sys.exit(1)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{faster_diffbloch-0.2.0 → faster_diffbloch-0.2.2}/src/faster_diffbloch/native/batch_cgemm.metal
RENAMED
|
File without changes
|
|
File without changes
|
{faster_diffbloch-0.2.0 → faster_diffbloch-0.2.2}/src/faster_diffbloch/native/metal_batch_cgemm.m
RENAMED
|
File without changes
|
{faster_diffbloch-0.2.0 → faster_diffbloch-0.2.2}/src/faster_diffbloch/native/native_scattering.c
RENAMED
|
File without changes
|
{faster_diffbloch-0.2.0 → faster_diffbloch-0.2.2}/src/faster_diffbloch/native/native_scattering.h
RENAMED
|
File without changes
|
|
File without changes
|