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

Update docs #301

Merged
merged 2 commits into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 0 additions & 2 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
DocumenterMarkdown = "997ab1e6-3595-5248-9280-8efb232c3433"
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
LuxCore = "bb33d45b-7691-41d6-9220-0943567d0623"
Lux = "b2108857-7c20-44ae-9111-449ecde12c47"
LuxLib = "82251201-b29d-42c6-8e01-566dec8acb11"
Optimisers = "3bd65402-5787-11e9-1adc-39752487f4e2"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
16 changes: 4 additions & 12 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
using Documenter, DocumenterMarkdown, LuxCore, Lux, LuxLib, Pkg
using Documenter, DocumenterMarkdown, Lux, Pkg

import Flux # Load weak dependencies

deployconfig = Documenter.auto_detect_deploy_system()
Documenter.post_status(deployconfig; type="pending", repo="github.com/avik-pal/Lux.jl.git")

makedocs(; sitename="Lux", authors="Avik Pal et al.", clean=true, doctest=true,
modules=[Lux, LuxLib, LuxCore],
strict=[
:doctest,
:linkcheck,
:parse_error,
:example_block,
# Other available options are
# :autodocs_block, :cross_references, :docs_block, :eval_block, :example_block,
# :footnote, :meta_block, :missing_docs, :setup_block
], checkdocs=:all, format=Markdown(), draft=false,
build=joinpath(@__DIR__, "docs"))
modules=[Lux],
strict=[:doctest, :linkcheck, :parse_error, :example_block, :missing_docs],
checkdocs=:all, format=Markdown(), draft=false, build=joinpath(@__DIR__, "docs"))

deploydocs(; repo="github.com/avik-pal/Lux.jl.git", push_preview=true,
deps=Deps.pip("mkdocs", "pygments", "python-markdown-math", "mkdocs-material",
Expand Down
10 changes: 0 additions & 10 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,6 @@ nav:
- "Utilities": "api/utilities.md"
- "Flux & Lux InterOp": "api/flux2lux.md"
- "Experimental": "api/contrib.md"
- "Frameworks":
- "Boltz": "lib/Boltz/index.md"
- "FluxMPI": "https://avik-pal.github.io/FluxMPI.jl/dev/"
- "NNlib": "https://fluxml.ai/Flux.jl/stable/models/nnlib/"
- "LuxLib":
- "Introduction": "lib/LuxLib/index.md"
- "API Reference": "lib/LuxLib/api.md"
- "LuxCore":
- "Introduction": "lib/LuxCore/index.md"
- "API Reference": "lib/LuxCore/api.md"
- "Development Documentation":
- "Style Guide": "devdocs/style_guide.md"
- "Layer Implementation": "devdocs/layer_implementation.md"
14 changes: 8 additions & 6 deletions docs/src/api/contrib.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Experimental Features

```@meta
CurrentModule = Lux
```
Expand All @@ -11,6 +13,12 @@ All features listed on this page are **experimental** which means:
experimental sooner.
4. None of the features are exported.

## Index

```@index
Pages = ["contrib.md"]
```

## Training

!!! note
Expand Down Expand Up @@ -70,9 +78,3 @@ Lux.@layer_map
```@docs
Lux.share_parameters
```

## Index

```@index
Pages = ["contrib.md"]
```
4 changes: 3 additions & 1 deletion docs/src/api/core.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# LuxCore.jl

```@meta
CurrentModule = Lux
```

The documentation for this page has been moved to [LuxCore.jl](../lib/LuxCore/api.md).
The documentation for this page has been moved to [LuxCore.jl](https://luxdl.github.io/LuxCore.jl/dev).
However, this the functionality has in **no way been deprecated** and there is no plan
to deprecated access to these functionalities in the future. The change was made merely to
allow lighter dependencies for users extending `Lux.jl`.
14 changes: 8 additions & 6 deletions docs/src/api/flux2lux.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
# Flux Models to Lux Models

```@meta
CurrentModule = Lux
```

Accessing these functions require manually loading `Flux`, i.e., `using Flux` must be
present somewhere in the code for these to be used.

## Index

```@index
Pages = ["flux2lux.md"]
```

## Functions

```@docs
Expand All @@ -16,9 +24,3 @@ transform
```@docs
FluxLayer
```

## Index

```@index
Pages = ["flux2lux.md"]
```
10 changes: 7 additions & 3 deletions docs/src/api/functional.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# Functional Layers

```@meta
CurrentModule = Lux
```

## Functional Layers
!!! tip
It is recommended to use [LuxLib.jl](https://luxdl.github.io/LuxLib.jl/dev) for these
functionality.

!!! note
These functions expose the backend of `Lux.jl`. In the long-term we plan to move these
into NNlib
These functions expose the backend of `Lux.jl`. These will be removed in future
releases

```@docs
Lux.dropout
Expand Down
14 changes: 8 additions & 6 deletions docs/src/api/layers.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
# Layers

```@meta
CurrentModule = Lux
```

## Index

```@index
Pages = ["layers.md"]
```

## Containers

```@docs
Expand Down Expand Up @@ -86,9 +94,3 @@ WeightNorm
PixelShuffle
Upsample
```

## Index

```@index
Pages = ["layers.md"]
```
16 changes: 9 additions & 7 deletions docs/src/api/utilities.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
# Utilities

```@meta
CurrentModule = Lux
```

## Index

```@index
Pages = ["utilities.md"]
```

## Data Transfer

```@docs
Expand Down Expand Up @@ -35,12 +43,6 @@ Lux.replicate

## Truncated Stacktraces

```docs
```@docs
Lux.disable_stacktrace_truncation!
```

## Index

```@index
Pages = ["utilities.md"]
```
53 changes: 26 additions & 27 deletions docs/src/devdocs/style_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ We do have automatic formatter, which opens PR after fixing common style issues,

## Code Styling

* Keyword Arguments must be separated using a semicolon `;`
* Functions must use `return`. Returning the last value is quite ambiguous -- did the author
- Keyword Arguments must be separated using a semicolon `;`
- Functions must use `return`. Returning the last value is quite ambiguous -- did the author
actually want it returned?
* Format docstrings as you would format regular code. If the docstring constains LaTeX in
- Format docstrings as you would format regular code. If the docstring constains LaTeX in
multiple lines, use `math` block.
* No avoiding multiply symbol -- so `2x` is invalid instead do it like other languages
- No avoiding multiply symbol -- so `2x` is invalid instead do it like other languages
`2 * x`.

## Testing
Expand All @@ -33,17 +33,17 @@ We do have automatic formatter, which opens PR after fixing common style issues,
Unfortunately we haven't yet tested all the functionality in the base library using
these guidelines.

* The file structure of the `test` folder should mirror that of the `src` folder. Every file
- The file structure of the `test` folder should mirror that of the `src` folder. Every file
in src should have a complementary file in the test folder, containing tests relevant to
that file's contents.

* Add generic utilities for testing in `test/test_utils.jl` and include them in the relevant
- Add generic utilities for testing in `test/test_utils.jl` and include them in the relevant
files.

* Use [JET.jl](https://aviatesk.github.io/JET.jl/dev/) to test for dynamic dispatch in the
- Use [JET.jl](https://aviatesk.github.io/JET.jl/dev/) to test for dynamic dispatch in the
functionality you added, specifically use `run_JET_tests` from `test/test_utils.jl`.

* **Always** test for gradient correctness. Zygote can be notorious for incorrect gradients,
- **Always** test for gradient correctness. Zygote can be notorious for incorrect gradients,
so add tests using `test_gradient_correctness_fdm` for finite differencing or use any
other AD framework and tally the results.

Expand All @@ -57,7 +57,6 @@ using `NNlib.jl` get to benefit from these fixes.
Similarly, if a bug comes to the forefront from one of the backend packages, make sure to
open a corresponding issue there to ensure they are appropriately tracked.


## Mutability

This is strictly enforced, i.e. all layers/functions provided as part of the external API
Expand All @@ -71,13 +70,13 @@ away those optimizations (these can be tested via `Zygote.@code_ir`).

### Writing efficient non-branching code to make Zygote happy

* Rely on `@generated` functions to remove **most** runtime branching. Certain examples:
* Layers behaving differently during training and inference -- we know at compile-time
- Rely on `@generated` functions to remove **most** runtime branching. Certain examples:
- Layers behaving differently during training and inference -- we know at compile-time
whether a layer is being run in training/inference mode via `istraining(st)`.
* Composite Layers relying on a variable number of internal layers -- Again we know the
- Composite Layers relying on a variable number of internal layers -- Again we know the
length of the number of internal layers at compile time. Hence we can manually unroll
the loops. See [`Parallel`](@ref), [`Chain`](@ref), etc.
* Pass around `Val` in state. `Flux.jl` sets `training` to be `(:auto, true, false)`. Hence,
- Pass around `Val` in state. `Flux.jl` sets `training` to be `(:auto, true, false)`. Hence,
which branch will be evaluated, will have to be determined at runtime time (*bad*).
Instead if we pass `Val(true)`, we will be able to specialize functions directly based on
`true`, `false`, etc. ensuring there is no runtime cost for these operations.
Expand All @@ -93,14 +92,14 @@ modify their code for upcoming releases.
process of deprecating functionalities in Julia packages. We follow the same process. Some
additional guidelines are:

- Add tests using `Test.@test_deprecated` to ensure that deprecations are indeed working
as expected.
- Add a warning to the documentation about deprecations (and how to use the new
recommended functionality).
- Add `# Deprecated Functionality (Remove in <VERSION NUMBER>)` before the tests and
deprecated functionality not placed in `src/deprecated.jl` (like kwarg deprecations).
This makes it easier to search and delete the functionalities before making a breaking
release.
- Add tests using `Test.@test_deprecated` to ensure that deprecations are indeed working
as expected.
- Add a warning to the documentation about deprecations (and how to use the new
recommended functionality).
- Add `# Deprecated Functionality (Remove in <VERSION NUMBER>)` before the tests and
deprecated functionality not placed in `src/deprecated.jl` (like kwarg deprecations).
This makes it easier to search and delete the functionalities before making a breaking
release.

## Documentation

Expand All @@ -127,15 +126,15 @@ equations being used, i.e. equations and the internal code must be consistent.
Next, we will have certain subsections (though all of them might not be necessary for all
layers).

* **Arguments**: This section should be present unless the layer is constructed without any
- **Arguments**: This section should be present unless the layer is constructed without any
arguments (See [`NoOpLayer`](@ref)). All the arguments and their explicit constraints must
be explained.
* It is recommended to separate out the Keyword Arguments in their own section.
* **Inputs**: This section should always be present. List out the requirements `x` needs to
- It is recommended to separate out the Keyword Arguments in their own section.
- **Inputs**: This section should always be present. List out the requirements `x` needs to
satisfy. (Don't write about `ps` and `st` since that is expected by default.)
* **Returns**: What will the layer return? We know the second element will be a state but is
- **Returns**: What will the layer return? We know the second element will be a state but is
that updated in any form or not?
* **Parameters**: What are the properties of the NamedTuple returned from
- **Parameters**: What are the properties of the NamedTuple returned from
`initialparameters`? Omit if the layer is parameterless.
* **States**: What are the properties of the NamedTuple returned from `initialstates`? Omit
- **States**: What are the properties of the NamedTuple returned from `initialstates`? Omit
if the layer is stateless.
Loading