File tree Expand file tree Collapse file tree
transformer_engine/plugin/core/backends/vendor Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -192,6 +192,16 @@ def bgrad_quantize(
192192 quantizer : Any ,
193193 ) -> List [Any ]:
194194 tex = self ._get_tex ()
195+
196+ # Normalize quantizer.dtype to this backend's `tex.DType`.
197+ try :
198+ if quantizer is not None and hasattr (quantizer , "dtype" ) and hasattr (tex , "DType" ):
199+ qdtype = quantizer .dtype
200+ if qdtype is not None :
201+ quantizer .dtype = tex .DType (int (qdtype ))
202+ except Exception :
203+ pass
204+
195205 return tex .bgrad_quantize (input , quantizer )
196206
197207 def generic_gemm (
Original file line number Diff line number Diff line change @@ -169,6 +169,16 @@ def bgrad_quantize(
169169 quantizer : Any ,
170170 ) -> List [Any ]:
171171 tex = self ._get_tex ()
172+
173+ # Normalize quantizer.dtype to this backend's `tex.DType`.
174+ try :
175+ if quantizer is not None and hasattr (quantizer , "dtype" ) and hasattr (tex , "DType" ):
176+ qdtype = quantizer .dtype
177+ if qdtype is not None :
178+ quantizer .dtype = tex .DType (int (qdtype ))
179+ except Exception :
180+ pass
181+
172182 return tex .bgrad_quantize (input , quantizer )
173183
174184 def generic_gemm (
Original file line number Diff line number Diff line change @@ -195,6 +195,16 @@ def bgrad_quantize(
195195 quantizer : Any ,
196196 ) -> List [Any ]:
197197 tex = self ._get_tex ()
198+
199+ # Normalize quantizer.dtype to this backend's `tex.DType`.
200+ try :
201+ if quantizer is not None and hasattr (quantizer , "dtype" ) and hasattr (tex , "DType" ):
202+ qdtype = quantizer .dtype
203+ if qdtype is not None :
204+ quantizer .dtype = tex .DType (int (qdtype ))
205+ except Exception :
206+ pass
207+
198208 return tex .bgrad_quantize (input , quantizer )
199209
200210 def generic_gemm (
Original file line number Diff line number Diff line change @@ -150,6 +150,16 @@ def bgrad_quantize(
150150 quantizer : Any ,
151151 ) -> List [Any ]:
152152 tex = self ._get_tex ()
153+
154+ # Normalize quantizer.dtype to this backend's `tex.DType`.
155+ try :
156+ if quantizer is not None and hasattr (quantizer , "dtype" ) and hasattr (tex , "DType" ):
157+ qdtype = quantizer .dtype
158+ if qdtype is not None :
159+ quantizer .dtype = tex .DType (int (qdtype ))
160+ except Exception :
161+ pass
162+
153163 return tex .bgrad_quantize (input , quantizer )
154164
155165 def generic_gemm (
Original file line number Diff line number Diff line change @@ -162,6 +162,16 @@ def bgrad_quantize(
162162 quantizer : Any ,
163163 ) -> List [Any ]:
164164 tex = self ._get_tex ()
165+
166+ # Normalize quantizer.dtype to this backend's `tex.DType`.
167+ try :
168+ if quantizer is not None and hasattr (quantizer , "dtype" ) and hasattr (tex , "DType" ):
169+ qdtype = quantizer .dtype
170+ if qdtype is not None :
171+ quantizer .dtype = tex .DType (int (qdtype ))
172+ except Exception :
173+ pass
174+
165175 return tex .bgrad_quantize (input , quantizer )
166176
167177 def generic_gemm (
You can’t perform that action at this time.
0 commit comments