[PR #231] [CLOSED] fix: use float32 on CPU to avoid half-precision convolution error #231

Closed
opened 2026-10-26 21:14:22 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/deepseek-ai/Janus/pull/231
Author: @Mr-Neutr0n
Created: 2/6/2026
Status: ❌ Closed

Base: main ← Head: fix-cpu-half-precision-conv


📝 Commits (1)

  • b530551 fix: use float32 on CPU to avoid half-precision convolution error

📊 Changes

4 files changed (+6 additions, -5 deletions)

View changed files

📝 demo/app.py (+1 -1)
📝 demo/app_janusflow.py (+1 -1)
📝 demo/app_januspro.py (+3 -2)
📝 demo/fastapi_app.py (+1 -1)

📄 Description

Summary

Fixed CPU compatibility issue in demo scripts by using float32 instead of float16 when CUDA is not available.

Problem

When running on macOS or other CPU-only systems, users encounter:

RuntimeError: "slow_conv2d_cpu" not implemented for 'Half'

This happens because PyTorch's CPU backend doesn't support half-precision (fp16) convolutions.

Solution

Changed the dtype fallback from torch.float16 to torch.float32 for CPU in:

  • demo/app_januspro.py (model loading and input preparation)
  • demo/app.py
  • demo/app_janusflow.py
  • demo/fastapi_app.py

Fixes #196


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/deepseek-ai/Janus/pull/231 **Author:** [@Mr-Neutr0n](https://github.com/Mr-Neutr0n) **Created:** 2/6/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix-cpu-half-precision-conv` --- ### 📝 Commits (1) - [`b530551`](https://github.com/deepseek-ai/Janus/commit/b53055181a0b41ea60a9892639eafe26e8e049b9) fix: use float32 on CPU to avoid half-precision convolution error ### 📊 Changes **4 files changed** (+6 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `demo/app.py` (+1 -1) 📝 `demo/app_janusflow.py` (+1 -1) 📝 `demo/app_januspro.py` (+3 -2) 📝 `demo/fastapi_app.py` (+1 -1) </details> ### 📄 Description ## Summary Fixed CPU compatibility issue in demo scripts by using `float32` instead of `float16` when CUDA is not available. ## Problem When running on macOS or other CPU-only systems, users encounter: ``` RuntimeError: "slow_conv2d_cpu" not implemented for 'Half' ``` This happens because PyTorch's CPU backend doesn't support half-precision (fp16) convolutions. ## Solution Changed the dtype fallback from `torch.float16` to `torch.float32` for CPU in: - `demo/app_januspro.py` (model loading and input preparation) - `demo/app.py` - `demo/app_janusflow.py` - `demo/fastapi_app.py` Fixes #196 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-26 21:14:22 +00:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
deepseek-ai/Janus#231
No description provided.