Skip to content
KernelIndex
Search⌘K

submission 385935

VladRad · python · License unknown

Use it

Vendorable · source mirrored · license unknownView source →

No package. Vendor the mirrored source: 50 lines, June 9 Researcher Reciprocity License v1.0.

submission.py
curl "https://kernelindex.com/api/v1/implementations/kernelbot-nvfp4-group-gemm-385935?include=source"
interfacepython
Compatibility
measured onNVIDIA B200
declared hardwareNVIDIA B200
architecturessm_100
dtypesfp8_e4m3, nvfp4

Benchmark evidence

1 measurement across 1 GPU, fastest first.

Operation / workload
Hardware
Latency
Rank
Observed
NVFP4 group GEMMsuite of 4 cases
NVIDIA B200
97.0µs
#230 of 310
2026-01-20

Reported · How evidence levels are derived →

Source and license

sourceavailable
revision digestsha256:9e635b6336905fd1aaf904619b2ff12bd457f7aee45a5f434c5f25a095d90ec6
license declaredunknown
license concludedunknown
authorsVladRad
imported2026-08-15

Kernel source

submission.py50 lines
import torch                                                                                                       
from typing import Tuple, List                                                                                     
                                                                                                                    
def custom_kernel(data):                                                                                           
    abc_tensors, sfasfb_tensors, sfasfb_reordered_tensors, problem_sizes = data                                    
                                                                                                                    
    # Extract tensors                                                                                              
    abc_list = []                                                                                                  
    for a, b, c in abc_tensors:                                                                                    
        abc_list.append((a, b, c))                                                                                 
                                                                                                                    
    sfasfb_list = []                                                                                               
    for sfa, sfb in sfasfb_tensors:                                                                                
        sfasfb_list.append((sfa, sfb))                                                                             
                                                                                                                    
    sfasfb_reordered_list = []                                                                                     
    for sfa_r, sfb_r in sfasfb_reordered_tensors:                                                                  
        sfasfb_reordered_list.append((sfa_r, sfb_r))                                                               
                                                                                                                    
    # Process each group                                                                                           
    outputs = []                                                                                                   
    for i in range(len(abc_tensors)):                                                                              
        a, b, c = abc_list[i]                                                                                      
        sfa, sfb = sfasfb_list[i]                                                                                  
        sfa_r, sfb_r = sfasfb_reordered_list[i]                                                                    
                                                                                                                    
        # Use pre-reordered scale factors                                                                          
        sfa_block = sfa_r                                                                                          
        sfb_block = sfb_r                                                                                          
                                                                                                                    
        # Torch's _scaled_mm uses to_blocked() format                                                              
        if hasattr(torch, '_scaled_mm'):                                                                           
            try:                                                                                                   
                # Use torch._scaled_mm with pre-blocked scale factors                                              
                result = torch._scaled_mm(                                                                         
                    a, b, sfa_block, sfb_block, out=c, bias=None, scale=sfa_block,                                 
                    sfa_dtype=torch.float8_e4m3fnuz, sfb_dtype=torch.float8_e4m3fnuz                               
                )                                                                                                  
                outputs.append(result)                                                                             
            except Exception as e:                                                                                 
                print(f"torch._scaled_mm failed: {e}")                                                             
                # Fall back to Triton kernel                                                                       
                # ... implement Triton kernel ...                                                                  
                pass                                                                                               
        else:                                                                                                      
            # Fallback to standard matmul                                                                          
            result = torch.matmul(a, b, out=c)                                                                     
            outputs.append(result)                                                                                 
                                                                                                                    
    return outputs
scrolls · 50 lines total

Source code from GPU Mode and the KernelBot dataset · June 9 Researcher Reciprocity License v1.0

Best evidence level for this revision: reported

JSON