Skip to content

Commit 65c6a65

Browse files
committed
Remove LZ4 compression
1 parent a249b5c commit 65c6a65

File tree

6 files changed

+1
-63
lines changed

6 files changed

+1
-63
lines changed

actorQ/d4pg/actor_main.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
import dm_env
3434
import gc
3535
import gym
36-
import lz4.block
37-
import lz4.frame
3836
import numpy as np
3937
import numpy as np
4038
import pickle
@@ -81,21 +79,15 @@ def get_variables(self, names):
8179
d = [x.tobytes() for x in sample.data]
8280

8381
try:
84-
#decoded = [pickle.loads(lz4.frame.decompress(x.tobytes() + b'\x00\x00\x00\x00')) for x in sample.data]
85-
#decoded = [pickle.loads(zlib.decompress(x.tobytes())) for x in sample.data]
8682
if self.args["compress"]:
8783
d = [zlib.decompress(x) for x in d]
88-
#d = [lz4.frame.decompress(x + b'\x00\x00\x00\x00') for x in d]
8984
tdecompress = time.time()
9085
decoded = [pickle.loads(x) for x in d]
91-
#decoded = [pickle.loads(x) for x in d]
92-
#decoded = [pickle.loads(zlib.decompress(x.item())) for x in sample.data]
93-
#decoded = [pickle.loads(x.tobytes()) for x in sample.data]
9486
tdecode = time.time()
9587
print("Pull time: %f, Decompress/tobytes time: %f, Deserialize time: %f" % (tend-tstart, tdecompress-tend, tdecode-tdecompress))
9688
return decoded
9789
except:
98-
# traceback.print_exc()
90+
traceback.print_exc()
9991
pass
10092
return []
10193

actorQ/d4pg/learner_main.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@
3333
import pickle
3434
from multiprocessing import Pool
3535
from multiprocessing.pool import ThreadPool
36-
import lz4.frame
37-
import lz4.block
38-
#import pytorch_actors
3936
import torch
4037
import zstd
4138
import msgpack
@@ -151,15 +148,9 @@ def broadcast_shutdown(should_shutdown):
151148
steps = 0
152149

153150
def broadcast_variables(weights):
154-
#learner.client.insert([tf2_utils.to_numpy(v) for v in
155-
# agent_networks["policy"].variables],
156-
#{args.model_table_name : 1.0})
157-
#learner.client.insert(weights, {args.model_table_name: 1.0})
158151
if weights is None:
159-
#weights = [tf2_utils.to_numpy(v) for v in agent_networks["policy"].variables]
160152
weights = [tf2_utils.to_numpy(v) for v in learner.learner._policy_network.variables]
161153
learner.client.insert(weights, {args.broadcaster_table_name: 1.0})
162-
#learner.client.insert(weights, {args.model_table_name: 1.0})
163154

164155
broadcast_shutdown(0)
165156
variable_broadcaster = PeriodicBroadcaster(broadcast_variables)
@@ -170,14 +161,6 @@ def broadcast_variables(weights):
170161
with tf.device(args.learner_device_placement):
171162
learner.learner.step()
172163

173-
#if i % 50 == 0:
174-
# # #weights = [tf2_utils.to_numpy(v) for v in agent_networks["policy"].variables]
175-
# weights = [tf2_utils.to_numpy(v) for v in learner.learner._policy_network.variables]
176-
# # #variable_broadcaster.update(weights)
177-
# broadcast_variables(weights)
178-
# # # # pass
179-
180-
#broadcast_variables(None)
181164
variable_broadcaster.update(None)
182165

183166

actorQ/d4pg/parameter_broadcaster.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
import pickle
3535
from multiprocessing import Pool
3636
from multiprocessing.pool import ThreadPool
37-
import lz4.frame
38-
import lz4.block
3937
import pytorch_actors
4038
import torch
4139
import zstd
@@ -78,9 +76,6 @@ def get_weights_to_broadcast(client, broadcast_table_name):
7876
client = reverb.Client(address)
7977

8078
def quantize_and_broadcast_weights(weights, id):
81-
#client.insert(weights,
82-
# {args.model_table_name : 1.0})
83-
#return
8479

8580
print("Broadcasting weights", time.time())
8681

@@ -108,19 +103,11 @@ def quantize_and_broadcast_weights(weights, id):
108103
state_dict["id"] = id
109104

