Skip to content

Fix standard deviation in PyTorch array summaries - #81

Closed
Linxiushen wants to merge 1 commit into
google-deepmind:mainfrom
Linxiushen:fix/torch-summary-standard-deviation
Closed

Linxiushen wants to merge 1 commit into
google-deepmind:mainfrom
Linxiushen:fix/torch-summary-standard-deviation

Conversation

@Linxiushen

Copy link
Copy Markdown

PyTorch floating-point summaries currently display the variance after ±, while NumPy and JAX display the population standard deviation. For example, [1.0, 5.0] is summarized as ≈3.0 ±4.0 instead of ≈3.0 ±2.0.

Take the square root of the existing finite-value variance, keeping the current NaN/infinity filtering. Exercise both values of fast in the existing backend-consistency test (it previously passed fast=True twice), cover singleton and non-finite inputs across all three backends, and update the affected rendering expectations.

Validation on Python 3.11 / Windows, NumPy 2.2.6, JAX 0.6.2 and PyTorch 2.7.1:

  • Before the fix: array-adapter tests report 4 failures; the new checks catch ±4.0 versus ±2.0 and the existing large-array consistency check catches variance versus standard deviation.
  • After the fix: python -m pytest tests/ndarray_adapters_test.py -q --tb=short — 28 passed, 96 subtests passed.
  • Full suite: 185 passed, 1 skipped, 588 subtests passed; one existing Windows path-separator assertion in test_closure_rendering fails identically on unchanged main (173 passed, 1 skipped, same failure).
  • pyink treescope tests --check (24.8.0) and pylint treescope (3.3.1) pass. Linux CI / pytype and GPU execution were not run locally.

@google-cla

google-cla Bot commented Sep 27, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@Linxiushen
Linxiushen force-pushed the fix/torch-summary-standard-deviation branch from 825cbd2 to dceaefe Compare September 28, 2026 03:51
@danieldjohnson

Copy link
Copy Markdown
Collaborator

Closing this PR since the contributions appear to be automated and unrelated to real-world use of this library.

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.

2 participants