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

Port functionality from gml to GeometricOptimizers #1

Merged
merged 19 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
e762cf6
SymbolicNeuralNetworks -> GeometricOptimizers.
benedict-96 Dec 16, 2024
9654c7d
Added manifolds from GML (including tests).
benedict-96 Dec 17, 2024
5fb7c9c
Copied manifold-related functionality from GeometricMachineLearning.
benedict-96 Dec 17, 2024
106a441
Added pre-push githook.
benedict-96 Dec 17, 2024
37e9e31
Not using testset wrapper now.
benedict-96 Dec 17, 2024
858fac8
Adjusted test directories to src directories.
benedict-96 Dec 18, 2024
8be5c8e
Added test for global sections and omega functions.
benedict-96 Dec 19, 2024
a9a39ff
Moved tests for custom arrays from GML to GOs.
benedict-96 Dec 19, 2024
febe349
Added Poisson tensor (yet to be seen if this is needed).
benedict-96 Dec 19, 2024
66c9392
Moved tests to appropriate places and did some clean up.
benedict-96 Dec 21, 2024
c0d8ebd
Added test for StiefelProjection.
benedict-96 Jan 8, 2025
06ab639
Added optimizer convergence test and adjusted src code for test to run.
benedict-96 Jan 8, 2025
49df708
Fixed docstrings so that docs compile.
benedict-96 Jan 9, 2025
b9f447e
Added workflow for docs and references.
benedict-96 Jan 9, 2025
99734b7
Removed 1.6 and 1.9. Added 1.11.
benedict-96 Jan 9, 2025
ca8a508
Changed names to files and directories to improve clarity.
benedict-96 Jan 9, 2025
cd81d4d
Removed LinearAlgebra and Random compat entries.
benedict-96 Jan 9, 2025
368faeb
Removed GML-specific bits from Documenter workflow.
benedict-96 Jan 9, 2025
827d493
Instantiating GeometricOptimizers.
benedict-96 Jan 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# pre-push git hook that runs all tests before pushing

red='\033[0;31m'
green='\033[0;32m'
no_color='\033[0m'

reponame=$(basename `git rev-parse --show-toplevel`)


echo "\nRunning pre-push hook\n"
echo "Testing $reponame"
julia --project=@. -e "using Pkg; Pkg.test(\"GeometricOptimizers\")"

if [[ $? -ne 0 ]]; then
echo "\n${red}ERROR - Tests must pass before push!\n${no_color}"
exit 1
fi

echo "\n${green}Git hook was SUCCESSFUL!${no_color}\n"
5 changes: 2 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ jobs:
fail-fast: false
matrix:
version:
- '1.6'
- '1.9'
- '^1.10.0-0'
- '1.10'
- '1.11'
os:
- ubuntu-latest
- macOS-latest
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/Documenter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Documentation

on:
push:
branches:
- main
tags: '*'
pull_request:

jobs:
build:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Make docs (call julia documenter)
run: |
julia --project=docs -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
julia --project=docs --color=yes --threads=2 docs/make.jl
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-docdeploy@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
4 changes: 2 additions & 2 deletions AUTHORS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Authors

GeometricOptimizers' development is coordinated by a group of *principal developers*, who are also its main contributors and who can be contacted in case of questions about GeometricOptimizers. In addition, there are *contributors* who have provided substantial additions or modifications. Together, these two groups form "The GeometricOptimizers Authors" as mentioned in the [LICENSE](LICENSE.md) file.
`GeometricOptimizers`' development is coordinated by a group of *principal developers*, who are also its main contributors and who can be contacted in case of questions about `GeometricOptimizers`. In addition, there are *contributors* who have provided substantial additions or modifications. Together, these two groups form "The GeometricOptimizers Authors" as mentioned in the [LICENSE](LICENSE.md) file.

## Principal Developers

Expand All @@ -11,7 +11,7 @@ GeometricOptimizers' development is coordinated by a group of *principal develop

## Contributors

The following people contributed to SymbolicNetworks and are listed in alphabetical order:
The following people contributed to `GeometricOptimizers` and are listed in alphabetical order:

* Benedikt Brantner
* Michael Kraus
18 changes: 16 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
name = "GeometricOptimizers"
uuid = "fc236c15-5557-4942-aa65-b650f329279e"
authors = ["Michael Kraus"]
authors = ["Michael Kraus", "Benedikt Brantner"]
version = "1.0.0-DEV"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[compat]
ChainRulesCore = "1.25.0"
KernelAbstractions = "0.9.31"
LazyArrays = "2.3.1"
SafeTestsets = "0.1.0"
Zygote = "0.7.1"
julia = "1.6"

[extras]
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