110105
# Send over packed params to avoid overhead
111-
#for name, child in quantized_actor._modules.items():
112-
# if type(child) == torch.nn.quantized.dynamic.modules.linear.Linear:
113-
# d_name = "%s._packed_params._packed_params.dumped" % name
114-
# state_dict[d_name] = pickle.dumps(child._packed_params._packed_params)
115106
tstart = time.time()
116107
weights = [pickle.dumps(state_dict)]
117108
if args.compress:
118109
weights = [zlib.compress(x) for x in weights]
119-
#weights = [lz4.frame.compress(x) for x in weights]
120-
#weights = [lz4.frame.compress(pickle.dumps(state_dict))]
121110
weights = [np.fromstring(x, dtype=np.uint8) for x in weights]
122-
#weights = [zlib.compress(pickle.dumps(state_dict), level=1)]
123-
#weights = [np.fromstring(pickle.dumps(state_dict), dtype=np.uint8)]
124111
print("Compress %f" % (time.time()-tstart))
125112

126113

actorQ/dqn/actor_main.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@
4747
import torch
4848
import pickle
4949
import zlib
50-
import lz4.frame
51-
import lz4.block
5250
import time
5351
import zstd
5452
import gc
@@ -80,16 +78,10 @@ def get_variables(self, names):
8078
d = [x.tobytes() for x in sample.data]
8179

8280
try:
83-
#decoded = [pickle.loads(lz4.frame.decompress(x.tobytes() + b'\x00\x00\x00\x00')) for x in sample.data]
84-
#decoded = [pickle.loads(zlib.decompress(x.tobytes())) for x in sample.data]
8581
if self.args["compress"]:
8682
d = [zlib.decompress(x) for x in d]
87-
#d = [lz4.frame.decompress(x + b'\x00\x00\x00\x00') for x in d]
8883
tdecompress = time.time()
8984
decoded = [pickle.loads(x) for x in d]
90-
#decoded = [pickle.loads(x) for x in d]
91-
#decoded = [pickle.loads(zlib.decompress(x.item())) for x in sample.data]
92-
#decoded = [pickle.loads(x.tobytes()) for x in sample.data]
9385
tdecode = time.time()
9486
print("Pull time: %f, Decompress/tobytes time: %f, Deserialize time: %f" % (tend-tstart, tdecompress-tend, tdecode-tdecompress))
9587
return decoded

actorQ/dqn/learner_main.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
import pickle
3535
from multiprocessing import Pool
3636
from multiprocessing.pool import ThreadPool
37-
import lz4.frame
38-
import lz4.block
3937
import pytorch_actors
4038
import torch
4139
import zstd

actorQ/dqn/parameter_broadcaster.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
import pickle
3535
from multiprocessing import Pool
3636
from multiprocessing.pool import ThreadPool
37-
import lz4.frame
38-
import lz4.block
3937
import pytorch_actors
4038
import torch
4139
import zstd
@@ -76,10 +74,6 @@ def get_weights_to_broadcast(client, broadcast_table_name):
7674
client = reverb.Client(address)
7775

7876
def quantize_and_broadcast_weights(weights, id):
79-
#client.insert(weights,
80-
# {args.model_table_name : 1.0})
81-
#return
82-
8377
print("Broadcasting weights", time.time())
8478

8579
# Quantize weights artificially
@@ -106,19 +100,11 @@ def quantize_and_broadcast_weights(weights, id):
106100
state_dict["id"] = id
107101

108102
# Send over packed params to avoid overhead
109-
#for name, child in quantized_actor._modules.items():
110-
# if type(child) == torch.nn.quantized.dynamic.modules.linear.Linear:
111-
# d_name = "%s._packed_params._packed_params.dumped" % name
112-
# state_dict[d_name] = pickle.dumps(child._packed_params._packed_params)
113103
tstart = time.time()
114104
weights = [pickle.dumps(state_dict)]
115105
if args.compress:
116106
weights = [zlib.compress(x) for x in weights]
117-
#weights = [lz4.frame.compress(x) for x in weights]
118-
#weights = [lz4.frame.compress(pickle.dumps(state_dict))]
119107
weights = [np.fromstring(x, dtype=np.uint8) for x in weights]
120-
#weights = [zlib.compress(pickle.dumps(state_dict), level=1)]
121-
#weights = [np.fromstring(pickle.dumps(state_dict), dtype=np.uint8)]
122108
print("Compress %f" % (time.time()-tstart))
123109

124110

0 commit comments

Comments
 (0)