Class EncodedGradientsAccumulator

    • Constructor Detail

      • EncodedGradientsAccumulator

        public EncodedGradientsAccumulator​(int parties,
                                           double threshold)
      • EncodedGradientsAccumulator

        public EncodedGradientsAccumulator​(int parties,
                                           ThresholdAlgorithm thresholdAlgorithm,
                                           ResidualPostProcessor residualPostProcessor,
                                           boolean encodingDebugMode)
      • EncodedGradientsAccumulator

        public EncodedGradientsAccumulator​(int parties,
                                           @NonNull
                                           @NonNull MessageHandler handler,
                                           long initialMemory,
                                           int queueSize,
                                           Integer boundary,
                                           boolean encodingDebugMode)
    • Method Detail

      • getOptimalBufferSize

        public static long getOptimalBufferSize​(long paramsLength,
                                                int numWorkers,
                                                int queueSize)
        This method returns optimal bufferSize for a given model We know, that updates are guaranteed to have MAX size of params / 16. So, here we go. I.e. for model with 100m params, that's 400m of floats (or 800m of doubles) The worst case for us is bitmap encoding, that takes 2 bits to encode each gradient value so, for float in worst case we'll have (100m / 16) int elements. So, our buffer size will be 6.25m * queueSize * 4 bytes per int
        Parameters:
        paramsLength -
        numWorkers -
        queueSize -
        Returns:
      • getOptimalBufferSize

        public static long getOptimalBufferSize​(Model model,
                                                int numWorkers,
                                                int queueSize)
      • fallbackToSingleConsumerMode

        public void fallbackToSingleConsumerMode​(boolean reallyFallback)
        Description copied from interface: Registerable
        This method enables/disables bypass mode
        Specified by:
        fallbackToSingleConsumerMode in interface Registerable
      • registerConsumers

        public void registerConsumers​(int numConsumers)
        Description copied from interface: Registerable
        This method notifies producer about number of consumers for the current consumption cycle
        Specified by:
        registerConsumers in interface Registerable
      • synchronize

        protected void synchronize​(int consumers)
      • synchronize

        protected void synchronize​(int consumers,
                                   boolean finalLock)
      • setExternalSource

        public void setExternalSource​(IndexedTail source)
        This method allows to pass external updates to accumulator, they will be populated across all workers using this GradientsAccumulator instance
        Specified by:
        setExternalSource in interface GradientsAccumulator
        Parameters:
        source -
      • touch

        public void touch()
        This method does initialization of given worker wrt Thread-Device Affinity
        Specified by:
        touch in interface GradientsAccumulator
      • storeUpdate

        public void storeUpdate​(INDArray array,
                                int iterationNumber,
                                int epochNumber)
        This method accepts updates suitable for StepFunction, and accumulates/propagates it across all workers
        Specified by:
        storeUpdate in interface GradientsAccumulator
        Parameters:
        array -
      • receiveUpdate

        public void receiveUpdate​(INDArray array)
        This method accepts updates suitable for StepFunction and puts them to the queue, which is used in backpropagation loop

        PLEASE NOTE: array is expected to be ready for use and match params dimensionality

        Specified by:
        receiveUpdate in interface GradientsAccumulator
        Parameters:
        array -
      • reset

        public void reset()
        This method resets all accumulated updates (if any)
        Specified by:
        reset in interface GradientsAccumulator