Skip to content

Commit

Permalink
[TORCH] WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
GuyPerets106 committed Aug 3, 2024
1 parent c9dfa6a commit 1e04142
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
8 changes: 8 additions & 0 deletions src_erl/NerlnetApp/src/Client/clientWorkersFunctions.erl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ create_workers(ClientName, ClientEtsRef , ShaToModelArgsMap , EtsStats) ->
{ModelType, ModelArgs, LayersSizes, LayersTypes, LayersFunctions, LossMethod,
LearningRate, Epochs, Optimizer, OptimizerArgs, _InfraType, DistributedSystemType,
DistributedSystemArgs, DistributedSystemToken} = maps:get(SHA, ShaToModelArgsMap),
DistributedTypeInteger = list_to_integer(DistributedSystemType),
if
DistributedTypeInteger > 0 -> % not none (distributed)
if length(DistributedSystemToken) == 5 ->
?LOG_INFO("~p Running a Distributed independent system on this device with Token: ~p",[WorkerName, DistributedSystemToken]);
true -> throw("Distributed non-independent system (e.g., Federated Learning) must have a token which is NOT none. Add it to the Distributed Config json file under distributedSystemToken field, make sure it is 5 characters long")
end
end,
MyClientPid = self(),
% TODO add documentation about this case of
% move this case to module called client_controller
Expand Down
12 changes: 3 additions & 9 deletions src_erl/NerlnetApp/src/Init/jsonParser.erl
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,6 @@ get_models(ShaToModelMaps) ->
DistributedSystemType = binary_to_list(maps:get(?WORKER_FIELD_KEY_DISTRIBUTED_SYSTEM_TYPE_BIN,ModelParams)),
DistributedSystemArgs = binary_to_list(maps:get(?WORKER_FIELD_KEY_DISTRIBUTED_SYSTEM_ARGS_BIN,ModelParams)),
DistributedSystemToken = binary_to_list(maps:get(?WORKER_FIELD_KEY_DISTRIBUTED_SYSTEM_TOKEN_BIN,ModelParams)),
case lists:member(DistributedSystemType, ["1", "2"]) of
true ->
case DistributedSystemToken of
"none" -> throw("Federated Learning Distributed System Must have a token which is NOT none. Add it to the Distributed Config json file under distributedSystemToken field, make sure it is 5 characters long");
_ -> io:format("Running a Federated Learning Model on this device with Token: ~p~n", [DistributedSystemToken])
end;
_ -> skip
end,
ModelTuple = {ModelType, ModelArgs , LayersSizes, LayersTypes, LayersFunctions, LossMethod, LearningRate, Epochs, Optimizer, OptimizerArgs, InfraType, DistributedSystemType, DistributedSystemArgs, DistributedSystemToken},
ModelTuple
end,
Expand Down Expand Up @@ -147,7 +139,9 @@ get_device_routers(DCMap, DeviceEntities) ->
%% return the ets name
%% --------------------------------------------------------------
json_to_ets(IPv4, JsonDCMap) ->

% Auto generated definitions validation
if ?DC_DISTRIBUTED_SYSTEM_TYPE_NONE_IDX_STR == "0" -> ok;
true -> throw("Auto generated definitions are not valid, none-distributed system type should be 0") end,
% update DeviceName
ets:insert(nerlnet_data, {?DC_IPV4_FIELD_ATOM, IPv4}),
ets:insert(nerlnet_data, {ipv4_bin, list_to_binary(IPv4)}), %% ? is this needed
Expand Down

0 comments on commit 1e04142

Please sign in to comment.