[Bug] ClusterBackend passes torch.Tensor to UMAP 0.6.0, causing a torch.float32 dtype TypeError
メンテナーはふだん 1 日以内に返信
@hansazilinon-art がすでに取り組んでいます。
2026年11月16日 から。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 84/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
調査の方向性
funasr/models/campplus/cluster_backend.py、特に ClusterBackend.forward と197行目付近のUMAP呼び出しを読みます。報告では、dtypeエラーを引き起こすテンソル入力が特定されています。提供された2,048×192の合成埋め込みで再現し、テンソル入力によってクラスタリングが完了し、埋め込みごとに1つの整数ラベルが返されることを確認します。issueによると、既存のpull requestも担当者もありません。
索引モデルが issue の本文から書いたものです。
説明
Summary
Thank you for maintaining FunASR. I can reproduce a CPU speaker-clustering failure with synthetic embeddings, without audio or model weights. With at least 2,048 embeddings and no oracle_num, ClusterBackend passes a PyTorch tensor to UMAP. In UMAP 0.6.0, fit_transform inspects the original input dtype and calls np.issubdtype(torch.float32, np.floating), which raises a TypeError.
The regular pipeline also passes a tensor here: auto_model.py in v1.4.26 calls the backend with spk_embedding.cpu().
In practice this showed up on a 4-hour, multi-speaker recording: recognition finished, then diarization crashed at the very last step (short clips stay below 2,048 embeddings and never take the UMAP path).
Environment
| Component | Version |
|---|---|
| OS / architecture | macOS 26.5 / arm64, CPU execution |
| Python | 3.11.15 |
| FunASR source under test | Official v1.4.26 cluster_backend.py |
| PyTorch | 2.15.0 |
| NumPy | 2.4.6 |
| SciPy | 1.17.1 |
| scikit-learn | 1.9.1 |
| umap-learn | 0.6.0 |
| numba | 0.68.1 |
| pynndescent | 0.7.0 |
| llvmlite | 0.50.0 |
I reproduced the failure using a temporary copy of the official tagged source (SHA-256 5bdea46a947e78be3c8501ab3ac4392a6d1107c8c9d727902c986264277c9140), not a locally modified file.
Steps to reproduce
No model download is needed. Save as repro.py and run python -B repro.py; it downloads only the small official source file into a temporary directory.
import os
import sys
import tempfile
from pathlib import Path
sys.dont_write_bytecode = True
with tempfile.TemporaryDirectory(prefix="funasr-repro-") as tmp:
for key in ("NUMBA_CACHE_DIR", "MPLCONFIGDIR", "XDG_CACHE_HOME"):
os.environ[key] = str(Path(tmp) / key)
for key in ("NUMBA_NUM_THREADS", "OMP_NUM_THREADS", "OPENBLAS_NUM_THREADS"):
os.environ[key] = "1"
import importlib.util
import urllib.request
import numpy as np
import torch
torch.set_num_threads(1)
url = ("https://raw.githubusercontent.com/modelscope/FunASR/"
"v1.4.26/funasr/models/campplus/cluster_backend.py")
path = Path(tmp) / "cluster_backend.py"
path.write_bytes(urllib.request.urlopen(url, timeout=30).read())
spec = importlib.util.spec_from_file_location("cluster_backend_repro", path)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
rng = np.random.default_rng(0)
x = np.repeat(np.eye(4, 192, dtype=np.float32), 512, axis=0)
x += rng.normal(0, 0.01, x.shape).astype(np.float32)
labels = module.ClusterBackend()(torch.from_numpy(x))
print(labels.shape, np.unique(labels))
Expected behavior
CPU float32 speaker embeddings should complete clustering and return one integer label per embedding (this synthetic input has four well-separated groups).
Actual behavior
TypeError: Cannot interpret 'torch.float32' as a data type, raised from cluster_backend.py:197 (reached from forward at line 266) inside UMAP umap_.py:4163.
File "$TMP/upstream_cluster_backend.py", line 266, in forward
labels = self.umap_hdbscan_cluster(X)
File "$TMP/upstream_cluster_backend.py", line 197, in __call__
).fit_transform(X)
File "$VENV/lib/python3.11/site-packages/umap/umap_.py", line 4163, in fit_transform
if _input_dtype is not None and np.issubdtype(_input_dtype, np.floating):
File "$VENV/lib/python3.11/site-packages/numpy/_core/numerictypes.py", line 534, in issubdtype
arg1 = dtype(arg1).type
TypeError: Cannot interpret 'torch.float32' as a data type
Suggested one-line fix
Normalize the input once at the start of ClusterBackend.forward, so both UMAP and the later centroid operations receive a NumPy array:
--- a/funasr/models/campplus/cluster_backend.py
+++ b/funasr/models/campplus/cluster_backend.py
@@ -257,1 +257,2 @@
+ X = X.detach().cpu().numpy() if isinstance(X, torch.Tensor) else np.asarray(X)
k = params["oracle_num"] if "oracle_num" in params else None
Tested on a separate temporary copy of the tagged file with the same 2,048 × 192 synthetic embeddings and the real UMAP/HDBSCAN implementation: tensor input and ndarray input both return shape (2048,) with labels [0, 1, 2, 3]. This validates completion on this synthetic CPU case only, not diarization accuracy; GPU/bfloat16 inputs and other dependency versions were not tested. I have not isolated a NumPy version regression, so I'd describe it as an input-dtype interoperability issue.
Duplicate search
Searched open and closed issues on 2026-11-16 for issubdtype, Cannot interpret, torch.float32, and UMAP; no exact match. Related but different: #1372 (pynndescent correct_alternative_cosine), #1302 (CUDA tensor-to-NumPy), #3514 (spectral clustering performance), PR #3674 (NumPy 2.x alias cleanup; the tagged backend still passes tensors to UMAP). The same missing conversion is present on main at c1e3018. Happy to have this tracked under an existing report or handled at the UMAP boundary instead.
- 主要言語
- Python
- スター
- 21.2k
- フォーク
- 2.2k
- 平均マージ
- 5時間 38分
- マージ済み PR(30日)
- 116
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
modelscope/FunASR のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
modelscope/FunASR#3801 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
modelscope/FunASR#3796 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
modelscope/FunASR#3762 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Bug: blank lines in wav.scp / jsonl file lists crash prepare_data_iterator (IndexError / JSONDecodeError)対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンneeds feedback
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
modelscope/FunASR#3757 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
modelscope/FunASR#3704 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
modelscope/FunASR の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
AIR-Bench Foundation reads the first letter of the word after "answer" as the model's choice対応中かも @beartester34 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
modelscope/evalscope#2330 ·
メンテナーはふだん 1 日以内に返信
-
Distribution plot crashes when a numeric feature is constant in the train or test set対応中かも @adembilge が今日担当しました。 オープンbug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 10 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 2 日以内に返信
-
namespace team:operations
難易度 2/5 1〜3時間 初心者へのやさしさ 60/100
EclipseFdn/open-vsx.org#16738 ·
メンテナーはふだん 1 日以内に返信