Skip to content

Finalize: delete legacy, optimize, rename, clean up#1074

Open
yutingye wants to merge 6 commits intomainfrom
export-D94847831
Open

Finalize: delete legacy, optimize, rename, clean up#1074
yutingye wants to merge 6 commits intomainfrom
export-D94847831

Conversation

@yutingye
Copy link
Contributor

@yutingye yutingye commented Mar 2, 2026

Summary:
Final phase of the error function refactoring:

  1. Delete legacy VertexErrorFunctionT and old standalone VertexProjectionErrorFunctionT
  2. Performance: wR precomputation (Position gradient -15%, Orientation -27%),
    scaledDfdv, single-evalFunction interface, Distance/Projection standalone
  3. Rename VertexConstraintErrorFunctionT → VertexErrorFunctionT, drop "Constraint"
    from vertex leaf names/files, consolidate types into error_function_types.h
  4. Unify getNumConstraints(), fix solver2 bindings, update pymomentum tests

Performance (1000 constraints, vs pre-refactor baseline):
Position: Gradient -15%, Jacobian -2.5% | Orientation: Gradient -27%, Jacobian -2.3%
FixedAxis: Gradient -18%, Jacobian -5.1% | AimDist: Gradient -17%, Jacobian -5.6%
All JointErrorFunctionT subclasses strictly faster than baseline.

Differential Revision: D94847831

yutingye added 6 commits March 2, 2026 11:35
Summary:
Adds SkeletonDerivativeT, a shared utility class that encapsulates the fundamental
derivative primitive used by all skeleton-based error functions: the joint hierarchy
walk that accumulates derivatives from a joint up to the root.

This utility will be used by JointErrorFunctionT, VertexErrorFunctionT,
MultiSourceErrorFunctionT, and standalone error functions that need skeleton
derivative computation.

Key features:
- accumulateJointGradient: batched hierarchy walk for gradient computation
- accumulateJointJacobian: batched hierarchy walk for Jacobian computation
- accumulateVertexGradient/Jacobian: mesh vertex derivative computation via skinning weights
- accumulateBlendShapeGradient/Jacobian: blend shape parameter derivatives
- Per-DOF activeJointParams check, ancestor-only traversal, batched vectors

Differential Revision: D94558394
Summary:
Renames ConstraintErrorFunctionT to JointErrorFunctionT and restructures it to
inherit directly from SkeletonErrorFunctionT (removing the GeneralErrorFunctionT
intermediate layer). Uses SkeletonDerivativeT for hierarchy walks in
getGradient/getJacobian.

Key changes:
- ConstraintErrorFunctionT -> JointErrorFunctionT (new files: joint_error_function.h/inl.h)
- Inherits SkeletonErrorFunctionT directly instead of GeneralErrorFunctionT
- Leaf classes use new evalFunction(worldVecs) + getLocalVectors() interface
- All 11 leaf classes updated: Position, Plane, Normal, Orientation, Aim*, FixedAxis*, Distance, Projection
- Distance and Projection error functions now inherit JointErrorFunctionT (previously SkeletonErrorFunctionT)
- GeneralizedLossT gets isL2()/invC2() accessors for optimization
- diff_ik downstream updated for ProjectionErrorFunctionT member rename
- External PointSplineErrorFunction (rocktenn/drita) updated

Differential Revision: D94558392
Summary:
Adds VertexConstraintErrorFunctionT and its leaf classes (VertexPosition, VertexPlane,
VertexProjection, VertexNormal) as new vertex-based error functions that inherit from
SkeletonErrorFunctionT directly instead of through GeneralErrorFunctionT.

Key changes:
- VertexConstraintErrorFunctionT inherits SkeletonErrorFunctionT directly
- Uses SkeletonDerivativeT for vertex derivative computation (skinning weights, blend shapes)
- Supports parallel threading via dispenso
- L2 fast-path optimization
- VertexNormalConstraintErrorFunctionT handles normal rotation correction via SkeletonDerivativeT
- Includes comprehensive vertex constraint leaf tests (48 new tests)

Differential Revision: D94558395
Summary:
Adds MultiSourceErrorFunctionT, renamed from GeneralErrorFunctionT, as the base class
for error functions that use the multi-source contribution model. Also adds
CenterOfMassErrorFunctionT as a subclass, and updates JtJDistance and JtJPosition
error functions to use the renamed base class.

Key changes:
- GeneralErrorFunctionT -> MultiSourceErrorFunctionT
- ContributionT -> SourceT
- CenterOfMassErrorFunctionT added as new MultiSource subclass
- JtJDistance and JtJPosition updated to use MultiSourceErrorFunctionT
- Tests for MultiSourceErrorFunctionT edge cases and CenterOfMass

Note: CameraProjectionConstraintErrorFunctionT will be added in a follow-up
diff as it requires more design work to restructure from ConstraintErrorFunctionT
to MultiSourceErrorFunctionT.

Differential Revision: D94558389
Summary:
Updates standalone error functions (collision, collision_stateless,
point_triangle_vertex, vertex_vertex_distance, camera_projection) to use
SkeletonDerivativeT as a utility member for derivative computation.

Also applies Option B (inline hierarchy walk) to JointErrorFunctionT's
getGradient/getJacobian to eliminate the 25-50% performance regression
from delegating to SkeletonDerivativeT. The inline walk matches the
pre-refactor performance within 1-7%.

Adds baseline_all benchmark target for comprehensive performance validation.

Differential Revision: D94558396
Summary:
Final phase of the error function refactoring:

1. Delete legacy VertexErrorFunctionT and old standalone VertexProjectionErrorFunctionT
2. Performance: wR precomputation (Position gradient -15%, Orientation -27%),
   scaledDfdv, single-evalFunction interface, Distance/Projection standalone
3. Rename VertexConstraintErrorFunctionT → VertexErrorFunctionT, drop "Constraint"
   from vertex leaf names/files, consolidate types into error_function_types.h
4. Unify getNumConstraints(), fix solver2 bindings, update pymomentum tests

Performance (1000 constraints, vs pre-refactor baseline):
  Position: Gradient -15%, Jacobian -2.5%  |  Orientation: Gradient -27%, Jacobian -2.3%
  FixedAxis: Gradient -18%, Jacobian -5.1%  |  AimDist: Gradient -17%, Jacobian -5.6%
  All JointErrorFunctionT subclasses strictly faster than baseline.

Differential Revision: D94847831
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Mar 2, 2026
@meta-codesync
Copy link
Contributor

meta-codesync bot commented Mar 2, 2026

@yutingye has exported this pull request. If you are a Meta employee, you can view the originating Diff in D94847831.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant