Skip to content

Commit b79f415

Browse files
committed
clean up: remove delta-dump related configs / args
1 parent 67f41d3 commit b79f415

File tree

4 files changed

+2
-88
lines changed

4 files changed

+2
-88
lines changed

mldaikon/collect_trace.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -359,24 +359,6 @@ def is_path_md_output_dir(output_dir: str) -> bool:
359359
default="hash",
360360
help="The format for dumping tensors. Choose from 'hash'(default), 'stats' or 'full'.",
361361
)
362-
parser.add_argument(
363-
"--delta-dump",
364-
type=bool,
365-
default=proxy_config.delta_dump_config["delta_dump"],
366-
help="Only dump the changed part of the object",
367-
)
368-
parser.add_argument(
369-
"--delta-dump-meta-var",
370-
type=bool,
371-
default=proxy_config.delta_dump_config["delta_dump_meta_var"],
372-
help="Only dump the changed part of the meta_var",
373-
)
374-
parser.add_argument(
375-
"--delta-dump-attributes",
376-
type=bool,
377-
default=proxy_config.delta_dump_config["delta_dump_attributes"],
378-
help="Only dump the changed part of the attribute",
379-
)
380362
parser.add_argument(
381363
"--enable-C-level-observer",
382364
type=bool,
@@ -444,20 +426,12 @@ def is_path_md_output_dir(output_dir: str) -> bool:
444426
# set the chosen one to True
445427
tensor_dump_format[f"dump_tensor_{args.tensor_dump_format}"] = True
446428

447-
# set up delta_dump_config
448-
delta_dump_config: dict[str, int | bool] = {}
449-
for configs in ["delta_dump", "delta_dump_meta_var", "delta_dump_attributes"]:
450-
if proxy_config.delta_dump_config[configs] != getattr(args, configs):
451-
delta_dump_config[configs] = getattr(args, configs)
452-
print(f"Setting {configs} to {getattr(args, configs)}")
453-
454429
auto_observer_config = proxy_config.auto_observer_config
455430
# call into the instrumentor
456431
adjusted_proxy_config: list[dict] = [
457432
auto_observer_config, # Ziming: add auto_observer_config for proxy_wrapper
458433
proxy_basic_config, # Ziming: add proxy_basic_config for proxy_wrapper
459434
tensor_dump_format, # Ziming: add tensor_dump_format for proxy_wrapper
460-
delta_dump_config, # Ziming: add delta_dump_config for proxy_wrapper
461435
]
462436

463437
# if args.disable_scan_proxy_in_args:

mldaikon/instrumentor/source_file.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,6 @@ def instrument_model_tracker_proxy(
327327
auto_observer_config: dict[str, int | bool | str] = adjusted_proxy_config[0]
328328
proxy_basic_config: dict[str, int | bool | str] = adjusted_proxy_config[1]
329329
tensor_dump_format: dict[str, int | bool | str] = adjusted_proxy_config[2]
330-
delta_dump_config: dict[str, int | bool | str] = adjusted_proxy_config[3]
331330

332331
## proxy configs
333332
proxy_start_code = ""
@@ -348,11 +347,7 @@ def instrument_model_tracker_proxy(
348347
from mldaikon.proxy_wrapper.proxy_config import tensor_dump_format
349348
tensor_dump_format.update({tensor_dump_format})
350349
"""
351-
if delta_dump_config:
352-
proxy_start_code += f"""
353-
from mldaikon.proxy_wrapper.proxy_config import delta_dump_config
354-
delta_dump_config.update({delta_dump_config})
355-
"""
350+
356351
proxy_start_code += """
357352
from mldaikon.proxy_wrapper.proxy import Proxy
358353
"""

mldaikon/proxy_wrapper/dumper.py

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55
from mldaikon.instrumentor.tracer import TraceLineType
66
from mldaikon.instrumentor.tracer import get_meta_vars as tracer_get_meta_vars
77
from mldaikon.proxy_wrapper.proxy_basics import is_proxied
8-
from mldaikon.proxy_wrapper.proxy_config import delta_dump_config, primitive_types
9-
10-
delta_dump = delta_dump_config["delta_dump"]
11-
delta_dump_attributes = delta_dump_config["delta_dump_attributes"]
12-
delta_dump_meta_var = delta_dump_config["delta_dump_meta_var"]
8+
from mldaikon.proxy_wrapper.proxy_config import primitive_types
139

1410

1511
class Singleton(type):
@@ -87,60 +83,14 @@ def dump_attributes(obj, value):
8783
value = obj_dict["_obj"]
8884

8985
result = convert_var_to_dict(value)
90-
91-
if delta_dump and delta_dump_attributes:
92-
# if they have common keys, only dump when old value is different from the new value
93-
old_value = obj.__dict__.get("old_value", {})
94-
# store the old value of the attribute
95-
store_old_value(obj, result)
96-
if old_value is not None:
97-
result = {
98-
key: value
99-
for key, value in result.items()
100-
if key not in old_value or old_value[key] != value
101-
}
10286
return result
10387

10488

10589
def get_meta_vars(obj):
10690
all_meta_vars = tracer_get_meta_vars()
10791

108-
if delta_dump and delta_dump_meta_var:
109-
# if they have common keys, only dump when old value is different from the new value
110-
old_value = obj.__dict__.get("old_meta_vars", {})
111-
# store the old value of the meta_var
112-
store_old_value_meta_var(obj, meta_vars=all_meta_vars)
113-
if old_value is not None:
114-
all_meta_vars = {
115-
key: value
116-
for key, value in all_meta_vars.items()
117-
if key not in old_value or old_value[key] != value
118-
}
11992
return all_meta_vars
12093

12194

12295
def concat_dicts(dict1, dict2):
12396
return {**dict1, **dict2}
124-
125-
126-
def store_old_value(obj, result):
127-
# set the current snapshot as the "old_value" attribute of the object
128-
if delta_dump:
129-
obj_dict = obj.__dict__
130-
assert is_proxied(obj), "The object is not a proxied object"
131-
if delta_dump_attributes:
132-
import copy
133-
134-
obj_dict["old_value"] = copy.deepcopy(result)
135-
136-
137-
def store_old_value_meta_var(obj, meta_vars=None):
138-
# save the current meta_var of the function stack
139-
if delta_dump:
140-
obj_dict = obj.__dict__
141-
assert is_proxied(obj), "The object is not a proxied object"
142-
if delta_dump_meta_var:
143-
if meta_vars is None:
144-
obj_dict["old_meta_vars"] = get_meta_vars(obj)
145-
else:
146-
obj_dict["old_meta_vars"] = meta_vars

mldaikon/proxy_wrapper/proxy_config.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
proxy_log_dir = "proxy_log.json" # FIXME: ad-hoc
44
debug_mode = False
55

6-
delta_dump_config = {
7-
"delta_dump": False, # only dump the changed part of the object (if this is set to be False, we would dump the whole object no matter what values delta_dump_meta_var and delta_dump_attribute are)
8-
"delta_dump_meta_var": True, # only dump the changed part of the meta_var
9-
"delta_dump_attributes": True, # only dump the changed part of the attribute
10-
}
116
tensor_dump_format = {
127
"dump_tensor_hash": True, # dump the hash of the tensor
138
"dump_tensor_stats": False, # dump the statistics of tensor {min, max, mean, shape}

0 commit comments

Comments
 (0)