Skip to content

Commit 1289c66

Browse files
committed
Remove runtime changing of debug settings from tests and examples (except test/operations/micrograd_demo_logging.ml) including commented-out
They lead to confusion with user configurations.
1 parent 75b5fb7 commit 1289c66

13 files changed

+31
-58
lines changed

bin/compilation_speed.ml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ let fresh_backend = Backends.fresh_backend
1414
let benchmark_overhead backend () =
1515
let n_data = 20 in
1616
let module Backend = (val backend : Backend) in
17-
(* Utils.settings.with_debug <- true; *)
18-
(* Utils.settings.output_debug_files_in_build_directory <- true; *)
19-
(* Utils.settings.debug_log_from_routines <- true; *)
2017
CDSL.disable_all_debugs ();
2118
Stdio.prerr_endline @@ "\n\n****** Benchmarking " ^ Backend.name ^ " ******";
2219
Rand.init 0;

bin/einsum_trivia.ml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ let _suspended () =
1212
let module Backend = (val Backends.fresh_backend ()) in
1313
let stream = Backend.(new_stream @@ get_device ~ordinal:0) in
1414
let ctx = Backend.make_context stream in
15-
Utils.settings.output_debug_files_in_build_directory <- true;
1615
let a = TDSL.range_of_shape ~label:[ "a" ] ~input_dims:[ 2 ] ~output_dims:[ 2 ] () in
1716
let b = TDSL.range_of_shape ~label:[ "b" ] ~input_dims:[ 2; 3; 4 ] ~output_dims:[ 2 ] () in
1817
let%op c = a *+ "i->1; ij...->0 => ...->ji" b in
@@ -21,9 +20,6 @@ let _suspended () =
2120
Stdio.printf "\n%!"
2221

