Skip to content

Conversation

@cdtwigg
Copy link
Contributor

@cdtwigg cdtwigg commented Jan 22, 2026

Summary:
Adds 4 new consistency tests to verify that pymomentum.geometry functions
(using numpy arrays/py::buffers) match their pymomentum.diff_geometry counterparts
(using torch tensors):

  • test_apply_inverse_parameter_transform_matches: Tests inverse parameter transform
  • test_model_parameters_to_blend_shape_coefficients_matches: Tests blend shape coeff extraction
  • test_model_parameters_to_face_expression_coefficients_matches: Tests face expression coeff extraction
  • test_map_model_parameters_with_names_matches: Tests parameter mapping with names

These tests complete the coverage for the torch.Tensor to py::buffer conversion,
bringing total consistency tests from 21 to 25 (100% coverage of converted functions).

Reviewed By: jeongseok-meta

Differential Revision: D89915090

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jan 22, 2026
@meta-codesync
Copy link
Contributor

meta-codesync bot commented Jan 22, 2026

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

cdtwigg added a commit that referenced this pull request Jan 22, 2026
Summary:
Pull Request resolved: #977

Adds 4 new consistency tests to verify that pymomentum.geometry functions
(using numpy arrays/py::buffers) match their pymomentum.diff_geometry counterparts
(using torch tensors):

- test_apply_inverse_parameter_transform_matches: Tests inverse parameter transform
- test_model_parameters_to_blend_shape_coefficients_matches: Tests blend shape coeff extraction
- test_model_parameters_to_face_expression_coefficients_matches: Tests face expression coeff extraction
- test_map_model_parameters_with_names_matches: Tests parameter mapping with names

These tests complete the coverage for the torch.Tensor to py::buffer conversion,
bringing total consistency tests from 21 to 25 (100% coverage of converted functions).

Reviewed By: jeongseok-meta

Differential Revision: D89915090
cdtwigg added a commit that referenced this pull request Jan 22, 2026
Summary:
Pull Request resolved: #977

Adds 4 new consistency tests to verify that pymomentum.geometry functions
(using numpy arrays/py::buffers) match their pymomentum.diff_geometry counterparts
(using torch tensors):

- test_apply_inverse_parameter_transform_matches: Tests inverse parameter transform
- test_model_parameters_to_blend_shape_coefficients_matches: Tests blend shape coeff extraction
- test_model_parameters_to_face_expression_coefficients_matches: Tests face expression coeff extraction
- test_map_model_parameters_with_names_matches: Tests parameter mapping with names

These tests complete the coverage for the torch.Tensor to py::buffer conversion,
bringing total consistency tests from 21 to 25 (100% coverage of converted functions).

Reviewed By: jeongseok-meta

Differential Revision: D89915090
cdtwigg added a commit that referenced this pull request Jan 22, 2026
Summary:
Pull Request resolved: #977

Adds 4 new consistency tests to verify that pymomentum.geometry functions
(using numpy arrays/py::buffers) match their pymomentum.diff_geometry counterparts
(using torch tensors):

- test_apply_inverse_parameter_transform_matches: Tests inverse parameter transform
- test_model_parameters_to_blend_shape_coefficients_matches: Tests blend shape coeff extraction
- test_model_parameters_to_face_expression_coefficients_matches: Tests face expression coeff extraction
- test_map_model_parameters_with_names_matches: Tests parameter mapping with names

These tests complete the coverage for the torch.Tensor to py::buffer conversion,
bringing total consistency tests from 21 to 25 (100% coverage of converted functions).

Reviewed By: jeongseok-meta

Differential Revision: D89915090
cdtwigg added a commit that referenced this pull request Jan 22, 2026
Summary:
Pull Request resolved: #977

Adds 4 new consistency tests to verify that pymomentum.geometry functions
(using numpy arrays/py::buffers) match their pymomentum.diff_geometry counterparts
(using torch tensors):

- test_apply_inverse_parameter_transform_matches: Tests inverse parameter transform
- test_model_parameters_to_blend_shape_coefficients_matches: Tests blend shape coeff extraction
- test_model_parameters_to_face_expression_coefficients_matches: Tests face expression coeff extraction
- test_map_model_parameters_with_names_matches: Tests parameter mapping with names

These tests complete the coverage for the torch.Tensor to py::buffer conversion,
bringing total consistency tests from 21 to 25 (100% coverage of converted functions).

Reviewed By: jeongseok-meta

Differential Revision: D89915090
cdtwigg added a commit that referenced this pull request Jan 22, 2026
Summary:
Pull Request resolved: #977

Adds 4 new consistency tests to verify that pymomentum.geometry functions
(using numpy arrays/py::buffers) match their pymomentum.diff_geometry counterparts
(using torch tensors):

- test_apply_inverse_parameter_transform_matches: Tests inverse parameter transform
- test_model_parameters_to_blend_shape_coefficients_matches: Tests blend shape coeff extraction
- test_model_parameters_to_face_expression_coefficients_matches: Tests face expression coeff extraction
- test_map_model_parameters_with_names_matches: Tests parameter mapping with names

These tests complete the coverage for the torch.Tensor to py::buffer conversion,
bringing total consistency tests from 21 to 25 (100% coverage of converted functions).

Reviewed By: jeongseok-meta

Differential Revision: D89915090
cdtwigg added a commit that referenced this pull request Jan 22, 2026
Summary:
Pull Request resolved: #977

Adds 4 new consistency tests to verify that pymomentum.geometry functions
(using numpy arrays/py::buffers) match their pymomentum.diff_geometry counterparts
(using torch tensors):

- test_apply_inverse_parameter_transform_matches: Tests inverse parameter transform
- test_model_parameters_to_blend_shape_coefficients_matches: Tests blend shape coeff extraction
- test_model_parameters_to_face_expression_coefficients_matches: Tests face expression coeff extraction
- test_map_model_parameters_with_names_matches: Tests parameter mapping with names

These tests complete the coverage for the torch.Tensor to py::buffer conversion,
bringing total consistency tests from 21 to 25 (100% coverage of converted functions).

Reviewed By: jeongseok-meta

Differential Revision: D89915090
cdtwigg added a commit that referenced this pull request Jan 22, 2026
Summary:
Pull Request resolved: #977

Adds 4 new consistency tests to verify that pymomentum.geometry functions
(using numpy arrays/py::buffers) match their pymomentum.diff_geometry counterparts
(using torch tensors):

- test_apply_inverse_parameter_transform_matches: Tests inverse parameter transform
- test_model_parameters_to_blend_shape_coefficients_matches: Tests blend shape coeff extraction
- test_model_parameters_to_face_expression_coefficients_matches: Tests face expression coeff extraction
- test_map_model_parameters_with_names_matches: Tests parameter mapping with names

These tests complete the coverage for the torch.Tensor to py::buffer conversion,
bringing total consistency tests from 21 to 25 (100% coverage of converted functions).

Reviewed By: jeongseok-meta

Differential Revision: D89915090
cdtwigg added a commit that referenced this pull request Jan 22, 2026
Summary:
Pull Request resolved: #977

Adds 4 new consistency tests to verify that pymomentum.geometry functions
(using numpy arrays/py::buffers) match their pymomentum.diff_geometry counterparts
(using torch tensors):

- test_apply_inverse_parameter_transform_matches: Tests inverse parameter transform
- test_model_parameters_to_blend_shape_coefficients_matches: Tests blend shape coeff extraction
- test_model_parameters_to_face_expression_coefficients_matches: Tests face expression coeff extraction
- test_map_model_parameters_with_names_matches: Tests parameter mapping with names

These tests complete the coverage for the torch.Tensor to py::buffer conversion,
bringing total consistency tests from 21 to 25 (100% coverage of converted functions).

Reviewed By: jeongseok-meta

