1111import nvdlfw_inspect .api as debug_api
1212
1313
14- from nvdlfw_inspect .debug_features .log_tensor_stats import LogTensorStats as BaseLogTensorStats
14+ from nvdlfw_inspect .debug_features .log_tensor_stats import (
15+ LogTensorStats as BaseLogTensorStats ,
16+ )
1517from nvdlfw_inspect .registry import Registry , api_method
1618
1719from transformer_engine .debug .features .utils .stats_buffer import STATS_BUFFERS
2123 Float8CurrentScalingQuantizer ,
2224)
2325from transformer_engine .pytorch .tensor .mxfp8_tensor import MXFP8Quantizer
24- from transformer_engine .pytorch .tensor .float8_blockwise_tensor import Float8BlockQuantizer
25- from transformer_engine .debug .features .utils import get_reduction_params , next_enabled_iter
26+ from transformer_engine .pytorch .tensor .float8_blockwise_tensor import (
27+ Float8BlockQuantizer ,
28+ )
29+ from transformer_engine .debug .features .utils import (
30+ get_reduction_params ,
31+ next_enabled_iter ,
32+ )
2633
2734
28- ALL_RECIPE_NAMES = ["fp8_delayed_scaling" , "fp8_current_scaling" , "mxfp8" , "fp8_block_scaling" ]
35+ ALL_RECIPE_NAMES = [
36+ "fp8_delayed_scaling" ,
37+ "fp8_current_scaling" ,
38+ "mxfp8" ,
39+ "fp8_block_scaling" ,
40+ ]
2941
3042
3143def _get_recipe_name (quantizer : Optional [Quantizer ]):
@@ -47,7 +59,10 @@ def _get_new_quantizer(recipe_name, fp8_dtype):
4759 return Float8BlockQuantizer (fp8_dtype = fp8_dtype , rowwise = True , columnwise = True )
4860 if recipe_name == "fp8_current_scaling" :
4961 return Float8CurrentScalingQuantizer (
50- fp8_dtype = fp8_dtype , device = torch .device ("cuda" ), rowwise = True , columnwise = True
62+ fp8_dtype = fp8_dtype ,
63+ device = torch .device ("cuda" ),
64+ rowwise = True ,
65+ columnwise = True ,
5166 )
5267 if recipe_name == "mxfp8" :
5368 return MXFP8Quantizer (fp8_dtype = fp8_dtype , rowwise = True , columnwise = True )
@@ -214,9 +229,14 @@ def update_aux_dict(
214229 Needs to clean after usage, because it possibly change the usage of the quantized tensor.
215230 """
216231 fp8_dtype = None
217- if recipe_name in ["fp8_delayed_scaling" , "fp8_current_scaling" , "fp8_block_scaling" ]:
232+ if recipe_name in [
233+ "fp8_delayed_scaling" ,
234+ "fp8_current_scaling" ,
235+ "fp8_block_scaling" ,
236+ ]:
218237 assert isinstance (
219- quantizer , (Float8Quantizer , Float8CurrentScalingQuantizer , Float8BlockQuantizer )
238+ quantizer ,
239+ (Float8Quantizer , Float8CurrentScalingQuantizer , Float8BlockQuantizer ),
220240 )
221241 fp8_dtype = quantizer .dtype
222242
@@ -242,7 +262,8 @@ def update_aux_dict(
242262 finally :
243263 if isinstance (quantized_tensor , QuantizedTensor ):
244264 quantized_tensor .update_usage (
245- rowwise_usage = old_rowwise_usage , columnwise_usage = old_columnwise_usage
265+ rowwise_usage = old_rowwise_usage ,
266+ columnwise_usage = old_columnwise_usage ,
246267 )
247268
248269 @api_method
0 commit comments