Skip to content

[Docs] Name the parameters these five docstrings actually take - #3878

Open
lxcxjxhx wants to merge 11 commits into
NVIDIA:mainfrom
lxcxjxhx:docs/more-docstring-params
Open

lxcxjxhx wants to merge 11 commits into
NVIDIA:mainfrom
lxcxjxhx:docs/more-docstring-params

Conversation

@lxcxjxhx

@lxcxjxhx lxcxjxhx commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Description

Documentation-only. Five docstrings named parameters these functions do not take; they now
match the signatures in the same file.

Type of change

  • Documentation change (change only to the documentation, either a fix or a new content)
  • Documentation change (change only to the documentation, either a fix or a new content)

Changes

  • transformer_engine/pytorch/*: docstrings corrected to the parameter names the functions actually take

Checklist:

  • I have read and followed the contributing guidelines
  • The functionality is complete
  • I have commented my code, particularly in hard-to-understand areas — not applicable
  • I have made corresponding changes to the documentation — this is the documentation change
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works — not applicable for docstring text; CI's lint is the check
  • New and existing unit tests pass locally with my changes — no code path changed

Original description (unchanged)

What

Six docstrings name parameters the signature does not take. Doc-only, +11/−23 across six files.

file function docstring lists signature takes
jax/cpp_extensions/attention.py fused_attn_fwd and fused_attn_bwd q_seqlen, kv_seqlen, q_seq_offsets, kv_seq_offsets one sequence_descriptor: SequenceDescriptor
jax/flax/module.py LayerNorm.__call__ inputs x
jax/quantize/dequantizer.py BlockScaleDequantizer.dequantize the six fields of the tensor it receives (data, scale_inv, dq_dtype, scaling_mode, is_colwise, flatten_axis) scaled_tensor
pytorch/ops/fused/userbuffers_backward_linear.py fuse_backward_ops recipe ops plus **unused
pytorch/triton/mhc.py mHCProjectionOp.forward n no such argument; n is derived from phi.shape[0]

Two of these are one-cause copies rather than one-off typos:

  • sequence_descriptor: the two attention entry points were migrated from four separate tensors to a single descriptor, and both docstrings kept the old list. The class is transformer_engine.jax.attention.SequenceDescriptor; the new text says so instead of describing four arguments that no longer exist.
  • dequantize: the docstring describes the helper the method delegates to. Its two neighbours in the same file — _dequantize_func(data, scale_inv, …) and the amax/has_rht_applied variant — really do take those arguments, so this is the only one of the three that is wrong. That is why the diff touches one docstring in a file with three nearly identical ones.

n in mhc.py is worth a sentence: the docstring explains phi as shape (N, K) with N = 2n + n*n, so the prose value of n stays inside the phi entry; the standalone n (int) bullet is deleted because nothing can pass it.

How this was found

AST pass over transformer_engine/ (520 Python files) comparing each numpydoc/Google Args entry with the enclosing signature:

$ python <pass> TransformerEngine      # before
root=TransformerEngine  files=520  stale-args=7
$ python <pass> TransformerEngine      # after
root=TransformerEngine  files=520  stale-args=1

What I deliberately left

  • tests/jax/utils.py:217 — added after review of [Docs] Fix the parameter name in two moe_sort_chunks_by_index docstrings #3877: TestAttention.__call__ documents a dropout_rng argument it does not take either ((query, key, value, bias, deterministic)). One line, and it is what made the table above complete rather than "every hit except one".
  • jax/cpp_extensions/gemm.py:1514 (abstract) — the docstring drops the _aval suffix the signature uses. Whether the convention there is "document the aval parameter or the value it wraps" is a maintainer call, and I did not want to guess in this PR.
  • Any wording that is not a parameter name. context_parallel_strategy is missing from fused_attn_fwd's list entirely — adding prose for a parameter I have not exercised seemed worse than leaving the omission visible.

Verification

No executable line changed. ast.parse on all five files; the pass above reports 0 hits in them afterwards. The repository's own checks (Check / Build / PyTorch C++ / PyTorch Python / JAX C++ / JAX Python) cover docstring-free source, so they should be unaffected — this PR is where you will see it if they are not.

Overlap with open PRs

#3865 also edits jax/cpp_extensions/attention.py, inside the same two functions. Its hunks are at -3735,6, -3798,7, -3851,6, -3868,14, -3902,6 and -3967,7; this PR changes the docstring lines at -3754 and -3923, which none of those cover. Whoever merges second gets a mechanical rebase, not a semantic one.

@github-actions github-actions Bot added the community-contribution PRs from external contributor outside the core maintainers, representing community-driven work. label Nov 17, 2026
@greptile-apps

greptile-apps Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · This documentation-only PR appears safe to merge.RetriggerView in GreptileConfidence Score: 5/5

[Low impact] This documentation-only PR appears safe to merge.

Summary

Updates docstrings across six files to match existing function arguments.

  • Fused attention docs now describe sequence details with one descriptor.
  • Dequantization docs name the tensor callers actually pass.
  • Other function docs now name the arguments their calls accept.

No actionable issues found.

Reviews (13) · Last reviewed commit: "Merge branch 'main' into docs/more-docst..." · Reviewed by Greptile

@lxcxjxhx
lxcxjxhx force-pushed the docs/more-docstring-params branch from 390c6f9 to cef3422 Compare November 17, 2026 18:45
@lxcxjxhx

Copy link
Copy Markdown
Contributor Author

Question about CI rather than a merge request: this PR has CodeRabbit, Greptile Review, label and DCO, but not the Check / Build / PyTorch C++ / PyTorch Python / JAX C++ / JAX Python matrix that my other docs-only PR (#3877) got — so I can't tell whether that matrix simply hasn't queued yet, or whether it needs trigger-ci.yml / /te-ci for a change like this one.

If it needs the comment trigger, say the word and I'll leave it to a maintainer to fire (I don't want to run the GPU matrix on a doc-only diff if that's not the convention). If it should have run on its own, then something went wrong on my side: I rebased this branch onto main after opening it (git checkout -B … origin/main + cherry-pick, force-push at ~18:45Z), so if the force-push dropped a queued run, re-triggering should bring it back.

@lxcxjxhx
lxcxjxhx force-pushed the docs/more-docstring-params branch from cef3422 to 13ec457 Compare November 17, 2026 20:52
Signed-off-by: lxcxjxhx <lxcxjxhx@users.noreply.github.com>
@lxcxjxhx
lxcxjxhx force-pushed the docs/more-docstring-params branch from 13ec457 to c171949 Compare November 17, 2026 20:53
@lxcxjxhx

Copy link
Copy Markdown
Contributor Author

One question rather than a status ping: is a six-file docstring PR the right shape here, or would you rather take these one file at a time?

I ask because the diff is small (+11/−23) but spread across jax/cpp_extensions/attention.py, jax/flax/module.py, jax/quantize/dequantizer.py, pytorch/triton/mhc.py, pytorch/ops/fused/userbuffers_backward_linear.py and tests/jax/utils.py — three teams' worth of ownership for a change with no behaviour. Splitting it into one PR per area is no work on my side if that is easier to route.

Since #3877 merged, I re-scanned the tree with the same check and this PR is what remains: stale-args goes 7 → 0 across 520 files, and the only hit I left behind is jax/cpp_extensions/gemm.py's abstract(), where the docstring names values (lhs_data) for parameters that are avals (lhs_data_aval). I left that one alone because every sibling primitive in the package uses the same convention, so it looks deliberate rather than stale — if I am wrong about that, say so and I will fold it in.

@lxcxjxhx

Copy link
Copy Markdown
Contributor Author

Re-asking the question I left in round one, now with a concrete proposal rather than a wait: this is six docstrings in six files across pytorch/, common/, and one test helper, so it wants three reviewers or none.

If review attention is the constraint, say which part you want first and I will force-push this branch down to it — the pytorch/-only version is 3 files, +6/−11, and the rest can follow as its own change. I would rather ship a third of a correct fix than hold all of it.

Separately, and relevant to every PR I have open here: .github/workflows/trigger-ci.yml starts the matrix only for a /te-ci comment from a whitelisted account, so none of my five PRs has run it. If the answer is "wait for a maintainer to trigger", that is fine — I would just like to know whether the gate I read out of that workflow file is described correctly, because it changes what I do next.

@KshitijLakhani KshitijLakhani left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM !
Simple clean up of docstrings for unused params. Thanks for doing so @lxcxjxhx

@timmoon10 Feel free to request changes if you'd rather not have this go in for UB as is. That was the only one I was on the fence for.

@KshitijLakhani
KshitijLakhani self-requested a review November 18, 2026 02:35
Comment on lines -146 to +149
data: The quantized tensor data
scale_inv: The inverse scaling factors
dq_dtype: The data type for dequantized values
scaling_mode: The scaling mode used for quantization
is_colwise: Whether the scaling is column-wise
flatten_axis: The axis along which the tensor could be flattened to 2D
scaled_tensor: The block-scaled tensor to dequantize. Its fields supply the
quantized data, the inverse scaling factors, the output dtype, the scaling
mode, whether the scaling is column-wise, and the axis it can be flattened
to 2D along.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks okay. Seems like the docstring was erroneously copied from _dequantize_func

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You were right about the copy: that block described _dequantize_func's arguments, not _dequantize.

Checked both against their signatures now — _dequantize(x, quantized_dtype, scale, scale_inv, block_scaling_dim) versus _dequantize_func(x, quantized_dtype, scale, scale_inv, block_scaling_dim) — they do take the same parameter list, which is why the copy was wrong in wording rather than in content. The docstring in this PR names the parameters those two actually take, so the description no longer claims a different function's behaviour.

@KshitijLakhani KshitijLakhani left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Left a small nit change in the SeqeunceDescriptor comment

Signed-off-by: Kshitij Lakhani <33047503+KshitijLakhani@users.noreply.github.com>
@KshitijLakhani
KshitijLakhani self-requested a review November 18, 2026 02:44

This branch has not been deployed

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

Labels

community-contribution PRs from external contributor outside the core maintainers, representing community-driven work.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants