Skip to content

Commit 357f873

Browse files
authored
[Bugfix] Fix Cosmos3 FP8 tensor parallelism (#14921)
Fix Cosmos3 FP8 tensor parallelism
1 parent 4156630 commit 357f873

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎examples/cosmos3/cosmos_parallel.py‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,15 @@ def enable_cosmos3_tensor_parallel(transformer, tp_mesh):
431431
own processor) on a 2-D ``(tp, cp)`` mesh, or with ``enable_cosmos3_flash_attention``
432432
for TP without CP.
433433
"""
434-
from torch.distributed.tensor.parallel import ColwiseParallel, RowwiseParallel, parallelize_module
434+
from torch.distributed.tensor.parallel import ColwiseParallel, parallelize_module
435+
from torch.distributed.tensor.parallel import RowwiseParallel as TorchRowwiseParallel
436+
437+
# Skip ModelOpt quantizer children to avoid:
438+
# AttributeError: 'TensorQuantizer' object has no attribute 'weight'
439+
class RowwiseParallel(TorchRowwiseParallel):
440+
def _partition_linear_fn(self, name, module, device_mesh):
441+
if isinstance(module, torch.nn.Linear):
442+
return super()._partition_linear_fn(name, module, device_mesh)
435443

436444
tp = tp_mesh.size()
437445
dev = torch.device("cuda", torch.cuda.current_device())

0 commit comments

Comments
 (0)