Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
There was a problem hiding this comment.
Sorry @r-fedorov, your pull request is larger than the review limit of 300000 diff characters
📝 WalkthroughWalkthroughThis PR adds MLX-compatible spherical and Cartesian tensor helpers, tutorial notebooks and compatibility documentation, intermediate and output irrep filtering for ChangesReduced tensor-product filtering
MLX tensor helpers
Tutorial package and notebooks
Custom-kernel routing
Estimated code review effort: 4 (Complex) | ~75 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
tutorials/other_helpers.py (1)
140-152: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove the dead, buggy first
plotdefinition (shadowed by Lines 210-243).This
plotis overridden by the later definition of the same name, so it is unreachable. It also contains a bug: at Line 149d['surfacecolor'].abs()is called on a NumPy array (tracerunsnp.asarray), which has no.abs()method and would raiseAttributeError. Delete this duplicate to avoid confusion.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tutorials/other_helpers.py` around lines 140 - 152, Remove the earlier duplicate plot function definition, including its trace-building and figure-display logic. Keep the later plot definition around Lines 210–243 as the sole implementation, since the earlier version is shadowed and contains the invalid d['surfacecolor'].abs() call.tests/test_upstream_o3_reduce_tensor.py (1)
107-128: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for the new filter validation paths.
Only the combined happy-path (
filter_ir_mid+filter_ir_outboth valid) is tested. The newValueErrorbranches inReducedTensorProducts.__init__for invalidfilter_ir_mid/filter_ir_outcontent, and the case of using each filter independently, are untested.♻️ Suggested additional test
def test_upstream_reduced_tensor_rejects_invalid_filters() -> None: irreps = o3.Irreps.spherical_harmonics(2) with pytest.raises(ValueError, match="filter_ir_mid"): o3.ReducedTensorProducts("ij=ji", i=irreps, filter_ir_mid=[object()]) with pytest.raises(ValueError, match="filter_ir_out"): o3.ReducedTensorProducts("ij=ji", i=irreps, filter_ir_out=[object()])🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/test_upstream_o3_reduce_tensor.py` around lines 107 - 128, Add tests alongside test_upstream_reduced_tensor_supports_intermediate_and_output_filters for ReducedTensorProducts filter validation: assert ValueError with matching “filter_ir_mid” and “filter_ir_out” messages when each filter receives invalid content, and add separate cases exercising filter_ir_mid alone and filter_ir_out alone with valid filters.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/test_documentation_contract.py`:
- Around line 181-185: Correct the contract entry in
tests/test_documentation_contract.py by keeping the filter_ir_mid claim while
pointing its source to an existing tracked documentation file containing the
exact excerpt, or restore docs/guide/tutorial_compatibility.md with that claim.
Ensure the referenced path and excerpt both resolve without changing the
contract text or associated test symbol.
In `@tutorials/data_types.ipynb`:
- Around line 629-630: Update the matrix construction near CartesianTensor to
transpose M with axes (1, 0) instead of (0, 1), so M + M.transpose(1, 0)
actually symmetrizes the matrix while preserving the existing formula and
conversion flow.
In `@tutorials/other_helpers.py`:
- Around line 201-206: Update random_point_signal to use MLX APIs throughout:
generate points with mx.random.normal(shape=(n, 3)), normalize them with
mx.linalg.norm(points, axis=-1, keepdims=True), and construct the result via
SphericalTensor.from_geometry(points, lmax) instead of the foreign
io.SphericalTensor/from_geometry_adjusted call.
---
Nitpick comments:
In `@tests/test_upstream_o3_reduce_tensor.py`:
- Around line 107-128: Add tests alongside
test_upstream_reduced_tensor_supports_intermediate_and_output_filters for
ReducedTensorProducts filter validation: assert ValueError with matching
“filter_ir_mid” and “filter_ir_out” messages when each filter receives invalid
content, and add separate cases exercising filter_ir_mid alone and filter_ir_out
alone with valid filters.
In `@tutorials/other_helpers.py`:
- Around line 140-152: Remove the earlier duplicate plot function definition,
including its trace-building and figure-display logic. Keep the later plot
definition around Lines 210–243 as the sole implementation, since the earlier
version is shadowed and contains the invalid d['surfacecolor'].abs() call.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: c2c1ac1f-be7b-44e5-b489-ede5ad31a625
📒 Files selected for processing (13)
.gitignoredocs/guide/tensor_products.mde3nn_mlx/ops_reduce_tensor.pytests/test_documentation_contract.pytests/test_tutorial_tensor_helpers.pytests/test_upstream_o3_reduce_tensor.pytutorials/README.mdtutorials/__init__.pytutorials/data_types.ipynbtutorials/e3nn_MRS_invariants_tutorial_lecture_pt1.ipynbtutorials/operations_on_spherical_tensors.ipynbtutorials/other_helpers.pytutorials/tensor_helpers.py
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tutorials/other_helpers.py`:
- Around line 194-196: Update the helper containing the
SphericalTensor.from_geometry call so r_min is honored by filtering generated
points according to the minimum-radius threshold before construction; otherwise
remove r_min from the helper’s interface and all related usage. Ensure the
resulting points passed to SphericalTensor.from_geometry reflect the chosen
behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 4f62fd2f-b4e7-4e1e-b1c4-0900ea2f2207
📒 Files selected for processing (5)
docs/guide/tensor_products.mdtests/test_documentation_contract.pytests/test_upstream_o3_reduce_tensor.pytutorials/data_types.ipynbtutorials/other_helpers.py
🚧 Files skipped from review as they are similar to previous changes (2)
- tests/test_upstream_o3_reduce_tensor.py
- docs/guide/tensor_products.md
| points = mx.random.normal(shape=(n, 3)) * std / mx.sqrt(3.) | ||
| points /= mx.linalg.norm(points, axis=-1, keepdims=True) | ||
| return SphericalTensor.from_geometry(points, lmax) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Honor or remove r_min.
This implementation normalizes every point to radius 1, so r_min has no effect. Either remove the parameter or apply its intended filtering behavior before constructing the spherical tensor.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@tutorials/other_helpers.py` around lines 194 - 196, Update the helper
containing the SphericalTensor.from_geometry call so r_min is honored by
filtering generated points according to the minimum-radius threshold before
construction; otherwise remove r_min from the helper’s interface and all related
usage. Ensure the resulting points passed to SphericalTensor.from_geometry
reflect the chosen behavior.
Summary by CodeRabbit
use_custom_kerneltoggle for v2.1.0.6 point-cloud models, propagated through message passing, convolutions, and geometry computations.