-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add DAGRUN
(or PIPERUN
) command
#88
Comments
I have more thoughts on this variant but could be a bit sophisticated and might remove certain benefits that we could get from the proposed DAGRUN. I am not completely sure about the performance implication but if that's negligible, this could be a good feature to have Proposal UpdateIf a user could name the DAGRUN AI.DAGRUN dag_name MODELRUN ... Advantages
An Example
AI.DAGRUN my_dag -k TENSORSET ~a~ FLOAT 2 VALUES 2 3 => \
TENSORSET ~b~ FLOAT 2 VALUES 2 3 => \
MODELRUN foo INPUTS ~a~ ~b~ OUTPUTS ~c~
AI.DAGRUN my_dag -k TENSORSET ~d~ FLOAT 2 VALUES 3 4 => \
MODELRUN bar INPUTS ~c~ ~d~ OUTPUTS ~e~
AI.DAGRUN my_dag MODELRUN baz INPUTS ~e~ OUTPUTS f => \
TENSORGET f |
Thank you @hhsecond, I'm going to think about this. One essential feature of DAG to me is that it has to be isolated: it has to clearly fail or succeed as a whole, volatile vars should not be visible to other clients or to other calls, the client should block for the duration of the DAG, etc. This proposal adds some complexity, as we need to have the DAG persist in key-space itself if we want it to survive a failure, etc. So mainly the failure modes and AOF/replication need further consideration. What we could do is proceed without naming the DAG for now (there's enough to implement) and keep options open using a slightly different syntax in the future AI.DAGRUN NAME my_dag MODELRUN ... This way we'll know if the DAG is named or not. NoteBTW, important design point: regarding fail or succeed, for non-volatile keys we should treat them as volatile and then write them upon unblocking. This way if you run AI.DAGRUN TENSORSET a FLOAT 2 VALUES 2 3 => MODELRUN foo INPUTS a OUTPUTS b => TENSORGET b
|
That makes sense, let's do that. Just out of curiosity, why do you think the volatile vars should not be visible to other calls -> because of the complexity you mentioned above or are there other reasons as well? |
Making them persistent introduces a few complications that I'd rather not address right now:
Making them live within a command gives us a lot of power for very little added complication, with no impact on Redis as we know it. |
@lantiga @K-Jo @gkorland @hhsecond following the discussed today, bringing this subject up with the minimum POC required: DAGRUN (1 level depth ) Design ProposalSpecify a direct acyclic graph of operations ( for now we only allow chaining ) to run within redisai.
Some considerations:By default, the results of each operation will only live during the execution of the DAG. IF COMMAND1 sets a tensor, it can be referenced by any further command on the chaining. The reference order first to look locally, then search for the key in the keyspace. Chaining operations:To chain operations, we will use Pipe-forward operator (|>): Commands in scope of the POC:
|
Hi @filipecosta90 thank you. My observations:
|
Given the following example, if we want to only persist
If we analyze even further the example you gave, modelrun would be using 2 local "volatile" tensors ( foo and bar ) and one tensor present on the keyset ( fiz ). Regarding the operator to use, anyone that enables us to do a quick separation is good for me :) |
For more clarity, I want to have the freedom to identify keys as volatile (I just added
I don't like command-level PERSIST or LOCAL because they impose an unnecessary constraint, as they apply to all the output keys. I'm leaning strongly towards declaring LOCALS as part of the command. It's very explicit and flexible. |
You're right :) Agree that it brings more freedom and control from command based granularity to output based 👍 |
With reference to:
Apart from PERSIST (see above), it all sounds good. What needs a bit of extra care is the fact that whatever comes after MODELRUN will have to be called from the Run_Reply callback. Since generalizing this may be brittle, I propose to keep an intermediate representation of the DAG in This way generalizing to multi-level DAG might not be that much of a deal. |
A common pattern is enqueuing multiple
SCRIPTRUN
andMODELRUN
commands. Setting input tensors, storing intermediates of*RUN
commands and storing outputs all in keyspace means that all written keys will be AOF'd and replicated even if they will be disposed of shortly after.DAGRUN
A general solution to this problem is to have a
DAGRUN
(orPIPERUN
, we'll see about the name - it is a DAG rather than a pipe, so it should probably be named correctly) command that allows to run a sequence ofAI.*
commands, e.g.:Note the key names between
~ ~
: these are volatile keys (~a~
is volatile because it has small wings :-) ). A volatile key is not set into keyspace, but it just lives in-memory for the duration of the command, after which is deallocated. In the command above,~a~
,~b~
,~c~
are volatile, so they don't touch keyspace (and are not replicated). Only the output keyd
is stored in keyspace, for later retrieval.Relationship to MODELRUN that returns results
This design supersedes #85, which proposed a
MODELRUN
variant that returns the output. This can be now obtained by:or, without touching keyspace at all
Advantages
Apart from the obvious convenience, there are several advantages with this design:
DAGRUN
command is sent, we can apply DAG optimization strategies; for instance, in case of ensambles, we can execute differentMODELRUN
subcalls in parallel (this was not possible before because each call was blocking on the client) and then join on the results to execute a furtherSCRIPTRUN
that computes the ensembled outputs;DAGRUN
call executes or if it fails, all volatile keys are deallocated at once; volatile keys are never seen by other clients, they only exist in the context of the call; therefore, we just need a small hash object in the call context that gets naturally deallocatedAdditional commands
DAGRUNRO
: read-only variant that is amenable for execution on replicas; if a non volatile key is attempted to be written, it errors outDAGRUNASYNC
: fully async variant, that just returnsOK
, or, probably better, an id (for eventually querying the status of the run or cancel it, as future commands). The user can then listen to keyspace notifications on the output keys (or check that the key has been written, or in the future query the status of the computation). This is relevant for use in webservices in which handlers shouldn't block.The text was updated successfully, but these errors were encountered: