()
| 18 | reason="smoothquant linear not installed properly", |
| 19 | ) |
| 20 | def test_linear(): |
| 21 | a = torch.randint(-127, 127, (128, 512), dtype=torch.int8, device="cuda") |
| 22 | b = torch.randint(-127, 127, (512, 256), dtype=torch.int8, device="cuda") |
| 23 | c = torch.rand(256, dtype=torch.float, device="cuda") |
| 24 | |
| 25 | alpha = 1 / 127 |
| 26 | beta = 1.0 |
| 27 | torch_out = torch.mm(a.to(torch.float) * alpha, b.to(torch.float)) + c |
| 28 | |
| 29 | silu = torch.nn.SiLU() |
| 30 | torch_out = silu(torch_out) |
| 31 | |
| 32 | b = b.transpose(0, 1).contiguous() |
| 33 | cuda_out = smoothquant_cuda.linear_silu_a8_w8_bfp32_ofp32(a, b, c, alpha, beta) |
| 34 | |
| 35 | assert torch.allclose(torch_out, cuda_out, rtol=1e-02, atol=1e-02) |
| 36 | |
| 37 | |
| 38 | if __name__ == "__main__": |
no test coverage detected
searching dependent graphs…