Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

offsets shape bug #72

Closed
wants to merge 3 commits into from
Closed

offsets shape bug #72

wants to merge 3 commits into from

Conversation

jf514
Copy link
Contributor

@jf514 jf514 commented Oct 9, 2024

Summary by CodeRabbit

  • New Features

    • Updated configuration settings for improved motion capture optimization processes.
    • Introduced detailed logging for fitting and inverse kinematics processes.
  • Bug Fixes

    • Corrected indentation issues in configuration files.
  • Chores

    • Reduced numerical parameters to optimize performance and efficiency.
    • Updated timestamps and logging formats for better error tracking and output clarity.

Copy link
Contributor

coderabbitai bot commented Oct 9, 2024

Walkthrough

The pull request introduces modifications to several configuration files, notably configs/model/rodent.yaml and configs/stac/demo.yaml, along with updates to output.txt. Key changes include reductions in numerical parameters related to optimization and sampling, the replacement of the ik_only parameter with skip_ik_only, and corrections in indentation. The output.txt file now contains detailed configurations for a motion capture optimization process, including paths and settings relevant to the MuJoCo physics engine, as well as logging adjustments.

Changes

File(s) Change Summary
configs/model/rodent.yaml - N_FRAMES_PER_CLIP: 250 → 1
- N_ITERS: 6 → 1
- N_SAMPLE_FRAMES: 100 → 1
configs/stac/demo.yaml - ik_only replaced with skip_ik_only: False
- Corrected indentation for iterations and ls_iterations
output.txt - Added configuration parameters for motion capture optimization including paths, settings for MuJoCo, and logs.
demos/api_usage.ipynb - Updated timestamps, increased operation durations, altered output statistics, and adjusted logging format.
stac_mjx/stac.py - Modified _package_data and render methods for input validation and reshaping.

Possibly related PRs

  • basic python api #31: The changes in README.md and stac_mjx/main.py regarding configuration loading and usage instructions may relate to the modifications in configuration files in the main PR, particularly the handling of parameters like ik_only and skip_ik_only.
  • Merge initial mouse work.  #57: The modifications in configs/rodent.yaml and the introduction of new configuration files in this PR align with the changes made to configs/model/rodent.yaml in the main PR, specifically regarding parameters for motion capture and optimization.
  • Rename functions, classes, and modules for clarity + mjx bug fix. #64: The renaming of parameters in configuration files, such as transform_path to ik_only_path, directly connects to the changes made in configs/stac/demo.yaml and configs/stac/stac.yaml in the main PR, indicating a shift in focus towards inverse kinematics processing.

Suggested reviewers

  • talmo

Poem

In the meadow where rabbits play,
Configs change in a clever way.
With frames reduced and paths defined,
Our motion's smooth, our steps aligned.
Hops of joy in every tweak,
Optimization's what we seek! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@jf514 jf514 changed the title Offset shape bug offsets shape bug Oct 9, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between de8217b and 963070d.

📒 Files selected for processing (3)
  • configs/model/rodent.yaml (3 hunks)
  • configs/stac/demo.yaml (1 hunks)
  • output.txt (1 hunks)
🧰 Additional context used
🪛 LanguageTool
output.txt

[grammar] ~181-~181: Make sure that the singular noun after the number ‘11.590774774551392’ is correct.
Context: ...eplace 1 finished in 11.590774774551392 starting q_opt 2 q_opt 2 finished in 0.020217895...

(CD_POINT_CD_NN)


[grammar] ~196-~196: This phrase is duplicated. You should probably use “pose optimization” only once.
Context: ...ion finished in 31.25155758857727 Final pose optimization Pose Optimization: Pose Optimization done in 0.5810093879...

(PHRASE_REPETITION)


[style] ~213-~213: This adverb was used twice in the sentence. Consider removing one of them or replacing them with a synonym.
Context: ... in run_stac ik_only_data = stac.ik_only(kp_data, offsets) ^^...

(ADVERB_REPETITION_PREMIUM)


[uncategorized] ~238-~238: Commas should not be placed before a closing parenthesis. Either move the comma outside of the parentheses, or remove it altogether.
Context: ... Incompatible shapes for broadcasting: (69,) and requested shape (23, 3) -----------...

