Skip to content

Use eltype(x) everywhere, ignore typeof(η) #151

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

Merged
merged 19 commits into from
Aug 21, 2023
Merged

Conversation

mcabbott
Copy link
Member

@mcabbott mcabbott commented Jul 26, 2023

First commit should fix #150, by working all in Float32. Chooses to do this by always following the momentum from setup, not the x, but perhaps that's messy? changed to eltype(x) now.

Since the type of η is now ignored, perhaps we should just remove all the type parameters? Then e.g. Adam(0) == Adam(0.0), fixes #119, closes #120. Also closes #86 (redundant).

Not all rules are changed yet, RFC?

@CarloLucibello
Copy link
Member

we should just remove all the type parameters?

definitely, we also get nicer prints of the opt_state has a bonus

@ToucheSir
Copy link
Member

If using the eltype of momentum is too restrictive, we could always change to some promoted eltype of various parts of input + state (e.g. momentum + param + gradient eltypes). Otherwise 👍 from me though, nice to see that this works!

@mcabbott mcabbott changed the title Use eltype(momentum) everywhere, ignore typeof(η) Use eltype(x) everywhere, ignore typeof(η) Jul 26, 2023
Copy link
Member Author

@mcabbott mcabbott left a comment

Choose a reason for hiding this comment

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

All rules now changed, and tests pass. The big question is probably whether this counts as a breaking change, or not?

test/runtests.jl Outdated
Comment on lines 41 to 43
@static if VERSION <= v"1.10-"
# In July 2023, Yota works on 1.9 but not nightly (1.11)
using Yota
Copy link
Member Author

Choose a reason for hiding this comment

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

This doesn't prevent an error from Yota not compiling on master. Could revert as it's unrelated to this PR.

Copy link
Member

Choose a reason for hiding this comment

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

since this doesn't solve the CI problem let's remove the change from this PR

Copy link
Member Author

Choose a reason for hiding this comment

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

Reverted.

@darsnack
Copy link
Member

We removed Descent{T}(…) type constructors, so unfortunately, yes.

@mcabbott
Copy link
Member Author

In fact Descent{T} was the one I left, since IIRC someone had a paper doing "gradient descent" with complex learning rate.

I doubt anyone types that, but the concern is things like BSON, right?

@mcabbott
Copy link
Member Author

I merge this now, we can think about whether anything else wants to be ganged into a breaking release.

@mcabbott mcabbott merged commit 5ac2d6f into FluxML:master Aug 21, 2023
@mcabbott mcabbott deleted the types2 branch August 21, 2023 13:52
@CarloLucibello
Copy link
Member

Tagging a new breaking release now since this fixes a lot of problems and I don't see any breaking change on the horizon.

mashu pushed a commit to mashu/Optimisers.jl that referenced this pull request Nov 14, 2024
* always convert learning rate to eltype(momentum) before use

* don't parameterise rule structs, just use Float64

* fix tests like === 0.2f0

* fix a constructor

* fix AdamW

* fix Rprop

* use a macro to define structs with default values

* use T = eltype(x)

* a few more structs

* more structs

* fix tests

* doc fixes

* fix docstrings

* skip Yota on nightly

* docstrings

* breaking change, v0.3-dev

* print Adam(0.01f0) without 0.009999999776482582

* Revert "skip Yota on nightly"

This reverts commit abf0e13.

* don't accidentally write to stdout
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.

Error in update! for Metal arrays and Adam optimiser Adam(0) fails
4 participants