同步操作将从 Ascend/MindSpeed 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
from mindspeed.ops.lcal_functional import coc_ops
coc_ops.matmul_all_reduce(input1, input2, output, bias)
该接口对输入的左右矩阵进行Matmul操作,并对其结果进行All-Reduce通信,最后加上bias(如果bias不为None)。将最终结果赋值到output内存区域中。
假设Matmul操作对应的shape为[m, k]和[k, n]:
接口输入:
接口输出:
import torch
import torch_npu
from mindspeed.ops.lcal_functional import coc_ops
m, k, n = 2048, 4096, 8192
dtype = torch.float16
input1 = torch.rand(m, k, dtype, device=torch.npu.current_device())
input2 = torch.rand(k, n, dtype, device=torch.npu.current_device())
bias = torch.rand(1, n, dtype, device=torch.npu.current_device())
output = torch.zeros(m, n, dtype)
coc_ops.matmul_all_reduce(input1, input2, output, bias)
from mindspeed.ops.lcal_functional import coc_ops
coc_ops.all_gather_matmul(input1, input2, output, bias)
该接口对输入的左矩阵进行All-Gather操作,然后将其与右矩阵做Matmul操作,最后加上bias(如果bias不为None)。将最终结果赋值到output内存区域中。
假设Matmul操作对应的shape为[m, k]和[k, n](m必须为world_size的倍数):
接口输入:
接口输出:
import torch
import torch_npu
from mindspeed.ops.lcal_functional import coc_ops
m, k, n = 2048, 4096, 8192
world_size = 8
dtype = torch.float16
input1 = torch.rand(m // world_size, k, dtype, device=torch.npu.current_device())
input2 = torch.rand(k, n, dtype, device=torch.npu.current_device())
bias = torch.rand(1, n, dtype, device=torch.npu.current_device())
output = torch.zeros(m, n, dtype, device=torch.npu.current_device())
coc_ops.all_gather_matmul(input1, input2, output, bias)
from mindspeed.ops.lcal_functional import coc_ops
coc_ops.all_gather_matmul_v2(input1, input2, output, comm_output, bias)
该接口对输入的左矩阵进行All-Gather操作,然后将其与右矩阵做Matmul操作,最后加上bias(如果bias不为None)。将最终结果赋值到output内存区域中,并将左矩阵进行All-Gather操作后得到的结果赋值到comm_output内存区域中。
假设Matmul操作对应的shape为[m, k]和[k, n](m必须为world_size的倍数):
接口输入:
接口输出:
import torch
import torch_npu
from mindspeed.ops.lcal_functional import coc_ops
m, k, n = 2048, 4096, 8192
world_size = 8
dtype = torch.float16
input1 = torch.rand(m // world_size, k, dtype, device=torch.npu.current_device())
input2 = torch.rand(k, n, dtype, device=torch.npu.current_device())
bias = torch.rand(1, n, dtype, device=torch.npu.current_device())
output = torch.zeros(m, n, dtype, device=torch.npu.current_device())
comm_output = torch.zeros(m, k, dtype, device=torch.npu.current_device())
coc_ops.all_gather_matmul_v2(input1, input2, output, comm_output, bias)
from mindspeed.ops.lcal_functional import coc_ops
coc_ops.matmul_reduce_scatter(input1, input2, output, bias)
该接口对输入的左右矩阵进行Matmul操作,并对其结果进行Reduce-Scatter通信,最后加上bias(如果bias不为None)。将最终结果赋值到output内存区域中。
假设Matmul操作对应的shape为[m, k]和[k, n](m必须为world_size的倍数):
接口输入:
接口输出:
import torch
import torch_npu
from mindspeed.ops.lcal_functional import coc_ops
m, k, n = 2048, 4096, 8192
world_size = 8
dtype = torch.float16
input1 = torch.rand(m, k, dtype, device=torch.npu.current_device())
input2 = torch.rand(k, n, dtype, device=torch.npu.current_device())
bias = torch.rand(1, n, dtype, device=torch.npu.current_device())
output = torch.zeros(m // word_size, n, dtype, device=torch.npu.current_device())
coc_ops.matmul_reduce_scatter(input1, input2, output, bias)
from mindspeed.ops.lcal_functional import coc_ops
coc_ops.pure_matmul(input1, input2, output, bias)
该接口对输入的左右矩阵进行Lcal Matmul操作,最后加上bias(如果bias不为None)。将最终结果赋值到output内存区域中。
假设Matmul操作对应的shape为[m, k]和[k, n]:
接口输入:
接口输出:
import torch
import torch_npu
from mindspeed.ops.lcal_functional import coc_ops
m, k, n = 2048, 4096, 8192
world_size = 8
dtype = torch.float16
input1 = torch.rand(m, k, dtype, device=torch.npu.current_device())
input2 = torch.rand(k, n, dtype, device=torch.npu.current_device())
bias = torch.rand(1, n, dtype, device=torch.npu.current_device())
output = torch.zeros(m, n, dtype, device=torch.npu.current_device())
coc_ops.pure_matmul(input1, input2, output, bias)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。