(COMMA_CLOSING_PARENTHESIS)

🔇 Additional comments (8)
configs/stac/demo.yaml (2)

Line range hint 10-12: Verify indentation correction for mujoco section

The AI summary mentions that the indentation of iterations and ls_iterations under the mujoco section has been corrected. However, this change is not visible in the provided code snippet.

Please confirm if:

  1. The indentation correction was made in a previous commit.
  2. The AI summary is inconsistent with the actual changes.

You can use the following script to check the git history for recent changes to this file:

This will display the last 5 commits that modified this file, allowing you to verify if the indentation was corrected in a recent commit.


7-7: Confirm the logic change for inverse kinematics processing

The parameter ik_only: True has been replaced with skip_ik_only: False. While this maintains the same effective behavior (IK processing will be performed), the change in naming convention implies a potential logic inversion in the code that uses this parameter.

Please ensure that:

  1. The code that consumes this parameter has been updated to handle skip_ik_only instead of ik_only.
  2. The logic has been adjusted to accommodate the inverted boolean meaning.

You can use the following script to verify the usage of this parameter in the codebase:

This will help identify any places where the parameter might still be referenced by its old name or where the logic might need to be updated.

configs/model/rodent.yaml (4)

4-4: Clarify the overall intention behind parameter reductions.

I've noticed a pattern where multiple parameters (N_FRAMES_PER_CLIP, N_ITERS, N_SAMPLE_FRAMES) have all been reduced to 1. This consistent change across different aspects of the model suggests a deliberate modification to the system's behavior.

Could you please provide more context on the overall goal of these changes? Are these modifications part of:

  1. A debugging process?
  2. A performance optimization effort?
  3. A shift in the model's intended use or functionality?

Understanding the broader intention will help ensure that these changes align with the project's objectives and don't unintentionally compromise the model's effectiveness.

Also applies to: 13-13, 192-192


192-192: Verify the intentionality of reducing N_SAMPLE_FRAMES to 1.

The number of sample frames has been drastically reduced from 100 to 1. This change could significantly impact the statistical robustness of any sampling-based operations in the model.

Please confirm if this change is intentional and explain the reasoning behind it. If it's for debugging or a specific use case, consider adding a comment to clarify the purpose of this change.

To help verify the impact, you can run the following script:

#!/bin/bash
# Description: Check for any dependencies on N_SAMPLE_FRAMES in the codebase

# Search for usage of N_SAMPLE_FRAMES
echo "Searching for N_SAMPLE_FRAMES usage:"
rg --type python -i "N_SAMPLE_FRAMES"

# Search for any sampling-related operations that might be affected
echo "Searching for potential sampling-related operations:"
rg --type python -e "sample" -e "random.choice" -e "np.random"

This script will help identify any code that might be affected by this change.


13-13: Verify the intentionality of reducing N_ITERS to 1.

The number of alternating pose and offset optimization rounds has been significantly reduced from 6 to 1. This change could have a substantial impact on the convergence and accuracy of the optimization process.

Please confirm if this change is intentional and explain the reasoning behind it. If it's for debugging or a specific use case, consider adding a comment to clarify the purpose of this change.

To help verify the impact, you can run the following script:

#!/bin/bash
# Description: Check for any dependencies on N_ITERS in the codebase

# Search for usage of N_ITERS
echo "Searching for N_ITERS usage:"
rg --type python -i "N_ITERS"

# Search for any iteration-related loops that might be affected
echo "Searching for potential iteration-related loops:"
rg --type python -e "for.*range.*iter" -e "while.*iter"

This script will help identify any code that might be affected by this change.


4-4: Verify the intentionality of reducing N_FRAMES_PER_CLIP to 1.

The number of frames per clip for inverse kinematics has been drastically reduced from 250 to 1. This change could significantly impact the accuracy and stability of the IK solution.

Please confirm if this change is intentional and explain the reasoning behind it. If it's for debugging or a specific use case, consider adding a comment to clarify the purpose of this change.

To help verify the impact, you can run the following script:

This script will help identify any code that might be affected by this change.

output.txt (2)

179-202: Optimization process completed successfully.

The optimization process has completed successfully, showing decreasing error values over iterations. The final pose optimization achieved a low error of 5.823266474180855e-05, indicating a good fit to the motion capture data.

