diff --git a/docs/ORTModule_Convergence_Notes.md b/docs/ORTModule_Convergence_Notes.md index ff3a915efe..be28ef23d4 100644 --- a/docs/ORTModule_Convergence_Notes.md +++ b/docs/ORTModule_Convergence_Notes.md @@ -3,47 +3,90 @@ ## 1. Discovering Convergence issues can be identified by: -- Large discrepancy on core training metrics including training loss, evaluation loss, model specific AUC metrics. -- Runtime failures (for example loss scaler reach the minimum triggering an exception). +- Large discrepancies in core training metrics including training loss, evaluation loss, model specific AUC metrics. +- Runtime failures (for example when the loss scaler reaches the minimum, triggering an exception). -Before looking into further, we should clarify few things (if possible): -- If we change seed for baseline run, whether the metric diff is big? - (Make sure the discrepancy is not introduced by random) -- What's the very first steps we see obvious diverges? -- Still repro once remove randomness? - - Set same seeds - - Set dropout ratio to 0 - - Set compute to be deterministic and torch-comparable (TODO(pengwa): need a flag for this). +Before looking into this further, we should clarify a few things (if possible): +- If we change the seed for the baseline run, whether the metric diff is big? + (Make sure the discrepancy is not introduced by randomness) +- What are the very first steps we see obvious divergence? +- Still reproducible once randomness is removed? +- Set same seeds +- Set the dropout ratio to 0 +- Set compute to be deterministic and torch-comparable (TODO(pengwa): need a flag for this). ## 2. Collect Activation Statistics -Add codes: +### Add a few lines of code, run script to collect statistics: + +
| Baseline | +ORTModule | +
|---|---|
| + ```diff -+ from onnxruntime.training.utils.hooks import SubscriberManager, StatisticsSubscriber -+ SubscriberManager.subscribe(model, [StatisticsSubscriber("pt_out", override_output_dir=True)]) - ++ from onnxruntime.training.utils.hooks import SubscriberManager, ++ StatisticsSubscriber ++ sub_m = SubscriberManager() ++ sub_m.subscribe(model, [StatisticsSubscriber(output_dir="pt_out", ++ override_output_dir=True)]) ``` -Run training script to the steps that triggered the divergence. A folder named `pt_out` is created in current working directory. For each step, there is a folder containing summaries for every activation tensor. + + | ++ -Add few lines of code: ```diff - from onnxruntime.training.ortmodule import ORTModule - from onnxruntime.training.utils.hooks import SubscriberManager, StatisticsSubscriber - model = ORTModule(model) -+ SubscriberManager.subscribe(model, [StatisticsSubscriber("ort_out", override_output_dir=True)]) +model = ORTModule(model) ++ from onnxruntime.training.utils.hooks import SubscriberManager, ++ StatisticsSubscriber ++ sub_m = SubscriberManager() ++ sub_m.subscribe(model, [StatisticsSubscriber(output_dir="ort_out", ++ override_output_dir=True)]) ``` -> `StatisticsSubscriber` can be initialized before OR after wrapping ORTModule. + + | +
| -Run command to generate per step summary +- Run training script to the steps that trigger the divergence. +- A folder named `pt_out` is created in the current working directory. +- For each step, there is a folder containing summaries for every activation tensor. + + | ++ + +- Run training script to the steps that trigger the divergence. +- Similarly, a folder named `ort_out` is created in the current working directory. +- `StatisticsSubscriber` can be subscribed before OR after wrapping ORTModule. + + | +