You may want to check out the unit tests to see how the reference implementation is defined there and try to pass those unit tests instead of making your own and being unsure about whats different.

  

      github.com
  

  
    pytorch/pytorch/blob/7ee84ad321207e31a29a93ed4ea1e5890125ecec/test/quantization/core/test_quantized_op.py#L3161



      
      
                  q_mod = torch.nn.quantized.ConvTranspose3d
                  dq_op = torch.ops.quantized.conv_transpose3d_dynamic
                  dim = 5
                  dtype = torch.quint8
          
          
        if qengine_is_qnnpack():
                      return  # TODO: fix MakeDeConvOutputShape overflowing for convT3d with qnnpack
                  self._test_qconv_op_impl(q_mod, dq_op, dim, dtype)
          
          

          
class TestQuantizedLinear(TestCase):
              """Tests the correctness of the quantized linear and linear_relu op."""
              @given(batch_size=st.integers(1, 4),
                     input_channels=st.integers(16, 32),
                     output_channels=st.integers(4, 8),
                     use_bias=st.booleans(),
                     use_relu=st.booleans(),
                     use_multi_dim_input=st.booleans(),
                     use_channelwise=st.booleans())
              @override_qengines
              def test_qlinear(self, batch_size, input_channels, output_channels, use_bias,
      
    
  


  

  
    
    
  

  


and

  

      github.com
  

  
    pytorch/pytorch/blob/7ee84ad321207e31a29a93ed4ea1e5890125ecec/test/test_nnapi.py#L644



      
      
                              qpt([[1.0, 2.0]], 0.25, 128),
                              qpt([[3.0, 4.0]], 0.25, 128),
                          ],
                          convert_args=[
                              qpt(torch.zeros((1, 2)), 0.25, 128),
                              qpt(torch.zeros((1, 2)), 0.25, 128),
                          ]
                      )
                      # NOTE: NNAPI qadd supports broadcast, but PT does not.
          
          
def test_qlinear(self):
              torch.manual_seed(29)
              weight = qpt(torch.randn(16, 32), 0.125, 0, torch.qint8)
              bias = torch.randn(16)
              mod = torch.nn.quantized.Linear(32, 16)
              mod.set_weight_bias(weight, bias)
              inp = qpt(torch.randn(2, 32), 0.05, 130, torch.quint8)
              self.check(mod, inp)
          
          
def test_seblock_mul(self):
              class MulModel(torch.nn.Module):
      
    
  


  

  
    
    
  

  


although i’d rather not dig through the actual linear implementation’s c++ code, I believe its something along the lines of Lei Mao's Log Book – Quantization for Neural Networks