Great job on implementing an effective optimization process!

🧰 Tools
🪛 LanguageTool

[grammar] ~181-~181: Make sure that the singular noun after the number ‘11.590774774551392’ is correct.
Context: ...eplace 1 finished in 11.590774774551392 starting q_opt 2 q_opt 2 finished in 0.020217895...

(CD_POINT_CD_NN)


[grammar] ~196-~196: This phrase is duplicated. You should probably use “pose optimization” only once.
Context: ...ion finished in 31.25155758857727 Final pose optimization Pose Optimization: Pose Optimization done in 0.5810093879...

(PHRASE_REPETITION)


203-242: ⚠️ Potential issue

Fix shape mismatch in ik_only function.

There's a critical error in the ik_only function due to incompatible shapes for broadcasting. The error occurs when trying to set site positions:

ValueError: Incompatible shapes for broadcasting: (69,) and requested shape (23, 3)

This suggests that the offsets parameter doesn't match the expected shape for the site positions.

To resolve this issue:

  1. Check the shape of the offsets parameter passed to the ik_only function. It should be (23, 3) but is currently (69,).
  2. Verify that the offsets are correctly prepared before calling ik_only. You may need to reshape the data:
offsets = offsets.reshape(-1, 3)  # Reshape to (23, 3) if it's a flat array of 69 elements
  1. Review the set_site_pos function in op_utils.py to ensure it's handling the input shapes correctly.
  2. Add shape assertions or validation at the beginning of the ik_only function to catch such issues early:
assert offsets.shape == (23, 3), f"Expected offsets shape (23, 3), but got {offsets.shape}"

To help diagnose the issue, please run the following script to check the shapes of relevant variables:

This script will help us understand how the ik_only function is defined and used, and what shapes the kp_data and offsets variables have. The results will guide us in pinpointing the source of the shape mismatch.

🧰 Tools
🪛 LanguageTool

[style] ~213-~213: This adverb was used twice in the sentence. Consider removing one of them or replacing them with a synonym.
Context: ... in run_stac ik_only_data = stac.ik_only(kp_data, offsets) ^^...

(ADVERB_REPETITION_PREMIUM)


[uncategorized] ~238-~238: Commas should not be placed before a closing parenthesis. Either move the comma outside of the parentheses, or remove it altogether.
Context: ... Incompatible shapes for broadcasting: (69,) and requested shape (23, 3) -----------...

(COMMA_CLOSING_PARENTHESIS)

Comment on lines +1 to +175
FootR: 0.02109994311367263 -0.007614327297542731 -0.002752166493087734
HandL: 0.003031746915839468 0.001515873457919734 -0.008337304018558537
HandR: 0.003031746915839468 -0.001515873457919734 -0.008337304018558537
HipL: -0.015 0.015 0.
HipR: -0.015 -0.015 0.
KneeL: 0.01542264534586861 0.01747899805865108 -0.02570440890978101
KneeR: 0.01542264534586861 -0.01747899805865108 -0.02570440890978101
ShoulderL: 0.0287 0.00984 -0.02542
ShoulderR: 0.0287 -0.00984 -0.02542
Snout: 0. 0. 0.
SpineF: -0.015 0. 0.0
SpineL: 0. 0. 0.0
SpineM: 0. 0. 0.0
TailBase: 0. 0. 0.
WristL: 0. 0. 0.0
WristR: 0. 0. 0.0
TRUNK_OPTIMIZATION_KEYPOINTS:
- SpineF
- SpineL
- SpineM
- HipL
- HipR
- ShoulderL
- ShoulderR
- TailBase
INDIVIDUAL_PART_OPTIMIZATION:
r_leg:
- vertebra_1
- vertebra_2
- vertebra_3
- vertebra_4
- vertebra_5
- vertebra_6
- hip_R
- knee_R
- ankle_R
- foot_R
l_leg:
- vertebra_1
- vertebra_2
- vertebra_3
- vertebra_4
- vertebra_5
- vertebra_6
- hip_L
- knee_L
- ankle_L
- foot_L
r_arm:
- scapula_R
- shoulder_R
- elbow_R
- hand_R
- finger_R
l_arm:
- scapula_L
- shoulder_L
- elbow_L
- hand_L
- finger_L
head:
- atlas
- cervical
- atlant_extend
KEYPOINT_COLOR_PAIRS:
AnkleL: 0 0 .3 1
AnkleR: .3 0 0 1
EarL: 0 0 .8 1
EarR: .8 0 0 1
ElbowL: 0 0 .8 1
ElbowR: .8 0 0 1
FootL: 0 0 .3 1
FootR: .3 0 0 1
HandL: 0 0 .8 1
HandR: .8 0 0 1
HipL: 0 0 .3 1
HipR: .3 0 0 1
KneeL: 0 0 .3 1
KneeR: .3 0 0 1
ShoulderL: 0 0 .8 1
ShoulderR: .8 0 0 1
Snout: .8 .8 .8 1
SpineF: .8 .8 .8 1
SpineL: .8 .8 .8 1
SpineM: .8 .8 .8 1
TailBase: .8 .8 .8 1
WristL: 0 0 .8 1
WristR: .8 0 0 1
SCALE_FACTOR: 0.9
MOCAP_SCALE_FACTOR: 0.001
SITES_TO_REGULARIZE:
- HandL
- HandR
- SpineF
- SpineL
- SpineM
RENDER_FPS: 50
N_SAMPLE_FRAMES: 1
M_REG_COEF: 1

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider improving configuration flexibility and maintainability.

