DeepGPR 0.1.0__tar.gz → 0.1.3__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 (76) hide show
  1. {deepgpr-0.1.0/src/DeepGPR.egg-info → deepgpr-0.1.3}/PKG-INFO +22 -20
  2. {deepgpr-0.1.0 → deepgpr-0.1.3}/README.md +20 -18
  3. {deepgpr-0.1.0 → deepgpr-0.1.3/docs}/CHANGELOG.md +126 -6
  4. deepgpr-0.1.3/docs/Fig/2dfwiinit.png +0 -0
  5. deepgpr-0.1.3/docs/Fig/2dfwipred.png +0 -0
  6. deepgpr-0.1.3/docs/Fig/2dfwitrue.png +0 -0
  7. deepgpr-0.1.3/docs/Fig/3dfwiinit.png +0 -0
  8. deepgpr-0.1.3/docs/Fig/3dfwipred.png +0 -0
  9. deepgpr-0.1.3/docs/Fig/3dfwitrue.png +0 -0
  10. deepgpr-0.1.3/docs/Fig/example.png +0 -0
  11. {deepgpr-0.1.0 → deepgpr-0.1.3/docs}/MANIFEST.in +6 -4
  12. deepgpr-0.1.3/docs/build_support.py +20 -0
  13. {deepgpr-0.1.0 → deepgpr-0.1.3}/pyproject.toml +7 -4
  14. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/__init__.py +5 -0
  15. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/_version.py +1 -1
  16. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/config/constants.py +45 -0
  17. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/config/defaults.py +9 -0
  18. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/inversion/regularization.py +1 -1
  19. deepgpr-0.1.3/src/DeepGPR/lib/cuda_resources.h +156 -0
  20. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/lib/deepgpr.cu +1822 -742
  21. deepgpr-0.1.3/src/DeepGPR/lib/deepgpr.dll +0 -0
  22. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/lib/deepgpr.h +24 -0
  23. deepgpr-0.1.3/src/DeepGPR/lib/deepgpr.so +0 -0
  24. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/lib/deepgpr_cpu.c +229 -91
  25. deepgpr-0.1.3/src/DeepGPR/lib/deepgpr_cpu.dll +0 -0
  26. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/lib/deepgpr_cpu.dylib +0 -0
  27. deepgpr-0.1.3/src/DeepGPR/lib/deepgpr_cpu.so +0 -0
  28. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/native/__init__.py +2 -0
  29. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/native/abi.py +5 -0
  30. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/native/loader.py +26 -0
  31. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/preprocessing/model_setup.py +16 -8
  32. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/solver/__init__.py +3 -0
  33. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/solver/autograd.py +137 -14
  34. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/solver/memory.py +67 -13
  35. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/solver/modeling.py +193 -14
  36. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/solver/pml.py +36 -13
  37. deepgpr-0.1.3/src/DeepGPR/solver/sampling.py +169 -0
  38. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/solver/storage.py +157 -1
  39. {deepgpr-0.1.0 → deepgpr-0.1.3/src/DeepGPR.egg-info}/PKG-INFO +22 -20
  40. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR.egg-info/SOURCES.txt +12 -2
  41. deepgpr-0.1.0/src/DeepGPR/lib/deepgpr.dll +0 -0
  42. deepgpr-0.1.0/src/DeepGPR/lib/deepgpr.so +0 -0
  43. deepgpr-0.1.0/src/DeepGPR/lib/deepgpr_cpu.dll +0 -0
  44. deepgpr-0.1.0/src/DeepGPR/lib/deepgpr_cpu.so +0 -0
  45. {deepgpr-0.1.0 → deepgpr-0.1.3}/license +0 -0
  46. {deepgpr-0.1.0 → deepgpr-0.1.3}/requirements.txt +0 -0
  47. {deepgpr-0.1.0 → deepgpr-0.1.3}/setup.cfg +0 -0
  48. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/common.py +0 -0
  49. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/compute2.py +0 -0
  50. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/config/__init__.py +0 -0
  51. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/inversion/__init__.py +0 -0
  52. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/lib/libomp.dylib +0 -0
  53. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/multiscale.py +0 -0
  54. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/native/bridge.py +0 -0
  55. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/postprocessing/__init__.py +0 -0
  56. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/postprocessing/filters.py +0 -0
  57. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/postprocessing/io.py +0 -0
  58. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/preprocessing/__init__.py +0 -0
  59. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/preprocessing/grid.py +0 -0
  60. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/preprocessing/stability.py +0 -0
  61. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/preprocessing/wavelets.py +0 -0
  62. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/py.typed +0 -0
  63. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/solver/fields.py +0 -0
  64. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/utils/__init__.py +0 -0
  65. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/utils/devices.py +0 -0
  66. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/utils/exceptions.py +0 -0
  67. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/utils/formatting.py +0 -0
  68. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/utils/logger.py +0 -0
  69. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/utils/tensor_checks.py +0 -0
  70. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/utils/validators.py +0 -0
  71. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/visualization/__init__.py +0 -0
  72. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/visualization/plotting.py +0 -0
  73. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR/wavelet.py +0 -0
  74. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR.egg-info/dependency_links.txt +0 -0
  75. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR.egg-info/requires.txt +0 -0
  76. {deepgpr-0.1.0 → deepgpr-0.1.3}/src/DeepGPR.egg-info/top_level.txt +0 -0
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: DeepGPR
3
- Version: 0.1.0
3
+ Version: 0.1.3
4
4
  Summary: PyTorch and CUDA for GPR FWI
5
5
  Author-email: Lei Liu <liulei990222@gmail.com>
6
6
  License-Expression: MIT
7
7
  Project-URL: Homepage, https://github.com/songc0a/DeepGPR
8
8
  Project-URL: Repository, https://github.com/songc0a/DeepGPR
9
9
  Project-URL: Documentation, https://songc0a.github.io/DeepGPR/
10
- Project-URL: Changelog, https://github.com/songc0a/DeepGPR/blob/main/CHANGELOG.md
10
+ Project-URL: Changelog, https://github.com/songc0a/DeepGPR/blob/main/docs/CHANGELOG.md
11
11
  Keywords: ground penetrating radar,GPR,FDTD,full waveform inversion,PyTorch,CUDA
