@@ -124,11 +124,6 @@ def _fp8_scaled_mm(
124124except ImportError :
125125 marlin_cuda_quant = None
126126
127- try :
128- import sycl_kernels
129- except ImportError :
130- sycl_kernels = None
131-
132127
133128class MMWeightTemplate (metaclass = ABCMeta ):
134129 def __init__ (
@@ -2634,64 +2629,3 @@ def apply(self, input_tensor):
26342629def unwrap_tp_weight (module ):
26352630 """Return the concrete tensor-owning MM implementation from a TP wrapper."""
26362631 return module ._mm if isinstance (module , MMWeightTP ) else module
2637-
2638-
2639- @MM_WEIGHT_REGISTER ("fp8-intel-xpu" )
2640- class MMWeightFp8IntelXpu (MMWeightQuantTemplate ):
2641- """
2642- Name: W-fp8-channel-sym-A-fp16-Intel-XPU
2643-
2644- Intel XPU optimized FP8 kernel:
2645- Weight Storage: fp8 (torch.float8_e4m3fn) - saves 50% memory
2646- Computation: fp16 using PyTorch native ops
2647- - Dynamically dequantize FP8 → FP16 during forward
2648- - Use torch.nn.functional.linear (compatible with Intel XPU)
2649-
2650- Benefits:
2651- - Memory efficient: FP8 storage (8-bit)
2652- - Compatible: FP16 compute using PyTorch native ops
2653- - Intel XPU friendly: No CUDA-specific kernels
2654-
2655- Usage in config:
2656- {
2657- "dit_quant_scheme": "fp8-intel-xpu",
2658- "weight_auto_quant": true,
2659- "dit_quantized": true
2660- }
2661- """
2662-
2663- def __init__ (self , weight_name , bias_name , create_cuda_buffer = False , create_cpu_buffer = False , lazy_load = False , lazy_load_file = None , is_post_adapter = False , lora_prefix = None , lora_path = "" ):
2664- super ().__init__ (weight_name , bias_name , create_cuda_buffer , create_cpu_buffer , lazy_load , lazy_load_file , is_post_adapter , lora_prefix , lora_path )
2665-
2666- self .load_func = self .load_fp8_perchannel_sym
2667- self .weight_need_transpose = False # We'll handle transpose in apply
2668-
2669- def apply (self , input_tensor ):
2670- # # """
2671- # Forward pass with FP8 → FP16 dequantization
2672-
2673- # Steps:
2674- # 1. Dequantize weight: fp8 → fp16 (weight * scale)
2675- # 2. Compute: torch.nn.functional.linear(input_fp16, weight_fp16, bias)
2676- # """
2677- # # Ensure input is FP16
2678- # # print(input_tensor.dtype)
2679-
2680- if sycl_kernels is not None :
2681- try :
2682- return sycl_kernels .onednn_w8a16_fp8 (input_tensor , self .weight , self .weight_scale .to (torch .float ))
2683- except RuntimeError :
2684- pass # Fall through to torch dequantization path
2685-
2686- infer_dtype = self .infer_dtype
2687- squeeze_output = False
2688- if input_tensor .dim () == 3 and input_tensor .shape [0 ] == 1 :
2689- input_tensor = input_tensor .squeeze (0 )
2690- squeeze_output = True
2691- input_tensor = input_tensor .to (infer_dtype )
2692- weight_fp16 = self .weight .to (infer_dtype ) * self .weight_scale .to (infer_dtype )
2693- bias_fp16 = self .bias .to (infer_dtype ) if hasattr (self , "bias" ) and self .bias is not None else None
2694- output = torch .nn .functional .linear (input_tensor , weight_fp16 , bias_fp16 )
2695- if squeeze_output :
2696- output = output .unsqueeze (0 )
2697- return output
0 commit comments