org.apache.clojure-mxnet.kvstore
barrier
(barrier kvstore)
Global barrier among all worker nodes
For example, assume there are n machines, we want to let machine 0 first
init the values, and then pull the inited value to all machines. Before
pulling, we can place a barrier to guarantee that the initialization is
finished.
create
(create name)
(create)
Create a new KVStore
WARNING: it is your responsibility to clear this object through dispose.
- name : #{local, dist} (default is local)
The type of KVStore
- local works for multiple devices on a single machine (single process)
- dist works for multi-machines (multiple processes)
dispose
(dispose kvstore)
Release the native memory.
The object shall never be used after it is disposed.
init
(init kvstore ks vs)
Initialize a single or a sequence of key-value pairs into the store.
For each key, one must init it before push and pull.
Only worker 0's (rank == 0) data are used.
This function returns after data have been initialized successfully
kvstore - KVstore
ks - keys (vec or strings or single string)
vs - values (vec or NDArrays or single ndarry)
load-optimizer-states
(load-optimizer-states kvstore fname)
Load optimizer (updater) state from file
- kvstore
-fname Path to input states file.
num-dead-node
(num-dead-node kvstore node-id)
num-workers
(num-workers kvstore)
Get the number of worker nodes
pull
(pull kvstore ks outs priority)
(pull kvstore ks outs)
Pull a single value or a sequence of values from the store.
Data consistency:
1. this function returns after adding an operator to the engine. But any
further read on out will be blocked until it is finished.
2. pull is always called after all previous push and pull on the same key are finished
3. It pulls the newest value from the store.
- kvstore
- ks single or vector of (strings)
- outs single or vector of outs (NDArrays)
- priority
The priority of the push operation.
The higher the priority, the faster this action is likely
to be executed before other push actions.
push
(push kvstore ks vs priority)
(push kvstore ks vs)
Push a single or a sequence of key-value pairs into the store.
Data consistency:
1. this function returns after adding an operator to the engine.
2. push is always called after all previous push and pull on the same key are finished
3. there is no synchronization between workers. One can use _barrier() to sync all workers
-ks Keys
-vs values According values
- priority
The priority of the push operation.
The higher the priority, the faster this action is likely
to be executed before other push actions.
rank
(rank kvstore)
Get the rank of this worker node
returns The rank of this node, which is in [0, get_num_workers())
save-optimizer-states
(save-optimizer-states kvstore fname)
Save optimizer (updater) state to file
- kvstore
- fname Path to output states file.
send-command-to-servers
(send-command-to-servers kvstore head body)
Send a command to all server nodes
Send a command to all server nodes, which will make each server node run
KVStoreServer.controller
This function returns after the command has been executed in all server nodes
-kvstore
-head the head of the command
- body the body of the command
set-barrier-before-exit
(set-barrier-before-exit kvstore barrier-before-exit)
Whether to do barrier when the kvstore finalizes
- kvstore
- barrier-before-exit boolean
set-optimizer
(set-optimizer kvstore optimizer)
Register an optimizer to the store
If there are multiple machines, this process (should be a worker node)
will pack this optimizer and send it to all servers. It returns after
this action is done
type
(type kvstore)
Get the type of the kvstore