-
Notifications
You must be signed in to change notification settings - Fork 106
script execute command #682
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
d09d8b8
to
cfe2222
Compare
Codecov Report
@@ Coverage Diff @@
## master #682 +/- ##
==========================================
+ Coverage 78.86% 78.93% +0.06%
==========================================
Files 43 48 +5
Lines 6865 7343 +478
==========================================
+ Hits 5414 5796 +382
- Misses 1451 1547 +96
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!!! liked the new files structure and organization. I left some comments and suggestions, we can discuss it also tomorrow. Besides that, looks like there are quite a few cases of parsing errors that are not tested, consider adding some tests to increase coverage (depends on how thorough we want to be...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, added another few comments and suggestions.
docs/commands.md
Outdated
@@ -514,7 +514,122 @@ OK | |||
The `AI.SCRIPTDEL` is equivalent to the [Redis `DEL` command](https://redis.io/commands/del) and should be used in its stead. This ensures compatibility with all deployment options (i.e., stand-alone vs. cluster, OSS vs. Enterprise). | |||
|
|||
|
|||
## AI.SCRIPTEXECUTE | |||
|
|||
The **`AI.SCRIPTEXECUTE`** command runs a script stored as a key's value on its specified device. It accepts one or more input tensors, int, float or strings and store output tensors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe instead of "it accepts one or more input tensors..." say something like: "it uses one or more Redis keys both as inputs and/or by directly accessing them from within the script itself. Inputs may include tensors, integers, floats or strings, while outputs are tensors to be stored in Redis"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It accepts one or more inputs, where the inputs could be tensors stored in RedisAI, int, float, or strings and stores the script outputs as RedisAI tensors if required.
docs/commands.md
Outdated
**Redis API** | ||
|
||
``` | ||
AI.SCRIPTRUN <key> <function> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AI.SCRIPTEXECUTE
KEYS n <key> [keys...]
[INPUTS m <input> [input ...]
| LIST_INPUTS l <input> [input ...]]*
[OUTPUTS k <output> [output ...]] [TIMEOUT t]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AI.SCRIPTEXECUTE <key> <function>
KEYS n <key> [keys...]
[INPUTS m <input> [input ...] | [LIST_INPUTS l <input> [input ...]]*]+
[OUTPUTS k <output> [output ...] [TIMEOUT t]]+
docs/commands.md
Outdated
return a + torch.stack(args).sum() | ||
``` | ||
|
||
then one can provide an arbitrary number of inputs after the `$` sign: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a leftover... should be replaced with "LIST_INPUTS"
docs/commands.md
Outdated
OK | ||
redis> AI.TENSORSET mytensor3{tag} FLOAT 1 VALUES 1 | ||
OK | ||
redis> AI.SCRIPTRUN myscript{tag} addn keys 1 {tag} INPUTS 1 mytensor1{tag} LIST_INPUTS 2 mytensor2{tag} mytensor3{tag} OUTPUTS 1 result{tag} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ai.scriptexecute
docs/commands.md
Outdated
``` | ||
|
||
### Redis Commands support. | ||
In RedisAI TorchScript now supports simple (non-blocking) Redis commnands via the `redis.execute` API. The following (usless) script gets a key name, an `int` value and sets it in a tensor. Note that the inputs are `str` and `int`. The script sets and gets the value and set it into a tensor. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rephrase the last sentence: "here, the script sets an integer value (3) under the key 'x{1}' and then gets this value and set it into a tensor which is eventually stored under the key 'y{1}'."
This PR implements the new command:
The new command infers the types of its inputs from the function signature and allows support for the following types:
torch::Tensor
torch::string
int
float
List[T]
whereT
is one of the above.This support allows better flexibility and expressiveness on the torch-redis commands extension in RedisAI.
The new command structure scopes:
KEYS
- mandatory scope - this scope was added in order to infer the execution shard according to a given hash slot tag, or a list of keys that the script execution is going to access, either is inputs, outputs, or during the script run itself via the torch-redis extension.For example, for a script key
s{1}
. if the inputs area{1}
,b{1}
and the output isc{1}
than the user just needs to provideKEYS 1 {1}
. if the inputs area
,b
, and the output isc
, and the user is not sure about the hash slot, the user need to provideKEYS 3 a b c
.INPUTS
- In this new command, an input is a union oftorch::Tensor | torch::string | int | float
, meaning that inputs now may not be tensors in the keyspace. If there are keyspace tensors in the inputs they either should be mentioned on theKEYS
scope or have theKEYS
scope aware of their hash slot tagging. The inputs should be provided in the order they are appearing in the function signature (without lists). Inputs number must be provided.LIST_INPUTS
- a list of inputs. Multiple lists can be provided and they should be provided in the order they are appearing in the function signature. list size must be providedOUTPUTS
- key names to store output tensors in the keyspace. Outputs number must be provided.TIMEOUT
- same as before