Repository: pytorch
Issue: 'make html' will print 'duplicate object description' warnings when there are 1~5 CPUs in the running machine
Labels: module: docs,triaged

### 🐛 Describe the bug

Hello, PyTorch team.

I discovered that when building the PyTorch documentation using `sphinx-build`, if the `sphinx-build` command does not include the `-j auto` argument, the following warning message appears:

```bash
/home/hwhsu1231/Repo/testing/pytorch-v2.3.1/docs/source/nn.rst:566: WARNING: duplicate object description of torch.nn.parallel.data_parallel, other instance in generated/torch.nn.functional.torch.nn.parallel.data_parallel, use :noindex: for one of them
/home/hwhsu1231/Repo/testing/pytorch-v2.3.1/docs/source/nn.rst:581: WARNING: duplicate object description of torch.nn.utils.spectral_norm, other instance in generated/torch.nn.utils.spectral_norm, use :noindex: for one of them
/home/hwhsu1231/Repo/testing/pytorch-v2.3.1/docs/source/nn.rst:582: WARNING: duplicate object description of torch.nn.utils.weight_norm, other instance in generated/torch.nn.utils.weight_norm, use :noindex: for one of them
/home/hwhsu1231/Repo/testing/pytorch-v2.3.1/docs/source/quantization.rst:1348: WARNING: duplicate object description of torch.ao.quantization.quantize, other instance in generated/torch.ao.quantization.quantize, use :noindex: for one of them
```

Actually, this issue seems to be related/duplicated to this PR: [https://github.com/pytorch/pytorch/pull/123244](https://github.com/pytorch/pytorch/pull/123244). Based on the discussion in this PR, it appears that at the time, PyTorch Team did not intend to fix this error (based on this [comment](https://github.com/pytorch/pytorch/pull/123244#issuecomment-2037681048)) because adding `-j auto` would hide the error message.

However, the reason I discovered this error is because:

I tried to build PyTorch documentation automatically via GitHub Actions. I found that although running `make html` on my local computer won't show these warning messages, running `make html` via GitHub Actions somehow showed these warning message.

After numerous attempts, I discovered that the cause seemed to be that **`sphinx-build` uses the number of CPUs on the current machine when using the `-j auto` argument ([link](https://www.sphinx-doc.org/en/master/man/sphinx-build.html#cmdoption-sphinx-build-j))**. And `ubuntu-latest` image has 4 CPUs, while my local machine has 8 CPUs.

So, I tested different values of `-j N` in GitHub Actions, where `N` ranges from `1` to `8` and `auto`. It turns out that except for `6`, `7`, and `8`, all other tests resulted in errors:

https://github.com/hwhsu1231-demo/demo-build-pytorch-docs/actions/runs/9478542873

![image](https://github.com/pytorch/pytorch/assets/71438617/b6a49440-0c95-48f5-8abc-c7651d167ebc)

Alternatively, we can test it by running the following commands locally to check it out:

```bash
# Prepare the PyTorch repository and requirements
git clone --depth=1 --branch=v2.3.1 https://github.com/pytorch/pytorch.git pytorch-v2.3.1
cd pytorch-v2.3.1
python -m venv .venv
source .venv/bin/activate
python -m pip install pip --upgrade
python -m pip install torch==2.3.1 torchvision==0.18.1 -f https://download.pytorch.org/whl/torch_stable.html
python -m pip install -r docs/requirements.txt
export LANG=en_US.UTF-8

# Build PyTorch Documentation with different jobs
make -C docs figures onnx opset exportdb
sphinx-build -M html docs/source docs/build -v -WT --keep-going -j 1
git clean -xfdf -e .venv
make -C docs figures onnx opset exportdb
sphinx-build -M html docs/source docs/build -v -WT --keep-going -j 2
git clean -xfdf -e .venv
make -C docs figures onnx opset exportdb
sphinx-build -M html docs/source docs/build -v -WT --keep-going -j 3
# ...etc
```

### Versions

- Python version: `3.10.x`
- PyTorch version: `v2.3.1`

<details><summary>Click to expand the output of `python collect_env.py`</summary>

```bash
hwhsu1231@vb-kubuntu:~/Repo/testing$ python collect_env.py
Collecting environment information...
PyTorch version: N/A
Is debug build: N/A
CUDA used to build PyTorch: N/A
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.4 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: 14.0.0-1ubuntu1.1
CMake version: version 3.29.5
Libc version: glibc-2.35

Python version: 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (64-bit runtime)
Python platform: Linux-6.5.0-35-generic-x86_64-with-glibc2.35
Is CUDA available: N/A
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: N/A

CPU:
Architecture:                       x86_64
CPU op-mode(s):                     32-bit, 64-bit
Address sizes:                      39 bits physical, 48 bits virtual
Byte Order:                         Little Endian
CPU(s):                             8
On-line CPU(s) list:                0-7
Vendor ID:                          GenuineIntel
Model name:                         Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
CPU family:                         6
Model:                              142
Thread(s) per core:                 2
Core(s) per socket:                 4
Socket(s):                          1
Stepping:                           11
CPU max MHz:                        3900.0000
CPU min MHz:                        400.0000
BogoMIPS:                           3600.00
Flags:                              fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single ssbd ibrs ibpb stibp tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp vnmi md_clear flush_l1d arch_capabilities
Virtualization:                     VT-x
L1d cache:                          128 KiB (4 instances)
L1i cache:                          128 KiB (4 instances)
L2 cache:                           1 MiB (4 instances)
L3 cache:                           6 MiB (1 instance)
NUMA node(s):                       1
NUMA node0 CPU(s):                  0-7
Vulnerability Gather data sampling: Mitigation; Microcode
Vulnerability Itlb multihit:        KVM: Mitigation: VMX disabled
Vulnerability L1tf:                 Not affected
Vulnerability Mds:                  Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Meltdown:             Not affected
Vulnerability Mmio stale data:      Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Retbleed:             Mitigation; IBRS
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass:    Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:           Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:           Mitigation; IBRS; IBPB conditional; STIBP conditional; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected
Vulnerability Srbds:                Mitigation; Microcode
Vulnerability Tsx async abort:      Not affected

Versions of relevant libraries:
[pip3] No relevant packages
[conda] _anaconda_depends         2024.02             py311_mkl_1  
[conda] blas                      1.0                         mkl  
[conda] mkl                       2023.1.0         h213fc3f_46344  
[conda] mkl-include               2023.2.0            intel_49495    intel
[conda] mkl-service               2.4.0           py311h5eee18b_1  
[conda] mkl-static                2023.2.0            intel_49495    intel
[conda] mkl_fft                   1.3.8           py311h5eee18b_0  
[conda] mkl_random                1.2.4           py311hdb19cb5_0  
[conda] numpy                     1.26.4          py311h08b1b3b_0  
[conda] numpy-base                1.26.4          py311hf175353_0  
[conda] numpydoc                  1.5.0           py311h06a4308_0  
[conda] torch                     2.4.0a0+git89ca0cb           dev_0    <develop>
hwhsu1231@vb-kubuntu:~/Repo/testing$ 
```

</details>


cc @svekars @brycebortree