partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
GlobalState.error_messages
Get the error messages for all drivers or a specific driver. Args: driver_id: The specific driver to get the errors for. If this is None, then this method retrieves the errors for all drivers. Returns: A dictionary mapping driver ID to a list of the error messag...
python/ray/experimental/state.py
def error_messages(self, driver_id=None): """Get the error messages for all drivers or a specific driver. Args: driver_id: The specific driver to get the errors for. If this is None, then this method retrieves the errors for all drivers. Returns: A dicti...
def error_messages(self, driver_id=None): """Get the error messages for all drivers or a specific driver. Args: driver_id: The specific driver to get the errors for. If this is None, then this method retrieves the errors for all drivers. Returns: A dicti...
[ "Get", "the", "error", "messages", "for", "all", "drivers", "or", "a", "specific", "driver", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/state.py#L876-L902
[ "def", "error_messages", "(", "self", ",", "driver_id", "=", "None", ")", ":", "if", "driver_id", "is", "not", "None", ":", "assert", "isinstance", "(", "driver_id", ",", "ray", ".", "DriverID", ")", "return", "self", ".", "_error_messages", "(", "driver_i...
4eade036a0505e244c976f36aaa2d64386b5129b
train
GlobalState.actor_checkpoint_info
Get checkpoint info for the given actor id. Args: actor_id: Actor's ID. Returns: A dictionary with information about the actor's checkpoint IDs and their timestamps.
python/ray/experimental/state.py
def actor_checkpoint_info(self, actor_id): """Get checkpoint info for the given actor id. Args: actor_id: Actor's ID. Returns: A dictionary with information about the actor's checkpoint IDs and their timestamps. """ self._check_connected() ...
def actor_checkpoint_info(self, actor_id): """Get checkpoint info for the given actor id. Args: actor_id: Actor's ID. Returns: A dictionary with information about the actor's checkpoint IDs and their timestamps. """ self._check_connected() ...
[ "Get", "checkpoint", "info", "for", "the", "given", "actor", "id", ".", "Args", ":", "actor_id", ":", "Actor", "s", "ID", ".", "Returns", ":", "A", "dictionary", "with", "information", "about", "the", "actor", "s", "checkpoint", "IDs", "and", "their", "t...
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/state.py#L904-L941
[ "def", "actor_checkpoint_info", "(", "self", ",", "actor_id", ")", ":", "self", ".", "_check_connected", "(", ")", "message", "=", "self", ".", "_execute_command", "(", "actor_id", ",", "\"RAY.TABLE_LOOKUP\"", ",", "ray", ".", "gcs_utils", ".", "TablePrefix", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
TensorFlowVariables.get_flat_size
Returns the total length of all of the flattened variables. Returns: The length of all flattened variables concatenated.
python/ray/experimental/tf_utils.py
def get_flat_size(self): """Returns the total length of all of the flattened variables. Returns: The length of all flattened variables concatenated. """ return sum( np.prod(v.get_shape().as_list()) for v in self.variables.values())
def get_flat_size(self): """Returns the total length of all of the flattened variables. Returns: The length of all flattened variables concatenated. """ return sum( np.prod(v.get_shape().as_list()) for v in self.variables.values())
[ "Returns", "the", "total", "length", "of", "all", "of", "the", "flattened", "variables", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/tf_utils.py#L111-L118
[ "def", "get_flat_size", "(", "self", ")", ":", "return", "sum", "(", "np", ".", "prod", "(", "v", ".", "get_shape", "(", ")", ".", "as_list", "(", ")", ")", "for", "v", "in", "self", ".", "variables", ".", "values", "(", ")", ")" ]
4eade036a0505e244c976f36aaa2d64386b5129b
train
TensorFlowVariables.get_flat
Gets the weights and returns them as a flat array. Returns: 1D Array containing the flattened weights.
python/ray/experimental/tf_utils.py
def get_flat(self): """Gets the weights and returns them as a flat array. Returns: 1D Array containing the flattened weights. """ self._check_sess() return np.concatenate([ v.eval(session=self.sess).flatten() for v in self.variables.values() ...
def get_flat(self): """Gets the weights and returns them as a flat array. Returns: 1D Array containing the flattened weights. """ self._check_sess() return np.concatenate([ v.eval(session=self.sess).flatten() for v in self.variables.values() ...
[ "Gets", "the", "weights", "and", "returns", "them", "as", "a", "flat", "array", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/tf_utils.py#L127-L137
[ "def", "get_flat", "(", "self", ")", ":", "self", ".", "_check_sess", "(", ")", "return", "np", ".", "concatenate", "(", "[", "v", ".", "eval", "(", "session", "=", "self", ".", "sess", ")", ".", "flatten", "(", ")", "for", "v", "in", "self", "."...
4eade036a0505e244c976f36aaa2d64386b5129b
train
TensorFlowVariables.set_flat
Sets the weights to new_weights, converting from a flat array. Note: You can only set all weights in the network using this function, i.e., the length of the array must match get_flat_size. Args: new_weights (np.ndarray): Flat array containing weights.
python/ray/experimental/tf_utils.py
def set_flat(self, new_weights): """Sets the weights to new_weights, converting from a flat array. Note: You can only set all weights in the network using this function, i.e., the length of the array must match get_flat_size. Args: new_weights (np.ndarray): ...
def set_flat(self, new_weights): """Sets the weights to new_weights, converting from a flat array. Note: You can only set all weights in the network using this function, i.e., the length of the array must match get_flat_size. Args: new_weights (np.ndarray): ...
[ "Sets", "the", "weights", "to", "new_weights", "converting", "from", "a", "flat", "array", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/tf_utils.py#L139-L157
[ "def", "set_flat", "(", "self", ",", "new_weights", ")", ":", "self", ".", "_check_sess", "(", ")", "shapes", "=", "[", "v", ".", "get_shape", "(", ")", ".", "as_list", "(", ")", "for", "v", "in", "self", ".", "variables", ".", "values", "(", ")", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
TensorFlowVariables.get_weights
Returns a dictionary containing the weights of the network. Returns: Dictionary mapping variable names to their weights.
python/ray/experimental/tf_utils.py
def get_weights(self): """Returns a dictionary containing the weights of the network. Returns: Dictionary mapping variable names to their weights. """ self._check_sess() return { k: v.eval(session=self.sess) for k, v in self.variables.items() ...
def get_weights(self): """Returns a dictionary containing the weights of the network. Returns: Dictionary mapping variable names to their weights. """ self._check_sess() return { k: v.eval(session=self.sess) for k, v in self.variables.items() ...
[ "Returns", "a", "dictionary", "containing", "the", "weights", "of", "the", "network", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/tf_utils.py#L159-L169
[ "def", "get_weights", "(", "self", ")", ":", "self", ".", "_check_sess", "(", ")", "return", "{", "k", ":", "v", ".", "eval", "(", "session", "=", "self", ".", "sess", ")", "for", "k", ",", "v", "in", "self", ".", "variables", ".", "items", "(", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
TensorFlowVariables.set_weights
Sets the weights to new_weights. Note: Can set subsets of variables as well, by only passing in the variables you want to be set. Args: new_weights (Dict): Dictionary mapping variable names to their weights.
python/ray/experimental/tf_utils.py
def set_weights(self, new_weights): """Sets the weights to new_weights. Note: Can set subsets of variables as well, by only passing in the variables you want to be set. Args: new_weights (Dict): Dictionary mapping variable names to their weig...
def set_weights(self, new_weights): """Sets the weights to new_weights. Note: Can set subsets of variables as well, by only passing in the variables you want to be set. Args: new_weights (Dict): Dictionary mapping variable names to their weig...
[ "Sets", "the", "weights", "to", "new_weights", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/tf_utils.py#L171-L198
[ "def", "set_weights", "(", "self", ",", "new_weights", ")", ":", "self", ".", "_check_sess", "(", ")", "assign_list", "=", "[", "self", ".", "assignment_nodes", "[", "name", "]", "for", "name", "in", "new_weights", ".", "keys", "(", ")", "if", "name", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
construct_error_message
Construct a serialized ErrorTableData object. Args: driver_id: The ID of the driver that the error should go to. If this is nil, then the error will go to all drivers. error_type: The type of the error. message: The error message. timestamp: The time of the error. R...
python/ray/gcs_utils.py
def construct_error_message(driver_id, error_type, message, timestamp): """Construct a serialized ErrorTableData object. Args: driver_id: The ID of the driver that the error should go to. If this is nil, then the error will go to all drivers. error_type: The type of the error. ...
def construct_error_message(driver_id, error_type, message, timestamp): """Construct a serialized ErrorTableData object. Args: driver_id: The ID of the driver that the error should go to. If this is nil, then the error will go to all drivers. error_type: The type of the error. ...
[ "Construct", "a", "serialized", "ErrorTableData", "object", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/gcs_utils.py#L60-L91
[ "def", "construct_error_message", "(", "driver_id", ",", "error_type", ",", "message", ",", "timestamp", ")", ":", "builder", "=", "flatbuffers", ".", "Builder", "(", "0", ")", "driver_offset", "=", "builder", ".", "CreateString", "(", "driver_id", ".", "binar...
4eade036a0505e244c976f36aaa2d64386b5129b
train
init
Initialize synchronously.
python/ray/experimental/async_api.py
def init(): """ Initialize synchronously. """ loop = asyncio.get_event_loop() if loop.is_running(): raise Exception("You must initialize the Ray async API by calling " "async_api.init() or async_api.as_future(obj) before " "the event loop start...
def init(): """ Initialize synchronously. """ loop = asyncio.get_event_loop() if loop.is_running(): raise Exception("You must initialize the Ray async API by calling " "async_api.init() or async_api.as_future(obj) before " "the event loop start...
[ "Initialize", "synchronously", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/async_api.py#L24-L34
[ "def", "init", "(", ")", ":", "loop", "=", "asyncio", ".", "get_event_loop", "(", ")", "if", "loop", ".", "is_running", "(", ")", ":", "raise", "Exception", "(", "\"You must initialize the Ray async API by calling \"", "\"async_api.init() or async_api.as_future(obj) bef...
4eade036a0505e244c976f36aaa2d64386b5129b
train
shutdown
Manually shutdown the async API. Cancels all related tasks and all the socket transportation.
python/ray/experimental/async_api.py
def shutdown(): """Manually shutdown the async API. Cancels all related tasks and all the socket transportation. """ global handler, transport, protocol if handler is not None: handler.close() transport.close() handler = None transport = None protocol = None
def shutdown(): """Manually shutdown the async API. Cancels all related tasks and all the socket transportation. """ global handler, transport, protocol if handler is not None: handler.close() transport.close() handler = None transport = None protocol = None
[ "Manually", "shutdown", "the", "async", "API", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/async_api.py#L51-L62
[ "def", "shutdown", "(", ")", ":", "global", "handler", ",", "transport", ",", "protocol", "if", "handler", "is", "not", "None", ":", "handler", ".", "close", "(", ")", "transport", ".", "close", "(", ")", "handler", "=", "None", "transport", "=", "None...
4eade036a0505e244c976f36aaa2d64386b5129b
train
flush_redis_unsafe
This removes some non-critical state from the primary Redis shard. This removes the log files as well as the event log from Redis. This can be used to try to address out-of-memory errors caused by the accumulation of metadata in Redis. However, it will only partially address the issue as much of the da...
python/ray/experimental/features.py
def flush_redis_unsafe(redis_client=None): """This removes some non-critical state from the primary Redis shard. This removes the log files as well as the event log from Redis. This can be used to try to address out-of-memory errors caused by the accumulation of metadata in Redis. However, it will only...
def flush_redis_unsafe(redis_client=None): """This removes some non-critical state from the primary Redis shard. This removes the log files as well as the event log from Redis. This can be used to try to address out-of-memory errors caused by the accumulation of metadata in Redis. However, it will only...
[ "This", "removes", "some", "non", "-", "critical", "state", "from", "the", "primary", "Redis", "shard", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/features.py#L13-L44
[ "def", "flush_redis_unsafe", "(", "redis_client", "=", "None", ")", ":", "if", "redis_client", "is", "None", ":", "ray", ".", "worker", ".", "global_worker", ".", "check_connected", "(", ")", "redis_client", "=", "ray", ".", "worker", ".", "global_worker", "...
4eade036a0505e244c976f36aaa2d64386b5129b
train
flush_task_and_object_metadata_unsafe
This removes some critical state from the Redis shards. In a multitenant environment, this will flush metadata for all jobs, which may be undesirable. This removes all of the object and task metadata. This can be used to try to address out-of-memory errors caused by the accumulation of metadata in ...
python/ray/experimental/features.py
def flush_task_and_object_metadata_unsafe(): """This removes some critical state from the Redis shards. In a multitenant environment, this will flush metadata for all jobs, which may be undesirable. This removes all of the object and task metadata. This can be used to try to address out-of-memory ...
def flush_task_and_object_metadata_unsafe(): """This removes some critical state from the Redis shards. In a multitenant environment, this will flush metadata for all jobs, which may be undesirable. This removes all of the object and task metadata. This can be used to try to address out-of-memory ...
[ "This", "removes", "some", "critical", "state", "from", "the", "Redis", "shards", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/features.py#L47-L84
[ "def", "flush_task_and_object_metadata_unsafe", "(", ")", ":", "ray", ".", "worker", ".", "global_worker", ".", "check_connected", "(", ")", "def", "flush_shard", "(", "redis_client", ")", ":", "# Flush the task table. Note that this also flushes the driver tasks", "# which...
4eade036a0505e244c976f36aaa2d64386b5129b
train
flush_finished_tasks_unsafe
This removes some critical state from the Redis shards. In a multitenant environment, this will flush metadata for all jobs, which may be undesirable. This removes all of the metadata for finished tasks. This can be used to try to address out-of-memory errors caused by the accumulation of metadata ...
python/ray/experimental/features.py
def flush_finished_tasks_unsafe(): """This removes some critical state from the Redis shards. In a multitenant environment, this will flush metadata for all jobs, which may be undesirable. This removes all of the metadata for finished tasks. This can be used to try to address out-of-memory errors ...
def flush_finished_tasks_unsafe(): """This removes some critical state from the Redis shards. In a multitenant environment, this will flush metadata for all jobs, which may be undesirable. This removes all of the metadata for finished tasks. This can be used to try to address out-of-memory errors ...
[ "This", "removes", "some", "critical", "state", "from", "the", "Redis", "shards", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/features.py#L155-L169
[ "def", "flush_finished_tasks_unsafe", "(", ")", ":", "ray", ".", "worker", ".", "global_worker", ".", "check_connected", "(", ")", "for", "shard_index", "in", "range", "(", "len", "(", "ray", ".", "global_state", ".", "redis_clients", ")", ")", ":", "_flush_...
4eade036a0505e244c976f36aaa2d64386b5129b
train
flush_evicted_objects_unsafe
This removes some critical state from the Redis shards. In a multitenant environment, this will flush metadata for all jobs, which may be undesirable. This removes all of the metadata for objects that have been evicted. This can be used to try to address out-of-memory errors caused by the accumula...
python/ray/experimental/features.py
def flush_evicted_objects_unsafe(): """This removes some critical state from the Redis shards. In a multitenant environment, this will flush metadata for all jobs, which may be undesirable. This removes all of the metadata for objects that have been evicted. This can be used to try to address out-...
def flush_evicted_objects_unsafe(): """This removes some critical state from the Redis shards. In a multitenant environment, this will flush metadata for all jobs, which may be undesirable. This removes all of the metadata for objects that have been evicted. This can be used to try to address out-...
[ "This", "removes", "some", "critical", "state", "from", "the", "Redis", "shards", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/features.py#L172-L186
[ "def", "flush_evicted_objects_unsafe", "(", ")", ":", "ray", ".", "worker", ".", "global_worker", ".", "check_connected", "(", ")", "for", "shard_index", "in", "range", "(", "len", "(", "ray", ".", "global_state", ".", "redis_clients", ")", ")", ":", "_flush...
4eade036a0505e244c976f36aaa2d64386b5129b
train
PPOPolicyGraph.copy
Creates a copy of self using existing input placeholders.
python/ray/rllib/agents/ppo/ppo_policy_graph.py
def copy(self, existing_inputs): """Creates a copy of self using existing input placeholders.""" return PPOPolicyGraph( self.observation_space, self.action_space, self.config, existing_inputs=existing_inputs)
def copy(self, existing_inputs): """Creates a copy of self using existing input placeholders.""" return PPOPolicyGraph( self.observation_space, self.action_space, self.config, existing_inputs=existing_inputs)
[ "Creates", "a", "copy", "of", "self", "using", "existing", "input", "placeholders", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/ppo/ppo_policy_graph.py#L318-L324
[ "def", "copy", "(", "self", ",", "existing_inputs", ")", ":", "return", "PPOPolicyGraph", "(", "self", ".", "observation_space", ",", "self", ".", "action_space", ",", "self", ".", "config", ",", "existing_inputs", "=", "existing_inputs", ")" ]
4eade036a0505e244c976f36aaa2d64386b5129b
train
deepnn
deepnn builds the graph for a deep net for classifying digits. Args: x: an input tensor with the dimensions (N_examples, 784), where 784 is the number of pixels in a standard MNIST image. Returns: A tuple (y, keep_prob). y is a tensor of shape (N_examples, 10), with val...
examples/parameter_server/model.py
def deepnn(x): """deepnn builds the graph for a deep net for classifying digits. Args: x: an input tensor with the dimensions (N_examples, 784), where 784 is the number of pixels in a standard MNIST image. Returns: A tuple (y, keep_prob). y is a tensor of shape (N_examples, 10)...
def deepnn(x): """deepnn builds the graph for a deep net for classifying digits. Args: x: an input tensor with the dimensions (N_examples, 784), where 784 is the number of pixels in a standard MNIST image. Returns: A tuple (y, keep_prob). y is a tensor of shape (N_examples, 10)...
[ "deepnn", "builds", "the", "graph", "for", "a", "deep", "net", "for", "classifying", "digits", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/examples/parameter_server/model.py#L120-L180
[ "def", "deepnn", "(", "x", ")", ":", "# Reshape to use within a convolutional neural net.", "# Last dimension is for \"features\" - there is only one here, since images", "# are grayscale -- it would be 3 for an RGB image, 4 for RGBA, etc.", "with", "tf", ".", "name_scope", "(", "\"resha...
4eade036a0505e244c976f36aaa2d64386b5129b
train
get_signature_params
Get signature parameters Support Cython functions by grabbing relevant attributes from the Cython function and attaching to a no-op function. This is somewhat brittle, since funcsigs may change, but given that funcsigs is written to a PEP, we hope it is relatively stable. Future versions of Python may ...
python/ray/signature.py
def get_signature_params(func): """Get signature parameters Support Cython functions by grabbing relevant attributes from the Cython function and attaching to a no-op function. This is somewhat brittle, since funcsigs may change, but given that funcsigs is written to a PEP, we hope it is relatively...
def get_signature_params(func): """Get signature parameters Support Cython functions by grabbing relevant attributes from the Cython function and attaching to a no-op function. This is somewhat brittle, since funcsigs may change, but given that funcsigs is written to a PEP, we hope it is relatively...
[ "Get", "signature", "parameters" ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/signature.py#L39-L75
[ "def", "get_signature_params", "(", "func", ")", ":", "# The first condition for Cython functions, the latter for Cython instance", "# methods", "if", "is_cython", "(", "func", ")", ":", "attrs", "=", "[", "\"__code__\"", ",", "\"__annotations__\"", ",", "\"__defaults__\"",...
4eade036a0505e244c976f36aaa2d64386b5129b
train
check_signature_supported
Check if we support the signature of this function. We currently do not allow remote functions to have **kwargs. We also do not support keyword arguments in conjunction with a *args argument. Args: func: The function whose signature should be checked. warn: If this is true, a warning will ...
python/ray/signature.py
def check_signature_supported(func, warn=False): """Check if we support the signature of this function. We currently do not allow remote functions to have **kwargs. We also do not support keyword arguments in conjunction with a *args argument. Args: func: The function whose signature should be...
def check_signature_supported(func, warn=False): """Check if we support the signature of this function. We currently do not allow remote functions to have **kwargs. We also do not support keyword arguments in conjunction with a *args argument. Args: func: The function whose signature should be...
[ "Check", "if", "we", "support", "the", "signature", "of", "this", "function", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/signature.py#L78-L119
[ "def", "check_signature_supported", "(", "func", ",", "warn", "=", "False", ")", ":", "function_name", "=", "func", ".", "__name__", "sig_params", "=", "get_signature_params", "(", "func", ")", "has_kwargs_param", "=", "False", "has_kwonly_param", "=", "False", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
extract_signature
Extract the function signature from the function. Args: func: The function whose signature should be extracted. ignore_first: True if the first argument should be ignored. This should be used when func is a method of a class. Returns: A function signature object, which incl...
python/ray/signature.py
def extract_signature(func, ignore_first=False): """Extract the function signature from the function. Args: func: The function whose signature should be extracted. ignore_first: True if the first argument should be ignored. This should be used when func is a method of a class. ...
def extract_signature(func, ignore_first=False): """Extract the function signature from the function. Args: func: The function whose signature should be extracted. ignore_first: True if the first argument should be ignored. This should be used when func is a method of a class. ...
[ "Extract", "the", "function", "signature", "from", "the", "function", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/signature.py#L122-L157
[ "def", "extract_signature", "(", "func", ",", "ignore_first", "=", "False", ")", ":", "sig_params", "=", "get_signature_params", "(", "func", ")", "if", "ignore_first", ":", "if", "len", "(", "sig_params", ")", "==", "0", ":", "raise", "Exception", "(", "\...
4eade036a0505e244c976f36aaa2d64386b5129b
train
extend_args
Extend the arguments that were passed into a function. This extends the arguments that were passed into a function with the default arguments provided in the function definition. Args: function_signature: The function signature of the function being called. args: The non-keywor...
python/ray/signature.py
def extend_args(function_signature, args, kwargs): """Extend the arguments that were passed into a function. This extends the arguments that were passed into a function with the default arguments provided in the function definition. Args: function_signature: The function signature of the funct...
def extend_args(function_signature, args, kwargs): """Extend the arguments that were passed into a function. This extends the arguments that were passed into a function with the default arguments provided in the function definition. Args: function_signature: The function signature of the funct...
[ "Extend", "the", "arguments", "that", "were", "passed", "into", "a", "function", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/signature.py#L160-L222
[ "def", "extend_args", "(", "function_signature", ",", "args", ",", "kwargs", ")", ":", "arg_names", "=", "function_signature", ".", "arg_names", "arg_defaults", "=", "function_signature", ".", "arg_defaults", "arg_is_positionals", "=", "function_signature", ".", "arg_...
4eade036a0505e244c976f36aaa2d64386b5129b
train
wait_for_crm_operation
Poll for cloud resource manager operation until finished.
python/ray/autoscaler/gcp/config.py
def wait_for_crm_operation(operation): """Poll for cloud resource manager operation until finished.""" logger.info("wait_for_crm_operation: " "Waiting for operation {} to finish...".format(operation)) for _ in range(MAX_POLLS): result = crm.operations().get(name=operation["name"]).e...
def wait_for_crm_operation(operation): """Poll for cloud resource manager operation until finished.""" logger.info("wait_for_crm_operation: " "Waiting for operation {} to finish...".format(operation)) for _ in range(MAX_POLLS): result = crm.operations().get(name=operation["name"]).e...
[ "Poll", "for", "cloud", "resource", "manager", "operation", "until", "finished", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/gcp/config.py#L36-L52
[ "def", "wait_for_crm_operation", "(", "operation", ")", ":", "logger", ".", "info", "(", "\"wait_for_crm_operation: \"", "\"Waiting for operation {} to finish...\"", ".", "format", "(", "operation", ")", ")", "for", "_", "in", "range", "(", "MAX_POLLS", ")", ":", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
wait_for_compute_global_operation
Poll for global compute operation until finished.
python/ray/autoscaler/gcp/config.py
def wait_for_compute_global_operation(project_name, operation): """Poll for global compute operation until finished.""" logger.info("wait_for_compute_global_operation: " "Waiting for operation {} to finish...".format( operation["name"])) for _ in range(MAX_POLLS): ...
def wait_for_compute_global_operation(project_name, operation): """Poll for global compute operation until finished.""" logger.info("wait_for_compute_global_operation: " "Waiting for operation {} to finish...".format( operation["name"])) for _ in range(MAX_POLLS): ...
[ "Poll", "for", "global", "compute", "operation", "until", "finished", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/gcp/config.py#L55-L76
[ "def", "wait_for_compute_global_operation", "(", "project_name", ",", "operation", ")", ":", "logger", ".", "info", "(", "\"wait_for_compute_global_operation: \"", "\"Waiting for operation {} to finish...\"", ".", "format", "(", "operation", "[", "\"name\"", "]", ")", ")"...
4eade036a0505e244c976f36aaa2d64386b5129b
train
key_pair_name
Returns the ith default gcp_key_pair_name.
python/ray/autoscaler/gcp/config.py
def key_pair_name(i, region, project_id, ssh_user): """Returns the ith default gcp_key_pair_name.""" key_name = "{}_gcp_{}_{}_{}".format(RAY, region, project_id, ssh_user, i) return key_name
def key_pair_name(i, region, project_id, ssh_user): """Returns the ith default gcp_key_pair_name.""" key_name = "{}_gcp_{}_{}_{}".format(RAY, region, project_id, ssh_user, i) return key_name
[ "Returns", "the", "ith", "default", "gcp_key_pair_name", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/gcp/config.py#L79-L82
[ "def", "key_pair_name", "(", "i", ",", "region", ",", "project_id", ",", "ssh_user", ")", ":", "key_name", "=", "\"{}_gcp_{}_{}_{}\"", ".", "format", "(", "RAY", ",", "region", ",", "project_id", ",", "ssh_user", ",", "i", ")", "return", "key_name" ]
4eade036a0505e244c976f36aaa2d64386b5129b
train
key_pair_paths
Returns public and private key paths for a given key_name.
python/ray/autoscaler/gcp/config.py
def key_pair_paths(key_name): """Returns public and private key paths for a given key_name.""" public_key_path = os.path.expanduser("~/.ssh/{}.pub".format(key_name)) private_key_path = os.path.expanduser("~/.ssh/{}.pem".format(key_name)) return public_key_path, private_key_path
def key_pair_paths(key_name): """Returns public and private key paths for a given key_name.""" public_key_path = os.path.expanduser("~/.ssh/{}.pub".format(key_name)) private_key_path = os.path.expanduser("~/.ssh/{}.pem".format(key_name)) return public_key_path, private_key_path
[ "Returns", "public", "and", "private", "key", "paths", "for", "a", "given", "key_name", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/gcp/config.py#L85-L89
[ "def", "key_pair_paths", "(", "key_name", ")", ":", "public_key_path", "=", "os", ".", "path", ".", "expanduser", "(", "\"~/.ssh/{}.pub\"", ".", "format", "(", "key_name", ")", ")", "private_key_path", "=", "os", ".", "path", ".", "expanduser", "(", "\"~/.ss...
4eade036a0505e244c976f36aaa2d64386b5129b
train
generate_rsa_key_pair
Create public and private ssh-keys.
python/ray/autoscaler/gcp/config.py
def generate_rsa_key_pair(): """Create public and private ssh-keys.""" key = rsa.generate_private_key( backend=default_backend(), public_exponent=65537, key_size=2048) public_key = key.public_key().public_bytes( serialization.Encoding.OpenSSH, serialization.PublicFormat.OpenSSH).de...
def generate_rsa_key_pair(): """Create public and private ssh-keys.""" key = rsa.generate_private_key( backend=default_backend(), public_exponent=65537, key_size=2048) public_key = key.public_key().public_bytes( serialization.Encoding.OpenSSH, serialization.PublicFormat.OpenSSH).de...
[ "Create", "public", "and", "private", "ssh", "-", "keys", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/gcp/config.py#L92-L107
[ "def", "generate_rsa_key_pair", "(", ")", ":", "key", "=", "rsa", ".", "generate_private_key", "(", "backend", "=", "default_backend", "(", ")", ",", "public_exponent", "=", "65537", ",", "key_size", "=", "2048", ")", "public_key", "=", "key", ".", "public_k...
4eade036a0505e244c976f36aaa2d64386b5129b
train
_configure_project
Setup a Google Cloud Platform Project. Google Compute Platform organizes all the resources, such as storage buckets, users, and instances under projects. This is different from aws ec2 where everything is global.
python/ray/autoscaler/gcp/config.py
def _configure_project(config): """Setup a Google Cloud Platform Project. Google Compute Platform organizes all the resources, such as storage buckets, users, and instances under projects. This is different from aws ec2 where everything is global. """ project_id = config["provider"].get("projec...
def _configure_project(config): """Setup a Google Cloud Platform Project. Google Compute Platform organizes all the resources, such as storage buckets, users, and instances under projects. This is different from aws ec2 where everything is global. """ project_id = config["provider"].get("projec...
[ "Setup", "a", "Google", "Cloud", "Platform", "Project", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/gcp/config.py#L119-L144
[ "def", "_configure_project", "(", "config", ")", ":", "project_id", "=", "config", "[", "\"provider\"", "]", ".", "get", "(", "\"project_id\"", ")", "assert", "config", "[", "\"provider\"", "]", "[", "\"project_id\"", "]", "is", "not", "None", ",", "(", "\...
4eade036a0505e244c976f36aaa2d64386b5129b
train
_configure_iam_role
Setup a gcp service account with IAM roles. Creates a gcp service acconut and binds IAM roles which allow it to control control storage/compute services. Specifically, the head node needs to have an IAM role that allows it to create further gce instances and store items in google cloud storage. TO...
python/ray/autoscaler/gcp/config.py
def _configure_iam_role(config): """Setup a gcp service account with IAM roles. Creates a gcp service acconut and binds IAM roles which allow it to control control storage/compute services. Specifically, the head node needs to have an IAM role that allows it to create further gce instances and store it...
def _configure_iam_role(config): """Setup a gcp service account with IAM roles. Creates a gcp service acconut and binds IAM roles which allow it to control control storage/compute services. Specifically, the head node needs to have an IAM role that allows it to create further gce instances and store it...
[ "Setup", "a", "gcp", "service", "account", "with", "IAM", "roles", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/gcp/config.py#L147-L183
[ "def", "_configure_iam_role", "(", "config", ")", ":", "email", "=", "SERVICE_ACCOUNT_EMAIL_TEMPLATE", ".", "format", "(", "account_id", "=", "DEFAULT_SERVICE_ACCOUNT_ID", ",", "project_id", "=", "config", "[", "\"provider\"", "]", "[", "\"project_id\"", "]", ")", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
_configure_key_pair
Configure SSH access, using an existing key pair if possible. Creates a project-wide ssh key that can be used to access all the instances unless explicitly prohibited by instance config. The ssh-keys created by ray are of format: [USERNAME]:ssh-rsa [KEY_VALUE] [USERNAME] where: [USERNAM...
python/ray/autoscaler/gcp/config.py
def _configure_key_pair(config): """Configure SSH access, using an existing key pair if possible. Creates a project-wide ssh key that can be used to access all the instances unless explicitly prohibited by instance config. The ssh-keys created by ray are of format: [USERNAME]:ssh-rsa [KEY_VALUE...
def _configure_key_pair(config): """Configure SSH access, using an existing key pair if possible. Creates a project-wide ssh key that can be used to access all the instances unless explicitly prohibited by instance config. The ssh-keys created by ray are of format: [USERNAME]:ssh-rsa [KEY_VALUE...
[ "Configure", "SSH", "access", "using", "an", "existing", "key", "pair", "if", "possible", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/gcp/config.py#L186-L269
[ "def", "_configure_key_pair", "(", "config", ")", ":", "if", "\"ssh_private_key\"", "in", "config", "[", "\"auth\"", "]", ":", "return", "config", "ssh_user", "=", "config", "[", "\"auth\"", "]", "[", "\"ssh_user\"", "]", "project", "=", "compute", ".", "pro...
4eade036a0505e244c976f36aaa2d64386b5129b
train
_configure_subnet
Pick a reasonable subnet if not specified by the config.
python/ray/autoscaler/gcp/config.py
def _configure_subnet(config): """Pick a reasonable subnet if not specified by the config.""" # Rationale: avoid subnet lookup if the network is already # completely manually configured if ("networkInterfaces" in config["head_node"] and "networkInterfaces" in config["worker_nodes"]): ...
def _configure_subnet(config): """Pick a reasonable subnet if not specified by the config.""" # Rationale: avoid subnet lookup if the network is already # completely manually configured if ("networkInterfaces" in config["head_node"] and "networkInterfaces" in config["worker_nodes"]): ...
[ "Pick", "a", "reasonable", "subnet", "if", "not", "specified", "by", "the", "config", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/gcp/config.py#L272-L309
[ "def", "_configure_subnet", "(", "config", ")", ":", "# Rationale: avoid subnet lookup if the network is already", "# completely manually configured", "if", "(", "\"networkInterfaces\"", "in", "config", "[", "\"head_node\"", "]", "and", "\"networkInterfaces\"", "in", "config", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
_add_iam_policy_binding
Add new IAM roles for the service account.
python/ray/autoscaler/gcp/config.py
def _add_iam_policy_binding(service_account, roles): """Add new IAM roles for the service account.""" project_id = service_account["projectId"] email = service_account["email"] member_id = "serviceAccount:" + email policy = crm.projects().getIamPolicy(resource=project_id).execute() already_con...
def _add_iam_policy_binding(service_account, roles): """Add new IAM roles for the service account.""" project_id = service_account["projectId"] email = service_account["email"] member_id = "serviceAccount:" + email policy = crm.projects().getIamPolicy(resource=project_id).execute() already_con...
[ "Add", "new", "IAM", "roles", "for", "the", "service", "account", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/gcp/config.py#L380-L416
[ "def", "_add_iam_policy_binding", "(", "service_account", ",", "roles", ")", ":", "project_id", "=", "service_account", "[", "\"projectId\"", "]", "email", "=", "service_account", "[", "\"email\"", "]", "member_id", "=", "\"serviceAccount:\"", "+", "email", "policy"...
4eade036a0505e244c976f36aaa2d64386b5129b
train
_create_project_ssh_key_pair
Inserts an ssh-key into project commonInstanceMetadata
python/ray/autoscaler/gcp/config.py
def _create_project_ssh_key_pair(project, public_key, ssh_user): """Inserts an ssh-key into project commonInstanceMetadata""" key_parts = public_key.split(" ") # Sanity checks to make sure that the generated key matches expectation assert len(key_parts) == 2, key_parts assert key_parts[0] == "ssh-...
def _create_project_ssh_key_pair(project, public_key, ssh_user): """Inserts an ssh-key into project commonInstanceMetadata""" key_parts = public_key.split(" ") # Sanity checks to make sure that the generated key matches expectation assert len(key_parts) == 2, key_parts assert key_parts[0] == "ssh-...
[ "Inserts", "an", "ssh", "-", "key", "into", "project", "commonInstanceMetadata" ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/gcp/config.py#L419-L451
[ "def", "_create_project_ssh_key_pair", "(", "project", ",", "public_key", ",", "ssh_user", ")", ":", "key_parts", "=", "public_key", ".", "split", "(", "\" \"", ")", "# Sanity checks to make sure that the generated key matches expectation", "assert", "len", "(", "key_part...
4eade036a0505e244c976f36aaa2d64386b5129b
train
RemoteFunction._remote
An experimental alternate way to submit remote functions.
python/ray/remote_function.py
def _remote(self, args=None, kwargs=None, num_return_vals=None, num_cpus=None, num_gpus=None, resources=None): """An experimental alternate way to submit remote functions.""" worker = ray.worker.get_global_wo...
def _remote(self, args=None, kwargs=None, num_return_vals=None, num_cpus=None, num_gpus=None, resources=None): """An experimental alternate way to submit remote functions.""" worker = ray.worker.get_global_wo...
[ "An", "experimental", "alternate", "way", "to", "submit", "remote", "functions", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/remote_function.py#L92-L135
[ "def", "_remote", "(", "self", ",", "args", "=", "None", ",", "kwargs", "=", "None", ",", "num_return_vals", "=", "None", ",", "num_cpus", "=", "None", ",", "num_gpus", "=", "None", ",", "resources", "=", "None", ")", ":", "worker", "=", "ray", ".", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
PlasmaObjectLinkedList.append
Append an object to the linked list. Args: future (PlasmaObjectFuture): A PlasmaObjectFuture instance.
python/ray/experimental/async_plasma.py
def append(self, future): """Append an object to the linked list. Args: future (PlasmaObjectFuture): A PlasmaObjectFuture instance. """ future.prev = self.tail if self.tail is None: assert self.head is None self.head = future else: ...
def append(self, future): """Append an object to the linked list. Args: future (PlasmaObjectFuture): A PlasmaObjectFuture instance. """ future.prev = self.tail if self.tail is None: assert self.head is None self.head = future else: ...
[ "Append", "an", "object", "to", "the", "linked", "list", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/async_plasma.py#L97-L111
[ "def", "append", "(", "self", ",", "future", ")", ":", "future", ".", "prev", "=", "self", ".", "tail", "if", "self", ".", "tail", "is", "None", ":", "assert", "self", ".", "head", "is", "None", "self", ".", "head", "=", "future", "else", ":", "s...
4eade036a0505e244c976f36aaa2d64386b5129b
train
PlasmaObjectLinkedList.remove
Remove an object from the linked list. Args: future (PlasmaObjectFuture): A PlasmaObjectFuture instance.
python/ray/experimental/async_plasma.py
def remove(self, future): """Remove an object from the linked list. Args: future (PlasmaObjectFuture): A PlasmaObjectFuture instance. """ if self._loop.get_debug(): logger.debug("Removing %s from the linked list.", future) if future.prev is None: ...
def remove(self, future): """Remove an object from the linked list. Args: future (PlasmaObjectFuture): A PlasmaObjectFuture instance. """ if self._loop.get_debug(): logger.debug("Removing %s from the linked list.", future) if future.prev is None: ...
[ "Remove", "an", "object", "from", "the", "linked", "list", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/async_plasma.py#L113-L138
[ "def", "remove", "(", "self", ",", "future", ")", ":", "if", "self", ".", "_loop", ".", "get_debug", "(", ")", ":", "logger", ".", "debug", "(", "\"Removing %s from the linked list.\"", ",", "future", ")", "if", "future", ".", "prev", "is", "None", ":", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
PlasmaObjectLinkedList.cancel
Manually cancel all tasks assigned to this event loop.
python/ray/experimental/async_plasma.py
def cancel(self, *args, **kwargs): """Manually cancel all tasks assigned to this event loop.""" # Because remove all futures will trigger `set_result`, # we cancel itself first. super().cancel() for future in self.traverse(): # All cancelled futures should have callba...
def cancel(self, *args, **kwargs): """Manually cancel all tasks assigned to this event loop.""" # Because remove all futures will trigger `set_result`, # we cancel itself first. super().cancel() for future in self.traverse(): # All cancelled futures should have callba...
[ "Manually", "cancel", "all", "tasks", "assigned", "to", "this", "event", "loop", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/async_plasma.py#L140-L150
[ "def", "cancel", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Because remove all futures will trigger `set_result`,", "# we cancel itself first.", "super", "(", ")", ".", "cancel", "(", ")", "for", "future", "in", "self", ".", "traverse",...
4eade036a0505e244c976f36aaa2d64386b5129b
train
PlasmaObjectLinkedList.set_result
Complete all tasks.
python/ray/experimental/async_plasma.py
def set_result(self, result): """Complete all tasks. """ for future in self.traverse(): # All cancelled futures should have callbacks to removed itself # from this linked list. However, these callbacks are scheduled in # an event loop, so we could still find them in o...
def set_result(self, result): """Complete all tasks. """ for future in self.traverse(): # All cancelled futures should have callbacks to removed itself # from this linked list. However, these callbacks are scheduled in # an event loop, so we could still find them in o...
[ "Complete", "all", "tasks", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/async_plasma.py#L152-L160
[ "def", "set_result", "(", "self", ",", "result", ")", ":", "for", "future", "in", "self", ".", "traverse", "(", ")", ":", "# All cancelled futures should have callbacks to removed itself", "# from this linked list. However, these callbacks are scheduled in", "# an event loop, s...
4eade036a0505e244c976f36aaa2d64386b5129b
train
PlasmaObjectLinkedList.traverse
Traverse this linked list. Yields: PlasmaObjectFuture: PlasmaObjectFuture instances.
python/ray/experimental/async_plasma.py
def traverse(self): """Traverse this linked list. Yields: PlasmaObjectFuture: PlasmaObjectFuture instances. """ current = self.head while current is not None: yield current current = current.next
def traverse(self): """Traverse this linked list. Yields: PlasmaObjectFuture: PlasmaObjectFuture instances. """ current = self.head while current is not None: yield current current = current.next
[ "Traverse", "this", "linked", "list", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/async_plasma.py#L162-L171
[ "def", "traverse", "(", "self", ")", ":", "current", "=", "self", ".", "head", "while", "current", "is", "not", "None", ":", "yield", "current", "current", "=", "current", ".", "next" ]
4eade036a0505e244c976f36aaa2d64386b5129b
train
PlasmaEventHandler.process_notifications
Process notifications.
python/ray/experimental/async_plasma.py
def process_notifications(self, messages): """Process notifications.""" for object_id, object_size, metadata_size in messages: if object_size > 0 and object_id in self._waiting_dict: linked_list = self._waiting_dict[object_id] self._complete_future(linked_list...
def process_notifications(self, messages): """Process notifications.""" for object_id, object_size, metadata_size in messages: if object_size > 0 and object_id in self._waiting_dict: linked_list = self._waiting_dict[object_id] self._complete_future(linked_list...
[ "Process", "notifications", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/async_plasma.py#L183-L188
[ "def", "process_notifications", "(", "self", ",", "messages", ")", ":", "for", "object_id", ",", "object_size", ",", "metadata_size", "in", "messages", ":", "if", "object_size", ">", "0", "and", "object_id", "in", "self", ".", "_waiting_dict", ":", "linked_lis...
4eade036a0505e244c976f36aaa2d64386b5129b
train
PlasmaEventHandler.as_future
Turn an object_id into a Future object. Args: object_id: A Ray's object_id. check_ready (bool): If true, check if the object_id is ready. Returns: PlasmaObjectFuture: A future object that waits the object_id.
python/ray/experimental/async_plasma.py
def as_future(self, object_id, check_ready=True): """Turn an object_id into a Future object. Args: object_id: A Ray's object_id. check_ready (bool): If true, check if the object_id is ready. Returns: PlasmaObjectFuture: A future object that waits the object_...
def as_future(self, object_id, check_ready=True): """Turn an object_id into a Future object. Args: object_id: A Ray's object_id. check_ready (bool): If true, check if the object_id is ready. Returns: PlasmaObjectFuture: A future object that waits the object_...
[ "Turn", "an", "object_id", "into", "a", "Future", "object", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/async_plasma.py#L205-L237
[ "def", "as_future", "(", "self", ",", "object_id", ",", "check_ready", "=", "True", ")", ":", "if", "not", "isinstance", "(", "object_id", ",", "ray", ".", "ObjectID", ")", ":", "raise", "TypeError", "(", "\"Input should be an ObjectID.\"", ")", "plain_object_...
4eade036a0505e244c976f36aaa2d64386b5129b
train
TuneClient.get_all_trials
Returns a list of all trials' information.
python/ray/tune/web_server.py
def get_all_trials(self): """Returns a list of all trials' information.""" response = requests.get(urljoin(self._path, "trials")) return self._deserialize(response)
def get_all_trials(self): """Returns a list of all trials' information.""" response = requests.get(urljoin(self._path, "trials")) return self._deserialize(response)
[ "Returns", "a", "list", "of", "all", "trials", "information", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/web_server.py#L48-L51
[ "def", "get_all_trials", "(", "self", ")", ":", "response", "=", "requests", ".", "get", "(", "urljoin", "(", "self", ".", "_path", ",", "\"trials\"", ")", ")", "return", "self", ".", "_deserialize", "(", "response", ")" ]
4eade036a0505e244c976f36aaa2d64386b5129b
train
TuneClient.get_trial
Returns trial information by trial_id.
python/ray/tune/web_server.py
def get_trial(self, trial_id): """Returns trial information by trial_id.""" response = requests.get( urljoin(self._path, "trials/{}".format(trial_id))) return self._deserialize(response)
def get_trial(self, trial_id): """Returns trial information by trial_id.""" response = requests.get( urljoin(self._path, "trials/{}".format(trial_id))) return self._deserialize(response)
[ "Returns", "trial", "information", "by", "trial_id", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/web_server.py#L53-L57
[ "def", "get_trial", "(", "self", ",", "trial_id", ")", ":", "response", "=", "requests", ".", "get", "(", "urljoin", "(", "self", ".", "_path", ",", "\"trials/{}\"", ".", "format", "(", "trial_id", ")", ")", ")", "return", "self", ".", "_deserialize", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
TuneClient.add_trial
Adds a trial by name and specification (dict).
python/ray/tune/web_server.py
def add_trial(self, name, specification): """Adds a trial by name and specification (dict).""" payload = {"name": name, "spec": specification} response = requests.post(urljoin(self._path, "trials"), json=payload) return self._deserialize(response)
def add_trial(self, name, specification): """Adds a trial by name and specification (dict).""" payload = {"name": name, "spec": specification} response = requests.post(urljoin(self._path, "trials"), json=payload) return self._deserialize(response)
[ "Adds", "a", "trial", "by", "name", "and", "specification", "(", "dict", ")", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/web_server.py#L59-L63
[ "def", "add_trial", "(", "self", ",", "name", ",", "specification", ")", ":", "payload", "=", "{", "\"name\"", ":", "name", ",", "\"spec\"", ":", "specification", "}", "response", "=", "requests", ".", "post", "(", "urljoin", "(", "self", ".", "_path", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
TuneClient.stop_trial
Requests to stop trial by trial_id.
python/ray/tune/web_server.py
def stop_trial(self, trial_id): """Requests to stop trial by trial_id.""" response = requests.put( urljoin(self._path, "trials/{}".format(trial_id))) return self._deserialize(response)
def stop_trial(self, trial_id): """Requests to stop trial by trial_id.""" response = requests.put( urljoin(self._path, "trials/{}".format(trial_id))) return self._deserialize(response)
[ "Requests", "to", "stop", "trial", "by", "trial_id", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/web_server.py#L65-L69
[ "def", "stop_trial", "(", "self", ",", "trial_id", ")", ":", "response", "=", "requests", ".", "put", "(", "urljoin", "(", "self", ".", "_path", ",", "\"trials/{}\"", ".", "format", "(", "trial_id", ")", ")", ")", "return", "self", ".", "_deserialize", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
DistributedSGD.foreach_worker
Apply the given function to each remote worker. Returns: List of results from applying the function.
python/ray/experimental/sgd/sgd.py
def foreach_worker(self, fn): """Apply the given function to each remote worker. Returns: List of results from applying the function. """ results = ray.get([w.foreach_worker.remote(fn) for w in self.workers]) return results
def foreach_worker(self, fn): """Apply the given function to each remote worker. Returns: List of results from applying the function. """ results = ray.get([w.foreach_worker.remote(fn) for w in self.workers]) return results
[ "Apply", "the", "given", "function", "to", "each", "remote", "worker", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/sgd.py#L130-L137
[ "def", "foreach_worker", "(", "self", ",", "fn", ")", ":", "results", "=", "ray", ".", "get", "(", "[", "w", ".", "foreach_worker", ".", "remote", "(", "fn", ")", "for", "w", "in", "self", ".", "workers", "]", ")", "return", "results" ]
4eade036a0505e244c976f36aaa2d64386b5129b
train
DistributedSGD.foreach_model
Apply the given function to each model replica in each worker. Returns: List of results from applying the function.
python/ray/experimental/sgd/sgd.py
def foreach_model(self, fn): """Apply the given function to each model replica in each worker. Returns: List of results from applying the function. """ results = ray.get([w.foreach_model.remote(fn) for w in self.workers]) out = [] for r in results: ...
def foreach_model(self, fn): """Apply the given function to each model replica in each worker. Returns: List of results from applying the function. """ results = ray.get([w.foreach_model.remote(fn) for w in self.workers]) out = [] for r in results: ...
[ "Apply", "the", "given", "function", "to", "each", "model", "replica", "in", "each", "worker", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/sgd.py#L139-L150
[ "def", "foreach_model", "(", "self", ",", "fn", ")", ":", "results", "=", "ray", ".", "get", "(", "[", "w", ".", "foreach_model", ".", "remote", "(", "fn", ")", "for", "w", "in", "self", ".", "workers", "]", ")", "out", "=", "[", "]", "for", "r...
4eade036a0505e244c976f36aaa2d64386b5129b
train
DistributedSGD.for_model
Apply the given function to a single model replica. Returns: Result from applying the function.
python/ray/experimental/sgd/sgd.py
def for_model(self, fn): """Apply the given function to a single model replica. Returns: Result from applying the function. """ return ray.get(self.workers[0].for_model.remote(fn))
def for_model(self, fn): """Apply the given function to a single model replica. Returns: Result from applying the function. """ return ray.get(self.workers[0].for_model.remote(fn))
[ "Apply", "the", "given", "function", "to", "a", "single", "model", "replica", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/sgd.py#L152-L158
[ "def", "for_model", "(", "self", ",", "fn", ")", ":", "return", "ray", ".", "get", "(", "self", ".", "workers", "[", "0", "]", ".", "for_model", ".", "remote", "(", "fn", ")", ")" ]
4eade036a0505e244c976f36aaa2d64386b5129b
train
DistributedSGD.step
Run a single SGD step. Arguments: fetch_stats (bool): Whether to return stats from the step. This can slow down the computation by acting as a global barrier.
python/ray/experimental/sgd/sgd.py
def step(self, fetch_stats=False): """Run a single SGD step. Arguments: fetch_stats (bool): Whether to return stats from the step. This can slow down the computation by acting as a global barrier. """ if self.strategy == "ps": return _distributed_...
def step(self, fetch_stats=False): """Run a single SGD step. Arguments: fetch_stats (bool): Whether to return stats from the step. This can slow down the computation by acting as a global barrier. """ if self.strategy == "ps": return _distributed_...
[ "Run", "a", "single", "SGD", "step", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/sgd.py#L160-L174
[ "def", "step", "(", "self", ",", "fetch_stats", "=", "False", ")", ":", "if", "self", ".", "strategy", "==", "\"ps\"", ":", "return", "_distributed_sgd_step", "(", "self", ".", "workers", ",", "self", ".", "ps_list", ",", "write_timeline", "=", "False", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
start_router
Wrapper for starting a router and register it. Args: router_class: The router class to instantiate. router_name: The name to give to the router. Returns: A handle to newly started router actor.
python/ray/experimental/serve/router/__init__.py
def start_router(router_class, router_name): """Wrapper for starting a router and register it. Args: router_class: The router class to instantiate. router_name: The name to give to the router. Returns: A handle to newly started router actor. """ handle = router_class.remote...
def start_router(router_class, router_name): """Wrapper for starting a router and register it. Args: router_class: The router class to instantiate. router_name: The name to give to the router. Returns: A handle to newly started router actor. """ handle = router_class.remote...
[ "Wrapper", "for", "starting", "a", "router", "and", "register", "it", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/serve/router/__init__.py#L10-L23
[ "def", "start_router", "(", "router_class", ",", "router_name", ")", ":", "handle", "=", "router_class", ".", "remote", "(", "router_name", ")", "ray", ".", "experimental", ".", "register_actor", "(", "router_name", ",", "handle", ")", "handle", ".", "start", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
SearchSpace.generate_random_one_hot_encoding
Returns a list of one-hot encodings for all parameters. 1 one-hot np.array for 1 parameter, and the 1's place is randomly chosen.
python/ray/tune/automl/search_space.py
def generate_random_one_hot_encoding(self): """Returns a list of one-hot encodings for all parameters. 1 one-hot np.array for 1 parameter, and the 1's place is randomly chosen. """ encoding = [] for ps in self.param_list: one_hot = np.zeros(ps.choices_count()...
def generate_random_one_hot_encoding(self): """Returns a list of one-hot encodings for all parameters. 1 one-hot np.array for 1 parameter, and the 1's place is randomly chosen. """ encoding = [] for ps in self.param_list: one_hot = np.zeros(ps.choices_count()...
[ "Returns", "a", "list", "of", "one", "-", "hot", "encodings", "for", "all", "parameters", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automl/search_space.py#L153-L165
[ "def", "generate_random_one_hot_encoding", "(", "self", ")", ":", "encoding", "=", "[", "]", "for", "ps", "in", "self", ".", "param_list", ":", "one_hot", "=", "np", ".", "zeros", "(", "ps", ".", "choices_count", "(", ")", ")", "choice", "=", "random", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
SearchSpace.apply_one_hot_encoding
Apply one hot encoding to generate a specific config. Arguments: one_hot_encoding (list): A list of one hot encodings, 1 for each parameter. The shape of each encoding should match that ``ParameterSpace`` Returns: A dict config with specific <na...
python/ray/tune/automl/search_space.py
def apply_one_hot_encoding(self, one_hot_encoding): """Apply one hot encoding to generate a specific config. Arguments: one_hot_encoding (list): A list of one hot encodings, 1 for each parameter. The shape of each encoding should match that ``ParameterSpace`...
def apply_one_hot_encoding(self, one_hot_encoding): """Apply one hot encoding to generate a specific config. Arguments: one_hot_encoding (list): A list of one hot encodings, 1 for each parameter. The shape of each encoding should match that ``ParameterSpace`...
[ "Apply", "one", "hot", "encoding", "to", "generate", "a", "specific", "config", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automl/search_space.py#L167-L183
[ "def", "apply_one_hot_encoding", "(", "self", ",", "one_hot_encoding", ")", ":", "config", "=", "{", "}", "for", "ps", ",", "one_hot", "in", "zip", "(", "self", ".", "param_list", ",", "one_hot_encoding", ")", ":", "index", "=", "np", ".", "argmax", "(",...
4eade036a0505e244c976f36aaa2d64386b5129b
train
pin_in_object_store
Pin an object in the object store. It will be available as long as the pinning process is alive. The pinned object can be retrieved by calling get_pinned_object on the identifier returned by this call.
python/ray/tune/util.py
def pin_in_object_store(obj): """Pin an object in the object store. It will be available as long as the pinning process is alive. The pinned object can be retrieved by calling get_pinned_object on the identifier returned by this call. """ obj_id = ray.put(_to_pinnable(obj)) _pinned_objects...
def pin_in_object_store(obj): """Pin an object in the object store. It will be available as long as the pinning process is alive. The pinned object can be retrieved by calling get_pinned_object on the identifier returned by this call. """ obj_id = ray.put(_to_pinnable(obj)) _pinned_objects...
[ "Pin", "an", "object", "in", "the", "object", "store", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/util.py#L19-L30
[ "def", "pin_in_object_store", "(", "obj", ")", ":", "obj_id", "=", "ray", ".", "put", "(", "_to_pinnable", "(", "obj", ")", ")", "_pinned_objects", ".", "append", "(", "ray", ".", "get", "(", "obj_id", ")", ")", "return", "\"{}{}\"", ".", "format", "("...
4eade036a0505e244c976f36aaa2d64386b5129b
train
get_pinned_object
Retrieve a pinned object from the object store.
python/ray/tune/util.py
def get_pinned_object(pinned_id): """Retrieve a pinned object from the object store.""" from ray import ObjectID return _from_pinnable( ray.get( ObjectID(base64.b64decode(pinned_id[len(PINNED_OBJECT_PREFIX):]))))
def get_pinned_object(pinned_id): """Retrieve a pinned object from the object store.""" from ray import ObjectID return _from_pinnable( ray.get( ObjectID(base64.b64decode(pinned_id[len(PINNED_OBJECT_PREFIX):]))))
[ "Retrieve", "a", "pinned", "object", "from", "the", "object", "store", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/util.py#L33-L40
[ "def", "get_pinned_object", "(", "pinned_id", ")", ":", "from", "ray", "import", "ObjectID", "return", "_from_pinnable", "(", "ray", ".", "get", "(", "ObjectID", "(", "base64", ".", "b64decode", "(", "pinned_id", "[", "len", "(", "PINNED_OBJECT_PREFIX", ")", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
merge_dicts
Returns a new dict that is d1 and d2 deep merged.
python/ray/tune/util.py
def merge_dicts(d1, d2): """Returns a new dict that is d1 and d2 deep merged.""" merged = copy.deepcopy(d1) deep_update(merged, d2, True, []) return merged
def merge_dicts(d1, d2): """Returns a new dict that is d1 and d2 deep merged.""" merged = copy.deepcopy(d1) deep_update(merged, d2, True, []) return merged
[ "Returns", "a", "new", "dict", "that", "is", "d1", "and", "d2", "deep", "merged", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/util.py#L65-L69
[ "def", "merge_dicts", "(", "d1", ",", "d2", ")", ":", "merged", "=", "copy", ".", "deepcopy", "(", "d1", ")", "deep_update", "(", "merged", ",", "d2", ",", "True", ",", "[", "]", ")", "return", "merged" ]
4eade036a0505e244c976f36aaa2d64386b5129b
train
deep_update
Updates original dict with values from new_dict recursively. If new key is introduced in new_dict, then if new_keys_allowed is not True, an error will be thrown. Further, for sub-dicts, if the key is in the whitelist, then new subkeys can be introduced. Args: original (dict): Dictionary with de...
python/ray/tune/util.py
def deep_update(original, new_dict, new_keys_allowed, whitelist): """Updates original dict with values from new_dict recursively. If new key is introduced in new_dict, then if new_keys_allowed is not True, an error will be thrown. Further, for sub-dicts, if the key is in the whitelist, then new subkeys ...
def deep_update(original, new_dict, new_keys_allowed, whitelist): """Updates original dict with values from new_dict recursively. If new key is introduced in new_dict, then if new_keys_allowed is not True, an error will be thrown. Further, for sub-dicts, if the key is in the whitelist, then new subkeys ...
[ "Updates", "original", "dict", "with", "values", "from", "new_dict", "recursively", ".", "If", "new", "key", "is", "introduced", "in", "new_dict", "then", "if", "new_keys_allowed", "is", "not", "True", "an", "error", "will", "be", "thrown", ".", "Further", "...
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/util.py#L72-L97
[ "def", "deep_update", "(", "original", ",", "new_dict", ",", "new_keys_allowed", ",", "whitelist", ")", ":", "for", "k", ",", "value", "in", "new_dict", ".", "items", "(", ")", ":", "if", "k", "not", "in", "original", ":", "if", "not", "new_keys_allowed"...
4eade036a0505e244c976f36aaa2d64386b5129b
train
TaskPool.completed_prefetch
Similar to completed but only returns once the object is local. Assumes obj_id only is one id.
python/ray/rllib/utils/actors.py
def completed_prefetch(self, blocking_wait=False, max_yield=999): """Similar to completed but only returns once the object is local. Assumes obj_id only is one id.""" for worker, obj_id in self.completed(blocking_wait=blocking_wait): plasma_id = ray.pyarrow.plasma.ObjectID(obj_id.b...
def completed_prefetch(self, blocking_wait=False, max_yield=999): """Similar to completed but only returns once the object is local. Assumes obj_id only is one id.""" for worker, obj_id in self.completed(blocking_wait=blocking_wait): plasma_id = ray.pyarrow.plasma.ObjectID(obj_id.b...
[ "Similar", "to", "completed", "but", "only", "returns", "once", "the", "object", "is", "local", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/utils/actors.py#L37-L59
[ "def", "completed_prefetch", "(", "self", ",", "blocking_wait", "=", "False", ",", "max_yield", "=", "999", ")", ":", "for", "worker", ",", "obj_id", "in", "self", ".", "completed", "(", "blocking_wait", "=", "blocking_wait", ")", ":", "plasma_id", "=", "r...
4eade036a0505e244c976f36aaa2d64386b5129b
train
TaskPool.reset_evaluators
Notify that some evaluators may be removed.
python/ray/rllib/utils/actors.py
def reset_evaluators(self, evaluators): """Notify that some evaluators may be removed.""" for obj_id, ev in self._tasks.copy().items(): if ev not in evaluators: del self._tasks[obj_id] del self._objects[obj_id] ok = [] for ev, obj_id in self._f...
def reset_evaluators(self, evaluators): """Notify that some evaluators may be removed.""" for obj_id, ev in self._tasks.copy().items(): if ev not in evaluators: del self._tasks[obj_id] del self._objects[obj_id] ok = [] for ev, obj_id in self._f...
[ "Notify", "that", "some", "evaluators", "may", "be", "removed", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/utils/actors.py#L61-L71
[ "def", "reset_evaluators", "(", "self", ",", "evaluators", ")", ":", "for", "obj_id", ",", "ev", "in", "self", ".", "_tasks", ".", "copy", "(", ")", ".", "items", "(", ")", ":", "if", "ev", "not", "in", "evaluators", ":", "del", "self", ".", "_task...
4eade036a0505e244c976f36aaa2d64386b5129b
train
AggregationWorkerBase.iter_train_batches
Iterate over train batches. Arguments: max_yield (int): Max number of batches to iterate over in this cycle. Setting this avoids iter_train_batches returning too much data at once.
python/ray/rllib/optimizers/aso_aggregator.py
def iter_train_batches(self, max_yield=999): """Iterate over train batches. Arguments: max_yield (int): Max number of batches to iterate over in this cycle. Setting this avoids iter_train_batches returning too much data at once. """ for ev, s...
def iter_train_batches(self, max_yield=999): """Iterate over train batches. Arguments: max_yield (int): Max number of batches to iterate over in this cycle. Setting this avoids iter_train_batches returning too much data at once. """ for ev, s...
[ "Iterate", "over", "train", "batches", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/optimizers/aso_aggregator.py#L92-L131
[ "def", "iter_train_batches", "(", "self", ",", "max_yield", "=", "999", ")", ":", "for", "ev", ",", "sample_batch", "in", "self", ".", "_augment_with_replay", "(", "self", ".", "sample_tasks", ".", "completed_prefetch", "(", "blocking_wait", "=", "True", ",", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
create_or_update_cluster
Create or updates an autoscaling Ray cluster from a config json.
python/ray/autoscaler/commands.py
def create_or_update_cluster(config_file, override_min_workers, override_max_workers, no_restart, restart_only, yes, override_cluster_name): """Create or updates an autoscaling Ray cluster from a config json.""" config = yaml.load(open(config_file).read(...
def create_or_update_cluster(config_file, override_min_workers, override_max_workers, no_restart, restart_only, yes, override_cluster_name): """Create or updates an autoscaling Ray cluster from a config json.""" config = yaml.load(open(config_file).read(...
[ "Create", "or", "updates", "an", "autoscaling", "Ray", "cluster", "from", "a", "config", "json", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/commands.py#L34-L47
[ "def", "create_or_update_cluster", "(", "config_file", ",", "override_min_workers", ",", "override_max_workers", ",", "no_restart", ",", "restart_only", ",", "yes", ",", "override_cluster_name", ")", ":", "config", "=", "yaml", ".", "load", "(", "open", "(", "conf...
4eade036a0505e244c976f36aaa2d64386b5129b
train
teardown_cluster
Destroys all nodes of a Ray cluster described by a config json.
python/ray/autoscaler/commands.py
def teardown_cluster(config_file, yes, workers_only, override_cluster_name): """Destroys all nodes of a Ray cluster described by a config json.""" config = yaml.load(open(config_file).read()) if override_cluster_name is not None: config["cluster_name"] = override_cluster_name validate_config(co...
def teardown_cluster(config_file, yes, workers_only, override_cluster_name): """Destroys all nodes of a Ray cluster described by a config json.""" config = yaml.load(open(config_file).read()) if override_cluster_name is not None: config["cluster_name"] = override_cluster_name validate_config(co...
[ "Destroys", "all", "nodes", "of", "a", "Ray", "cluster", "described", "by", "a", "config", "json", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/commands.py#L73-L116
[ "def", "teardown_cluster", "(", "config_file", ",", "yes", ",", "workers_only", ",", "override_cluster_name", ")", ":", "config", "=", "yaml", ".", "load", "(", "open", "(", "config_file", ")", ".", "read", "(", ")", ")", "if", "override_cluster_name", "is",...
4eade036a0505e244c976f36aaa2d64386b5129b
train
kill_node
Kills a random Raylet worker.
python/ray/autoscaler/commands.py
def kill_node(config_file, yes, override_cluster_name): """Kills a random Raylet worker.""" config = yaml.load(open(config_file).read()) if override_cluster_name is not None: config["cluster_name"] = override_cluster_name config = _bootstrap_config(config) confirm("This will kill a node in...
def kill_node(config_file, yes, override_cluster_name): """Kills a random Raylet worker.""" config = yaml.load(open(config_file).read()) if override_cluster_name is not None: config["cluster_name"] = override_cluster_name config = _bootstrap_config(config) confirm("This will kill a node in...
[ "Kills", "a", "random", "Raylet", "worker", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/commands.py#L119-L157
[ "def", "kill_node", "(", "config_file", ",", "yes", ",", "override_cluster_name", ")", ":", "config", "=", "yaml", ".", "load", "(", "open", "(", "config_file", ")", ".", "read", "(", ")", ")", "if", "override_cluster_name", "is", "not", "None", ":", "co...
4eade036a0505e244c976f36aaa2d64386b5129b
train
get_or_create_head_node
Create the cluster head node, which in turn creates the workers.
python/ray/autoscaler/commands.py
def get_or_create_head_node(config, config_file, no_restart, restart_only, yes, override_cluster_name): """Create the cluster head node, which in turn creates the workers.""" provider = get_node_provider(config["provider"], config["cluster_name"]) try: head_node_tags = { ...
def get_or_create_head_node(config, config_file, no_restart, restart_only, yes, override_cluster_name): """Create the cluster head node, which in turn creates the workers.""" provider = get_node_provider(config["provider"], config["cluster_name"]) try: head_node_tags = { ...
[ "Create", "the", "cluster", "head", "node", "which", "in", "turn", "creates", "the", "workers", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/commands.py#L160-L283
[ "def", "get_or_create_head_node", "(", "config", ",", "config_file", ",", "no_restart", ",", "restart_only", ",", "yes", ",", "override_cluster_name", ")", ":", "provider", "=", "get_node_provider", "(", "config", "[", "\"provider\"", "]", ",", "config", "[", "\...
4eade036a0505e244c976f36aaa2d64386b5129b
train
attach_cluster
Attaches to a screen for the specified cluster. Arguments: config_file: path to the cluster yaml start: whether to start the cluster if it isn't up use_tmux: whether to use tmux as multiplexer override_cluster_name: set the name of the cluster new: whether to force a new scr...
python/ray/autoscaler/commands.py
def attach_cluster(config_file, start, use_tmux, override_cluster_name, new): """Attaches to a screen for the specified cluster. Arguments: config_file: path to the cluster yaml start: whether to start the cluster if it isn't up use_tmux: whether to use tmux as multiplexer overr...
def attach_cluster(config_file, start, use_tmux, override_cluster_name, new): """Attaches to a screen for the specified cluster. Arguments: config_file: path to the cluster yaml start: whether to start the cluster if it isn't up use_tmux: whether to use tmux as multiplexer overr...
[ "Attaches", "to", "a", "screen", "for", "the", "specified", "cluster", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/commands.py#L286-L309
[ "def", "attach_cluster", "(", "config_file", ",", "start", ",", "use_tmux", ",", "override_cluster_name", ",", "new", ")", ":", "if", "use_tmux", ":", "if", "new", ":", "cmd", "=", "\"tmux new\"", "else", ":", "cmd", "=", "\"tmux attach || tmux new\"", "else",...
4eade036a0505e244c976f36aaa2d64386b5129b
train
exec_cluster
Runs a command on the specified cluster. Arguments: config_file: path to the cluster yaml cmd: command to run docker: whether to run command in docker container of config screen: whether to run in a screen tmux: whether to run in a tmux session stop: whether to stop ...
python/ray/autoscaler/commands.py
def exec_cluster(config_file, cmd, docker, screen, tmux, stop, start, override_cluster_name, port_forward): """Runs a command on the specified cluster. Arguments: config_file: path to the cluster yaml cmd: command to run docker: whether to run command in docker containe...
def exec_cluster(config_file, cmd, docker, screen, tmux, stop, start, override_cluster_name, port_forward): """Runs a command on the specified cluster. Arguments: config_file: path to the cluster yaml cmd: command to run docker: whether to run command in docker containe...
[ "Runs", "a", "command", "on", "the", "specified", "cluster", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/commands.py#L312-L391
[ "def", "exec_cluster", "(", "config_file", ",", "cmd", ",", "docker", ",", "screen", ",", "tmux", ",", "stop", ",", "start", ",", "override_cluster_name", ",", "port_forward", ")", ":", "assert", "not", "(", "screen", "and", "tmux", ")", ",", "\"Can specif...
4eade036a0505e244c976f36aaa2d64386b5129b
train
rsync
Rsyncs files. Arguments: config_file: path to the cluster yaml source: source dir target: target dir override_cluster_name: set the name of the cluster down: whether we're syncing remote -> local
python/ray/autoscaler/commands.py
def rsync(config_file, source, target, override_cluster_name, down): """Rsyncs files. Arguments: config_file: path to the cluster yaml source: source dir target: target dir override_cluster_name: set the name of the cluster down: whether we're syncing remote -> local ...
def rsync(config_file, source, target, override_cluster_name, down): """Rsyncs files. Arguments: config_file: path to the cluster yaml source: source dir target: target dir override_cluster_name: set the name of the cluster down: whether we're syncing remote -> local ...
[ "Rsyncs", "files", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/commands.py#L416-L453
[ "def", "rsync", "(", "config_file", ",", "source", ",", "target", ",", "override_cluster_name", ",", "down", ")", ":", "config", "=", "yaml", ".", "load", "(", "open", "(", "config_file", ")", ".", "read", "(", ")", ")", "if", "override_cluster_name", "i...
4eade036a0505e244c976f36aaa2d64386b5129b
train
get_head_node_ip
Returns head node IP for given configuration file if exists.
python/ray/autoscaler/commands.py
def get_head_node_ip(config_file, override_cluster_name): """Returns head node IP for given configuration file if exists.""" config = yaml.load(open(config_file).read()) if override_cluster_name is not None: config["cluster_name"] = override_cluster_name provider = get_node_provider(config["pr...
def get_head_node_ip(config_file, override_cluster_name): """Returns head node IP for given configuration file if exists.""" config = yaml.load(open(config_file).read()) if override_cluster_name is not None: config["cluster_name"] = override_cluster_name provider = get_node_provider(config["pr...
[ "Returns", "head", "node", "IP", "for", "given", "configuration", "file", "if", "exists", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/commands.py#L456-L473
[ "def", "get_head_node_ip", "(", "config_file", ",", "override_cluster_name", ")", ":", "config", "=", "yaml", ".", "load", "(", "open", "(", "config_file", ")", ".", "read", "(", ")", ")", "if", "override_cluster_name", "is", "not", "None", ":", "config", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
get_worker_node_ips
Returns worker node IPs for given configuration file.
python/ray/autoscaler/commands.py
def get_worker_node_ips(config_file, override_cluster_name): """Returns worker node IPs for given configuration file.""" config = yaml.load(open(config_file).read()) if override_cluster_name is not None: config["cluster_name"] = override_cluster_name provider = get_node_provider(config["provid...
def get_worker_node_ips(config_file, override_cluster_name): """Returns worker node IPs for given configuration file.""" config = yaml.load(open(config_file).read()) if override_cluster_name is not None: config["cluster_name"] = override_cluster_name provider = get_node_provider(config["provid...
[ "Returns", "worker", "node", "IPs", "for", "given", "configuration", "file", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/commands.py#L476-L492
[ "def", "get_worker_node_ips", "(", "config_file", ",", "override_cluster_name", ")", ":", "config", "=", "yaml", ".", "load", "(", "open", "(", "config_file", ")", ".", "read", "(", ")", ")", "if", "override_cluster_name", "is", "not", "None", ":", "config",...
4eade036a0505e244c976f36aaa2d64386b5129b
train
FunctionRunner._train
Implements train() for a Function API. If the RunnerThread finishes without reporting "done", Tune will automatically provide a magic keyword __duplicate__ along with a result with "done=True". The TrialRunner will handle the result accordingly (see tune/trial_runner.py).
python/ray/tune/function_runner.py
def _train(self): """Implements train() for a Function API. If the RunnerThread finishes without reporting "done", Tune will automatically provide a magic keyword __duplicate__ along with a result with "done=True". The TrialRunner will handle the result accordingly (see tune/tri...
def _train(self): """Implements train() for a Function API. If the RunnerThread finishes without reporting "done", Tune will automatically provide a magic keyword __duplicate__ along with a result with "done=True". The TrialRunner will handle the result accordingly (see tune/tri...
[ "Implements", "train", "()", "for", "a", "Function", "API", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/function_runner.py#L151-L221
[ "def", "_train", "(", "self", ")", ":", "if", "self", ".", "_runner", ".", "is_alive", "(", ")", ":", "# if started and alive, inform the reporter to continue and", "# generate the next result", "self", ".", "_continue_semaphore", ".", "release", "(", ")", "else", "...
4eade036a0505e244c976f36aaa2d64386b5129b
train
Model.build_network
Returns logits and aux_logits from images.
python/ray/experimental/sgd/tfbench/model.py
def build_network(self, images, phase_train=True, nclass=1001, image_depth=3, data_type=tf.float32, data_format="NCHW", use_tf_layers=True, fp16...
def build_network(self, images, phase_train=True, nclass=1001, image_depth=3, data_type=tf.float32, data_format="NCHW", use_tf_layers=True, fp16...
[ "Returns", "logits", "and", "aux_logits", "from", "images", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/tfbench/model.py#L79-L114
[ "def", "build_network", "(", "self", ",", "images", ",", "phase_train", "=", "True", ",", "nclass", "=", "1001", ",", "image_depth", "=", "3", ",", "data_type", "=", "tf", ".", "float32", ",", "data_format", "=", "\"NCHW\"", ",", "use_tf_layers", "=", "T...
4eade036a0505e244c976f36aaa2d64386b5129b
train
renamed_class
Helper class for renaming Agent => Trainer with a warning.
python/ray/rllib/utils/__init__.py
def renamed_class(cls): """Helper class for renaming Agent => Trainer with a warning.""" class DeprecationWrapper(cls): def __init__(self, config=None, env=None, logger_creator=None): old_name = cls.__name__.replace("Trainer", "Agent") new_name = cls.__name__ logger....
def renamed_class(cls): """Helper class for renaming Agent => Trainer with a warning.""" class DeprecationWrapper(cls): def __init__(self, config=None, env=None, logger_creator=None): old_name = cls.__name__.replace("Trainer", "Agent") new_name = cls.__name__ logger....
[ "Helper", "class", "for", "renaming", "Agent", "=", ">", "Trainer", "with", "a", "warning", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/utils/__init__.py#L12-L26
[ "def", "renamed_class", "(", "cls", ")", ":", "class", "DeprecationWrapper", "(", "cls", ")", ":", "def", "__init__", "(", "self", ",", "config", "=", "None", ",", "env", "=", "None", ",", "logger_creator", "=", "None", ")", ":", "old_name", "=", "cls"...
4eade036a0505e244c976f36aaa2d64386b5129b
train
profile
Profile a span of time so that it appears in the timeline visualization. Note that this only works in the raylet code path. This function can be used as follows (both on the driver or within a task). .. code-block:: python with ray.profile("custom event", extra_data={'key': 'value'}): ...
python/ray/profiling.py
def profile(event_type, extra_data=None): """Profile a span of time so that it appears in the timeline visualization. Note that this only works in the raylet code path. This function can be used as follows (both on the driver or within a task). .. code-block:: python with ray.profile("custom...
def profile(event_type, extra_data=None): """Profile a span of time so that it appears in the timeline visualization. Note that this only works in the raylet code path. This function can be used as follows (both on the driver or within a task). .. code-block:: python with ray.profile("custom...
[ "Profile", "a", "span", "of", "time", "so", "that", "it", "appears", "in", "the", "timeline", "visualization", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/profiling.py#L30-L61
[ "def", "profile", "(", "event_type", ",", "extra_data", "=", "None", ")", ":", "worker", "=", "ray", ".", "worker", ".", "global_worker", "return", "RayLogSpanRaylet", "(", "worker", ".", "profiler", ",", "event_type", ",", "extra_data", "=", "extra_data", "...
4eade036a0505e244c976f36aaa2d64386b5129b
train
Profiler._periodically_flush_profile_events
Drivers run this as a thread to flush profile data in the background.
python/ray/profiling.py
def _periodically_flush_profile_events(self): """Drivers run this as a thread to flush profile data in the background.""" # Note(rkn): This is run on a background thread in the driver. It uses # the raylet client. This should be ok because it doesn't read # from the raylet client...
def _periodically_flush_profile_events(self): """Drivers run this as a thread to flush profile data in the background.""" # Note(rkn): This is run on a background thread in the driver. It uses # the raylet client. This should be ok because it doesn't read # from the raylet client...
[ "Drivers", "run", "this", "as", "a", "thread", "to", "flush", "profile", "data", "in", "the", "background", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/profiling.py#L94-L110
[ "def", "_periodically_flush_profile_events", "(", "self", ")", ":", "# Note(rkn): This is run on a background thread in the driver. It uses", "# the raylet client. This should be ok because it doesn't read", "# from the raylet client and we have the GIL here. However,", "# if either of those thing...
4eade036a0505e244c976f36aaa2d64386b5129b
train
Profiler.flush_profile_data
Push the logged profiling data to the global control store.
python/ray/profiling.py
def flush_profile_data(self): """Push the logged profiling data to the global control store.""" with self.lock: events = self.events self.events = [] if self.worker.mode == ray.WORKER_MODE: component_type = "worker" else: component_type = ...
def flush_profile_data(self): """Push the logged profiling data to the global control store.""" with self.lock: events = self.events self.events = [] if self.worker.mode == ray.WORKER_MODE: component_type = "worker" else: component_type = ...
[ "Push", "the", "logged", "profiling", "data", "to", "the", "global", "control", "store", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/profiling.py#L112-L125
[ "def", "flush_profile_data", "(", "self", ")", ":", "with", "self", ".", "lock", ":", "events", "=", "self", ".", "events", "self", ".", "events", "=", "[", "]", "if", "self", ".", "worker", ".", "mode", "==", "ray", ".", "WORKER_MODE", ":", "compone...
4eade036a0505e244c976f36aaa2d64386b5129b
train
RayLogSpanRaylet.set_attribute
Add a key-value pair to the extra_data dict. This can be used to add attributes that are not available when ray.profile was called. Args: key: The attribute name. value: The attribute value.
python/ray/profiling.py
def set_attribute(self, key, value): """Add a key-value pair to the extra_data dict. This can be used to add attributes that are not available when ray.profile was called. Args: key: The attribute name. value: The attribute value. """ if not isin...
def set_attribute(self, key, value): """Add a key-value pair to the extra_data dict. This can be used to add attributes that are not available when ray.profile was called. Args: key: The attribute name. value: The attribute value. """ if not isin...
[ "Add", "a", "key", "-", "value", "pair", "to", "the", "extra_data", "dict", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/profiling.py#L146-L160
[ "def", "set_attribute", "(", "self", ",", "key", ",", "value", ")", ":", "if", "not", "isinstance", "(", "key", ",", "str", ")", "or", "not", "isinstance", "(", "value", ",", "str", ")", ":", "raise", "ValueError", "(", "\"The arguments 'key' and 'value' m...
4eade036a0505e244c976f36aaa2d64386b5129b
train
_LogSyncer.sync_to_worker_if_possible
Syncs the local logdir on driver to worker if possible. Requires ray cluster to be started with the autoscaler. Also requires rsync to be installed.
python/ray/tune/log_sync.py
def sync_to_worker_if_possible(self): """Syncs the local logdir on driver to worker if possible. Requires ray cluster to be started with the autoscaler. Also requires rsync to be installed. """ if self.worker_ip == self.local_ip: return ssh_key = get_ssh_key(...
def sync_to_worker_if_possible(self): """Syncs the local logdir on driver to worker if possible. Requires ray cluster to be started with the autoscaler. Also requires rsync to be installed. """ if self.worker_ip == self.local_ip: return ssh_key = get_ssh_key(...
[ "Syncs", "the", "local", "logdir", "on", "driver", "to", "worker", "if", "possible", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/log_sync.py#L131-L159
[ "def", "sync_to_worker_if_possible", "(", "self", ")", ":", "if", "self", ".", "worker_ip", "==", "self", ".", "local_ip", ":", "return", "ssh_key", "=", "get_ssh_key", "(", ")", "ssh_user", "=", "get_ssh_user", "(", ")", "global", "_log_sync_warned", "if", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
QMixer.forward
Forward pass for the mixer. Arguments: agent_qs: Tensor of shape [B, T, n_agents, n_actions] states: Tensor of shape [B, T, state_dim]
python/ray/rllib/agents/qmix/mixers.py
def forward(self, agent_qs, states): """Forward pass for the mixer. Arguments: agent_qs: Tensor of shape [B, T, n_agents, n_actions] states: Tensor of shape [B, T, state_dim] """ bs = agent_qs.size(0) states = states.reshape(-1, self.state_dim) ag...
def forward(self, agent_qs, states): """Forward pass for the mixer. Arguments: agent_qs: Tensor of shape [B, T, n_agents, n_actions] states: Tensor of shape [B, T, state_dim] """ bs = agent_qs.size(0) states = states.reshape(-1, self.state_dim) ag...
[ "Forward", "pass", "for", "the", "mixer", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/qmix/mixers.py#L39-L64
[ "def", "forward", "(", "self", ",", "agent_qs", ",", "states", ")", ":", "bs", "=", "agent_qs", ".", "size", "(", "0", ")", "states", "=", "states", ".", "reshape", "(", "-", "1", ",", "self", ".", "state_dim", ")", "agent_qs", "=", "agent_qs", "."...
4eade036a0505e244c976f36aaa2d64386b5129b
train
SigOptSearch.on_trial_complete
Passes the result to SigOpt unless early terminated or errored. If a trial fails, it will be reported as a failed Observation, telling the optimizer that the Suggestion led to a metric failure, which updates the feasible region and improves parameter recommendation. Creates SigOpt Obse...
python/ray/tune/suggest/sigopt.py
def on_trial_complete(self, trial_id, result=None, error=False, early_terminated=False): """Passes the result to SigOpt unless early terminated or errored. If a trial fails, it will be reported as a ...
def on_trial_complete(self, trial_id, result=None, error=False, early_terminated=False): """Passes the result to SigOpt unless early terminated or errored. If a trial fails, it will be reported as a ...
[ "Passes", "the", "result", "to", "SigOpt", "unless", "early", "terminated", "or", "errored", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/suggest/sigopt.py#L95-L119
[ "def", "on_trial_complete", "(", "self", ",", "trial_id", ",", "result", "=", "None", ",", "error", "=", "False", ",", "early_terminated", "=", "False", ")", ":", "if", "result", ":", "self", ".", "conn", ".", "experiments", "(", "self", ".", "experiment...
4eade036a0505e244c976f36aaa2d64386b5129b
train
compute_ranks
Returns ranks in [0, len(x)) Note: This is different from scipy.stats.rankdata, which returns ranks in [1, len(x)].
python/ray/rllib/agents/ars/utils.py
def compute_ranks(x): """Returns ranks in [0, len(x)) Note: This is different from scipy.stats.rankdata, which returns ranks in [1, len(x)]. """ assert x.ndim == 1 ranks = np.empty(len(x), dtype=int) ranks[x.argsort()] = np.arange(len(x)) return ranks
def compute_ranks(x): """Returns ranks in [0, len(x)) Note: This is different from scipy.stats.rankdata, which returns ranks in [1, len(x)]. """ assert x.ndim == 1 ranks = np.empty(len(x), dtype=int) ranks[x.argsort()] = np.arange(len(x)) return ranks
[ "Returns", "ranks", "in", "[", "0", "len", "(", "x", "))" ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/ars/utils.py#L12-L21
[ "def", "compute_ranks", "(", "x", ")", ":", "assert", "x", ".", "ndim", "==", "1", "ranks", "=", "np", ".", "empty", "(", "len", "(", "x", ")", ",", "dtype", "=", "int", ")", "ranks", "[", "x", ".", "argsort", "(", ")", "]", "=", "np", ".", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
bottleneck_block_v1
Bottleneck block with identity short-cut for ResNet v1. Args: cnn: the network to append bottleneck blocks. depth: the number of output filters for this bottleneck block. depth_bottleneck: the number of bottleneck filters for this block. stride: Stride used in the first layer of the bottleneck block.
python/ray/experimental/sgd/tfbench/resnet_model.py
def bottleneck_block_v1(cnn, depth, depth_bottleneck, stride): """Bottleneck block with identity short-cut for ResNet v1. Args: cnn: the network to append bottleneck blocks. depth: the number of output filters for this bottleneck block. depth_bottleneck: the number of bottleneck filters for this bloc...
def bottleneck_block_v1(cnn, depth, depth_bottleneck, stride): """Bottleneck block with identity short-cut for ResNet v1. Args: cnn: the network to append bottleneck blocks. depth: the number of output filters for this bottleneck block. depth_bottleneck: the number of bottleneck filters for this bloc...
[ "Bottleneck", "block", "with", "identity", "short", "-", "cut", "for", "ResNet", "v1", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/tfbench/resnet_model.py#L39-L101
[ "def", "bottleneck_block_v1", "(", "cnn", ",", "depth", ",", "depth_bottleneck", ",", "stride", ")", ":", "input_layer", "=", "cnn", ".", "top_layer", "in_size", "=", "cnn", ".", "top_size", "name_key", "=", "\"resnet_v1\"", "name", "=", "name_key", "+", "st...
4eade036a0505e244c976f36aaa2d64386b5129b
train
bottleneck_block
Bottleneck block with identity short-cut. Args: cnn: the network to append bottleneck blocks. depth: the number of output filters for this bottleneck block. depth_bottleneck: the number of bottleneck filters for this block. stride: Stride used in the first layer of the bottleneck block. pre_activ...
python/ray/experimental/sgd/tfbench/resnet_model.py
def bottleneck_block(cnn, depth, depth_bottleneck, stride, pre_activation): """Bottleneck block with identity short-cut. Args: cnn: the network to append bottleneck blocks. depth: the number of output filters for this bottleneck block. depth_bottleneck: the number of bottleneck filters for this block...
def bottleneck_block(cnn, depth, depth_bottleneck, stride, pre_activation): """Bottleneck block with identity short-cut. Args: cnn: the network to append bottleneck blocks. depth: the number of output filters for this bottleneck block. depth_bottleneck: the number of bottleneck filters for this block...
[ "Bottleneck", "block", "with", "identity", "short", "-", "cut", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/tfbench/resnet_model.py#L182-L195
[ "def", "bottleneck_block", "(", "cnn", ",", "depth", ",", "depth_bottleneck", ",", "stride", ",", "pre_activation", ")", ":", "if", "pre_activation", ":", "bottleneck_block_v2", "(", "cnn", ",", "depth", ",", "depth_bottleneck", ",", "stride", ")", "else", ":"...
4eade036a0505e244c976f36aaa2d64386b5129b
train
residual_block
Residual block with identity short-cut. Args: cnn: the network to append residual blocks. depth: the number of output filters for this residual block. stride: Stride used in the first layer of the residual block. pre_activation: use pre_activation structure or not.
python/ray/experimental/sgd/tfbench/resnet_model.py
def residual_block(cnn, depth, stride, pre_activation): """Residual block with identity short-cut. Args: cnn: the network to append residual blocks. depth: the number of output filters for this residual block. stride: Stride used in the first layer of the residual block. pre_activation: use pre_a...
def residual_block(cnn, depth, stride, pre_activation): """Residual block with identity short-cut. Args: cnn: the network to append residual blocks. depth: the number of output filters for this residual block. stride: Stride used in the first layer of the residual block. pre_activation: use pre_a...
[ "Residual", "block", "with", "identity", "short", "-", "cut", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/tfbench/resnet_model.py#L198-L258
[ "def", "residual_block", "(", "cnn", ",", "depth", ",", "stride", ",", "pre_activation", ")", ":", "input_layer", "=", "cnn", ".", "top_layer", "in_size", "=", "cnn", ".", "top_size", "if", "in_size", "!=", "depth", ":", "# Plan A of shortcut.", "shortcut", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
MeanStdFilter.apply_changes
Applies updates from the buffer of another filter. Params: other (MeanStdFilter): Other filter to apply info from with_buffer (bool): Flag for specifying if the buffer should be copied from other. Examples: >>> a = MeanStdFilter(()) >>> a...
python/ray/rllib/utils/filter.py
def apply_changes(self, other, with_buffer=False): """Applies updates from the buffer of another filter. Params: other (MeanStdFilter): Other filter to apply info from with_buffer (bool): Flag for specifying if the buffer should be copied from other. Exa...
def apply_changes(self, other, with_buffer=False): """Applies updates from the buffer of another filter. Params: other (MeanStdFilter): Other filter to apply info from with_buffer (bool): Flag for specifying if the buffer should be copied from other. Exa...
[ "Applies", "updates", "from", "the", "buffer", "of", "another", "filter", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/utils/filter.py#L156-L181
[ "def", "apply_changes", "(", "self", ",", "other", ",", "with_buffer", "=", "False", ")", ":", "self", ".", "rs", ".", "update", "(", "other", ".", "buffer", ")", "if", "with_buffer", ":", "self", ".", "buffer", "=", "other", ".", "buffer", ".", "cop...
4eade036a0505e244c976f36aaa2d64386b5129b
train
MeanStdFilter.copy
Returns a copy of Filter.
python/ray/rllib/utils/filter.py
def copy(self): """Returns a copy of Filter.""" other = MeanStdFilter(self.shape) other.sync(self) return other
def copy(self): """Returns a copy of Filter.""" other = MeanStdFilter(self.shape) other.sync(self) return other
[ "Returns", "a", "copy", "of", "Filter", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/utils/filter.py#L183-L187
[ "def", "copy", "(", "self", ")", ":", "other", "=", "MeanStdFilter", "(", "self", ".", "shape", ")", "other", ".", "sync", "(", "self", ")", "return", "other" ]
4eade036a0505e244c976f36aaa2d64386b5129b
train
MeanStdFilter.sync
Syncs all fields together from other filter. Examples: >>> a = MeanStdFilter(()) >>> a(1) >>> a(2) >>> print([a.rs.n, a.rs.mean, a.buffer.n]) [2, array(1.5), 2] >>> b = MeanStdFilter(()) >>> b(10) >>> print([b.rs.n,...
python/ray/rllib/utils/filter.py
def sync(self, other): """Syncs all fields together from other filter. Examples: >>> a = MeanStdFilter(()) >>> a(1) >>> a(2) >>> print([a.rs.n, a.rs.mean, a.buffer.n]) [2, array(1.5), 2] >>> b = MeanStdFilter(()) >>> b(...
def sync(self, other): """Syncs all fields together from other filter. Examples: >>> a = MeanStdFilter(()) >>> a(1) >>> a(2) >>> print([a.rs.n, a.rs.mean, a.buffer.n]) [2, array(1.5), 2] >>> b = MeanStdFilter(()) >>> b(...
[ "Syncs", "all", "fields", "together", "from", "other", "filter", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/utils/filter.py#L192-L214
[ "def", "sync", "(", "self", ",", "other", ")", ":", "assert", "other", ".", "shape", "==", "self", ".", "shape", ",", "\"Shapes don't match!\"", "self", ".", "demean", "=", "other", ".", "demean", "self", ".", "destd", "=", "other", ".", "destd", "self...
4eade036a0505e244c976f36aaa2d64386b5129b
train
ConcurrentMeanStdFilter.as_serializable
Returns non-concurrent version of current class
python/ray/rllib/utils/filter.py
def as_serializable(self): """Returns non-concurrent version of current class""" other = MeanStdFilter(self.shape) other.sync(self) return other
def as_serializable(self): """Returns non-concurrent version of current class""" other = MeanStdFilter(self.shape) other.sync(self) return other
[ "Returns", "non", "-", "concurrent", "version", "of", "current", "class" ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/utils/filter.py#L258-L262
[ "def", "as_serializable", "(", "self", ")", ":", "other", "=", "MeanStdFilter", "(", "self", ".", "shape", ")", "other", ".", "sync", "(", "self", ")", "return", "other" ]
4eade036a0505e244c976f36aaa2d64386b5129b
train
ConcurrentMeanStdFilter.copy
Returns a copy of Filter.
python/ray/rllib/utils/filter.py
def copy(self): """Returns a copy of Filter.""" other = ConcurrentMeanStdFilter(self.shape) other.sync(self) return other
def copy(self): """Returns a copy of Filter.""" other = ConcurrentMeanStdFilter(self.shape) other.sync(self) return other
[ "Returns", "a", "copy", "of", "Filter", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/utils/filter.py#L264-L268
[ "def", "copy", "(", "self", ")", ":", "other", "=", "ConcurrentMeanStdFilter", "(", "self", ".", "shape", ")", "other", ".", "sync", "(", "self", ")", "return", "other" ]
4eade036a0505e244c976f36aaa2d64386b5129b
train
michalewicz_function
f(x) = -sum{sin(xi) * [sin(i*xi^2 / pi)]^(2m)}
python/ray/tune/examples/genetic_example.py
def michalewicz_function(config, reporter): """f(x) = -sum{sin(xi) * [sin(i*xi^2 / pi)]^(2m)}""" import numpy as np x = np.array( [config["x1"], config["x2"], config["x3"], config["x4"], config["x5"]]) sin_x = np.sin(x) z = (np.arange(1, 6) / np.pi * (x * x)) sin_z = np.power(np.sin(z), ...
def michalewicz_function(config, reporter): """f(x) = -sum{sin(xi) * [sin(i*xi^2 / pi)]^(2m)}""" import numpy as np x = np.array( [config["x1"], config["x2"], config["x3"], config["x4"], config["x5"]]) sin_x = np.sin(x) z = (np.arange(1, 6) / np.pi * (x * x)) sin_z = np.power(np.sin(z), ...
[ "f", "(", "x", ")", "=", "-", "sum", "{", "sin", "(", "xi", ")", "*", "[", "sin", "(", "i", "*", "xi^2", "/", "pi", ")", "]", "^", "(", "2m", ")", "}" ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/examples/genetic_example.py#L16-L27
[ "def", "michalewicz_function", "(", "config", ",", "reporter", ")", ":", "import", "numpy", "as", "np", "x", "=", "np", ".", "array", "(", "[", "config", "[", "\"x1\"", "]", ",", "config", "[", "\"x2\"", "]", ",", "config", "[", "\"x3\"", "]", ",", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
parse_general_int
Parse integer with power-of-2 suffix eg. 32k.
python/ray/experimental/sgd/modified_allreduce.py
def parse_general_int(s): """Parse integer with power-of-2 suffix eg. 32k.""" mo = re.match(r"(\d+)([KkMGT]?)$", s) if mo: i, suffix = mo.group(1, 2) v = int(i) if suffix: if suffix == "K" or suffix == "k": v *= 1024 elif suffix == "M": ...
def parse_general_int(s): """Parse integer with power-of-2 suffix eg. 32k.""" mo = re.match(r"(\d+)([KkMGT]?)$", s) if mo: i, suffix = mo.group(1, 2) v = int(i) if suffix: if suffix == "K" or suffix == "k": v *= 1024 elif suffix == "M": ...
[ "Parse", "integer", "with", "power", "-", "of", "-", "2", "suffix", "eg", ".", "32k", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/modified_allreduce.py#L38-L58
[ "def", "parse_general_int", "(", "s", ")", ":", "mo", "=", "re", ".", "match", "(", "r\"(\\d+)([KkMGT]?)$\"", ",", "s", ")", "if", "mo", ":", "i", ",", "suffix", "=", "mo", ".", "group", "(", "1", ",", "2", ")", "v", "=", "int", "(", "i", ")", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
parse_all_reduce_spec
Parse all_reduce_spec. Args: all_reduce_spec: a string specifying a combination of all-reduce algorithms to apply for gradient reduction. Returns: a list of AllReduceSpecTuple. Raises: ValueError: all_reduce_spec is not well-formed. An all_reduce_spec has BNF form: int ::= positive wh...
python/ray/experimental/sgd/modified_allreduce.py
def parse_all_reduce_spec(all_reduce_spec): """Parse all_reduce_spec. Args: all_reduce_spec: a string specifying a combination of all-reduce algorithms to apply for gradient reduction. Returns: a list of AllReduceSpecTuple. Raises: ValueError: all_reduce_spec is not well-formed. An all...
def parse_all_reduce_spec(all_reduce_spec): """Parse all_reduce_spec. Args: all_reduce_spec: a string specifying a combination of all-reduce algorithms to apply for gradient reduction. Returns: a list of AllReduceSpecTuple. Raises: ValueError: all_reduce_spec is not well-formed. An all...
[ "Parse", "all_reduce_spec", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/modified_allreduce.py#L61-L148
[ "def", "parse_all_reduce_spec", "(", "all_reduce_spec", ")", ":", "range_parts", "=", "all_reduce_spec", ".", "split", "(", "\":\"", ")", "+", "[", "\"-1\"", "]", "if", "len", "(", "range_parts", ")", "%", "2", ":", "raise", "ValueError", "(", "\"all_reduce_...
4eade036a0505e244c976f36aaa2d64386b5129b
train
build_all_reduce_device_prefixes
Build list of device prefix names for all_reduce. Args: job_name: "worker", "ps" or "localhost". num_tasks: number of jobs across which device names should be generated. Returns: A list of device name prefix strings. Each element spells out the full host name without adding the device. e.g....
python/ray/experimental/sgd/modified_allreduce.py
def build_all_reduce_device_prefixes(job_name, num_tasks): """Build list of device prefix names for all_reduce. Args: job_name: "worker", "ps" or "localhost". num_tasks: number of jobs across which device names should be generated. Returns: A list of device name prefix strings. Each element spell...
def build_all_reduce_device_prefixes(job_name, num_tasks): """Build list of device prefix names for all_reduce. Args: job_name: "worker", "ps" or "localhost". num_tasks: number of jobs across which device names should be generated. Returns: A list of device name prefix strings. Each element spell...
[ "Build", "list", "of", "device", "prefix", "names", "for", "all_reduce", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/modified_allreduce.py#L151-L167
[ "def", "build_all_reduce_device_prefixes", "(", "job_name", ",", "num_tasks", ")", ":", "if", "job_name", "!=", "\"localhost\"", ":", "return", "[", "\"/job:%s/task:%d\"", "%", "(", "job_name", ",", "d", ")", "for", "d", "in", "range", "(", "0", ",", "num_ta...
4eade036a0505e244c976f36aaa2d64386b5129b
train
group_device_names
Group device names into groups of group_size. Args: devices: list of strings naming devices. group_size: int >= 1 Returns: list of lists of devices, where each inner list is group_size long, and each device appears at least once in an inner list. If len(devices) % group_size = 0 then each...
python/ray/experimental/sgd/modified_allreduce.py
def group_device_names(devices, group_size): """Group device names into groups of group_size. Args: devices: list of strings naming devices. group_size: int >= 1 Returns: list of lists of devices, where each inner list is group_size long, and each device appears at least once in an inner lis...
def group_device_names(devices, group_size): """Group device names into groups of group_size. Args: devices: list of strings naming devices. group_size: int >= 1 Returns: list of lists of devices, where each inner list is group_size long, and each device appears at least once in an inner lis...
[ "Group", "device", "names", "into", "groups", "of", "group_size", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/modified_allreduce.py#L170-L196
[ "def", "group_device_names", "(", "devices", ",", "group_size", ")", ":", "num_devices", "=", "len", "(", "devices", ")", "if", "group_size", ">", "num_devices", ":", "raise", "ValueError", "(", "\"only %d devices, but group_size=%d\"", "%", "(", "num_devices", ",...
4eade036a0505e244c976f36aaa2d64386b5129b
train
split_grads_by_size
Break gradients into two sets according to tensor size. Args: threshold_size: int size cutoff for small vs large tensor. device_grads: List of lists of (gradient, variable) tuples. The outer list is over devices. The inner list is over individual gradients. Returns: small_grads: Subset of dev...
python/ray/experimental/sgd/modified_allreduce.py
def split_grads_by_size(threshold_size, device_grads): """Break gradients into two sets according to tensor size. Args: threshold_size: int size cutoff for small vs large tensor. device_grads: List of lists of (gradient, variable) tuples. The outer list is over devices. The inner list is over in...
def split_grads_by_size(threshold_size, device_grads): """Break gradients into two sets according to tensor size. Args: threshold_size: int size cutoff for small vs large tensor. device_grads: List of lists of (gradient, variable) tuples. The outer list is over devices. The inner list is over in...
[ "Break", "gradients", "into", "two", "sets", "according", "to", "tensor", "size", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/modified_allreduce.py#L199-L228
[ "def", "split_grads_by_size", "(", "threshold_size", ",", "device_grads", ")", ":", "small_grads", "=", "[", "]", "large_grads", "=", "[", "]", "for", "dl", "in", "device_grads", ":", "small_dl", "=", "[", "]", "large_dl", "=", "[", "]", "for", "(", "g",...
4eade036a0505e244c976f36aaa2d64386b5129b
train
aggregate_single_gradient
Calculate the average gradient for a shared variable across all towers. Note that this function provides a synchronization point across all towers. Args: grad_and_vars: A list or tuple of (gradient, variable) tuples. Each (gradient, variable) pair within the outer list represents the gradient of t...
python/ray/experimental/sgd/modified_allreduce.py
def aggregate_single_gradient(grad_and_vars, use_mean, check_inf_nan): """Calculate the average gradient for a shared variable across all towers. Note that this function provides a synchronization point across all towers. Args: grad_and_vars: A list or tuple of (gradient, variable) tuples. Each (gra...
def aggregate_single_gradient(grad_and_vars, use_mean, check_inf_nan): """Calculate the average gradient for a shared variable across all towers. Note that this function provides a synchronization point across all towers. Args: grad_and_vars: A list or tuple of (gradient, variable) tuples. Each (gra...
[ "Calculate", "the", "average", "gradient", "for", "a", "shared", "variable", "across", "all", "towers", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/modified_allreduce.py#L241-L270
[ "def", "aggregate_single_gradient", "(", "grad_and_vars", ",", "use_mean", ",", "check_inf_nan", ")", ":", "grads", "=", "[", "g", "for", "g", ",", "_", "in", "grad_and_vars", "]", "grad", "=", "tf", ".", "add_n", "(", "grads", ")", "if", "use_mean", "an...
4eade036a0505e244c976f36aaa2d64386b5129b
train
aggregate_gradients_using_copy_with_device_selection
Aggregate gradients, controlling device for the aggregation. Args: tower_grads: List of lists of (gradient, variable) tuples. The outer list is over towers. The inner list is over individual gradients. use_mean: if True, mean is taken, else sum of gradients is taken. check_inf_nan: If true, check g...
python/ray/experimental/sgd/modified_allreduce.py
def aggregate_gradients_using_copy_with_device_selection( tower_grads, avail_devices, use_mean=True, check_inf_nan=False): """Aggregate gradients, controlling device for the aggregation. Args: tower_grads: List of lists of (gradient, variable) tuples. The outer list is over towers. The inner li...
def aggregate_gradients_using_copy_with_device_selection( tower_grads, avail_devices, use_mean=True, check_inf_nan=False): """Aggregate gradients, controlling device for the aggregation. Args: tower_grads: List of lists of (gradient, variable) tuples. The outer list is over towers. The inner li...
[ "Aggregate", "gradients", "controlling", "device", "for", "the", "aggregation", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/modified_allreduce.py#L273-L296
[ "def", "aggregate_gradients_using_copy_with_device_selection", "(", "tower_grads", ",", "avail_devices", ",", "use_mean", "=", "True", ",", "check_inf_nan", "=", "False", ")", ":", "agg_grads", "=", "[", "]", "has_nan_or_inf_list", "=", "[", "]", "for", "i", ",", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
sum_grad_and_var_all_reduce
Apply all-reduce algorithm over specified gradient tensors.
python/ray/experimental/sgd/modified_allreduce.py
def sum_grad_and_var_all_reduce(grad_and_vars, num_workers, alg, gpu_indices, aux_devices=None, num_shards=1): """Apply all-reduce algorithm over specified ...
def sum_grad_and_var_all_reduce(grad_and_vars, num_workers, alg, gpu_indices, aux_devices=None, num_shards=1): """Apply all-reduce algorithm over specified ...
[ "Apply", "all", "-", "reduce", "algorithm", "over", "specified", "gradient", "tensors", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/modified_allreduce.py#L299-L346
[ "def", "sum_grad_and_var_all_reduce", "(", "grad_and_vars", ",", "num_workers", ",", "alg", ",", "gpu_indices", ",", "aux_devices", "=", "None", ",", "num_shards", "=", "1", ")", ":", "with", "tf", ".", "name_scope", "(", "\"allreduce\"", ")", ":", "# Note tha...
4eade036a0505e244c976f36aaa2d64386b5129b
train
sum_gradients_all_reduce
Apply all-reduce algorithm over specified gradient tensors. Args: dev_prefixes: list of prefix strings to use to generate PS device names. tower_grads: the gradients to reduce. num_workers: number of worker processes across entire job. alg: the all-reduce algorithm to apply. num_shards: alg-speci...
python/ray/experimental/sgd/modified_allreduce.py
def sum_gradients_all_reduce(dev_prefixes, tower_grads, num_workers, alg, num_shards, gpu_indices, agg_small_grads_max_bytes=0): """Apply all-...
def sum_gradients_all_reduce(dev_prefixes, tower_grads, num_workers, alg, num_shards, gpu_indices, agg_small_grads_max_bytes=0): """Apply all-...
[ "Apply", "all", "-", "reduce", "algorithm", "over", "specified", "gradient", "tensors", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/modified_allreduce.py#L366-L426
[ "def", "sum_gradients_all_reduce", "(", "dev_prefixes", ",", "tower_grads", ",", "num_workers", ",", "alg", ",", "num_shards", ",", "gpu_indices", ",", "agg_small_grads_max_bytes", "=", "0", ")", ":", "alg_contains_shuffle", "=", "contains_any", "(", "alg", ",", "...
4eade036a0505e244c976f36aaa2d64386b5129b
train
extract_ranges
Extract consecutive ranges and singles from index_list. Args: index_list: List of monotone increasing non-negative integers. range_size_limit: Largest size range to return. If a larger consecutive range exists it will be returned as multiple ranges. Returns: ranges, singles where ranges is...
python/ray/experimental/sgd/modified_allreduce.py
def extract_ranges(index_list, range_size_limit=32): """Extract consecutive ranges and singles from index_list. Args: index_list: List of monotone increasing non-negative integers. range_size_limit: Largest size range to return. If a larger consecutive range exists it will be returned as multiple ...
def extract_ranges(index_list, range_size_limit=32): """Extract consecutive ranges and singles from index_list. Args: index_list: List of monotone increasing non-negative integers. range_size_limit: Largest size range to return. If a larger consecutive range exists it will be returned as multiple ...
[ "Extract", "consecutive", "ranges", "and", "singles", "from", "index_list", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/modified_allreduce.py#L448-L482
[ "def", "extract_ranges", "(", "index_list", ",", "range_size_limit", "=", "32", ")", ":", "if", "not", "index_list", ":", "return", "[", "]", ",", "[", "]", "first", "=", "index_list", "[", "0", "]", "last", "=", "first", "ranges", "=", "[", "]", "si...
4eade036a0505e244c976f36aaa2d64386b5129b
train
pack_range
Form the concatenation of a specified range of gradient tensors. Args: key: Value under which to store meta-data in packing that will be used later to restore the grad_var list structure. packing: Dict holding data describing packed ranges of small tensors. grad_vars: List of (grad, var) pairs for ...
python/ray/experimental/sgd/modified_allreduce.py
def pack_range(key, packing, grad_vars, rng): """Form the concatenation of a specified range of gradient tensors. Args: key: Value under which to store meta-data in packing that will be used later to restore the grad_var list structure. packing: Dict holding data describing packed ranges of small t...
def pack_range(key, packing, grad_vars, rng): """Form the concatenation of a specified range of gradient tensors. Args: key: Value under which to store meta-data in packing that will be used later to restore the grad_var list structure. packing: Dict holding data describing packed ranges of small t...
[ "Form", "the", "concatenation", "of", "a", "specified", "range", "of", "gradient", "tensors", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/modified_allreduce.py#L488-L517
[ "def", "pack_range", "(", "key", ",", "packing", ",", "grad_vars", ",", "rng", ")", ":", "to_pack", "=", "grad_vars", "[", "rng", "[", "0", "]", ":", "rng", "[", "1", "]", "+", "1", "]", "members", "=", "[", "]", "variables", "=", "[", "]", "re...
4eade036a0505e244c976f36aaa2d64386b5129b
train
unpack_grad_tuple
Unpack a previously packed collection of gradient tensors. Args: gv: A (grad, var) pair to be unpacked. gpt: A GradPackTuple describing the packing operation that produced gv. Returns: A list of (grad, var) pairs corresponding to the values that were originally packed into gv, maybe following sub...
python/ray/experimental/sgd/modified_allreduce.py
def unpack_grad_tuple(gv, gpt): """Unpack a previously packed collection of gradient tensors. Args: gv: A (grad, var) pair to be unpacked. gpt: A GradPackTuple describing the packing operation that produced gv. Returns: A list of (grad, var) pairs corresponding to the values that were origina...
def unpack_grad_tuple(gv, gpt): """Unpack a previously packed collection of gradient tensors. Args: gv: A (grad, var) pair to be unpacked. gpt: A GradPackTuple describing the packing operation that produced gv. Returns: A list of (grad, var) pairs corresponding to the values that were origina...
[ "Unpack", "a", "previously", "packed", "collection", "of", "gradient", "tensors", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/modified_allreduce.py#L520-L540
[ "def", "unpack_grad_tuple", "(", "gv", ",", "gpt", ")", ":", "elt_widths", "=", "[", "x", ".", "num_elements", "(", ")", "for", "x", "in", "gpt", ".", "shapes", "]", "with", "tf", ".", "device", "(", "gv", "[", "0", "]", "[", "0", "]", ".", "de...
4eade036a0505e244c976f36aaa2d64386b5129b
train
pack_small_tensors
Concatenate gradients together more intelligently. Does binpacking Args: tower_grads: List of lists of (gradient, variable) tuples. max_bytes: Int giving max number of bytes in a tensor that may be considered small.
python/ray/experimental/sgd/modified_allreduce.py
def pack_small_tensors(tower_grads, max_bytes=0): """Concatenate gradients together more intelligently. Does binpacking Args: tower_grads: List of lists of (gradient, variable) tuples. max_bytes: Int giving max number of bytes in a tensor that may be considered small. """ assert max_bytes >...
def pack_small_tensors(tower_grads, max_bytes=0): """Concatenate gradients together more intelligently. Does binpacking Args: tower_grads: List of lists of (gradient, variable) tuples. max_bytes: Int giving max number of bytes in a tensor that may be considered small. """ assert max_bytes >...
[ "Concatenate", "gradients", "together", "more", "intelligently", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/modified_allreduce.py#L543-L606
[ "def", "pack_small_tensors", "(", "tower_grads", ",", "max_bytes", "=", "0", ")", ":", "assert", "max_bytes", ">=", "0", "orig_grads", "=", "[", "g", "for", "g", ",", "_", "in", "tower_grads", "[", "0", "]", "]", "# Check to make sure sizes are accurate; not e...
4eade036a0505e244c976f36aaa2d64386b5129b
train
unpack_small_tensors
Undo the structure alterations to tower_grads done by pack_small_tensors. Args: tower_grads: List of List of (grad, var) tuples. packing: A dict generated by pack_small_tensors describing the changes it made to tower_grads. Returns: new_tower_grads: identical to tower_grads except that concatent...
python/ray/experimental/sgd/modified_allreduce.py
def unpack_small_tensors(tower_grads, packing): """Undo the structure alterations to tower_grads done by pack_small_tensors. Args: tower_grads: List of List of (grad, var) tuples. packing: A dict generated by pack_small_tensors describing the changes it made to tower_grads. Returns: new_towe...
def unpack_small_tensors(tower_grads, packing): """Undo the structure alterations to tower_grads done by pack_small_tensors. Args: tower_grads: List of List of (grad, var) tuples. packing: A dict generated by pack_small_tensors describing the changes it made to tower_grads. Returns: new_towe...
[ "Undo", "the", "structure", "alterations", "to", "tower_grads", "done", "by", "pack_small_tensors", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/modified_allreduce.py#L609-L637
[ "def", "unpack_small_tensors", "(", "tower_grads", ",", "packing", ")", ":", "if", "not", "packing", ":", "return", "tower_grads", "new_tower_grads", "=", "[", "]", "num_devices", "=", "len", "(", "tower_grads", ")", "num_packed", "=", "len", "(", "packing", ...
4eade036a0505e244c976f36aaa2d64386b5129b