12
12
  Classifier: Programming Language :: Python :: 3
13
13
  Classifier: Operating System :: Microsoft :: Windows
@@ -44,10 +44,10 @@ DeepGPR provides a wave propagation module for PyTorch, designed for application
44
44
 
45
45
  - 2D and 3D forward modeling of Maxwell's equations with the Finite-Difference Time-Domain (FDTD) method, for single and multiple excitations.
46
46
  - Gradients of the receiver data with respect to relative permittivity, conductivity, the initial wavefield and the source amplitudes, computed by an exact discrete adjoint.
47
- - Automatic extension of the physical model into a CPML with an independent thickness on every face. Supply only air and the target region; material gradients keep the input model shape.
47
+ - Automatic extension of the physical model into a CPML with an independent thickness on every face. Supply only air and the target region; sensitivities from replicated PML materials are summed back to the input model edges. Absorption uses a fixed `pml_max_velocity` reference (vacuum light speed by default).
48
48
  - CUDA GPU backend and a C/OpenMP CPU backend (selected automatically with `device='cpu'`).
49
49
  - Spatial FDTD order 2, 4 or 8 (`fdtd_order`), and gradient mode 2 (Ez only) or 3 (Ex, Ey, Ez).
50
- - Large models: checkpointing, DDP, temporal sub-sampling, FP16/BF16 or GPU-native INT8 wavefield histories and asynchronous offload to host memory.
50
+ - Large models: checkpointing, DDP, temporal sub-sampling (fixed or `"auto"` from the source spectrum), E-only float32 histories (default; half the memory of E+R), FP16/BF16 or GPU-native INT8 wavefield histories and asynchronous offload to host memory. Material gradients with PML require `wavefield_history_region="extended"`; physical-only histories remain available for diagnostics, source/initial-state gradients and models without PML. See [`docs/API.md`](docs/API.md) §4.3-4.6.
51
51
 
52
52
  ## System requirements
53
53
 
@@ -68,8 +68,7 @@ pip install "DeepGPR[examples]" # + scipy, scikit-image, jupyter for the not
68
68
  For development from a clone:
69
69
 
70
70
  ```bash
71
- pip install -r requirements-dev.txt
72
- pip install -e .
71
+ pip install -e ".[dev,examples]"
73
72
  ```
74
73
 
75
74
  The prebuilt native libraries ship in `src/DeepGPR/lib`. To rebuild them see [`docs/BUILDING.md`](docs/BUILDING.md).
