From d841c44e55c834650ea5dd1fc70858d90eae5f6a Mon Sep 17 00:00:00 2001 From: EX Engine Date: Mon, 10 Aug 2026 04:45:24 +0000 Subject: [PATCH] =?UTF-8?q?fix(GDN):=20dtype=20guard=20on=20=5Fix=5Fmatmul?= =?UTF-8?q?/=5Fix=5Fbmm=20=E2=80=94=20ixformer.matmul=20requires=20kHalf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause from competition platform log: /opt/apps/ixformer/functions/matmul.cu:149 'Expected input.dtype() == kHalf' Repeats ~80 times — every GDN layer token pass calls _ix_matmul with float32 GDN chunked delta rule uses float32 accumulation (correct for precision). _ix_matmul was calling ixformer.matmul on float32 tensors → stderr spam. The try/except caught it and fell back to torch.matmul, but the stderr output floods the log and may slow down inference. Fix: check a.dtype == torch.float16 before calling ixformer.matmul. Non-half tensors go directly to torch.matmul — zero stderr noise. --- qwen3_6_scripts/qwen3_5.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/qwen3_6_scripts/qwen3_5.py b/qwen3_6_scripts/qwen3_5.py index 213b6678..fa07daea 100644 --- a/qwen3_6_scripts/qwen3_5.py +++ b/qwen3_6_scripts/qwen3_5.py @@ -163,8 +163,8 @@ except ImportError: # --------------------------------------------------------------------------- def _ix_matmul(a: torch.Tensor, b: torch.Tensor) -> torch.Tensor: - """BI-V100 accelerated matmul via ixformer, fallback to torch.""" - if _ix_available: + """BI-V100 accelerated matmul via ixformer. Only for half — ixformer rejects float32.""" + if _ix_available and a.dtype == torch.float16: try: return _ix.matmul(a, b) except Exception: @@ -172,8 +172,8 @@ def _ix_matmul(a: torch.Tensor, b: torch.Tensor) -> torch.Tensor: return torch.matmul(a, b) def _ix_bmm(a: torch.Tensor, b: torch.Tensor) -> torch.Tensor: - """Batched matmul — ixformer.matmul handles batched inputs.""" - if _ix_available: + """Batched matmul — ixformer.matmul handles batched half inputs.""" + if _ix_available and a.dtype == torch.float16: try: return _ix.matmul(a, b) except Exception: @@ -181,8 +181,8 @@ def _ix_bmm(a: torch.Tensor, b: torch.Tensor) -> torch.Tensor: return torch.matmul(a, b) def _ix_softmax(x: torch.Tensor, dim: int = -1) -> torch.Tensor: - """BI-V100 accelerated softmax via ixformer.""" - if _ix_available: + """BI-V100 accelerated softmax via ixformer. Only for half.""" + if _ix_available and x.dtype == torch.float16: try: return _ix.softmax(x, dim=dim) except Exception: