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

Add Clone trait to the OptimizerAdaptor and Clone implementations to the optimizers #1770

Merged
merged 2 commits into from
May 15, 2024

Conversation

getumen
Copy link
Contributor

@getumen getumen commented May 15, 2024

Pull Request Template

Some machine learning algorithms such as reinforcement learning need not only a model but also an optmizer.
Typical example is the following.

#[derive(Clone)]
pub struct DeepQNetworkAgent<B: AutodiffBackend> {
    model: DeepQNetworkModel<B>,
    optimizer: OptimizerAdaptor<Adam<B::InnerBackend>, DeepQNetworkModel<B>, B>,
    device: B::Device,
}

Optimizer's implementations looks clonable, so I add Clone trait to the OptimizerAdaptor and Clone implementations to the optimizers.

Checklist

  • Confirmed that run-checks all script has been executed.
  • Made sure the book is up to date with changes in this PR.

Related Issues/PRs

No dependency

Changes

  • Add Clone trait to OptimizerAdatptor
  • Add Clone implementation to optimizers

Testing

Some tests failed.
But it doesn't seem to be related to my changes.

failures:

---- tests::jit::remainder::tests::should_be_zero stdout ----
thread 'tests::jit::remainder::tests::should_be_zero' panicked at crates/burn-wgpu/src/lib.rs:75:5:
Tensors are not approx eq:
  => Position 0: 0 != 3.5 | difference 3.5 > tolerance 0.0010000000000000002
  => Position 1: 0 != 3.5 | difference 3.5 > tolerance 0.0010000000000000002
  => Position 2: 0 != 3.5 | difference 3.5 > tolerance 0.0010000000000000002

---- tests::jit::module_nearest_interpolate::tests::test_downsample_interpolation stdout ----
thread 'tests::jit::module_nearest_interpolate::tests::test_downsample_interpolation' panicked at crates/burn-wgpu/src/lib.rs:75:5:
Tensors are not approx eq:
  => Position 3: 7 != 6 | difference 1 > tolerance 0.0010000000000000002
  => Position 9: 161 != 160 | difference 1 > tolerance 0.0010000000000000002
  => Position 15: 315 != 314 | difference 1 > tolerance 0.0010000000000000002
  => Position 21: 469 != 468 | difference 1 > tolerance 0.0010000000000000002

---- tests::jit_fusion::module_nearest_interpolate::tests::test_downsample_interpolation stdout ----
thread 'tests::jit_fusion::module_nearest_interpolate::tests::test_downsample_interpolation' panicked at crates/burn-wgpu/src/lib.rs:75:5:
Tensors are not approx eq:
  => Position 3: 7 != 6 | difference 1 > tolerance 0.0010000000000000002
  => Position 9: 161 != 160 | difference 1 > tolerance 0.0010000000000000002
  => Position 15: 315 != 314 | difference 1 > tolerance 0.0010000000000000002
  => Position 21: 469 != 468 | difference 1 > tolerance 0.0010000000000000002

---- tests::jit_fusion::remainder::tests::should_be_zero stdout ----
thread 'tests::jit_fusion::remainder::tests::should_be_zero' panicked at crates/burn-wgpu/src/lib.rs:75:5:
Tensors are not approx eq:
  => Position 0: 0 != 3.5 | difference 3.5 > tolerance 0.0010000000000000002
  => Position 1: 0 != 3.5 | difference 3.5 > tolerance 0.0010000000000000002
  => Position 2: 0 != 3.5 | difference 3.5 > tolerance 0.0010000000000000002


failures:
    tests::jit::module_nearest_interpolate::tests::test_downsample_interpolation
    tests::jit::remainder::tests::should_be_zero
    tests::jit_fusion::module_nearest_interpolate::tests::test_downsample_interpolation
    tests::jit_fusion::remainder::tests::should_be_zero

test result: FAILED. 1499 passed; 4 failed; 4 ignored; 0 measured; 0 filtered out; finished in 13.30s

Copy link
Member

@nathanielsimard nathanielsimard left a comment

Choose a reason for hiding this comment

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

The tests are precision errors, I think they happen on AMD graphics cards, but it should be fine on the CI.

Copy link

codecov bot commented May 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.61%. Comparing base (d3cd6c4) to head (b42af1a).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1770   +/-   ##
=======================================
  Coverage   86.61%   86.61%           
=======================================
  Files         700      700           
  Lines       83479    83479           
=======================================
  Hits        72307    72307           
  Misses      11172    11172           

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

@nathanielsimard nathanielsimard merged commit e823338 into tracel-ai:main May 15, 2024
14 checks passed
@getumen getumen deleted the clonable-optimizer branch May 19, 2024 11:10
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