mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-07-11 14:24:27 +00:00
hotfix tensor unittest bugs (#862)
This commit is contained in:
parent
1258af71cc
commit
29159d9b5b
@ -8,6 +8,7 @@ from colossalai.core import global_context as gpc
|
|||||||
from packaging import version
|
from packaging import version
|
||||||
from colossalai.utils.cuda import get_current_device
|
from colossalai.utils.cuda import get_current_device
|
||||||
|
|
||||||
|
|
||||||
@colo_op_impl(torch.nn.functional.linear)
|
@colo_op_impl(torch.nn.functional.linear)
|
||||||
def colo_linear(types, args, kwargs, pg):
|
def colo_linear(types, args, kwargs, pg):
|
||||||
"""Handles ``__torch_function__`` dispatch for ``torch.nn.functional.linear``.
|
"""Handles ``__torch_function__`` dispatch for ``torch.nn.functional.linear``.
|
||||||
@ -34,7 +35,7 @@ def colo_linear(types, args, kwargs, pg):
|
|||||||
elif weight.shard_spec == '1Drow':
|
elif weight.shard_spec == '1Drow':
|
||||||
# Input:S[1] x Weight:S[0] = Output:P
|
# Input:S[1] x Weight:S[0] = Output:P
|
||||||
# All-Reduce(Output) + bias = res
|
# All-Reduce(Output) + bias = res
|
||||||
assert divide(input_tensor.shape[-1], gpc.tensor_parallel_size) == weight.size[-1], \
|
assert divide(input_tensor.shape[-1], gpc.tensor_parallel_size) == weight.size(-1), \
|
||||||
'Invalid shapes in 1Drow forward: input={}, weight={}. Expected last dim of input {}.'.format(
|
'Invalid shapes in 1Drow forward: input={}, weight={}. Expected last dim of input {}.'.format(
|
||||||
input_tensor.shape, weight.size, weight.size[-1] * gpc.tensor_parallel_size)
|
input_tensor.shape, weight.size, weight.size[-1] * gpc.tensor_parallel_size)
|
||||||
# Input:S[1]
|
# Input:S[1]
|
||||||
|
Loading…
Reference in New Issue
Block a user