Skip to content

Conversation

@Wolkenwandler
Copy link

This function is missing in rfd3, but it exists in rf3 and is not used there.

Copilot AI review requested due to automatic review settings December 16, 2025 04:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the _remap_outputs helper function by moving it from rf3.py (where it was unused) to rfd3.py (where it is needed). The function is used to remap network outputs according to a mapping tensor for alignment with ground truth data.

  • Removed unused _remap_outputs function from models/rf3/src/rf3/trainers/rf3.py
  • Added _remap_outputs function to models/rfd3/src/rfd3/trainer/rfd3.py along with required jaxtyping imports

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
models/rfd3/src/rfd3/trainer/rfd3.py Added _remap_outputs function and imported Float and Int from jaxtyping to support the function's type annotations
models/rf3/src/rf3/trainers/rf3.py Removed unused _remap_outputs function definition

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

) -> Float[torch.Tensor, "D L 3"]:
"""Helper function to remap outputs using a mapping tensor."""
for i in range(xyz.shape[0]):
xyz[i, mapping[i]] = xyz[i].clone()
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The remapping logic is incorrect. The current implementation assigns the cloned original values to positions specified by the mapping, which doesn't perform the intended remapping operation. The line should be xyz[i] = xyz[i, mapping[i]] or xyz[i] = xyz[i].clone()[mapping[i]] to correctly reorder the elements according to the mapping indices. With the current implementation, if mapping contains indices [2, 0, 1], the function won't reorder the tensor elements correctly.

Suggested change
xyz[i, mapping[i]] = xyz[i].clone()
xyz[i] = xyz[i, mapping[i]]

Copilot uses AI. Check for mistakes.
Comment on lines +33 to +39
def _remap_outputs(
xyz: Float[torch.Tensor, "D L 3"], mapping: Int[torch.Tensor, "D L"]
) -> Float[torch.Tensor, "D L 3"]:
"""Helper function to remap outputs using a mapping tensor."""
for i in range(xyz.shape[0]):
xyz[i, mapping[i]] = xyz[i].clone()
return xyz
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is duplicated from trainer_utils.py (lines 33-39) where an identical implementation already exists. Consider importing the function from trainer_utils instead to avoid code duplication and maintain a single source of truth. If there's a specific reason for the duplication, it should be documented.

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

@Ubiquinone-dot
Copy link
Collaborator

Was this causing issues?

LorenzoTarricone pushed a commit to LorenzoTarricone/foundry that referenced this pull request Dec 29, 2025
* refactor: delete files

* fix: add back files that included imported functions in chiral code

* chore: add back files to archive, update pyproject.yaml and gitignore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants