Commit 9c27634
committed
perf(BMT): recover the primal tendency from the Rosenbrock Jacobian pass
ForwardDiff's Jacobian pass already evaluates the primal tendency f as the dual
.value and discards it, so a separate f = g(x) repeats a full (quadrature-
dominated) tendency evaluation. Recover f from the same pass: seed the inputs
with static `Dual`s, evaluate g once, and read the values and partials directly
into the same `FieldVector` species type as `x` (`MicroState1M` or
`MicroState2MP3`). Applies to the 2M+P3 and the 1M ExactJacobian paths; the
analytic Donor/CoupledDonor 1M Jacobians (no f by-product) keep their separate
evaluation.
Static seeding replaces `DiffResults.JacobianResult`, whose mutable result
buffer heap-allocates on GPU; the `DiffResults` dependency is dropped. Both
paths go through the shared `_tendency_and_jacobian(jacobian, g, x)` method,
removing the duplicated code in the 2M+P3 substep loop.
Reduces the per-substep cost by roughly 27%. The tendency and Jacobian are
unchanged, the path stays type-stable, and it composes with an outer AD pass.1 parent 90f0aea commit 9c27634
2 files changed
Lines changed: 38 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| 31 | + | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
429 | 429 | | |
430 | 430 | | |
431 | 431 | | |
432 | | - | |
433 | 432 | | |
434 | 433 | | |
435 | | - | |
| 434 | + | |
| 435 | + | |
436 | 436 | | |
437 | 437 | | |
438 | 438 | | |
| |||
442 | 442 | | |
443 | 443 | | |
444 | 444 | | |
| 445 | + | |
445 | 446 | | |
446 | 447 | | |
447 | 448 | | |
| |||
749 | 750 | | |
750 | 751 | | |
751 | 752 | | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
752 | 783 | | |
753 | 784 | | |
754 | 785 | | |
| |||
777 | 808 | | |
778 | 809 | | |
779 | 810 | | |
780 | | - | |
781 | 811 | | |
782 | 812 | | |
783 | 813 | | |
784 | 814 | | |
785 | 815 | | |
786 | 816 | | |
787 | 817 | | |
788 | | - | |
789 | 818 | | |
790 | 819 | | |
791 | | - | |
| 820 | + | |
| 821 | + | |
792 | 822 | | |
793 | 823 | | |
794 | 824 | | |
| |||
798 | 828 | | |
799 | 829 | | |
800 | 830 | | |
| 831 | + | |
801 | 832 | | |
802 | 833 | | |
803 | 834 | | |
| |||
0 commit comments