Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Fix for missing dependency in word2vec BF16 benchmark" #569

Merged
merged 1 commit into from
Oct 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions models/recall/word2vec/benchmark/static_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ def net(self, inputs, is_infer=False):

return self.metrics

def create_optimizer(self, strategy=None):
pure_bf16 = self.config.get("pure_bf16")
def create_optimizer(self, strategy=None, pure_bf16=False):
lr = float(self.config.get("hyper_parameters.optimizer.learning_rate"))
decay_rate = float(
self.config.get("hyper_parameters.optimizer.decay_rate"))
Expand Down
9 changes: 2 additions & 7 deletions tools/static_ps_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
import warnings
import logging
import ast
import numpy as np
import struct

__dir__ = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.abspath(os.path.join(__dir__, '..')))
Expand Down Expand Up @@ -62,10 +60,6 @@ def parse_args():
return config


def bf16_to_fp32(val):
return np.float32(struct.unpack('<f', struct.pack('<I', val << 16))[0])


class Main(object):
def __init__(self, config):
self.metrics = {}
Expand Down Expand Up @@ -218,6 +212,7 @@ def dataloader_train_loop(self, epoch):
batch_id = 0
train_run_cost = 0.0
total_examples = 0
from paddle.fluid.tests.unittests.op_test import convert_uint16_to_float
self.reader.start()
while True:
try:
Expand All @@ -237,7 +232,7 @@ def dataloader_train_loop(self, epoch):
metrics_string += "{}: {}, ".format(
var_name, fetch_var[var_idx]
if var_name != "LOSS" or not config['pure_bf16']
else bf16_to_fp32(fetch_var[var_idx][0]))
else convert_uint16_to_float(fetch_var[var_idx]))
profiler_string = ""
profiler_string += "avg_batch_cost: {} sec, ".format(
format((train_run_cost) / print_step, '.5f'))
Expand Down