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

Merge Diffuser Agent #301

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

LiuTaowen-Tony
Copy link

@LiuTaowen-Tony LiuTaowen-Tony commented Jan 21, 2024

Description

Implemented the decision diffuser. Since there will be quite a lot of breaking change to train-eval-loop, I am making an initial pull request to discuss the change in API.
Decision Diffuser.pdf

The main contributions are:

  1. implemented DecisionDiffuserActor that can seamlessly incorporate with other components
  2. implemented training and testing loop in DecisionDiffuserAlgorithm
  3. implemented conditional offline trajectories dataset for DecisionDiffuserAlgorithm training
  4. implemented an environment for constraint composition demo
  5. adapted the model code from the original repo (need refactor and fix mypy)

Motivation and Context

Initial task for Internship.

Types of changes

What types of changes does your code introduce? Put an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds core functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (update in the documentation)

Checklist

Go over all the following points, and put an x in all the boxes that apply.
If you are unsure about any of these, don't hesitate to ask. We are here to help!

  • I have read the CONTRIBUTION guide. (required)
  • My change requires a change to the documentation.
  • I have updated the tests accordingly. (required for a bug fix or a new feature)
  • I have updated the documentation accordingly.
  • I have reformatted the code using make format. (required)
  • I have checked the code using make lint. (required)
  • I have ensured make test pass. (required)

@LiuTaowen-Tony
Copy link
Author

@Gaiejj

Hey Jiayi, I could you please kindly help me review the changes I made, and we can discuss design decision for dataset and evaluation integration?

@Gaiejj
Copy link
Member

Gaiejj commented Feb 5, 2024

I will conduct a code review recently. Please check the items that failed in CI, namely Tests, and Lint. It would enhance the code quality. You can perform a self-check locally by running make lint and make test.

@LiuTaowen-Tony
Copy link
Author

LiuTaowen-Tony commented Feb 5, 2024 via email

Copy link
Member

@Gaiejj Gaiejj left a comment

Choose a reason for hiding this comment

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

I found a number of minor typos and I think we can make this PR better to correct them.

@@ -26,7 +26,7 @@
env_name = 'SafetyAntVelocity-v1'
size = 1_000_000
agents = [
('PATH_TO_AGENT', 'epoch-500.pt', 1_000_000),
('train/PPOLag-{SafetyAntVelocity-v1}/seed-000-2024-01-07-21-14-30', 'epoch-500.pt', 1_000_000),
Copy link
Member

Choose a reason for hiding this comment

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

Should we change it to more general form like 'PATH_TO_AGENT', and make 'train/PPOLag-{SafetyAntVelocity-v1}/seed-000-2024-01-07-21-14-30' as an example in docs?

@@ -0,0 +1,110 @@
# Copyright 2022-2024 OmniSafe Team. All Rights Reserved.
Copy link
Member

Choose a reason for hiding this comment

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

2024 OmniSafe Team, the same for others

# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

Copy link
Member

Choose a reason for hiding this comment

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

Missing # ==============================================================================

actor: DecisionDiffuserActor = agent._actor


def cls_free_cond(actor: DecisionDiffuserActor) -> None:
Copy link
Member

Choose a reason for hiding this comment

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

The docstring should be google style.

"""
condition on both state and cls free condition


Copy link
Member

Choose a reason for hiding this comment

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

Empty line

"""Decision Diffuser algorithm.

References:
- Something.
Copy link
Member

Choose a reason for hiding this comment

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

What is "Something" ?

+-------------------------+----------------------------------------------------+
| Things to log | Description |
+=========================+====================================================+
| Loss/Loss | Loss of Diffusion and InvAR network |
Copy link
Member

Choose a reason for hiding this comment

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

Misaligned table.

@LiuTaowen-Tony
Copy link
Author

Any clue with the test errors? I felt like we have wrong wandb version or something

Copy link

codecov bot commented Mar 12, 2024

Codecov Report

Attention: Patch coverage is 29.06250% with 454 lines in your changes are missing coverage. Please review.

Project coverage is 91.20%. Comparing base (51a2692) to head (17ff03b).

❗ Current head 17ff03b differs from pull request most recent head d9ecd78. Consider uploading reports for the commit d9ecd78 to get more accurate results

Files Patch % Lines
omnisafe/models/diffuser/diffusion.py 16.57% 141 Missing ⚠️
omnisafe/models/diffuser/temporal_unet.py 21.09% 101 Missing ⚠️
omnisafe/common/offline/sequence_dataset.py 21.84% 68 Missing ⚠️
omnisafe/algorithms/offline/decision_diffuser.py 25.88% 63 Missing ⚠️
omnisafe/models/diffuser/helpers.py 42.86% 36 Missing ⚠️
omnisafe/envs/legacy_env.py 48.84% 22 Missing ⚠️
omnisafe/models/actor/decision_diffuser_actor.py 48.39% 16 Missing ⚠️
omnisafe/utils/ema.py 53.85% 6 Missing ⚠️
omnisafe/models/actor/actor_builder.py 66.67% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #301      +/-   ##
==========================================
- Coverage   96.89%   91.20%   -5.69%     
==========================================
  Files         138      148      +10     
  Lines        7000     7635     +635     
==========================================
+ Hits         6782     6963     +181     
- Misses        218      672     +454     

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

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.

None yet

2 participants