Differential Revision: D89915090
cdtwigg added a commit that referenced this pull request Jan 23, 2026
Summary:
Pull Request resolved: #977

Adds 4 new consistency tests to verify that pymomentum.geometry functions
(using numpy arrays/py::buffers) match their pymomentum.diff_geometry counterparts
(using torch tensors):

- test_apply_inverse_parameter_transform_matches: Tests inverse parameter transform
- test_model_parameters_to_blend_shape_coefficients_matches: Tests blend shape coeff extraction
- test_model_parameters_to_face_expression_coefficients_matches: Tests face expression coeff extraction
- test_map_model_parameters_with_names_matches: Tests parameter mapping with names

These tests complete the coverage for the torch.Tensor to py::buffer conversion,
bringing total consistency tests from 21 to 25 (100% coverage of converted functions).

Reviewed By: jeongseok-meta

Differential Revision: D89915090
cdtwigg added a commit that referenced this pull request Jan 24, 2026
Summary:
Pull Request resolved: #977

Adds 4 new consistency tests to verify that pymomentum.geometry functions
(using numpy arrays/py::buffers) match their pymomentum.diff_geometry counterparts
(using torch tensors):

- test_apply_inverse_parameter_transform_matches: Tests inverse parameter transform
- test_model_parameters_to_blend_shape_coefficients_matches: Tests blend shape coeff extraction
- test_model_parameters_to_face_expression_coefficients_matches: Tests face expression coeff extraction
- test_map_model_parameters_with_names_matches: Tests parameter mapping with names

These tests complete the coverage for the torch.Tensor to py::buffer conversion,
bringing total consistency tests from 21 to 25 (100% coverage of converted functions).

Reviewed By: jeongseok-meta

Differential Revision: D89915090
cdtwigg added a commit that referenced this pull request Jan 28, 2026
Summary:
Pull Request resolved: #977

Adds 4 new consistency tests to verify that pymomentum.geometry functions
(using numpy arrays/py::buffers) match their pymomentum.diff_geometry counterparts
(using torch tensors):

- test_apply_inverse_parameter_transform_matches: Tests inverse parameter transform
- test_model_parameters_to_blend_shape_coefficients_matches: Tests blend shape coeff extraction
- test_model_parameters_to_face_expression_coefficients_matches: Tests face expression coeff extraction
- test_map_model_parameters_with_names_matches: Tests parameter mapping with names

These tests complete the coverage for the torch.Tensor to py::buffer conversion,
bringing total consistency tests from 21 to 25 (100% coverage of converted functions).

Reviewed By: jeongseok-meta

Differential Revision: D89915090
Summary:
Completed migration of parameter transform functions in the geometry module from torch.Tensor to numpy arrays. This maintains consistency with the geometry module's design principle of using numpy for fast forward operations while keeping torch tensors in diff_geometry for differentiable operations.

Key changes:
- Implemented arrayToParameterSet() to convert boolean numpy arrays to ParameterSet
- Updated all parameter property bindings (scaling_parameters, rigid_parameters, etc.) to return numpy arrays
- Converted simplify(), simplify_parameter_transform(), parameters_for_joints(), and joints_for_parameters() to use arrays
- Updated reduce_to_selected_model_parameters() to use array-based parameter sets
- Updated tests to work with numpy arrays instead of tensors
- Updated .pyi type stubs to reflect numpy array usage

Differential Revision: D89891109
Summary:
Implemented numpy array version of apply_model_param_limits() for the geometry module. This function clamps model parameters to their specified min/max bounds using the character's parameter limits.

The implementation uses ModelParametersAccessor for clean data access and supports arbitrary batch dimensions with parallel processing. It only applies MinMax type parameter limits.

Key changes:
- Added applyModelParameterLimits() in momentum_geometry.cpp/h
- Uses ArrayChecker pattern for input validation
- Supports both float32 and float64 dtypes
- Parallel batch processing with dispenso
- Bound as Character.apply_model_param_limits()
- Added tests in test_geometry.py
- Added consistency test in test_geometry_diff_geometry_consistency.py
- Updated .pyi type stubs

