• Members 1 post
    2026年8月15日 14:46

    日期:2026-08-15
    硬件:MetaX C500(XCORE1000,64 GB HBM)
    系统:Ubuntu 22.04
    Python:3.10.10
    MACA:3.8.1.3
    Driver userspace:3.8.1.6
    Kernel driver:3.8.30
    torch:2.10.0+metax3.8.1.0
    triton:3.6.0+metax3.8.1.0

    问题一:cat 处理一维空张量失败

    Qwen3 首次建立 KV Cache 时,需要将一维空张量与四维 KV 张量沿 dim=-2 拼接。该操作在 MetaX Torch 2.10 的 CUDA 路径中会抛出 IndexError,在 CPU 和 MetaX Torch 2.8 中均可正常执行。

    最小复现代码:

    import torch
    
    a = torch.tensor([], device="cuda:0")
    b = torch.randn(1, 32, 1, 128, device="cuda:0")
    out = torch.cat([a, b], dim=-2)
    

    错误信息:
    IndexError: Dimension out of range
    (expected to be in range of [-1, 0], but got 2)

    关键调用位置:
    c10::detail::maybe_wrap_dim_slow(...)
    at::native::structured_cat_out_cuda::impl(...) # Shape.cu

    对照结果:
    使用 torch.tensor([]) 创建一维空张量时,拼接失败并抛出 IndexError。
    将空张量改为 torch.empty(1, 32, 0, 128) 后,拼接正常。
    保持一维空张量不变,并将 b 的最后一维由 128 改为 100,仍然抛出相同错误。
    相同用例在 CPU 和 MetaX Torch 2.8 中均执行正常。

    触发条件:
    一维空张量与高维张量沿非末维进行拼接。

    原因分析:
    dim=-2 按四维输入归一化后为 2。厂商实现随后使用一维空张量自身的 ndim=1 校验该维度,等价于调用 maybe_wrap_dim(2, 1),因此发生维度越界。由于相同用例在 CPU 和 MetaX Torch 2.8 中均正常,可以判断该问题是 MetaX Torch 2.10 引入的回归。

    问题二:copy_ 不支持宽位无符号目标类型

    问题描述:
    在 MetaX CUDA 设备上,将张量转换为 uint16、uint32 或 uint64 时会抛出 NotImplementedError;相同转换在 CPU 上可以正常执行。该问题在 MetaX Torch 2.8 和 MetaX Torch 2.10 中均可复现。

    最小复现代码:

    import torch
    
    x = torch.tensor([1, 2, 3], dtype=torch.int64, device="cuda:0")
    y = x.to(torch.uint32)
    

    错误信息:
    NotImplementedError: "copy_" not implemented for 'UInt32'

    关键调用位置:
    at::native::direct_copy_kernel_cuda(...) # Copy.cu:230
    at::native::copy_device_to_device(...)
    at::native::_to_copy(...)

    测试结果:
    源类型为 int64,目标类型为 bool、uint8、int8、int16、int32、int64、bfloat16、float16、float32 或 float64 时,MetaX CUDA 和 CPU 均正常。
    源类型为 int64,目标类型为 uint16、uint32 或 uint64 时,MetaX CUDA 执行失败,CPU 执行正常。

    原因分析:
    direct_copy_kernel_cuda 的类型分派未覆盖 UInt16、UInt32 和 UInt64 目标类型,因此进入未实现分支。

  • arrow_forward

    Thread has been moved from 产品&运维.

  • Members 794 posts
    2026年8月17日 10:15

    尊敬的开发者您好,感谢您的反馈,已反馈至内部,定位具体问题。

  • arrow_forward

    Thread has been moved from 解决中.