Commit 0b8b4fb
feat(dpmodel): NeighborGraph support for dpa1 tebd_input_mode="strip" (#5747)
## Summary
Adds NeighborGraph (graph-native lower) support for the dpa1 descriptor
with `tebd_input_mode="strip"`, closing the last descriptor-level gap
that forced strip-mode models (and `se_atten_v2`, which is
strip-by-construction) onto the legacy dense path.
The dense strip branch factorizes the per-neighbor feature as `gg =
gg_s*gg_t + gg_s` — a radial-only geometric embedding times a type-pair
strip embedding (optionally switch-smoothed). Because this has **no
neighbor-axis coupling**, it maps to the graph path edge-for-edge. The
change is:
- **Kernel** (`DescrptBlockSeAtten`): a new per-edge helper
`_graph_edge_gg_strip` (op-for-op mirror of the dense strip branch,
including the `center*ntypes_pad + nei` nei-fastest two-side table
layout and `int64` gather indices), selected by a `concat`/`strip`
branch in `call_graph`.
- **Routing** (`DescrptDPA1.uses_graph_lower`): admits `strip`, while
keeping compressed descriptors and `exclude_types` on the dense path
(they have no graph kernel here). `se_atten_v2` inherits this and
becomes graph-eligible for free.
- **pt_expt**: the two graph `make_fx` export tests are parametrized
over `tebd_input_mode` to prove the strip kernel is fx-traceable.
No new op, no attention/`segment_sum` change, no C++/serialization
change.
## Scope
This PR is deliberately **independent of #5733** (graph
`exclude_types`). It does **not** change `exclude_types` eligibility —
the `uses_graph_lower` `and not exclude_types` gate and the `call_graph`
`exclude_types` raise are both kept. When both land, whichever merges
second resolves a small (2–3 line) mechanical conflict at
`uses_graph_lower` / the `call_graph` guard.
## Test plan
- Block-level graph-vs-dense strip parity at `rtol=atol=1e-12` over
`type_one_side × smooth` (attn=0) and `type_one_side` (attn=2,
non-smooth).
- Descriptor-level routed-`call` vs `_call_dense` parity over
`type_one_side × smooth × attn_layer` (incl. attn=2 + smooth=True,
bit-exact via the `static_nnei` adapter), plus a negative-contract gate
test (compressed → dense, strip+`exclude_types` → dense).
- `se_atten_v2` eligibility + graph-vs-dense parity (replaces the
obsolete "strip stays dense" test).
- pt_expt strip `make_fx` export; cross-backend consistency strip cases
now route pt_expt through the graph adapter.
Validated on **CPU** and on **GPU (Tesla T4, cuda:0)**: pt_expt dpa1 50
passed, consistency strip 22 passed + `se_atten_v2` 110 passed, dpmodel
strip suites 46 passed. No tolerances relaxed, no tests skipped.
## Known limitations
- **Compression** stays on the dense path by design (strip-only
tabulation has no graph kernel); the gate excludes `self.compress`.
- **`exclude_types`** stays dense (out of scope — owned by #5733).
- **jax** graph lower remains energy-only (analytical force on the graph
route is a separate follow-up).
- The graph path's `segment_sum`→`index_add` is atomic/non-deterministic
on CUDA (1–2 fp64 ULP), inherent to atomic scatter; GPU parity validated
within tolerance.
- Pre-existing (not introduced here): a softmax `RuntimeWarning` on the
shared attention path (max over fully-masked segments), also present on
the concat path.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
## Summary
* **New Features**
* Added graph-based execution support for the additional stripped
type-embedding mode.
* **Bug Fixes**
* Updated graph routing eligibility: compressed descriptors and
excluded-type configurations now reliably fall back to dense execution;
graph routing is disabled when compression is enabled.
* **Tests**
* Added bit-exact parity tests between graph and dense paths for the new
stripped mode (including routing eligibility checks).
* Expanded FX graph export/trace coverage for both embedding modes.
* Adjusted neighbor-list fallback validation with model-specific
tolerance handling and added a new smooth variant.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Han Wang <wang_han@iapcm.ac.cn>1 parent d8892c7 commit 0b8b4fb
6 files changed
Lines changed: 397 additions & 37 deletions
File tree
- deepmd/dpmodel/descriptor
- source/tests
- common/dpmodel
- pt_expt
- descriptor
- utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
432 | 432 | | |
433 | 433 | | |
434 | 434 | | |
435 | | - | |
436 | | - | |
437 | | - | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
438 | 438 | | |
439 | 439 | | |
440 | 440 | | |
441 | 441 | | |
442 | 442 | | |
443 | 443 | | |
444 | 444 | | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
445 | 451 | | |
446 | | - | |
| 452 | + | |
447 | 453 | | |
448 | 454 | | |
449 | 455 | | |
| |||
575 | 581 | | |
576 | 582 | | |
577 | 583 | | |
578 | | - | |
| 584 | + | |
579 | 585 | | |
580 | 586 | | |
581 | 587 | | |
| |||
680 | 686 | | |
681 | 687 | | |
682 | 688 | | |
683 | | - | |
684 | | - | |
| 689 | + | |
| 690 | + | |
685 | 691 | | |
686 | 692 | | |
687 | 693 | | |
| |||
1749 | 1755 | | |
1750 | 1756 | | |
1751 | 1757 | | |
1752 | | - | |
| 1758 | + | |
1753 | 1759 | | |
1754 | 1760 | | |
1755 | 1761 | | |
1756 | 1762 | | |
1757 | 1763 | | |
1758 | 1764 | | |
1759 | 1765 | | |
1760 | | - | |
| 1766 | + | |
1761 | 1767 | | |
1762 | | - | |
| 1768 | + | |
1763 | 1769 | | |
1764 | 1770 | | |
1765 | 1771 | | |
| |||
1794 | 1800 | | |
1795 | 1801 | | |
1796 | 1802 | | |
1797 | | - | |
1798 | | - | |
1799 | | - | |
1800 | | - | |
1801 | | - | |
1802 | | - | |
1803 | | - | |
1804 | | - | |
1805 | | - | |
1806 | | - | |
1807 | | - | |
1808 | | - | |
1809 | | - | |
1810 | | - | |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
| 1806 | + | |
| 1807 | + | |
| 1808 | + | |
| 1809 | + | |
| 1810 | + | |
| 1811 | + | |
| 1812 | + | |
| 1813 | + | |
| 1814 | + | |
| 1815 | + | |
| 1816 | + | |
| 1817 | + | |
| 1818 | + | |
| 1819 | + | |
| 1820 | + | |
| 1821 | + | |
1811 | 1822 | | |
1812 | 1823 | | |
1813 | 1824 | | |
| |||
1835 | 1846 | | |
1836 | 1847 | | |
1837 | 1848 | | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
| 1874 | + | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
| 1882 | + | |
| 1883 | + | |
| 1884 | + | |
| 1885 | + | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
| 1894 | + | |
| 1895 | + | |
| 1896 | + | |
| 1897 | + | |
| 1898 | + | |
| 1899 | + | |
| 1900 | + | |
| 1901 | + | |
| 1902 | + | |
| 1903 | + | |
| 1904 | + | |
| 1905 | + | |
| 1906 | + | |
| 1907 | + | |
| 1908 | + | |
| 1909 | + | |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
1838 | 1921 | | |
1839 | 1922 | | |
1840 | 1923 | | |
| |||
Lines changed: 90 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
Lines changed: 89 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
103 | 102 | | |
104 | 103 | | |
105 | 104 | | |
106 | 105 | | |
107 | | - | |
108 | | - | |
109 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
110 | 109 | | |
111 | 110 | | |
112 | 111 | | |
| |||
200 | 199 | | |
201 | 200 | | |
202 | 201 | | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
0 commit comments