[targets]
test = ["Test"]
test = ["Test", "SafeTestsets", "Zygote"]
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,15 @@
[![Build Status](https://github.com/JuliaGNI/GeometricOptimizers.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/JuliaGNI/GeometricOptimizers.jl/actions/workflows/CI.yml?query=branch%3Amain)
[![Coverage](https://codecov.io/gh/JuliaGNI/GeometricOptimizers.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/JuliaGNI/GeometricOptimizers.jl)
[![PkgEval](https://JuliaCI.github.io/NanosoldierReports/pkgeval_badges/G/GeometricOptimizers.svg)](https://JuliaCI.github.io/NanosoldierReports/pkgeval_badges/G/GeometricOptimizers.html)


## References
- Brantner B. Generalizing Adam To Manifolds For Efficiently Training Transformers. arXiv preprint arXiv:2305.16901, 2023.

## Development

We are using git hooks, e.g., to enforce that all tests pass before pushing.
In order to activate these hooks, the following command must be executed once:
```
git config core.hooksPath .githooks
```
2 changes: 2 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[deps]
Bibliography = "f1be7e48-bf82-45af-a471-ae754a193061"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
DocumenterCitations = "daee34ce-89f3-4625-b898-19384cb65244"
GeometricOptimizers = "fc236c15-5557-4942-aa65-b650f329279e"
7 changes: 7 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
using GeometricOptimizers
using Documenter
using DocumenterCitations
import Bibliography

bib = CitationBibliography(joinpath(@__DIR__, "src", "GeometricOptimizers.bib"))
Bibliography.sort_bibliography!(bib.entries, :nyt) # name-year-title

DocMeta.setdocmeta!(GeometricOptimizers, :DocTestSetup, :(using GeometricOptimizers); recursive=true)

makedocs(;
plugins = [bib],
modules=[GeometricOptimizers],
authors="Michael Kraus",
repo="https://github.com/JuliaGNI/GeometricOptimizers.jl/blob/{commit}{path}#{line}",
Expand All @@ -16,6 +22,7 @@ makedocs(;
),
pages=[
"Home" => "index.md",
"References" => "references.md",
],
)

Expand Down
61 changes: 61 additions & 0 deletions docs/src/GeometricOptimizers.bib
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
@book{goodfellow2016deep,
title={Deep learning},
author={Goodfellow, Ian and Bengio, Yoshua and Courville, Aaron},
year={2016},
publisher={MIT press},
address={Cambridge, MA}
}

@article{brantner2023generalizing,
title={Generalizing Adam To Manifolds For Efficiently Training Transformers},
author={Brantner, Benedikt},
journal={arXiv preprint arXiv:2305.16901},
year={2023}
}

@book{hairer2006geometric,
title={Geometric Numerical integration: structure-preserving algorithms for ordinary differential equations},
author={Hairer, Ernst and Lubich, Christian and Wanner, Gerhard},
year={2006},
publisher={Springer},
address={Heidelberg}
}

@article{mezzadri2006generate,
title={How to generate random matrices from the classical compact groups},
author={Mezzadri, Francesco},
journal={arXiv preprint math-ph/0609050},
year={2006}
}

@article{absil2004riemannian,
title={Riemannian geometry of Grassmann manifolds with a view on algorithmic computation},
author={Absil, Pierre-Antoine and Mahony, Robert and Sepulchre, Rodolphe},
journal={Acta Applicandae Mathematica},
volume={80},
pages={199--220},
year={2004},
publisher={Springer}
}

@book{absil2008optimization,
title={Optimization algorithms on matrix manifolds},
author={Absil, Pierre-Antoine and Mahony, Robert and Sepulchre, Rodolphe},
publisher={Princeton University Press},
address={Princeton, New Jersey},
year={2008}
}

@article{bendokat2020grassmann,
title={A Grassmann manifold handbook: Basic geometry and computational aspects},
author={Bendokat, Thomas and Zimmermann, Ralf and Absil, Pierre-Antoine},
journal={arXiv preprint arXiv:2011.13699},
year={2020}
}

@article{bendokat2021real,
title={The real symplectic Stiefel and Grassmann manifolds: metrics, geodesics and applications},
author={Bendokat, Thomas and Zimmermann, Ralf},
journal={arXiv preprint arXiv:2108.12447},
year={2021}
}
9 changes: 9 additions & 0 deletions docs/src/references.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# References

```@raw latex
\thispagestyle{empty}
```

```@bibliography
*
```
58 changes: 57 additions & 1 deletion src/GeometricOptimizers.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,61 @@
module GeometricOptimizers

# Write your package code here.
using KernelAbstractions
using Random
using LinearAlgebra: Adjoint, qr!, norm, I, mul!, rmul!
import LinearAlgebra
import ChainRulesCore
using ChainRulesCore: ProjectTo
# we use the Vcat function from LazyArrays
import LazyArrays

include("utils.jl")

export Manifold, StiefelManifold, GrassmannManifold
export rgrad
include("manifolds/abstract_manifold.jl")
include("manifolds/stiefel_manifold.jl")
include("manifolds/grassmann_manifold.jl")

export SkewSymMatrix, SymmetricMatrix, LowerTriangular, UpperTriangular
include("special_matrices/skew_symmetric.jl")
include("special_matrices/symmetric.jl")
include("special_matrices/stiefel_projection.jl")
include("special_matrices/triangular.jl")
include("special_matrices/lower_triangular.jl")
include("special_matrices/upper_triangular.jl")

export StiefelLieAlgHorMatrix, GrassmannLieAlgHorMatrix
include("lie_algebras/abstract_lie_algebra_horizontal.jl")
include("lie_algebras/stiefel_lie_algebra_horizontal.jl")
include("lie_algebras/grassmann_lie_algebra_horizontal.jl")
include("lie_algebras/stiefel_projection.jl")

export GlobalSection, global_rep
include("global_sections/global_sections.jl")
include("global_sections/omega_functions.jl")

include("retractions/modified_exponential.jl")
include("retractions/retraction_types.jl")
include("retractions/retractions.jl")

# optimizer methods I
include("optimizers/optimizer_method.jl")

# optimizer caches
include("optimizers/optimizer_caches.jl")
include("optimizers/bfgs_cache.jl")

# optimizer
export Optimizer
include("optimizers/optimizer.jl")

# optimizer methods II
include("optimizers/gradient_optimizer.jl")
include("optimizers/momentum_optimizer.jl")
include("optimizers/adam_optimizer.jl")
include("optimizers/adam_optimizer_with_decay.jl")
include("optimizers/bfgs_optimizer.jl")

include("optimizers/init_optimizer_cache.jl")
end
Loading
Loading