@@ -114,7 +113,7 @@ DeepGPR.visualization.plot_model(eps_r.grad, ax=ax[1], title="Gradient", cmap="s
114
113
  plt.show()
115
114
  ```
116
115
 
117
- ![result](Fig/example.png)
116
+ ![result](docs/Fig/example.png)
118
117
 
119
118
  More examples are in [`examples/`](examples) (forward modeling, 2D FWI, 3D FWI).
120
119
 
@@ -141,15 +140,15 @@ The figures show the true model, the initial model and the inverted result.
141
140
 
142
141
  | True model | Initial model | Inverted result |
143
142
  | --- | --- | --- |
144
- | ![2D true model](Fig/2dfwitrue.png) | ![2D initial model](Fig/2dfwiinit.png) | ![2D inverted result](Fig/2dfwipred.png) |
143
+ | ![2D true model](docs/Fig/2dfwitrue.png) | ![2D initial model](docs/Fig/2dfwiinit.png) | ![2D inverted result](docs/Fig/2dfwipred.png) |
145
144
 
146
145
  ### 3D FWI (central slice)
147
146
 
148
147
  | Model | Central slice |
149
148
  | --- | --- |
150
- | True model | ![3D true model central slice](Fig/3dfwitrue.png) |
151
- | Initial model | ![3D initial model central slice](Fig/3dfwiinit.png) |
152
- | Inverted result | ![3D inverted result central slice](Fig/3dfwipred.png) |
149
+ | True model | ![3D true model central slice](docs/Fig/3dfwitrue.png) |
150
+ | Initial model | ![3D initial model central slice](docs/Fig/3dfwiinit.png) |
151
+ | Inverted result | ![3D inverted result central slice](docs/Fig/3dfwipred.png) |
153
152
 
154
153
  ## API overview
155
154
 
@@ -162,6 +161,7 @@ The figures show the true model, the initial model and the inverted result.
162
161
  | `DeepGPR.apply_filter`, `DeepGPR.hilbert_transform` | low-pass FIR and envelope for multi-scale FWI |
163
162
  | `DeepGPR.max_stable_time_step(...)` | largest CFL-stable `dt` for a grid, order and material |
164
163
  | `DeepGPR.estimate_compute_memory(...)` | memory estimate (also printed by `print_parameters=True`) |
164
+ | `DeepGPR.recommended_sampling_interval(...)`, `DeepGPR.source_max_frequency(...)` | gradient sampling interval bound `floor(1 / (4 f_max dt))` from a source waveform (what `model_gradient_sampling_interval="auto"` uses) |
165
165
  | `DeepGPR.decompress_wavefield_history(...)` | decode a packed INT8 history for diagnostics |
166
166
  | `DeepGPR.visualization.plot_*` | models, radargrams, traces, true/initial/inverted comparison |
167
167
  | `DeepGPR.configure_logging(level)` | enable DeepGPR log output |
@@ -197,10 +197,10 @@ src/DeepGPR/
197
197
  ├── utils/ logging, exceptions, validators, diagnostics
198
198
  ├── lib/ deepgpr.cu, deepgpr_cpu.c, deepgpr.h and prebuilt binaries
199
199
  ├── common.py, compute2.py, multiscale.py, wavelet.py compatibility modules
200
- docs/ API reference, build guide, code audit
200
+ docs/ API reference, build guide, changelog, manifest and Fig/
201
201
  examples/ forward, 2D FWI and 3D FWI notebooks
202
202
  tests/ unit tests, verification notebooks, benchmarks
203
- tools/ verify_equivalence.py
203
+ website/ static pages, assets, scripts/, tools/ and promo_pixel/
204
204
  ```
205
205
 
206
206
  Data flow of one `compute` call:
@@ -215,8 +215,8 @@ and the saved history.
215
215
  python -m unittest discover -s tests -p "test_*.py" # unit tests
216
216
  python -m unittest tests/test_native_abi.py # ABI check, no PyTorch needed
217
217
  python tests/run_notebook.py tests/00_local_backend_and_contracts.ipynb
218
- python tools/verify_equivalence.py --reference-src /path/to/DeepGPR-0.0.20/src/DeepGPR
219
- bash tools/run_local_validation.sh /path/to/DeepGPR-0.0.20 # rebuild CPU+CUDA libs, run everything
218
+ python website/tools/verify_equivalence.py --no-pml --reference-src /path/to/DeepGPR-0.0.20/src/DeepGPR
219
+ bash website/tools/run_local_validation.sh /path/to/DeepGPR-0.0.20 # rebuild CPU+CUDA libs, run everything
220
220
  ```
221
221
 
222
222
  Run the notebooks `00` to `09` in numeric order, followed by
@@ -224,20 +224,22 @@ Run the notebooks `00` to `09` in numeric order, followed by
224
224
  the complete matrix and CUDA options.
225
225
 
226
226
  **Reproducibility.** The CPU backend gives bitwise identical forward results
227
- and gradients for any `OMP_NUM_THREADS`. The CUDA adjoint accumulates with
228
- atomics and can differ in the last bits between runs.
227
+ and gradients for any `OMP_NUM_THREADS`. On CUDA, 2D Ez-TM runs (the 2D fast
228
+ path) gather their adjoint without atomics and are bitwise reproducible; the
229
+ general (3D) CUDA adjoint accumulates with atomics and can differ in the last
230
+ bits between runs.
229
231
 
230
232
  **Reproducing results from DeepGPR ≤ 0.0.20.** 0.1.0 corrects the FIR design
231
233
  for even filter lengths, the envelope for odd trace lengths and the isotropic
232
- TV (see [`CHANGELOG.md`](CHANGELOG.md)). Use `apply_filter(..., legacy=True)`,
234
+ TV (see [`docs/CHANGELOG.md`](docs/CHANGELOG.md)). Use `apply_filter(..., legacy=True)`,
233
235
  `design_fir_filter(..., legacy=True)`, `hilbert_transform(..., legacy=True)`
234
236
  and `TVRegularization(method="legacy_isotropic")` to reproduce earlier numbers.
235
237
 
236
238
  ## Development
237
239
 
238
- - Code style: PEP 8, enforced with `ruff check src/DeepGPR tools` (configuration in `pyproject.toml`).
240
+ - Code style: PEP 8, enforced with `ruff check src/DeepGPR website/tools docs/build_support.py` (configuration in `pyproject.toml`).
239
241
  - Type hints throughout; `mypy` configuration in `pyproject.toml`.
240
- - Changes are recorded in [`CHANGELOG.md`](CHANGELOG.md); known issues and recommended native work in [`docs/AUDIT.md`](docs/AUDIT.md).
242
+ - Changes are recorded in [`docs/CHANGELOG.md`](docs/CHANGELOG.md); known issues and recommended native work in [`docs/AUDIT.md`](docs/AUDIT.md).
241
243
  - Changes to `lib/deepgpr.h` must be mirrored in `src/DeepGPR/native/abi.py`; `tests/test_native_abi.py` enforces it.
242
244
 
243
245
  ## Citation
@@ -8,10 +8,10 @@ DeepGPR provides a wave propagation module for PyTorch, designed for application
8
8
 
9
9
  - 2D and 3D forward modeling of Maxwell's equations with the Finite-Difference Time-Domain (FDTD) method, for single and multiple excitations.
10
10
  - Gradients of the receiver data with respect to relative permittivity, conductivity, the initial wavefield and the source amplitudes, computed by an exact discrete adjoint.
11
- - Automatic extension of the physical model into a CPML with an independent thickness on every face. Supply only air and the target region; material gradients keep the input model shape.
11
+ - Automatic extension of the physical model into a CPML with an independent thickness on every face. Supply only air and the target region; sensitivities from replicated PML materials are summed back to the input model edges. Absorption uses a fixed `pml_max_velocity` reference (vacuum light speed by default).
12
12
  - CUDA GPU backend and a C/OpenMP CPU backend (selected automatically with `device='cpu'`).
13
13
  - Spatial FDTD order 2, 4 or 8 (`fdtd_order`), and gradient mode 2 (Ez only) or 3 (Ex, Ey, Ez).
14
- - Large models: checkpointing, DDP, temporal sub-sampling, FP16/BF16 or GPU-native INT8 wavefield histories and asynchronous offload to host memory.
14
+ - Large models: checkpointing, DDP, temporal sub-sampling (fixed or `"auto"` from the source spectrum), E-only float32 histories (default; half the memory of E+R), FP16/BF16 or GPU-native INT8 wavefield histories and asynchronous offload to host memory. Material gradients with PML require `wavefield_history_region="extended"`; physical-only histories remain available for diagnostics, source/initial-state gradients and models without PML. See [`docs/API.md`](docs/API.md) §4.3-4.6.
15
15
 
16
16
  ## System requirements
17
17
 
@@ -32,8 +32,7 @@ pip install "DeepGPR[examples]" # + scipy, scikit-image, jupyter for the not
32
32
  For development from a clone:
33
33
 
34
34
  ```bash
35
- pip install -r requirements-dev.txt
36
- pip install -e .
35
+ pip install -e ".[dev,examples]"
37
36
  ```
38
37
 
39
38
  The prebuilt native libraries ship in `src/DeepGPR/lib`. To rebuild them see [`docs/BUILDING.md`](docs/BUILDING.md).
@@ -78,7 +77,7 @@ DeepGPR.visualization.plot_model(eps_r.grad, ax=ax[1], title="Gradient", cmap="s
78
77
  plt.show()
79
78
  ```
80
79
 
81
- ![result](Fig/example.png)
80
+ ![result](docs/Fig/example.png)
82
81
 
83
82
  More examples are in [`examples/`](examples) (forward modeling, 2D FWI, 3D FWI).
84
83
 
@@ -105,15 +104,15 @@ The figures show the true model, the initial model and the inverted result.
105
104
 
106
105
  | True model | Initial model | Inverted result |
107
106
  | --- | --- | --- |
108
- | ![2D true model](Fig/2dfwitrue.png) | ![2D initial model](Fig/2dfwiinit.png) | ![2D inverted result](Fig/2dfwipred.png) |
107
+ | ![2D true model](docs/Fig/2dfwitrue.png) | ![2D initial model](docs/Fig/2dfwiinit.png) | ![2D inverted result](docs/Fig/2dfwipred.png) |
109
108
 
110
109
  ### 3D FWI (central slice)
111
110
 
112
111
  | Model | Central slice |
113
112
  | --- | --- |
114
- | True model | ![3D true model central slice](Fig/3dfwitrue.png) |
115
- | Initial model | ![3D initial model central slice](Fig/3dfwiinit.png) |
116
- | Inverted result | ![3D inverted result central slice](Fig/3dfwipred.png) |
113
+ | True model | ![3D true model central slice](docs/Fig/3dfwitrue.png) |
114
+ | Initial model | ![3D initial model central slice](docs/Fig/3dfwiinit.png) |
115
+ | Inverted result | ![3D inverted result central slice](docs/Fig/3dfwipred.png) |
117
116
 
118
117
  ## API overview
119
118
 
@@ -126,6 +125,7 @@ The figures show the true model, the initial model and the inverted result.
126
125
  | `DeepGPR.apply_filter`, `DeepGPR.hilbert_transform` | low-pass FIR and envelope for multi-scale FWI |
127
126
  | `DeepGPR.max_stable_time_step(...)` | largest CFL-stable `dt` for a grid, order and material |
128
127
  | `DeepGPR.estimate_compute_memory(...)` | memory estimate (also printed by `print_parameters=True`) |
128
+ | `DeepGPR.recommended_sampling_interval(...)`, `DeepGPR.source_max_frequency(...)` | gradient sampling interval bound `floor(1 / (4 f_max dt))` from a source waveform (what `model_gradient_sampling_interval="auto"` uses) |
129
129
  | `DeepGPR.decompress_wavefield_history(...)` | decode a packed INT8 history for diagnostics |
130
130
  | `DeepGPR.visualization.plot_*` | models, radargrams, traces, true/initial/inverted comparison |
131
131
  | `DeepGPR.configure_logging(level)` | enable DeepGPR log output |
@@ -161,10 +161,10 @@ src/DeepGPR/
161
161
  ├── utils/ logging, exceptions, validators, diagnostics
162
162
  ├── lib/ deepgpr.cu, deepgpr_cpu.c, deepgpr.h and prebuilt binaries
163
163
  ├── common.py, compute2.py, multiscale.py, wavelet.py compatibility modules
164
- docs/ API reference, build guide, code audit
164
+ docs/ API reference, build guide, changelog, manifest and Fig/
165
165
  examples/ forward, 2D FWI and 3D FWI notebooks
166
166
  tests/ unit tests, verification notebooks, benchmarks
167
- tools/ verify_equivalence.py
167
+ website/ static pages, assets, scripts/, tools/ and promo_pixel/
168
168
  ```
169
169
 
170
170
  Data flow of one `compute` call:
@@ -179,8 +179,8 @@ and the saved history.
179
179
  python -m unittest discover -s tests -p "test_*.py" # unit tests
180
180
  python -m unittest tests/test_native_abi.py # ABI check, no PyTorch needed
181
181
  python tests/run_notebook.py tests/00_local_backend_and_contracts.ipynb
182
- python tools/verify_equivalence.py --reference-src /path/to/DeepGPR-0.0.20/src/DeepGPR
183
- bash tools/run_local_validation.sh /path/to/DeepGPR-0.0.20 # rebuild CPU+CUDA libs, run everything
182
+ python website/tools/verify_equivalence.py --no-pml --reference-src /path/to/DeepGPR-0.0.20/src/DeepGPR
183
+ bash website/tools/run_local_validation.sh /path/to/DeepGPR-0.0.20 # rebuild CPU+CUDA libs, run everything
184
184
  ```
185
185
 
186
186
  Run the notebooks `00` to `09` in numeric order, followed by
@@ -188,20 +188,22 @@ Run the notebooks `00` to `09` in numeric order, followed by
188
188
  the complete matrix and CUDA options.
189
189
 
190
190
  **Reproducibility.** The CPU backend gives bitwise identical forward results
191
- and gradients for any `OMP_NUM_THREADS`. The CUDA adjoint accumulates with
192
- atomics and can differ in the last bits between runs.
191
+ and gradients for any `OMP_NUM_THREADS`. On CUDA, 2D Ez-TM runs (the 2D fast
192
+ path) gather their adjoint without atomics and are bitwise reproducible; the
193
+ general (3D) CUDA adjoint accumulates with atomics and can differ in the last
194
+ bits between runs.
193
195
 
194
196
  **Reproducing results from DeepGPR ≤ 0.0.20.** 0.1.0 corrects the FIR design
195
197
  for even filter lengths, the envelope for odd trace lengths and the isotropic
196
- TV (see [`CHANGELOG.md`](CHANGELOG.md)). Use `apply_filter(..., legacy=True)`,
198
+ TV (see [`docs/CHANGELOG.md`](docs/CHANGELOG.md)). Use `apply_filter(..., legacy=True)`,
197
199
  `design_fir_filter(..., legacy=True)`, `hilbert_transform(..., legacy=True)`
198
200
  and `TVRegularization(method="legacy_isotropic")` to reproduce earlier numbers.
199
201
 
200
202
  ## Development
201
203
 
202
- - Code style: PEP 8, enforced with `ruff check src/DeepGPR tools` (configuration in `pyproject.toml`).
204
+ - Code style: PEP 8, enforced with `ruff check src/DeepGPR website/tools docs/build_support.py` (configuration in `pyproject.toml`).
203
205
  - Type hints throughout; `mypy` configuration in `pyproject.toml`.
204
- - Changes are recorded in [`CHANGELOG.md`](CHANGELOG.md); known issues and recommended native work in [`docs/AUDIT.md`](docs/AUDIT.md).
206
+ - Changes are recorded in [`docs/CHANGELOG.md`](docs/CHANGELOG.md); known issues and recommended native work in [`docs/AUDIT.md`](docs/AUDIT.md).
205
207
  - Changes to `lib/deepgpr.h` must be mirrored in `src/DeepGPR/native/abi.py`; `tests/test_native_abi.py` enforces it.
206
208
 
207
209
  ## Citation
@@ -4,11 +4,131 @@ All notable changes to this project are documented here. The format follows
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses
5
5
  [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## [Unreleased] — History memory and CUDA adjoint performance
8
+
9
+ ### Repository layout
10
+
11
+ - Website tools, statistics scripts and pixel film sources now live under
12
+ `website/tools`, `website/scripts` and `website/promo_pixel`. Their input/output
13
+ paths and CI commands follow the new locations; Pages publishes public assets
14
+ without the source tool directories.
15
+ - Figures, changelog and the source-distribution template now live in `docs`.
16
+ The setuptools build hook reads `docs/MANIFEST.in`, including when building a
17
+ wheel from a source archive. Documentation and package metadata links updated.
18
+ - Development dependencies are installed with `pip install -e ".[dev,examples]"`.
19
+ Removed the duplicate development requirements file and local assistant
20
+ configuration, and cleaned embedded tool attribution from media metadata.
21
+
22
+ Measurements, protocol and per-item decisions:
23
+ [`tests/profiling_results/history_adjoint_gpu_report.md`](../tests/profiling_results/history_adjoint_gpu_report.md).
24
+
25
+ ### Added
26
+
27
+ - `model_gradient_sampling_interval="auto"` selects
28
+ `S = max(1, floor(1 / (4 f_max dt)))`, with `f_max` the highest frequency at
29
+ which the source amplitude spectrum exceeds `3e-3` of its peak (about
30
+ `3 f_peak` for a Ricker wavelet; several waveforms use the smallest `S`).
31
+ `DeepGPR.recommended_sampling_interval` and `DeepGPR.source_max_frequency`
32
+ expose the bound so segmented/checkpointed runs can evaluate it once on the
33
+ full waveform. The default stays `1`.
34
+ - `wavefield_rhs_history` (`"auto"`, `"stored"`, `"reconstructed"`). With
35
+ sampling interval 1 the adjoint rebuilds `R^n = (E^(n+1) - ca E^n) / cb` from
36
+ consecutive saved E frames, so only E is stored (plus one internal final
37
+ frame). The default `"auto"` does this for uncompressed `float32` histories:
38
+ history memory halves, the forward no longer runs the R-snapshot kernel, and
39
+ gradients are unchanged (bitwise on CPU). Low-precision and INT8 histories
40
+ keep E+R by default (rebuilding from two rounded frames was measurably less
41
+ accurate in some cases) and can opt in with `"reconstructed"`. New native
42
+ capability probe `deepgpr_supports_rhs_reconstruction` (ABI 6 unchanged);
43
+ older libraries fall back to E+R.
44
+ - `wavefield_history_region` (`"extended"` default, `"physical"`). `"physical"`
45
+ stores E/R histories only on physical cells for forward diagnostics,
46
+ source/initial-state gradients, or models without PML. Material inversion
47
+ with PML requires `"extended"`. INT8 histories widen the box to whole tiles of the
48
+ full-grid tiling so tiles and scales are identical to `"extended"`. New probe
49
+ `deepgpr_supports_physical_history`; saved files record the region.
50
+
51
+ ### Performance
52
+
53
+ - CUDA async-offload calls reuse streams, synchronization events and staging
54
+ buffers (audit N-8). Workspaces are exclusive to each call, partitioned by
55
+ device, and cached only after successful synchronization. At most one idle
56
+ workspace with up to 64 MiB of staging is retained per device;
57
+ `DeepGPR.clear_cuda_resource_cache(device=None)` releases idle resources.
58
+ Native forward/backward signatures and ABI 6 are unchanged. Measurements:
59
+ [CUDA resource cache report](../tests/profiling_results/cuda_resource_cache_report.md).
60
+ - CUDA full-grid kernels (E/H update and adjoint) take the shot from
61
+ `blockIdx.y` and decode `(i, j, k)` from a 32-bit per-shot index with a
62
+ multiply-high divider instead of four 64-bit `/` and `%` per thread. Grids
63
+ above `2^31 - 1` cells per shot are rejected explicitly.
64
+ - CUDA 2D TM fast path: for 2D models with an Ez source and zero Ex/Ey/Hz
65
+ states the solver launches only the `k = 0` layer and updates/transposes
66
+ only Ez, Hx and Hy (probe `deepgpr_supports_tm2d_fast_path`). Receiver data
67
+ is bitwise unchanged; initial-state gradients of Ex/Ey/Hz are zero on this
68
+ path. Other calls use the general kernels.
69
+
70
+ - CUDA 2D TM adjoint as a gather (AUDIT N-7): on the 2D TM fast path the
71
+ transposed curl and CPML updates no longer scatter with `atomicAdd`; every
72
+ target point gathers its source stencil in a fixed order with CPML
73
+ derivative weights from phi-sized scratch (2D backward about 30 % faster,
74
+ bitwise reproducible). Receiver and source-waveform adjoints add coincident
75
+ points in a fixed order on every path. The general (3D) CUDA adjoint keeps
76
+ the atomic scatter, which measured faster than a gather there;
77
+ `deepgpr_deterministic_adjoint()` stays 0. Gradients differ from the
78
+ previous release at rounding level only.
79
+ - CUDA kernel fusion on the 2D TM fast path: each cell's CPML corrections run
80
+ inside `update_e_gpu` / `update_h_gpu` right after its base update (same
81
+ face order and arithmetic; the other field is read only), and float32 /
82
+ float16 / bfloat16 E histories are written by `update_h_gpu`, where E is not
83
+ modified. Forward launches per time step drop from 6 to 3 (2D forward
84
+ 11-18 % faster; with INT8 histories 6-10 %). INT8 and `native_vec2`
85
+ histories and the stored-R snapshot keep their own kernels. The general
86
+ (3D) forward keeps separate CPML and snapshot kernels: fused, it was faster
87
+ on small 3D grids but up to 8 % slower on a 140^3 grid. The general scatter
88
+ adjoint applies the CPML transposes inside `adjoint_e_gpu` /
89
+ `adjoint_h_gpu` (6 to 4 launches per reverse step; 3D fp32 backward about
90
+ 3.5 % faster, other storage modes within noise). Receiver data, states and
91
+ histories are bitwise unchanged; 2D TM gradients are bitwise unchanged, 3D
92
+ gradients change at atomic-ordering level only. The material-gradient
93
+ kernel stays separate (it reduces over shots per cell in a fixed order and
94
+ runs only every `S` steps).
95
+
96
+ ### Changed
97
+
98
+ - PML materials remain derived from the physical model, with CPU/CUDA material
99
+ sensitivities retained throughout PML and summed back to model edges,
100
+ intersections and corners. Absorbing profiles use `pml_max_velocity`, a fixed
101
+ reference speed (default vacuum), instead of changing boundary material
102
+ averages. Keep it fixed during optimization, FD checks and checkpointing.
103
+ Old native libraries are rejected for PML material gradients via the new
104
+ `deepgpr_supports_pml_material_gradients` probe; ABI 6 is unchanged.
105
+ - Exactly zero local material sensitivities remain zero even when an
106
+ unobservable outer-CPML state cotangent overflows in long lossless runs.
107
+ CPU, CUDA and INT8 avoid `0 * Inf` without clipping nonzero sensitivities
108
+ or changing the forward equations. Arbitrary long-time initial-state
109
+ cotangents can still overflow on these outer cells.
110
+ - Corrected material gradients at Yee components that do not execute the base
111
+ electric update; source and CPML corrections still contribute through `cb`.
112
+ - Total variation losses preserve the input dtype, including float64.
113
+ - An explicit `model_gradient_sampling_interval > 1` no longer always raises a
114
+ `RuntimeWarning`; it warns (and states the bound) only above
115
+ `floor(1 / (4 f_max dt))`. Intervals inside the bound are logged at INFO.
116
+ - **Default history layout:** float32 histories at sampling interval 1 no
117
+ longer allocate `R_saved`; pass `wavefield_rhs_history="stored"` to restore
118
+ the previous layout. `estimate_compute_memory` gained `reconstruct_rhs` and a
119
+ `final_e_frame` entry; `print_parameters` reports the R-history mode.
120
+ - The native `storage_type` argument reserves bits 4-7 for history flags (the
121
+ storage kind now uses bits 0-3).
122
+ - Documentation: README, `docs/API.md`, `docs/BUILDING.md` (new capability
123
+ probes) and the website describe the new history options; the website now
124
+ links to `docs/API.md` instead of a README anchor that moved in 0.1.0 and no
125
+ longer lists SciPy as a runtime dependency.
126
+
7
127
  ## [0.1.0] — Structural refactor and numerical fixes
8
128
 
9
129
  This release reorganises the Python package into a layered, typed and
10
130
  documented code base and fixes the defects found in the review
11
- ([`docs/AUDIT.md`](docs/AUDIT.md)).
131
+ ([`docs/AUDIT.md`](AUDIT.md)).
12
132
 
13
133
  **What changes numerically** (all deliberate, see [Numerical fixes](#numerical-fixes)):
14
134
 
@@ -117,7 +237,7 @@ from the 0.1.0 sources. The CUDA (`deepgpr.so`, `deepgpr.dll`) and the Windows /
117
237
  macOS CPU binaries are still the 0.0.20 builds until the *Build Native
118
238
  Libraries* workflow runs; they load and compute as before but without error
119
239
  reporting (and, for the CPU ones, without the deterministic adjoint).
120
- `tools/run_local_validation.sh` rebuilds the CPU and CUDA libraries locally
240
+ `website/tools/run_local_validation.sh` rebuilds the CPU and CUDA libraries locally
121
241
  and runs the full validation.
122
242
 
123
243
  ### Fixed
@@ -149,7 +269,7 @@ and runs the full validation.
149
269
  (same `forward_wavefield_HH-MM[_NN].pt` scheme). Partially written files are
150
270
  removed on failure.
151
271
  - **Invalid requirement shipped in the wheel.** `src/DeepGPR/requirements.txt`
152
- contained `torch+cu` and was packaged via `MANIFEST.in`; removed.
272
+ contained `torch+cu` and was packaged via `docs/MANIFEST.in`; removed.
153
273
  - Error message of `apply_filter` used full-width punctuation (`。`).
154
274
 
155
275
  ### Changed
@@ -215,7 +335,7 @@ measurable:
215
335
  - `tests/test_signal_and_regularization.py` (FIR, envelope and TV against
216
336
  independent NumPy implementations; legacy switches).
217
337
  - `tests/test_cpu_determinism.py` (bitwise equality for 1, 2 and 5 threads).
218
- - `tools/verify_equivalence.py` (comparison with a reference release: forward
338
+ - `website/tools/verify_equivalence.py` (comparison with a reference release: forward
219
339
  and gradient tolerances, legacy reproduction, determinism, error reporting).
220
340
  - `legacy=` keyword for `design_fir_filter`, `apply_filter`,
221
341
  `hilbert_transform`; `remove_dc=` for `hilbert_transform`; `epsilon=` and
@@ -223,7 +343,7 @@ measurable:
223
343
  - Native functions `deepgpr_supports_error_reporting`, `deepgpr_last_error`,
224
344
  `deepgpr_clear_last_error`, `deepgpr_deterministic_adjoint` (ABI 6, additive).
225
345
  - `.github/workflows/quality.yml` (ruff, ABI test, CPU unit tests, equivalence).
226
- - `requirements.txt`, `requirements-dev.txt`, ruff/mypy/pytest configuration.
346
+ - `requirements.txt`, development extras in `pyproject.toml`, ruff/mypy/pytest configuration.
227
347
 
228
348
  ### Removed / internal changes
229
349
 
@@ -268,7 +388,7 @@ which is byte-identical to the 0.0.21 PyPI release):
268
388
 
269
389
  | Check | Scope | Result |
270
390
  |---|---|---|
271
- | `tools/verify_equivalence.py` | CPU and CUDA: 2D/3D × order 2/4/8 × fp32/fp16/bf16 × sampling 1/3, no/asymmetric PML, forward-only, mode 3, checkpoint segments; CUDA INT8 (2D/3D), async offload, fp16 conversion backends; legacy switches; error reporting; CPU determinism for 1/2/4/8 threads | all passed; forward outputs **bitwise identical**, gradients within 1.9·10⁻⁶ (CPU) / 4.7·10⁻⁷ (CUDA) relative |
391
+ | `website/tools/verify_equivalence.py` | CPU and CUDA: 2D/3D × order 2/4/8 × fp32/fp16/bf16 × sampling 1/3, no/asymmetric PML, forward-only, mode 3, checkpoint segments; CUDA INT8 (2D/3D), async offload, fp16 conversion backends; legacy switches; error reporting; CPU determinism for 1/2/4/8 threads | all passed; forward outputs **bitwise identical**, gradients within 1.9·10⁻⁶ (CPU) / 4.7·10⁻⁷ (CUDA) relative |
272
392
  | Unit tests | 105 tests, `OMP_NUM_THREADS` = 1, 2, 4, 8 | all passed (1 skip: needs two GPUs) |
273
393
  | Verification notebooks `tests/00`–`09`, `99` | `DEEPGPR_REQUIRE_CUDA=1` | 108 checks passed, CUDA parity evidence present |
274
394
  | CI simulation | Python 3.12, PyTorch 2.x CPU: unit tests and `verify_equivalence.py --device cpu --quick`; `ruff check src/DeepGPR tools` | all passed |
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,5 +1,4 @@
1
1
  include README.md
2
- include CHANGELOG.md
3
2
  include license
4
3
  include pyproject.toml
5
4
  include requirements.txt
@@ -9,14 +8,17 @@ recursive-include src/DeepGPR *.py *.typed *.cu *.h *.c *.dll *.so *.dylib
9
8
  # Exclude local state and repository-only resources.
10
9
  prune .*
11
10
  prune validation
12
- prune Fig
13
11
  prune docs
14
12
  prune examples
15
- prune scripts
16
13
  prune tests
17
- prune tools
18
14
  prune website
19
15
 
16
+ # Keep the relocated manifest and its build hook available in the sdist.
17
+ include docs/MANIFEST.in
18
+ include docs/build_support.py
19
+ include docs/CHANGELOG.md
20
+ recursive-include docs/Fig *.png
21
+
20
22
  global-exclude .DS_Store
21
23
  global-exclude *.py[cod]
22
24
  global-exclude __pycache__
@@ -0,0 +1,20 @@
1
+ """Keep the source-distribution manifest alongside the project documentation."""
2
+
3
+ from pathlib import Path
4
+
5
+ from setuptools.command.egg_info import egg_info, manifest_maker
6
+
7
+
8
+ class EggInfo(egg_info):
9
+ """Use docs/MANIFEST.in when setuptools generates the source file list."""
10
+
11
+ def find_sources(self):
12
+ template = Path("docs/MANIFEST.in")
13
+ if not template.is_file():
14
+ raise FileNotFoundError("Source distribution template missing: docs/MANIFEST.in")
15
+ maker = manifest_maker(self.distribution)
16
+ maker.ignore_egg_info_dir = self.ignore_egg_info_in_manifest
17
+ maker.template = str(template)
18
+ maker.manifest = str(Path(self.egg_info) / "SOURCES.txt")
19
+ maker.run()
20
+ self.filelist = maker.filelist
@@ -39,12 +39,15 @@ dev = ["ruff>=0.5", "mypy>=1.8", "pytest>=7", "nbformat", "nbclient"]
39
39
  Homepage = "https://github.com/songc0a/DeepGPR"
40
40
  Repository = "https://github.com/songc0a/DeepGPR"
41
41
  Documentation = "https://songc0a.github.io/DeepGPR/"
42
- Changelog = "https://github.com/songc0a/DeepGPR/blob/main/CHANGELOG.md"
42
+ Changelog = "https://github.com/songc0a/DeepGPR/blob/main/docs/CHANGELOG.md"
43
43
 
44
44
  [tool.setuptools]
45
- package-dir = { "" = "src" }
45
+ package-dir = { "" = "src", docs = "docs" }
46
46
  include-package-data = true
47
47
 
48
+ [tool.setuptools.cmdclass]
49
+ egg_info = "docs.build_support.EggInfo"
50
+
48
51
  [tool.setuptools.dynamic]
49
52
  version = { attr = "DeepGPR._version.__version__" }
50
53
 
@@ -77,8 +80,8 @@ DeepGPR = [
77
80
  [tool.ruff]
78
81
  line-length = 100
79
82
  target-version = "py38"
80
- src = ["src", "tests", "tools"]
81
- extend-exclude = ["tests/*.ipynb", "examples", "website", "scripts"]
83
+ src = ["src", "tests", "website/tools"]
84
+ extend-exclude = ["tests/*.ipynb", "examples", "website/assets", "website/scripts", "website/promo_pixel"]
82
85
 
83
86
  [tool.ruff.lint]
84
87
  select = ["E", "F", "W", "B", "UP", "SIM", "C4"]
@@ -34,6 +34,7 @@ from __future__ import annotations
34
34
  from . import config, utils
35
35
  from ._version import __version__
36
36
  from .native.loader import (
37
+ clear_cuda_resource_cache,
37
38
  get_deepgpr_lib,
38
39
  get_deepgpr_library_path,
39
40
  set_library_fdtd_order,
@@ -66,6 +67,7 @@ from .preprocessing.stability import max_stable_time_step
66
67
  from .solver.autograd import DeepGPR
67
68
  from .solver.modeling import compute
68
69
  from .solver.memory import estimate_compute_memory
70
+ from .solver.sampling import recommended_sampling_interval, source_max_frequency
69
71
  from .solver.storage import decompress_wavefield_history
70
72
  from .utils.exceptions import (
71
73
  CFLConditionError,
@@ -96,6 +98,7 @@ __all__ = [
96
98
  "check_cfl",
97
99
  "check_tensors_for_nan_inf",
98
100
  "checkpoint_initial_field",
101
+ "clear_cuda_resource_cache",
99
102
  "common",
100
103
  "compute",
101
104
  "compute2",
@@ -122,10 +125,12 @@ __all__ = [
122
125
  "pmlthick_revert",
123
126
  "postprocessing",
124
127
  "preprocessing",
128
+ "recommended_sampling_interval",
125
129
  "ricker",
126
130
  "set_library_fdtd_order",
127
131
  "sine_burst",
128
132
  "solver",
133
+ "source_max_frequency",
129
134
  "utils",
130
135
  "visualization",
131
136
  "wavelet",
@@ -1,3 +1,3 @@
1
1
  """Single source of truth for the package version."""
2
2
 
3
- __version__ = "0.1.0"
3
+ __version__ = "0.1.3"
@@ -101,6 +101,17 @@ CPML_PHI_TENSOR_COUNT: Final[int] = CPML_FACE_COUNT * CPML_PHI_TENSORS_PER_FACE
101
101
  #: Human readable CPML face names in native order.
102
102
  CPML_FACE_NAMES: Final[Tuple[str, ...]] = ("x0", "xm", "y0", "ym", "z0", "zm")
103
103
 
104
+ # ---------------------------------------------------------------------------
105
+ # Temporal sampling of the gradient history
106
+ # ---------------------------------------------------------------------------
107
+
108
+ #: Relative amplitude at which a source spectrum counts as decayed when
109
+ #: ``model_gradient_sampling_interval="auto"`` locates ``f_max``. For a Ricker
110
+ #: wavelet ``|W(f)| / |W(f_peak)| = (f/f_peak)^2 exp(1 - (f/f_peak)^2)`` equals
111
+ #: 3.0e-3 at ``f ~= 3 f_peak``, so the recommended interval is
112
+ #: ``floor(1 / (12 f_peak dt))``.
113
+ SOURCE_SPECTRUM_CUTOFF_FRACTION: Final[float] = 3.0e-3
114
+
104
115
  # ---------------------------------------------------------------------------
105
116
  # Native library ABI
106
117
  # ---------------------------------------------------------------------------
@@ -120,6 +131,32 @@ WAVEFIELD_STORAGE_FLOAT16: Final[int] = 1
120
131
  WAVEFIELD_STORAGE_BFLOAT16: Final[int] = 2
121
132
  WAVEFIELD_STORAGE_INT8: Final[int] = 3
122
133
 
134
+ #: Bits 0-3 of ``storage_type`` hold the storage code; bits 4-7 are history flags.
135
+ WAVEFIELD_STORAGE_KIND_MASK: Final[int] = 0x0F
136
+
137
+ #: History flag: store only E^n (sampling interval 1). ``R_saved`` receives the
138
+ #: final E^nt frame and the adjoint rebuilds R^n = (E^(n+1) - ca E^n) / cb.
139
+ #: Only set when the library reports ``deepgpr_supports_rhs_reconstruction``.
140
+ WAVEFIELD_RHS_FROM_E: Final[int] = 1 << 4
141
+
142
+ #: History flag: E/R frames cover only the physical model cells (no CPML).
143
+ #: Only set when the library reports ``deepgpr_supports_physical_history``.
144
+ WAVEFIELD_PHYSICAL_HISTORY: Final[int] = 1 << 5
145
+
146
+ #: Solver flag: 2D Ez-TM fast path (CUDA). Set only for nz = 1, an Ez source
147
+ #: and zero Ex/Ey/Hz states and when ``deepgpr_supports_tm2d_fast_path`` is 1.
148
+ SOLVER_TM2D: Final[int] = 1 << 6
149
+
150
+ #: Indices of the CPML auxiliary arrays (in the 24-array native order) that
151
+ #: couple only Ex, Ey and Hz in 2D: x0/xm/y0/ym E-phi1 and H-phi2.
152
+ TM2D_INACTIVE_PHI_INDICES: Final[Tuple[int, ...]] = (0, 3, 4, 7, 8, 11, 12, 15)
153
+
154
+ #: Accepted values of ``wavefield_history_region``.
155
+ WAVEFIELD_HISTORY_REGIONS: Final[Tuple[str, ...]] = ("extended", "physical")
156
+
157
+ #: Accepted values of ``wavefield_rhs_history``.
158
+ WAVEFIELD_RHS_HISTORY_MODES: Final[Tuple[str, ...]] = ("auto", "stored", "reconstructed")
159
+
123
160
  #: Bit offsets and mask of the INT8 block shape inside ``storage_type``.
124
161
  INT8_BLOCK_X_SHIFT: Final[int] = 8
125
162
  INT8_BLOCK_Y_SHIFT: Final[int] = 14
@@ -219,17 +256,25 @@ __all__ = [
219
256
  "MIN_RELATIVE_PERMITTIVITY",
220
257
  "NATIVE_ABI_VERSION",
221
258
  "PEC_CONDUCTIVITY_THRESHOLD",
259
+ "SOLVER_TM2D",
260
+ "SOURCE_SPECTRUM_CUTOFF_FRACTION",
222
261
  "SPEED_OF_LIGHT",
223
262
  "SUPPORTED_FDTD_ORDERS",
224
263
  "SUPPORTED_GRADIENT_MODES",
264
+ "TM2D_INACTIVE_PHI_INDICES",
225
265
  "TV_ISOTROPIC_EPSILON",
226
266
  "VACUUM_PERMEABILITY",
227
267
  "VACUUM_PERMITTIVITY",
228
268
  "WAVEFIELD_CONVERSION_BACKENDS",
229
269
  "WAVEFIELD_CONVERSION_SHIFT",
230
270
  "WAVEFIELD_HISTORY_DISABLED",
271
+ "WAVEFIELD_HISTORY_REGIONS",
272
+ "WAVEFIELD_PHYSICAL_HISTORY",
273
+ "WAVEFIELD_RHS_FROM_E",
274
+ "WAVEFIELD_RHS_HISTORY_MODES",
231
275
  "WAVEFIELD_STORAGE_BFLOAT16",
232
276
  "WAVEFIELD_STORAGE_FLOAT16",
233
277
  "WAVEFIELD_STORAGE_FLOAT32",
234
278
  "WAVEFIELD_STORAGE_INT8",
279
+ "WAVEFIELD_STORAGE_KIND_MASK",
235
280
  ]