(x, hidden_size, dtype, tensor_parallel_size,
tensor_parallel_rank, weights)
| 110 | |
| 111 | @torch.inference_mode |
| 112 | def column_linear_forward(x, hidden_size, dtype, tensor_parallel_size, |
| 113 | tensor_parallel_rank, weights): |
| 114 | |
| 115 | x = x.cuda() |
| 116 | l0 = Linear( |
| 117 | in_features=hidden_size, |
| 118 | out_features=hidden_size, |
| 119 | bias=False, |
| 120 | dtype=dtype, |
| 121 | mapping=Mapping( |
| 122 | world_size=tensor_parallel_size, |
| 123 | tp_size=tensor_parallel_size, |
| 124 | rank=tensor_parallel_rank, |
| 125 | ), |
| 126 | tensor_parallel_mode=TensorParallelMode.COLUMN, |
| 127 | gather_output=True, |
| 128 | ) |
| 129 | l0.load_weights([dict(weight=weights[0])]) |
| 130 | l0.cuda() |
| 131 | |
| 132 | l0 = torch.compile(l0, fullgraph=True) |
| 133 | output = l0.forward(x) |
| 134 | |
| 135 | # torch run |
| 136 | l0 = nn.Linear(in_features=hidden_size, |
| 137 | out_features=hidden_size, |
| 138 | bias=False, |
| 139 | dtype=dtype) |
| 140 | l0.weight.data.copy_(weights[0]) |
| 141 | l0.cuda() |
| 142 | |
| 143 | torch_output = l0.forward(x) |
| 144 | |
| 145 | # compare |
| 146 | torch.cuda.synchronize() |
| 147 | torch.testing.assert_close(output, torch_output) |
| 148 | |
| 149 | |
| 150 | @torch.inference_mode |
nothing calls this directly
no test coverage detected