RuntimeError: nonzero is not supported for tensors with more than INT_MAX  elements, file a support request
Labels: oncall: quantization, module: cuda, triaged, module: 64-bit, module: sorting and selection

### 🐛 Describe the bug

Hi,

I am trying to prune Dolly model (remove least x% weights from all layers combined) and was getting the following error

```
checkpoint = 'databricks/dolly-v1-6b'
model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto", torch_dtype=torch.bfloat16, trust_remote_code=True)
global_pruning(linear_layers_list, prune_percentage=prune_percentage)
```

where global_pruning function takes all the linear layers present in the model and does Global pruning i.e 

```
def global_pruning(linear_layers_list, prune_percentage):
    parameters_to_prune = tuple((x, 'weight') for x in linear_layers_list)
    prune.global_unstructured(parameters_to_prune, pruning_method=prune.L1Unstructured, amount=prune_percentage)
```

When I am loading the model with fp16 and doing the above pruning, I am getting the below error

```
 /hdd4/srinath2/.local/lib/python3.10/site-packages/torch/nn/utils/prune.py:1 
 119 in global_unstructured                                                   
                                                                              
   1116                                                                      
   1117    # use the `compute_mask` method from `PruningContainer` to combin 
   1118    # mask computed by the new method with the pre-existing mask      
 ❱ 1119    final_mask = container.compute_mask(relevant_importance_scores, d 
   1120                                                                      
   1121    # Pointer for slicing the mask to match the shape of each paramet 
   1122    pointer = 0                                                       
                                                                              
 /hdd4/srinath2/.local/lib/python3.10/site-packages/torch/nn/utils/prune.py:4 
 16 in compute_mask                                                           
                                                                              
    413          return new_mask                                           
    414                                                                     
    415       method = self._pruning_methods[-1]                            
 ❱  416       mask = _combine_masks(method, t, default_mask)                
    417       return mask                                                   
    418                                                                       
    419                                                                       
                                                                              
 /hdd4/srinath2/.local/lib/python3.10/site-packages/torch/nn/utils/prune.py:4 
 10 in _combine_masks                                                         
                                                                              
    407             )                                                     
    408                                                                    
    409          # compute the new mask on the unpruned slice of the tenso 
 ❱  410          partial_mask = method.compute_mask(t[slc], default_mask=m 
    411          new_mask[slc] = partial_mask.to(dtype=new_mask.dtype)     
    412                                                                    
    413          return new_mask                                           
RuntimeError: nonzero is not supported for tensors with more than INT_MAX 
elements,   file a support request
```

***Note:*** When I am doing it with fp32, I am getting a memory error because the `_mask and _orig` matrices are getting created temporarily and thus the memory requirement needs to be double i.e for ~26GB model, temporarily around ~52GB is getting occupied. (something similar to [https://github.com/ultralytics/yolov5/issues/304#issuecomment-654564855])

### Versions
```
Collecting environment information...
PyTorch version: 2.0.0+cu117
Is debug build: False
CUDA used to build PyTorch: 11.7
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.6 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Clang version: Could not collect
CMake version: version 3.26.3
Libc version: glibc-2.31

Python version: 3.10.9 (main, Jan 11 2023, 15:21:40) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.15.0-71-generic-x86_64-with-glibc2.31
Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: 
GPU 0: NVIDIA RTX A6000
GPU 1: NVIDIA GeForce RTX 3070

Nvidia driver version: 525.105.17
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture:                    x86_64
CPU op-mode(s):                  32-bit, 64-bit
Byte Order:                      Little Endian
Address sizes:                   48 bits physical, 48 bits virtual
CPU(s):                          24
On-line CPU(s) list:             0-23
Thread(s) per core:              2
Core(s) per socket:              12
Socket(s):                       1
NUMA node(s):                    1
Vendor ID:                       AuthenticAMD
CPU family:                      25
Model:                           33
Model name:                      AMD Ryzen 9 5900X 12-Core Processor
Stepping:                        0
Frequency boost:                 enabled
CPU MHz:                         4411.156
CPU max MHz:                     3700.0000
CPU min MHz:                     2200.0000
BogoMIPS:                        7386.15
Virtualization:                  AMD-V
L1d cache:                       384 KiB
L1i cache:                       384 KiB
L2 cache:                        6 MiB
L3 cache:                        64 MiB
NUMA node0 CPU(s):               0-23
Vulnerability Itlb multihit:     Not affected
Vulnerability L1tf:              Not affected
Vulnerability Mds:               Not affected
Vulnerability Meltdown:          Not affected
Vulnerability Mmio stale data:   Not affected
Vulnerability Retbleed:          Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1:        Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:        Mitigation; Retpolines, IBPB conditional, IBRS_FW, STIBP always-on, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Not affected
Flags:                           fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate ssbd mba ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr rdpru wbnoinvd arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif v_spec_ctrl umip pku ospke vaes vpclmulqdq rdpid overflow_recov succor smca fsrm

Versions of relevant libraries:
[pip3] numpy==1.23.5
[pip3] torch==2.0.0
[pip3] triton==2.0.0
[conda] blas                      1.0                         mkl  
[conda] mkl                       2021.4.0           h06a4308_640    anaconda
[conda] mkl-service               2.4.0           py310h7f8727e_0    anaconda
[conda] mkl_fft                   1.3.1           py310hd6ae3a3_0    anaconda
[conda] mkl_random                1.2.2           py310h00e6091_0    anaconda
[conda] numpy                     1.23.5          py310hd5efca6_0    anaconda
[conda] numpy-base                1.23.5          py310h8e6c178_0    anaconda
[conda] pytorch                   2.0.0              py3.10_cpu_0    pytorch
[conda] pytorch-mutex             1.0                         cpu    pytorch
```

**cc:** @ngimel 

cc @jerryzh168 @jianyuh @raghuramank100 @jamesr66a @vkuzo @jgong5 @Xia-Weiwen @leslie-fang-intel @ngimel