batched matmul pre-expands all “batch” dimensions to same sizes, so w tensor is replicated 1000 times.
There are two scenarios:

the operation is expressible with 3d tensors and torch.bmm (backend of matmul)
you’re out of luck, and processing by parts may be required

stub dimension in b suggests case 1, but these dimensions are confusing… 77x1000x150 @ 77x150x150 would perhaps do it