tfx icon indicating copy to clipboard operation
tfx copied to clipboard

Conditional Trainer base_model with RuntimeParameter?

Open pselden opened this issue 5 years ago • 4 comments

I have some code like this which I use for conditionally doing a "warm start" based on a previous model -- I toggle it true or false at build time when things like the schema changes.

However, I'd like to actually change it to a RuntimeParameter so it can be handled at execution time instead of build time, which is much less tedious to do.

// build_pipeline.py

 latest_model_resolver = ResolverNode(
        instance_name='latest_model_resolver',
        resolver_class=latest_artifacts_resolver.LatestArtifactsResolver,
        latest_model=Channel(type=Model))

    trainer = Trainer(
        // conditionally use a base model, or not
        base_model=latest_model_resolver.outputs['latest_model'] if warm_start_mode else None,
    )

Are there any ways to have warm_start_mode as a RuntimeParameter, or any other ways you achieve the same result?

pselden avatar Jul 21 '20 21:07 pselden

@ruoyu90 @zhitaoli I would like to do similar with Tuner. Any update on this? Documentation mentions conditional nodes: https://www.tensorflow.org/tfx/api_docs/python/tfx/components/ResolverNode#add_downstream_node

Does this already exist in some fashion?

ConverJens avatar Dec 18 '20 21:12 ConverJens

RuntimeParameter is designed to be a variable that will be filled upon pipeline being triggered and thus will not help in this case.

OTOH, we are working on conditional support. Please stay tuned for that.

/cc @kennethyang404

ruoyu90 avatar May 20 '21 16:05 ruoyu90

@ruoyu90 The point with having a conditional pipeline that can be controlled through a runtime parameter is to be able to control whether or not to run tuning for example. Rather than having to compile to separate pipelines, it would be much more convenient if one could simply change the input (runtime param) and disable/enable tuning for example.

If conditional support only works by acting on component output, then one would have to create a component that takes a runtime parameter and only outputs that value to the next component. This seems overly complicated.

Is there an RFC or CUJ for conditional support somewhere?

ConverJens avatar May 31 '21 08:05 ConverJens

Sorry for the late follow-up. But in this case, you can just pass latest_model_resolver.outputs['latest_model'] and an empty will be just ignore at the Trainer.

We have conditional for some orchestrators now, please check examples for use cases.

jiyongjung0 avatar Sep 28 '22 05:09 jiyongjung0

This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you.

github-actions[bot] avatar May 03 '23 01:05 github-actions[bot]

This issue was closed due to lack of activity after being marked stale for past 7 days.

github-actions[bot] avatar May 11 '23 01:05 github-actions[bot]