Differential Revision: D89891111
Summary:
Converted Character.skin_skinned_locators() from torch.Tensor to numpy arrays to maintain consistency with the geometry module. This function applies linear blend skinning to compute world-space positions of skinned locators.

The implementation follows the core skinning algorithm from momentum's skinned_locator_error_function: for each locator, transform the rest position using inverse bind pose and joint transforms weighted by bone influences.

Key changes:
- Added skinSkinnedLocatorsArray() in array_skinning.cpp/h
- Uses SkeletonStateAccessor and VectorArrayAccessor for clean data access
- Supports arbitrary batch dimensions with parallel processing
- Handles optional rest positions (uses locator positions if not provided)
- Returns empty [0, 3] array if character has no skinned locators
- Updated Character.skin_skinned_locators() binding to use array version
- Updated .pyi type stubs

Differential Revision: D89891114
Summary:
Migrated find_closest_points, find_closest_points_with_normals, and find_closest_points_on_mesh from torch tensors to numpy arrays. This continues the broader migration of pymomentum geometry operations from PyTorch to numpy.

The key technical challenge was ensuring correct memory layout for the SimdKdTree library. Eigen matrices use column-major storage by default, but SimdKdTree expects row-major data where each point's coordinates are contiguous. Added a conditional toMatrix() method to VectorArrayAccessor that uses RowMajor storage for multi-dimensional points (Dim > 1) while preserving ColMajor for column vectors (Dim == 1) as required by Eigen.

Differential Revision: D89891110
Summary:
Completed the migration from PyTorch tensors to numpy arrays for both MPPCA (Mixture of Probabilistic PCA) operations and kd-tree function bindings. This commit provides the Python bindings for both features.

Key changes:
- Implemented array_mppca for converting MPPCA models to numpy arrays
- Changed Mppca.to_tensors() to Mppca.to_arrays() returning numpy arrays instead of torch tensors
- Added Python bindings for find_closest_points, find_closest_points_with_normals, and find_closest_points_on_mesh using numpy arrays
- Removed dependency on ATen/PyTorch tensor headers from geometry module
- Updated test_posePrior to use numpy array indexing instead of tensor.select()

Note: This commit includes bindings for both the kd-tree functions (from the previous commit) and MPPCA, as they share common infrastructure changes (removing tensor includes and adding array includes).

Differential Revision: D89891113
Summary:
Removes all torch/aten dependencies from the pymomentum.geometry module now
that all geometry operations have been migrated to numpy arrays. This includes:
- Removing torch header includes from C++ source files
- Removing torch import from the Python module initialization
- Removing torch from BUCK python_typing_deps
- Removing PYMOMENTUM_LIMITED_TORCH_API guards (no longer needed)
- Regenerating geometry.pyi to reflect numpy-based API (to_arrays instead of to_tensors)

The geometry module now operates entirely on numpy arrays via the Buffer
protocol. The diff_geometry module retains its torch dependency for
differentiable operations.

Differential Revision: D89893026
Summary:
Pull Request resolved: #977

Adds 4 new consistency tests to verify that pymomentum.geometry functions
(using numpy arrays/py::buffers) match their pymomentum.diff_geometry counterparts
(using torch tensors):

- test_apply_inverse_parameter_transform_matches: Tests inverse parameter transform
- test_model_parameters_to_blend_shape_coefficients_matches: Tests blend shape coeff extraction
- test_model_parameters_to_face_expression_coefficients_matches: Tests face expression coeff extraction
- test_map_model_parameters_with_names_matches: Tests parameter mapping with names

These tests complete the coverage for the torch.Tensor to py::buffer conversion,
bringing total consistency tests from 21 to 25 (100% coverage of converted functions).

Reviewed By: jeongseok-meta

Differential Revision: D89915090
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.

2 participants