Skip to content

Commit

Permalink
deploy: e769d32
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomDefaultUser committed Oct 19, 2023
1 parent 76b7cd7 commit 0c11d55
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions _modules/mala/common/parameters.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ <h1>Source code for mala.common.parameters</h1><div class="highlight"><pre>
<span class="kn">import</span> <span class="nn">pickle</span>
<span class="kn">from</span> <span class="nn">time</span> <span class="kn">import</span> <span class="n">sleep</span>

<span class="n">horovod_available</span> <span class="o">=</span> <span class="kc">False</span>
<span class="k">try</span><span class="p">:</span>
<span class="kn">import</span> <span class="nn">horovod.torch</span> <span class="k">as</span> <span class="nn">hvd</span>
<span class="n">horovod_available</span> <span class="o">=</span> <span class="kc">True</span>
<span class="k">except</span> <span class="ne">ModuleNotFoundError</span><span class="p">:</span>
<span class="k">pass</span>
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
Expand Down Expand Up @@ -1333,19 +1335,25 @@ <h1>Source code for mala.common.parameters</h1><div class="highlight"><pre>

<span class="nd">@use_horovod</span><span class="o">.</span><span class="n">setter</span>
<span class="k">def</span> <span class="nf">use_horovod</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
<span class="k">if</span> <span class="n">value</span><span class="p">:</span>
<span class="n">hvd</span><span class="o">.</span><span class="n">init</span><span class="p">()</span>
<span class="k">if</span> <span class="n">value</span> <span class="ow">is</span> <span class="kc">False</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_use_horovod</span> <span class="o">=</span> <span class="kc">False</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">if</span> <span class="n">horovod_available</span><span class="p">:</span>
<span class="n">hvd</span><span class="o">.</span><span class="n">init</span><span class="p">()</span>
<span class="c1"># Invalidate, will be updated in setter.</span>
<span class="n">set_horovod_status</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">device</span> <span class="o">=</span> <span class="kc">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_use_horovod</span> <span class="o">=</span> <span class="n">value</span>
<span class="bp">self</span><span class="o">.</span><span class="n">network</span><span class="o">.</span><span class="n">_update_horovod</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">use_horovod</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">descriptors</span><span class="o">.</span><span class="n">_update_horovod</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">use_horovod</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">targets</span><span class="o">.</span><span class="n">_update_horovod</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">use_horovod</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">_update_horovod</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">use_horovod</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">running</span><span class="o">.</span><span class="n">_update_horovod</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">use_horovod</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">hyperparameters</span><span class="o">.</span><span class="n">_update_horovod</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">use_horovod</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">parallel_warn</span><span class="p">(</span><span class="s2">&quot;Horovod requested, but not installed found. &quot;</span>
<span class="s2">&quot;MALA will operate without horovod only.&quot;</span><span class="p">)</span>

<span class="c1"># Invalidate, will be updated in setter.</span>
<span class="n">set_horovod_status</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">device</span> <span class="o">=</span> <span class="kc">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_use_horovod</span> <span class="o">=</span> <span class="n">value</span>
<span class="bp">self</span><span class="o">.</span><span class="n">network</span><span class="o">.</span><span class="n">_update_horovod</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">use_horovod</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">descriptors</span><span class="o">.</span><span class="n">_update_horovod</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">use_horovod</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">targets</span><span class="o">.</span><span class="n">_update_horovod</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">use_horovod</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">_update_horovod</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">use_horovod</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">running</span><span class="o">.</span><span class="n">_update_horovod</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">use_horovod</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">hyperparameters</span><span class="o">.</span><span class="n">_update_horovod</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">use_horovod</span><span class="p">)</span>

<span class="nd">@property</span>
<span class="k">def</span> <span class="nf">device</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
Expand Down
Binary file modified objects.inv
Binary file not shown.

0 comments on commit 0c11d55

Please sign in to comment.