Repository navigation
fix(dpmodel): make se_e2_a type_one_side=False traceable - #6073
stanleys12 wants to merge 1 commit into
Conversation
The two-sided path sliced per-type blocks with bounds taken from int(xp.sum(atype_loc == ti)), which cannot be traced with symbolic shapes, so pt_expt compiled training and export failed. Gather each center type's atoms with nonzero instead and restore the order with the inverse of the stable sort. The embedding still runs once per atom. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to No actionable merge-blocking defect was established. The change is mergeable after normal checks. Pre-merge checks |
|
DescrptSeAwithtype_one_side=Falsesorted atoms by center type and sliced each type's block using bounds fromint(xp.sum(atype_loc == ti)). Undermake_fxwith symbolic shapes (pt_exptenable_compile=True, andtorch.export), thatint()raisesGuardOnDataDependentSymNode, so compiled training fails at the first trace.Now I gather each center type's atoms with
xp.nonzero+xp.take, run the(ti, tt)embeddings on that block, then concatenate the blocks and restore the atom order withargsort(argsort(atype_loc)).nonzeroreturns ascending indices, so the concatenated blocks are in stable sorted order. Each atom still goes through one embedding per neighbor type, so the cost is the same. In a quick eager CPU benchmark (nf=4, nloc=192, nnei=138, neuron [25,50,100], fwd+bwd) it runs at 1005 ms vs 1139 ms on master for ntypes=2, and 1127 ms vs 1251 ms for ntypes=8. The compressed array-API branch gets the same change. I also removed_add_to_slicesince nothing calls it anymore.jax.jitof the two-sided descriptor still fails, same as on master, becausenonzeroneeds a static size under jit.Tests:
source/tests/pt_expt/test_training.py::TestTraining::test_training_loop_compiled_two_side: new. Fails on master with the error above and passes here.test_make_fxinsource/tests/pt_expt/descriptor/test_se_e2_a.pynow also coverstype_one_side=Falseandexclude_types, including the export round trip.source/tests/consistent/descriptor/test_se_e2_a.pyandsource/tests/jax/test_model_compression.pypass locally. TF and the pt C++ op weren't installed, so those subtests were skipped. The pt_expttest_compressed_forwardneeds the custom op library, so only CI covers it.Fixes #6017
Summary by CodeRabbit