title: How to understand the effect of local_step in tf.ConditionalAccumulator()
body: <p>I want to implement the function which conducts <code>backward()</code> after multiple <code>forward()</code> operations in order to increase the actual <code>batch_size</code> with limited GPU memory. So I came to <code>tf.ConditionalAccumulator</code>.</p>
  
  <p>In the arguments of <a href="https://www.tensorflow.org/api_docs/python/tf/ConditionalAccumulator#apply_grad" rel="nofollow noreferrer"><code>tf.ConditionalAccumulator().apply_grad()</code></a>, there is an argument <code>local_step</code> which I do not understand how to appoint. The document explains as follow:</p>
  
  <blockquote>
    <p>Attempts to apply a gradient to the accumulator.</p>
    
    <p>The attempt is silently dropped if the gradient is stale, i.e., local_step is less than the accumulator's global time step.</p>
    
    <p>Args:</p>
    
    <p><code>grad</code>: The gradient tensor to be applied.</p>
    
    <p><code>local_step</code>: Time step at which the gradient was computed.</p>
    
    <p><code>name</code>: Optional name for the operation.</p>
  </blockquote>
  
  <p>I tried to search the implementation of <code>tf.CondionalAccumentor().apply_grad()</code>, but didn't find the member variable refers to <code>global_time_step</code>. In my understanding, there should be ten gradient slots, if we want to accumulate 10 times before one gradient update. The <code>global_time_step</code> is applied as an indicator to point out which slot should be used. if the <code>local_step</code> is less than the <code>global_time_step</code>, which means the corresponding slot has been used, so the gradient is stale and should be discarded.</p>
  
  <p>In my implementation, I assign it with <code>global_step</code> variable, which is used to record the number of gradient update in training procedure, and it increases one in every <code>batch_size</code> iterations, thus it increases one after <code>batch_size</code> examples forward. I am not sure about the correctness of my implementation.</p>
  
  <p>I hope someone can help to explain the mechanism of <code>tf.ConditionalAccumulator</code>. </p>