run_tests(model, quiz_machine, deterministic_synthesis=False)
- model.TRAINING_LOCK.release()
-
######################################################################
model.main_test_accuracy = 0.0
model.id = k
- model.TRAINING_LOCK = threading.Lock()
model.train_w_quizzes = quiz_machine.generate_token_sequences(args.nb_train_samples)
quiz_machine.reverse_random_half_in_place(model.train_w_quizzes)
weakest_models = ranked_models[: args.nb_gpus]
+ threads = []
+
for gpu_id, model in enumerate(weakest_models):
- model.TRAINING_LOCK.acquire()
+ log_string(f"training model {model.id}")
- log_string(
- f"training model {model.id} main_test_accuracy {model.main_test_accuracy}"
+ t = threading.Thread(
+ target=one_epoch, daemon=True, args=(model, quiz_machine, f"cuda:{gpu_id}")
)
- threading.Thread(
- target=one_epoch, daemon=True, args=(model, quiz_machine, f"cuda:{gpu_id}")
- ).start()
+ threads.append(t)
- for model in weakest_models:
- model.TRAINING_LOCK.acquire()
- model.TRAINING_LOCK.release()
+ t.start()
+
+ for t in threads:
+ t.join()
##################################################
# Replace a fraction of the w_quizzes with fresh ones