2322
let _suspended () =
24-
(* Utils.set_log_level 2; *)
25-
Utils.settings.output_debug_files_in_build_directory <- true;
26-
Utils.settings.debug_log_from_routines <- true;
2723
let module Backend = (val Backends.fresh_backend ~backend_name:"cuda" ()) in
2824
let backend =
2925
(module Backend : Backend
@@ -48,9 +44,6 @@ let _suspended () =
4844
Tensor.print ~here:[%here] ~with_code:false ~with_grad:false `Default @@ ho2
4945

5046
let () =
51-
(* Utils.set_log_level 2; *)
52-
Utils.settings.output_debug_files_in_build_directory <- true;
53-
Utils.settings.debug_log_from_routines <- true;
5447
let module Backend = (val Backends.fresh_backend ()) in
5548
let backend =
5649
(module Backend : Backend

bin/hello_world.ml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ module type Backend = Ir.Backend_intf.Backend
1212
let hello1 () =
1313
Rand.init 0;
1414
let module Backend = (val Backends.fresh_backend ()) in
15-
(* Utils.set_log_level 2; *)
16-
(* Utils.settings.output_debug_files_in_build_directory <- true; *)
1715
let stream = Backend.(new_stream @@ get_device ~ordinal:0) in
1816
let ctx = Backend.make_context stream in
1917
let open Operation.TDSL in
@@ -29,9 +27,6 @@ let hello1 () =
2927
let hello2 () =
3028
Rand.init 0;
3129
let module Backend = (val Backends.fresh_backend ()) in
32-
(* Utils.set_log_level 2; *)
33-
(* Utils.settings.output_debug_files_in_build_directory <- true; *)
34-
(* Utils.settings.debug_log_from_routines <- true; *)
3530
let stream = Backend.(new_stream @@ get_device ~ordinal:0) in
3631
let ctx = Backend.make_context stream in
3732
(* Hey is inferred to be a matrix. *)
@@ -45,8 +40,6 @@ let hello2 () =
4540
let hello3 () =
4641
Rand.init 0;
4742
let module Backend = (val Backends.fresh_backend ()) in
48-
Utils.settings.output_debug_files_in_build_directory <- true;
49-
(* Utils.settings.debug_log_from_routines <- true; *)
5043
let stream = Backend.(new_stream @@ get_device ~ordinal:0) in
5144
let ctx = Backend.make_context stream in
5245
(* Hey is inferred to be a matrix. *)
@@ -96,9 +89,6 @@ let hello4 () =
9689
Stdio.printf "\n%!"
9790

9891
let hello5 () =
99-
Utils.set_log_level 2;
100-
Utils.settings.output_debug_files_in_build_directory <- true;
101-
Utils.settings.debug_log_from_routines <- true;
10292
let module Backend = (val Backends.fresh_backend ()) in
10393
let backend =
10494
(module Backend : Backend
@@ -117,9 +107,6 @@ let hello5 () =
117107
Tensor.print ~here:[%here] ~with_code:false ~with_grad:false `Default @@ ho
118108

119109
let hello6 () =
120-
Utils.set_log_level 2;
121-
Utils.settings.output_debug_files_in_build_directory <- true;
122-
Utils.settings.debug_log_from_routines <- true;
123110
let module Backend = (val Backends.fresh_backend ()) in
124111
let backend =
125112
(module Backend : Backend

bin/hello_world_op.ml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ let _get_local_debug_runtime = Utils.get_local_debug_runtime
1313
[%%global_debug_log_level 9]
1414
[%%global_debug_log_level_from_env_var "OCANNL_LOG_LEVEL"]
1515

16-
let setup (() : unit) : unit =
17-
Utils.settings.output_debug_files_in_build_directory <- true;
18-
Utils.settings.debug_log_from_routines <- true
19-
2016
let%track2_sexp _Pointwise_multiplication_dims_1 (() : unit) : unit =
2117
Tensor.unsafe_reinitialize ();
2218
let module Backend = (val Backends.fresh_backend ()) in
@@ -216,12 +212,10 @@ let%track2_sexp _Very_big_tensor (() : unit) : unit =
216212
Tensor.print ~here:[%here] ~with_code:false ~with_grad:false `Default ye
217213

218214
let _suspended (() : unit) : unit =
219-
setup ();
220215
_Matrix_multiplication_dims_2x3 ();
221216
_Big_matrix ()
222217

223218
let _suspended (() : unit) : unit =
224-
setup ();
225219
_Pointwise_multiplication_dims_1 ();
226220
_Matrix_multiplication_dims_1x1 ();
227221
_Print_constant_tensor ();
@@ -230,7 +224,6 @@ let _suspended (() : unit) : unit =
230224
_Very_big_tensor ()
231225

232226
let (() : unit) : unit =
233-
setup ();
234227
_Matrix_multiplication_dims_2x3 ();
235228
_Big_matrix ();
236229
_Very_big_tensor ()

bin/micrograd_basic.ml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ let%diagn_sexp _suspended () =
1212
let module Backend = (val Backends.fresh_backend ~backend_name:"multicore_cc" ()) in
1313
let stream = Backend.(new_stream @@ get_device ~ordinal:0) in
1414
let ctx = Backend.make_context stream in
15-
Utils.settings.output_debug_files_in_build_directory <- true;
16-
Utils.settings.debug_log_from_routines <- true;
17-
Utils.set_log_level 2;
1815
Rand.init 0;
1916
let%op c = "a" [ -4 ] + "b" [ 2 ] in
2017
let%op d = c + c + 1 in
@@ -37,7 +34,6 @@ let%diagn_sexp () : unit =
3734
let module Backend = (val Backends.fresh_backend ()) in
3835
let stream = Backend.(new_stream @@ get_device ~ordinal:0) in
3936
let ctx = Backend.make_context stream in
40-
(* Utils.settings.output_debug_files_in_build_directory <- true; *)
4137
Rand.init 0;
4238
let%op c = "a" [ -4 ] + "b" [ 2 ] in
4339
let%op d = (a *. b) + (b **. 3) in

bin/micrograd_demo.ml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,13 @@ let _get_local_debug_runtime = Utils.get_local_debug_runtime
1212

1313
let experiment seed ~no_batch_shape_inference ~use_builtin_weight_decay () =
1414
Rand.init 0;
15-
(* Utils.enable_runtime_debug (); *)
16-
(* Utils.settings.debug_log_from_routines <- true; *)
1715
let hid_dim = 16 in
1816
let len = 300 in
1917
let batch_size = 20 in
2018
let n_batches = 2 * len / batch_size in
2119
let epochs = 75 in
2220
let steps = epochs * n_batches in
2321
(* let weight_decay = 0.0002 in *)
24-
Utils.settings.fixed_state_for_init <- Some seed;
2522
let moons_config = Datasets.Half_moons.Config.{ noise_range = 0.1; seed = Some seed } in
2623
let moons_coordinates, moons_labels = Datasets.Half_moons.generate ~config:moons_config ~len () in
2724
let moons_flat_ndarray = Ir.Ndarray.as_array Ir.Ops.Double moons_coordinates in

bin/micrograd_demo_logging.ml

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,9 @@ module Tn = Ir.Tnode
1010

1111
module type Backend = Ir.Backend_intf.Backend
1212

13-
let () =
13+
let () =
1414
Tensor.unsafe_reinitialize ();
1515
Rand.init 0;
16-
Utils.set_log_level 2;
17-
Utils.settings.output_debug_files_in_build_directory <- true;
18-
Utils.settings.debug_log_from_routines <- true;
1916
let module Backend = (val Backends.fresh_backend ()) in
2017
let stream = Backend.(new_stream @@ get_device ~ordinal:0) in
2118
let ctx = Backend.make_context stream in
@@ -35,9 +32,37 @@ let () =
3532
let ctx = init.context in
3633
let update = Train.grad_update g in
3734
let step = Train.to_routine (module Backend) ctx IDX.empty update in
35+
Tn.print_accessible_headers ();
3836
Utils.capture_stdout_logs @@ fun () ->
3937
Train.run init;
4038
Train.run step;
4139
Tensor.print ~here:[%here] ~with_code:false ~with_grad:false `Default g;
4240
Tensor.print ~here:[%here] ~with_code:false ~with_grad:true `Default a;
4341
Tensor.print ~here:[%here] ~with_code:false ~with_grad:true `Default b
42+
43+
let _suspended () =
44+
Tensor.unsafe_reinitialize ();
45+
Rand.init 0;
46+
let module Backend = (val Backends.fresh_backend ()) in
47+
let stream = Backend.(new_stream @@ get_device ~ordinal:0) in
48+
let ctx = Backend.make_context stream in
49+
let%op c = "a" [ -4 ] + "b" [ 2 ] in
50+
let%op d = (a *. b) + (b **. 3) in
51+
let%op c = c + c + 1 in
52+
let%op c = c + 1 + c + ~-a in
53+
let%op d = d + (d *. 2) + relu (b + a) in
54+
let%op d = d + (3 *. d) + relu (b - a) in
55+
let%op e = c - d in
56+
let%op f = e **. 2 in
57+
let%op g = f /. 2 in
58+
let%op g = g + (10. /. f) in
59+
List.iter ~f:(Option.iter ~f:(fun diff -> Train.set_hosted diff.Tensor.grad)) [ a.diff; b.diff ];
60+
let init_params = Tensor.init_params g in
61+
let update = Train.grad_update g in
62+
let step = Train.to_routine (module Backend) ctx IDX.empty @@ Asgns.sequence [init_params; update] in
63+
Tn.print_accessible_headers ();
64+
Utils.capture_stdout_logs @@ fun () ->
65+
Train.run step;
66+
Tensor.print ~here:[%here] ~with_code:false ~with_grad:false `Default g;
67+
Tensor.print ~here:[%here] ~with_code:false ~with_grad:true `Default a;
68+
Tensor.print ~here:[%here] ~with_code:false ~with_grad:true `Default b

bin/moons_benchmark.ml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ let classify_moons ~seed ~on_device ~inlining_cutoff ~num_streams ~batch_size ~b
3131
CDSL.virtualize_settings.max_visits <- inlining_cutoff;
3232
Tensor.default_value_prec := value_prec;
3333
Tensor.default_grad_prec := grad_prec;
34-
Utils.settings.output_debug_files_in_build_directory <- true;
35-
(* This will only log from routines if log-level is high enough. *)
36-
Utils.settings.debug_log_from_routines <- true;
3734
Rand.init (* seed *) 0;
3835
let hid_dim_1 = 16 in
3936
let hid_dim_2 = 8 in

bin/moons_demo.ml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,10 @@ let demo () =
1515
let seed = 3 in
1616
Rand.init seed;
1717
Utils.settings.fixed_state_for_init <- Some seed;
18-
Utils.settings.output_debug_files_in_build_directory <- true;
19-
(* Utils.enable_runtime_debug (); *)
2018
let hid_dim = 16 in
2119
let len = 512 in
2220
let batch_size = 32 in
2321
let epochs = 75 in
24-
(* Utils.settings.debug_log_from_routines <- true; *)
2522
(* TINY for debugging: *)
2623
(* let hid_dim = 2 in let len = 16 in let batch_size = 2 in let epochs = 2 in *)
2724
let n_batches = 2 * len / batch_size in

bin/moons_demo_parallel.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ module CDSL = Train.CDSL
88
module Rand = Ir.Rand.Lib
99

1010
let experiment ~seed ~backend_name ~config () =
11-
Utils.settings.output_debug_files_in_build_directory <- true;
12-
(* Utils.settings.debug_log_from_routines <- true; *)
1311
let hid_dim = 16 in
1412
(* let hid_dim = 4 in *)
1513
let batch_size = 120 in

0 commit comments

Comments
 (0)