Skip to content

Commit ebb6bae

Browse files
jarednielsenrahul003
authored andcommitted
Flattened JSON config format (aws#218)
* Flatten the JSON configuration format. See https://quip-amazon.com/ja7nAmXMVE5p for details. I rewrote the JSON for all the tests and ran them to ensure they still pass. * Flatten the JSON configuration format. See https://quip-amazon.com/ja7nAmXMVE5p for details. I rewrote the JSON for all the tests and ran them to ensure they still pass. * Undo formatting. * Undo formatting more * Fix typo that got reverted with the formatting revert * Fix JSON typo * Address Rahul's refactoring comments * Ensure we default to global mode if no specific train/eval/predict setting * Update .gitignore * Rewrite the logic for handling defaults. CollectionParameters default to HookParameters, and HookParameters default to the defaults. * Added test for merging logic * Fix failing test * Remove trailing comma in JSON
1 parent d520747 commit ebb6bae

40 files changed

+713
-909
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,12 @@ venv.bak/
108108
*~
109109
ts_output/
110110
log
111+
*.code-workspace
111112

112113
.DS_Store
113114
.idea/
114115
cm.ts
115116
default/
116-
newlogsRunTest/
117+
newlogsRunTest*/
117118
ts_outputs/
118-
newlogsRunTest1/
119+
test_output/

tests/mxnet/test_json_configs/full_example_json_config.json

Lines changed: 0 additions & 65 deletions
This file was deleted.

tests/mxnet/test_json_configs/test_hook_all_zero_hook.json

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,18 @@
11
{
2-
"config_name": "my training tornasole config",
3-
"s3_path": "s3://kjndjknd_bucket/prefix",
4-
"local_path" : "newlogsRunTest2/test_hook_all_zero_hook_from_json",
5-
"save_config" : "default_save_config",
6-
"include_collections" : ["ReluActivation", "weights", "bias","gradients"],
7-
"save_all" : false,
8-
"collections" : [
2+
"S3Path": "s3://kjndjknd_bucket/prefix",
3+
"LocalPath": "newlogsRunTest2/test_hook_all_zero_hook_from_json",
4+
"HookParameters": {
5+
"save_all": false,
6+
"save_steps": "0,1,2,3"
7+
},
8+
"CollectionConfiguration": [
9+
{ "CollectionName": "weights" },
10+
{ "CollectionName": "bias" },
11+
{ "CollectionName": "gradients" },
912
{
10-
"ReluActivation" : {
11-
"include_regex": ["relu*", "input_*"]
12-
}
13-
14-
}
15-
],
16-
"save_configs" : [
17-
{
18-
"save_config_collection" : {
19-
"save_steps" : [4,5,6]
20-
}
21-
},
22-
{
23-
"default_save_config" : {
24-
"save_steps" : [0,1,2,3]
13+
"CollectionName": "ReluActivation",
14+
"CollectionParameters": {
15+
"include_regex": "relu*,input_*"
2516
}
2617
}
2718
]
Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
{
2-
"config_name": "test_hook_from_json_config",
3-
"s3_path": "s3://kjndjknd_bucket/prefix",
4-
"local_path" : "newlogsRunTest1/test_hook_from_json_config",
5-
"save_config" : "save_cfg1",
6-
"save_configs" : [
7-
{
8-
"save_cfg1" : {
9-
"save_steps" : [0,1,2,3]
10-
}
11-
}
12-
]
13-
}
2+
"S3Path": "s3://kjndjknd_bucket/prefix",
3+
"LocalPath": "newlogsRunTest1/test_hook_from_json_config",
4+
"HookParameters": {
5+
"save_steps": "0,1,2,3"
6+
}
7+
}
Lines changed: 29 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,37 @@
11
{
2-
"config_name": "my training tornasole config",
3-
"s3_path": "s3://kjndjknd_bucket/prefix",
4-
"local_path" : "newlogsRunTest2/test_hook_from_json_config_full",
5-
"include_regex": ["regexe1", "regex2"],
6-
"save_config" : "name_of_save_Config_json_object",
7-
"reduction_config" : "name_of_redn_config_json_object",
8-
"include_collections" : ["collection_obj_name1", "collection_obj_name2"],
9-
"save_all" : false,
10-
"collections" : [
2+
"S3Path": "s3://kjndjknd_bucket/prefix",
3+
"LocalPath": "newlogsRunTest2/test_hook_from_json_config_full",
4+
"HookParameters": {
5+
"save_all": false,
6+
"include_regex": "regexe1,regex2",
7+
"save_interval": 100,
8+
"save_steps": "1,2,3,4",
9+
"skip_num_steps": 1,
10+
"when_nan": "tensor1*,tensor2*",
11+
"reductions": "min,max,mean, std,abs_variance,abs_sum,abs_l2_norm"
12+
},
13+
"CollectionConfiguration": [
1114
{
12-
"collection_obj_name1" : {
13-
"include_regex": ["regexe5*"],
14-
"save_config" : "name_of_save_Config_json__coll_object",
15-
"reduction_config" : "name_of_redn_config_json_object"
15+
"CollectionName": "collection_obj_name1",
16+
"CollectionParameters": {
17+
"include_regex": "regexe5*",
18+
"save_interval": 100,
19+
"save_steps": "1,2,3",
20+
"skip_num_steps": 1,
21+
"when_nan": "tensor3*,tensor4*",
22+
"reductions": "min, abs_max,l1_norm,abs_l2_norm"
1623
}
17-
1824
},
1925
{
20-
"collection_obj_name2" : {
21-
"include_regex": ["regexe6*"],
22-
"save_config" : "name_of_save_Config_json__coll_object",
23-
"reduction_config" : "name_of_redn_config_json_object_col"
26+
"CollectionName": "collection_obj_name2",
27+
"CollectionParameters": {
28+
"include_regex": "regexe6*",
29+
"save_interval": 100,
30+
"save_steps": "1,2,3",
31+
"skip_num_steps": 1,
32+
"when_nan": "tensor3*,tensor4*",
33+
"reductions": "min,abs_max, l1_norm,abs_l2_norm"
2434
}
2535
}
26-
],
27-
"save_configs" : [
28-
{
29-
"name_of_save_Config_json_object" : {
30-
"save_interval" : 100,
31-
"save_steps" : [1,2,3,4],
32-
"skip_num_steps" :1,
33-
"when_nan" : ["tensor1*","tensor2*"]
34-
}
35-
},
36-
{
37-
"name_of_save_Config_json__coll_object" : {
38-
"save_interval" : 100,
39-
"save_steps" : [1,2,3],
40-
"skip_num_steps" :1,
41-
"when_nan" : ["tensor3*","tensor4*"]
42-
}
43-
}
44-
],
45-
"reduction_configs" : [
46-
{
47-
"name_of_redn_config_json_object" :{
48-
"reductions" : ["min", "max", "mean", "std"] ,
49-
"abs_reductions" : ["variance", "sum"],
50-
"norms" : [],
51-
"abs_norms" : ["l2"]
52-
}
53-
},
54-
{
55-
"name_of_redn_config_json_object_col" :{
56-
"reductions" : ["min"] ,
57-
"abs_reductions" : [ "max"],
58-
"norms" : ["l1" ],
59-
"abs_norms" : ["l2"]
60-
}
61-
}
62-
]
36+
]
6337
}

tests/mxnet/test_json_configs/test_hook_reduce_config_hook.json

Lines changed: 22 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,30 @@
11
{
2-
"config_name": "my training tornasole config",
3-
"s3_path": "s3://kjndjknd_bucket/prefix",
4-
"local_path": "newlogsRunTest2/test_hook_reduce_config_hook_from_json",
5-
"save_config": "default_save_config",
6-
"reduction_config": "default_reduction_config",
7-
"include_collections" : ["weights", "bias","gradients", "default", "ReluActivation", "flatten"],
8-
"save_all": false,
9-
"collections" : [
2+
"S3Path": "s3://kjndjknd_bucket/prefix",
3+
"LocalPath": "newlogsRunTest2/test_hook_reduce_config_hook_from_json",
4+
"HookParameters": {
5+
"save_all": false,
6+
"reductions": "max,mean",
7+
"save_steps": "0,1,2,3"
8+
},
9+
"CollectionConfiguration": [
10+
{ "CollectionName": "weights" },
11+
{ "CollectionName": "bias" },
12+
{ "CollectionName": "gradients" },
13+
{ "CollectionName": "default" },
1014
{
11-
"ReluActivation" : {
12-
"include_regex": ["relu*"],
13-
"save_config": "save_config_collection",
14-
"reduction_config": "reduction_config_for_ReluActivation"
15+
"CollectionName": "ReluActivation",
16+
"CollectionParameters": {
17+
"include_regex": "relu*",
18+
"reductions": "min,abs_max",
19+
"save_steps": "4,5,6"
1520
}
1621
},
1722
{
18-
"flatten": {
19-
"include_regex": ["flatten*"],
20-
"save_config": "save_config_collection",
21-
"reduction_config": "reduction_config_for_flatten"
22-
}
23-
}
24-
],
25-
"save_configs" : [
26-
{
27-
"save_config_collection" : {
28-
"save_steps" : [4,5,6]
29-
}
30-
},
31-
{
32-
"default_save_config" : {
33-
"save_steps" : [0,1,2,3]
34-
}
35-
}
36-
],
37-
"reduction_configs" : [
38-
{
39-
"reduction_config_for_ReluActivation" :{
40-
"reductions" : ["min"],
41-
"abs_reductions" : ["max"]
42-
}
43-
},
44-
{
45-
"reduction_config_for_flatten" :{
46-
"norms" : ["l1"],
47-
"abs_norms" : ["l2"]
48-
}
49-
},
50-
{
51-
"default_reduction_config": {
52-
"reductions" : ["max", "mean"]
23+
"CollectionName": "flatten",
24+
"CollectionParameters": {
25+
"include_regex": "flatten*",
26+
"reductions": "l1_norm,abs_l2_norm",
27+
"save_steps": "4,5,6"
5328
}
5429
}
5530
]
Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
{
2-
"config_name": "my training tornasole config",
3-
"s3_path": "s3://kjndjknd_bucket/prefix",
4-
"local_path": "newlogsRunTest2/test_hook_save_all_hook_from_json",
5-
"save_config": "default_save_config",
6-
"save_all": true,
7-
"save_configs" : [
8-
{
9-
"default_save_config" : {
10-
"save_steps" : [0,1,2,3]
11-
}
12-
}
13-
]
2+
"S3Path": "s3://kjndjknd_bucket/prefix",
3+
"LocalPath": "newlogsRunTest2/test_hook_save_all_hook_from_json",
4+
"HookParameters": {
5+
"save_all": true,
6+
"save_steps": "0,1,2,3"
7+
}
148
}
Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
11
{
2-
"config_name": "test_hook_from_json_config",
3-
"s3_path": "s3://kjndjknd_bucket/prefix",
4-
"local_path" : "newlogsRunTest2/test_modes_hookjson",
5-
"include_collections" : ["gradients"],
6-
"save_config": {
7-
"TRAIN": "train_cfg1",
8-
"EVAL": "eval_cfg2"
2+
"S3Path": "s3://kjndjknd_bucket/prefix",
3+
"LocalPath": "newlogsRunTest2/test_modes_hookjson",
4+
"HookParameters": {
5+
"train.save_interval": 50,
6+
"eval.save_interval": 10
97
},
10-
"save_configs" : [
11-
{
12-
"train_cfg1" : {
13-
"save_interval" : 50
14-
},
15-
"eval_cfg2" : {
16-
"save_interval" : 10
17-
}
18-
}
8+
"CollectionConfiguration": [
9+
{ "CollectionName": "gradients" }
1910
]
2011
}

0 commit comments

Comments
 (0)