mirror of
https://github.com/deepseek-ai/Janus.git
synced 2026-11-05 00:57:18 +00:00
[PR #233] [CLOSED] fix: preserve original dtype in Upsample instead of hardcoding bfloat16 #232
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
deepseek-ai/Janus#232
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/deepseek-ai/Janus/pull/233
Author: @Mr-Neutr0n
Created: 2/11/2026
Status: ❌ Closed
Base:
main← Head:fix/upsample-preserve-dtype📝 Commits (1)
0e8fa03fix: preserve original dtype in Upsample instead of hardcoding bfloat16📊 Changes
1 file changed (+2 additions, -1 deletions)
View changed files
📝
janus/models/vq_model.py(+2 -1)📄 Description
Summary
The
Upsample.forwardmethod injanus/models/vq_model.pyhardcodes a cast totorch.bfloat16after interpolation when the input is not float32:This causes a problem when the input tensor is
float16(common on GPUs without native bfloat16 support, e.g. older NVIDIA architectures). The tensor is silently converted fromfloat16tobfloat16after interpolation, leading to dtype mismatches with downstream convolution layers that still expectfloat16weights.Fix
Store the original dtype before casting to float32 for interpolation, then cast back to it afterward:
This preserves whatever dtype the input originally had (float16, bfloat16, etc.) instead of always forcing bfloat16.
Test plan
float16input dtype through the upsample operationbfloat16inputs continue to work as before (orig_dtype would be bfloat16, matching the previous behavior)float32inputs (the else branch is unchanged)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.