Commit 9026b86d authored by Boris Fomitchev's avatar Boris Fomitchev
Browse files

Initialization fixes: allowing simple case like pytest pass, also making apex optional


Signed-off-by: default avatarBoris Fomitchev <bfomitchev@nvidia.com>
parent 05620ee4
...@@ -39,6 +39,12 @@ def initialize_megatron(extra_args_provider=None, args_defaults={}, ...@@ -39,6 +39,12 @@ def initialize_megatron(extra_args_provider=None, args_defaults={},
# Make sure cuda is available. # Make sure cuda is available.
assert torch.cuda.is_available(), 'Megatron requires CUDA.' assert torch.cuda.is_available(), 'Megatron requires CUDA.'
# This is temporary WAR to make simple case like pytest calling with same args twice
# Need to implement clean factory init.
if mpu.model_parallel_is_initialized():
return
# Parse args, build tokenizer, and set adlr-autoresume, # Parse args, build tokenizer, and set adlr-autoresume,
# tensorboard-writer, and timers. # tensorboard-writer, and timers.
set_global_variables(extra_args_provider=extra_args_provider, set_global_variables(extra_args_provider=extra_args_provider,
......
...@@ -18,7 +18,13 @@ ...@@ -18,7 +18,13 @@
import math import math
import torch import torch
from apex.normalization.fused_layer_norm import FusedLayerNorm as LayerNorm try:
from apex.normalization.fused_layer_norm import FusedLayerNorm as LayerNorm
# Try to use FusedLayerNorm from Apex - this will trigger an error.
_ = FusedLayerNorm(8, eps=1e-5)
except Exception as e:
from torch.nn import LayerNorm
from megatron import get_args from megatron import get_args
from megatron import mpu from megatron import mpu
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment