RuntimeError: expected mat1 and mat2 to have the same dtype, but got: c10::BFloat16 != c10::Half
@liusong1222 is already working on this.
Since Nov 21, 2025.
- Dominant language
- Python
- Stars
- 1.7k
- Forks
- 181
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 2
Description
您好,我使用offline的脚本训练时没遇到了这个问题,排查了一下是targehead的权重没有和输入的类型一致造成的,这个问题是已知的吗
[rank2]: Traceback (most recent call last):
[rank2]: File "/home//code/github/AngelSlim/tools/train_eagle3_offline.py", line 393, in
[rank2]: train()
[rank2]: File "/home//code/github/AngelSlim/tools/train_eagle3_offline.py", line 388, in train
[rank2]: trainer.train()
[rank2]: File "/opt/miniconda/envs/eagle/lib/python3.10/site-packages/transformers/trainer.py", line 2325, in train
[rank2]: return inner_training_loop(
[rank2]: File "/opt/miniconda/envs/eagle/lib/python3.10/site-packages/transformers/trainer.py", line 2674, in _inner_training_loop
[rank2]: tr_loss_step = self.training_step(model, inputs, num_items_in_batch)
[rank2]: File "/opt/miniconda/envs/eagle/lib/python3.10/site-packages/transformers/trainer.py", line 4020, in training_step
[rank2]: loss = self.compute_loss(model, inputs, num_items_in_batch=num_items_in_batch)
[rank2]: File "/home//code/github/AngelSlim/angelslim/compressor/speculative/train/trainer/eagle3_trainer.py", line 73, in compute_loss
[rank2]: data_for_draft_model = self.prepare_data_for_draft_model(inputs)
[rank2]: File "/home//code/github/AngelSlim/angelslim/compressor/speculative/train/trainer/eagle3_trainer.py", line 419, in prepare_data_for_draft_model
[rank2]: target_logits = self.target_head(inputs["target_hiddens"])
[rank2]: File "/opt/miniconda/envs/eagle/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1775, in _wrapped_call_impl
[rank2]: return self._call_impl(*args, **kwargs)
[rank2]: File "/opt/miniconda/envs/eagle/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1786, in _call_impl
[rank2]: return forward_call(*args, **kwargs)
[rank2]: File "/home//code/github/AngelSlim/angelslim/compressor/speculative/train/models/target/target_head.py", line 64, in forward
[rank2]: logits = self.lm_head(hidden_states)
[rank2]: File "/opt/miniconda/envs/eagle/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1775, in _wrapped_call_impl
[rank2]: return self._call_impl(*args, **kwargs)
[rank2]: File "/opt/miniconda/envs/eagle/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1786, in _call_impl
[rank2]: return forward_call(*args, **kwargs)
[rank2]: File "/opt/miniconda/envs/eagle/lib/python3.10/site-packages/torch/nn/modules/linear.py", line 134, in forward
[rank2]: return F.linear(input, self.weight, self.bias)
[rank2]: RuntimeError: expected mat1 and mat2 to have the same dtype, but got: c10::BFloat16 != c10::Half
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.