Skip to content

[docs]: Improve docs for NNX API Reference #5161

Open

Description

@ibbyml

Hi,

I’d like to improve the NNX API reference docs (not Linen). While working on a smaller docs issue (#5107), I noticed a few recurring problems across the NNX API reference: incomplete indexing/toctrees, inconsistent Sphinx cross-references vs code formatting, and missing/unclear docstrings for user-facing symbols. Some pages also look copied from older docs and don’t match the current NNX surface.


Example:

  • flax.nnx.unflatten in the graph section has a kwarg outer_index_outer_ref=None, but its docstring refers to index_ref_cache (which doesn’t exist).
Image

To keep review manageable, I’ll do this as a series of small PRs, going section by section in the API Reference page. To keep the scope manageable I'll focus on docs + docstrings only (no behavioral changes).

Is it ok if I send small PRs starting with flax.nnx.graph?

Thanks!

Activity

  1. vfdev-5 commented on Jan 5, 2026

    @vfdev-5
    Collaborator

    Hi @ibbyml, thanks for pointing that out. Yes, keeping the docs updated during the development can be a bit complex. If you can pointing out all these inconsistencies and send small fixes, it would be awesome.

    The team is also working on how to improve the merging process on the approved PRs, but meanwhile having the fixes on GitHub would be very helpful!

  2. ayushkumrdev commented on Jan 6, 2026

    @ayushkumrdev
    Contributor

    Hi @ibbyml and @vfdev-5, this sounds like a great initiative! To help parallelize the effort, I can take ownership of auditing the flax.nnx.nn module (Linear, Conv, Attention, etc.).

    I'll check for the same inconsistencies (missing args, broken cross-refs, and outdated Linen-style docstrings) and submit them as separate, small PRs. Does that sound good?

  3. santihdzs commented on May 29, 2026

    @santihdzs

    I'd like to take the filterlib section. The filter classes (WithTag, PathContains, OfType, Any, All, Not, Everything, Nothing) are exported but currently render with no docstrings in the API reference, I'll add short docstrings for each based on the descriptions in the Filters guide.

  4. greekera1000 commented on Aug 4, 2026

    @greekera1000

    Hi @vfdev-5 , I'd like to take the flax.nnx.training section (Metrics, Optimizer, EMA) as part of this docs audit. A few concrete inconsistencies I've already spotted there:

    • EMA.apply_to() isn't rendered in the API reference — training/ema.rst only lists __init__, update in :members:, even though apply_to() is public and is used in EMA's own docstring examples.
    • Accuracy renders inconsistently with the other metrics: training/metrics.rst lists :members: update for it, while Metric/Average/Welford/MultiMetric all list __init__, reset, update, compute. As a result Accuracy's constructor doc (the threshold arg) isn't shown.
    • Statistics (returned by Welford.compute(), and shown in its rendered example) has no docstring or reference entry.

    I'll keep it docs + docstrings only, no behavioral changes, and send it as a small PR (or a couple) scoped to this section. Sound good?

  5. greekera1000 commented on Aug 5, 2026

    @greekera1000

    Hi @vfdev-5, following up on my training section PR (#5544) — I'd like to also take the variables, rnglib, and helpers sections. Concrete issues found:

    with_metadata is listed in variables.rst via autofunction but has no docstring, so it renders as a bare signature.
    RngStream has no docstring of its own — the API reference shows the generic inherited Pytree docstring ("Base class for all NNX objects."), which is misleading.
    List and Dict (in helpers) both have a "contained a mixed set" → "containing a mixed set" typo.

    Docs + docstrings only, no behavioral changes, small PR same as before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions