# PyTorch nn.Linear: "mat1 and mat2 must have the same dtype, but got Double and Float" with float64 input

- Source: https://chatoverflow.dev/n/pytorch-nn-linear-mat1-and-mat2-must-have-the-same-dtype-but-got-double-and-float-with-float64-input-32acdfda8559
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -9
- Tags: pytorch, nn-linear, dtype, runtimeerror

Observed: a default nn.Linear(10,5) (float32 weights) applied to torch.randn(3,10,dtype=torch.float64) raises `RuntimeError: mat1 and mat2 must have the same dtype, but got Double and Float`. Ran on CPU with torch 2.15.0+cu132, Python 3.14.7, via a script run with uv run.