The configuration is comprehensive and well-structured. However, to enhance maintainability and flexibility, consider the following suggestions:

  1. Use environment variables or command-line arguments for paths (e.g., fit_path, ik_only_path, data_path, MJCF_PATH) to make it easier to run in different environments.
  2. Consider moving hard-coded values (e.g., KEYPOINT_INITIAL_OFFSETS, KEYPOINT_COLOR_PAIRS) to separate configuration files that can be easily updated without changing the main configuration.
  3. Use a configuration management system to handle different environments (development, testing, production) more effectively.

Would you like assistance in implementing these improvements?

Comment on lines +176 to +177
[2024-10-09 14:12:39,137][root][INFO] - Running fit. Mocap data shape: (1, 69)
/home/talmolab/miniconda3/envs/stac-mjx-env/lib/python3.11/site-packages/jaxopt/_src/optax_wrapper.py:120: DeprecationWarning: jax.tree_map is deprecated: use jax.tree.map (jax v0.4.25 or newer) or jax.tree_util.tree_map (any JAX version).
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Update jax.tree_map usage to address deprecation warning.

The code is using a deprecated function jax.tree_map. To future-proof your code, update it to use either jax.tree.map (for JAX v0.4.25 or newer) or jax.tree_util.tree_map (for any JAX version).

Replace the deprecated jax.tree_map with the appropriate alternative based on your JAX version:

# For JAX v0.4.25 or newer
from jax import tree
result = tree.map(update_fun, params, updates)

# For any JAX version
from jax.tree_util import tree_map
result = tree_map(update_fun, params, updates)

Copy link

codecov bot commented Oct 9, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 40.95%. Comparing base (527c0ee) to head (394025e).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
stac_mjx/stac.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #72      +/-   ##
==========================================
- Coverage   42.75%   40.95%   -1.80%     
==========================================
  Files           9       10       +1     
  Lines         545      586      +41     
==========================================
+ Hits          233      240       +7     
- Misses        312      346      +34     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
demos/api_usage.ipynb (1)

Line range hint 1-555: Summary of changes and recommendations for demos/api_usage.ipynb

The notebook demonstrates significant changes in the stac_mjx library's performance and output:

  1. Improved accuracy in optimization results, with lower mean errors.
  2. More detailed error reporting, providing arrays of error values instead of single values.
  3. Substantial increases in execution time for various steps, particularly in compilation and Pose Optimization.
  4. Addition of standard deviation reporting for optimization results.

While the improvements in accuracy are commendable, the increased execution times warrant careful consideration. It's recommended to:

  1. Investigate the causes of increased compilation and execution times.
  2. Evaluate the time-accuracy trade-off and consider making it configurable.
  3. Ensure that the more detailed error reporting is being utilized effectively for analysis and debugging.
  4. Update the documentation to reflect these changes and provide guidance on interpreting the new output format.

Consider implementing a configurable mode that allows users to choose between high-accuracy (current behavior) and high-speed (previous behavior) optimization, depending on their specific needs and computational resources.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 963070d and 394025e.

📒 Files selected for processing (2)
  • demos/api_usage.ipynb (3 hunks)
  • stac_mjx/stac.py (1 hunks)
🧰 Additional context used
🪛 GitHub Check: codecov/patch
stac_mjx/stac.py

[warning] 393-393: stac_mjx/stac.py#L393
Added line #L393 was not covered by tests

🔇 Additional comments (6)
stac_mjx/stac.py (1)

393-393: Approved: Improved offset formatting for consistency

The change to reshape self._offsets ensures that the offsets are consistently formatted as a 2D array with 3 columns when not batched. This improvement in data consistency is crucial for subsequent processing.

To ensure this change doesn't introduce any regressions, please add a test case that covers this scenario. You can use the following script to check for existing tests:

If no relevant tests are found, consider adding a new test case to cover this scenario.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 393-393: stac_mjx/stac.py#L393
Added line #L393 was not covered by tests

demos/api_usage.ipynb (5)

144-347: Enhanced error reporting in optimization process.

The error output for q_opt 1 has been significantly expanded:

  1. Instead of a single error value, it now provides an array of 600 float values.
  2. This detailed error reporting could represent errors for individual iterations or data points during the optimization process.
  3. The Replace 1 operation time has slightly decreased from 44.80 to 42.78 seconds, indicating a minor performance improvement.

These changes offer more granular insights into the optimization process, which can be valuable for debugging and fine-tuning the algorithm.

To better understand the implications of this change, please run the following script:

#!/bin/bash
# Description: Investigate the implementation of the new error reporting mechanism

# Test: Look for changes in error calculation and reporting
rg --type python -g '*.py' -e '(calculate_error|report_error|error_array)' -C 10

# Test: Check for any new visualization or analysis functions for the error array
rg --type python -g '*.py' -e '(plot_error|analyze_error|error_statistics)' -C 5

553-555: ⚠️ Potential issue

Significant changes in Pose Optimization performance and results.

The Pose Optimization step shows notable changes:

  1. Execution time has increased dramatically from 0.098 seconds to 46.727 seconds.
  2. Mean error has improved from 0.00022817964782007039 to 0.0001599203678779304.
  3. A standard deviation of 5.567146581597626e-05 is now reported, providing additional statistical insight.

While the accuracy has improved, the substantial increase in execution time warrants careful consideration of the time-accuracy trade-off.

To better understand these changes and their implications, please run the following script:

#!/bin/bash
# Description: Investigate changes in Pose Optimization implementation and performance

# Test: Look for recent changes in Pose Optimization implementation
rg --type python -g '*.py' -e 'def (pose_optimization|optimize_pose)' -C 20

# Test: Check for any new computations or algorithm changes in the Pose Optimization process
rg --type python -g '*.py' -e '(pose_optimization_step|pose_refinement)' -C 10

# Test: Look for any performance profiling or logging related to Pose Optimization
rg --type python -g '*.py' -e '(profile|log_performance).*pose.*optimization' -C 5

# Test: Check for any configurable parameters that might affect the time-accuracy trade-off
rg --type python -g '*.py' -e '(pose_optimization_iterations|pose_accuracy_threshold)' -C 5

348-350: ⚠️ Potential issue

Consistent error reporting but increased execution time for q_opt 2.

The changes in q_opt 2 output are noteworthy:

  1. The error reporting now uses the same array format as q_opt 1, providing consistency and detailed insights.
  2. However, the execution time for q_opt 2 has increased significantly from 0.0062 seconds to 1.3736 seconds.

While the consistent error reporting is a positive change, the substantial increase in execution time warrants investigation.

To investigate the cause of the increased execution time, please run the following script:


75-81: ⚠️ Potential issue

Significant increase in compilation time detected.

The compilation time for the jit_q_opt module has increased from 27m43s to 30m42s. This substantial increase (approximately 3 minutes) may indicate changes in the optimization algorithm, increased model complexity, or a potential performance regression.

To investigate this further, please run the following script:


90-101: Improved optimization results observed.

