-
Notifications
You must be signed in to change notification settings - Fork 684
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
Eager mode: enable awaitable execution graphs in Flyte #3672
Eager mode: enable awaitable execution graphs in Flyte #3672
Comments
Use Cases
|
@fg91 I think the HPO early stopping use case is actually a separate RFC: basically if we can give tasks access to some state store (an RDBMS or something more light-weight like a key-value store) we could implement something similar to what's described in the optuna pruning docs import logging
import sys
import sklearn.datasets
import sklearn.linear_model
import sklearn.model_selection
def objective(trial):
iris = sklearn.datasets.load_iris()
classes = list(set(iris.target))
train_x, valid_x, train_y, valid_y = sklearn.model_selection.train_test_split(
iris.data, iris.target, test_size=0.25, random_state=0
)
alpha = trial.suggest_float("alpha", 1e-5, 1e-1, log=True)
clf = sklearn.linear_model.SGDClassifier(alpha=alpha)
for step in range(100):
clf.partial_fit(train_x, train_y, classes=classes)
# Report intermediate objective value.
intermediate_value = 1.0 - clf.score(valid_x, valid_y)
trial.report(intermediate_value, step)
# Handle pruning based on the intermediate value.
if trial.should_prune(): # << 👈 This
raise optuna.TrialPruned
return 1.0 - clf.score(valid_x, valid_y) The flyte task basically needs to know whether a particular run in a HPO experiment should be stopped. We could integrate with specific frameworks like Optuna, but if we want a flyte-specific construct for this we'll need some way of storing and sharing state across tasks, and then either built-in or user-defined pruners to say, "based on past hyperparameter settings, we should stop this particular run because it has hyperparameter setting X = ..., which was found to be ineffective in other similar trials"). In short, I think that's a separate but complementary RFC. |
Agreed, makes sense, thanks for the summary 👍 I have a follow up question that just came to my mind: if I cancel a workflow with an |
2023-05-25 Contributors meetup notes: "What happens to “child executions” when an @eager task is aborted?" |
Sorry I have a stupid question. I have not been following this work and I'm trying to understand how it is supposed work, mostly from the context whether we would want to have the same capability in Java SDK. I will describe how I understood it, and please let me where I made it wrong. Thank you.
|
Until here this is exactly my understanding as well.
@cosmicBboy are the tasks called within the |
Correct. only flyte tasks use |
Discussed in #3396
Originally posted by cosmicBboy March 3, 2023
Background
Currently, Flyte offers two constructs for composing
task
s into more complex execution graphs: static workflows (via the@workflow
decorator) and dynamic workflows (via the@dynamic
decorator). As the names suggest, static workflows are created at compile time and registered to some target Flyte cluster. On the other hand, dynamic workflows are compiled at runtime so that they can materialize the inputs of the workflow and use them to influence the shape of the execution graph.Problem Statement
Both static and dynamic workflows pose a problem. While they provide type safety (moreso for static, although type errors will occur when dynamic workflows are created at runtime), they both suffer from inflexibility in expressing execution graphs that many Python
flytekit
users may be accustomed to. This is because in actuality,@workflow
and@dynamic
function code is not Python code: it's a DSL for constructing execution graphs that suffer from the "uncanny valley" of looking like Python code, but isn't actually Python code. For example:if... elif... else
statements not supported and the equivalent syntax is cumbersome to write withconditionals
.try... except
statements are not supported.async
code is not supported.For Python users who come in with expectations of writing Python to compose their workflows, Flyte is surprising both in terms of (a) the lack of useful error messages when trying illegal combinations of Flyte and Python syntax and (b) the inability to compose tasks using the
asyncio
syntax. The scope of this RFC is to focus on the latter.Proposal
This RFC proposes adding support for "eager workflows" indicated by the
@eager
decorator in a new subpackageflytekit.experimental
, which will contain experimental features. This construct allows users to write workflows pretty much like how one would write asynchronous Python code. For example:Trade-offs
At a high-level, we can think of these three ways of writing workflows in terms of Flyte promises, and what data are accessible to the user in the workflow code:
@workflow
@dynamic
@workflow
, can do Python operations on inputs@eager
Open Questions
FlyteRemote
configuration?MVP
WIP PR: flyteorg/flytekit#1579
flytepropeller
and hard-coded secret group/key:The text was updated successfully, but these errors were encountered: