Commit bbc3908
fix(tf2): register se_t, se_t_tebd, and se_atten_v2 descriptors (deepmodeling#5721)
## Problem
Fixes deepmodeling#5677. TF2 standard-model construction resolves descriptor classes
through `BaseDescriptor.get_class_by_type(<type>)`, and the TF2
descriptor registry is a distinct registry from the dpmodel and JAX ones
(each backend builds its own via `make_base_descriptor`). The `se_t`,
`se_t_tebd`, and `se_atten_v2` wrappers were defined without the
`@BaseDescriptor.register(...)` decorators their JAX counterparts carry,
so their config type names could not be resolved and TF2 model
construction failed with an unknown-descriptor error even though the
wrapper classes exist and are exported by `deepmd.tf2.descriptor`. The
affected type names are `se_e3`, `se_at`, `se_a_3be` (all `se_t`),
`se_e3_tebd` (`se_t_tebd`), and `se_atten_v2`.
## Fix
Add the missing `@BaseDescriptor.register(...)` decorators, matching the
JAX registrations for the same descriptor names. The `se_e3_tebd`
registration goes on the outer `DescrptSeTTebd` only (not the block),
mirroring JAX.
## Test
Adds `source/tests/consistent/test_tf2_descriptor_registration.py`,
which asserts that every TF2 descriptor config type name resolves via
`get_class_by_type`. It fails on master for the five
previously-unregistered names and passes with the fix. The test is gated
on `INSTALLED_TF2` (run with `DEEPMD_TEST_TF2=1`). Existing TF2
consistency tests never caught this because they instantiate the wrapper
classes directly rather than through the registry string lookup.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Expanded TF2 descriptor availability so more descriptor names are
recognized and usable.
* **Bug Fixes**
* Improved descriptor lookup reliability, helping ensure the correct TF2
descriptor is resolved at runtime.
* **Tests**
* Added coverage to verify that all expected TF2 descriptor types are
registered and callable when the TF2 backend is available.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Co-authored-by: Han Wang <wang_han@iapcm.ac.cn>1 parent dd38b35 commit bbc3908
4 files changed
Lines changed: 68 additions & 0 deletions
File tree
- deepmd/tf2/descriptor
- source/tests/consistent
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
7 | 10 | | |
8 | 11 | | |
9 | 12 | | |
10 | 13 | | |
11 | 14 | | |
| 15 | + | |
12 | 16 | | |
13 | 17 | | |
14 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
9 | 12 | | |
10 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
11 | 17 | | |
12 | 18 | | |
13 | 19 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
13 | 16 | | |
14 | 17 | | |
15 | 18 | | |
16 | 19 | | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
| 23 | + | |
20 | 24 | | |
21 | 25 | | |
22 | 26 | | |
Lines changed: 54 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
0 commit comments