The optimization process shows significant improvements:

  1. The final error has decreased from 0.00022817964782007039 to 5.8231067669112235e-05, which is a substantial reduction.
  2. The q_opt and Replace operation times have changed, potentially indicating algorithmic improvements.

These changes suggest enhancements in the optimization process, possibly due to algorithm refinements or hyperparameter tuning.

To ensure these improvements are consistent and not a result of overfitting, please run the following validation script:

✅ Verification successful

Verification script encountered errors. Retrying with corrected commands.

Please execute the following scripts to continue the verification process:


Retrying verification with corrected rg commands.

Please execute the following scripts to continue the verification process:


Further verification needed for optimization logging.

Please execute the following scripts to gather additional information regarding logging of optimization metrics:


Optimization logging verified.

The code includes logging statements related to optimization processes, such as:

  • logging.info(f"Running fit. Mocap data shape: {fit_data.shape}")
  • logging.info(f"saving data to {fit_path}")
  • logging.info("skipping ik_only()")
  • logging.info("Running ik_only()")
  • logging.info(f"kp_data shape: {kp_data.shape}")
  • logging.info(f"Saving data to {ik_only_path}. Finished in {time.time() - start_time} seconds")
  • logging.info(f"Run complete. \n fit path: {fit_path} \n ik_only path: {ik_only_path}")
  • logging.info(f"cfg: {OmegaConf.to_yaml(cfg)}")

These logs confirm that the optimization steps are being tracked and recorded appropriately.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistency in optimization improvements across different runs or datasets

# Test: Look for recent changes in optimization-related parameters or algorithms
rg --type python -g '*.py' -e '(q_opt|optimization|hyperparameter)' -C 5

# Test: Check for any logging of optimization metrics across multiple runs
rg --type python -g '*.py' -e '(log_metric|record_optimization)' -C 5

Length of output: 376


Script:

#!/bin/bash
# Description: Check for consistency in optimization improvements across different runs or datasets

# Test: Look for recent changes in optimization-related parameters or algorithms
rg --type=python -g '*.py' -e '(q_opt|optimization|hyperparameter)' -C 5

# Test: Check for any logging of optimization metrics across multiple runs
rg --type=python -g '*.py' -e '(log_metric|record_optimization)' -C 5

Length of output: 208


Script:

#!/bin/bash
# Description: Check for consistency in optimization improvements across different runs or datasets

# Test: Look for recent changes in optimization-related parameters or algorithms
rg -g '*.py' -e '(q_opt|optimization|hyperparameter)' -C 5

# Test: Check for any logging of optimization metrics across multiple runs
rg -g '*.py' -e '(log_metric|record_optimization)' -C 5

Length of output: 16184


Script:

#!/bin/bash
# Description: Enhanced search for logging of optimization metrics across the codebase

# Test 1: Look for various logging patterns related to optimization
rg -g '*.py' -e '(log_metric|record_optimization|logging\.info|logger\.info|log\.debug)' -C 5

# Test 2: Search for logging configurations that might handle optimization metrics
rg -g '*.py' -e '(logging\.basicConfig|logging\.getLogger)' -C 5

# Test 3: Check other file types for potential logging implementations
rg -e '(log_metric|record_optimization|logging\.info|logger\.info|log\.debug)' -C 5

Length of output: 5290

Copy link
Contributor Author

@jf514 jf514 left a comment

Choose a reason for hiding this comment

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

Can you clean this up for official review and submission? Three things:

  1. Check the one comment
  2. Can you please add a unit to catch this next time? Perhaps write the data out, and read it back in, etc..
  3. Revert/delete non-relevant files. (I included those for your ease of debugging.)

Thank you!

@@ -390,7 +390,7 @@ def _package_data(self, mjx_model, q, x, walker_body_sites, kp_data, batched=Fal
x = x.reshape(-1, x.shape[-1])
q = q.reshape(-1, q.shape[-1])
else:
offsets = self._offsets
offsets = self._offsets.reshape((-1, 3))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's what I figured, but I wanted to make, since a few things were changed by the PR that introduced it.

Just to double check, the other branch of this doesn't need it as well?

@jf514 jf514 closed this Oct 25, 2024
@jf514 jf514 deleted the offset-shape-bug branch October 25, 2024 20:14
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