Reusing Completed Kubeflow Pipeline Steps with Component Caching
Kubeflow Pipelines can skip expensive steps when inputs and images match, but caching behaves differently across SDK versions and can hide stale results.
27 Oct 2025, 04:35 UTC

The problem: rerunning work you already finished
You fix a bug in the last modeling step of a Kubeflow Pipelines run and submit the pipeline again. The upstream preprocessing step takes forty minutes, so you wait forty minutes for a result you already have. If your team runs retries, hyperparameter sweeps, or daily retraining, those repeated runs add up quickly.
Kubeflow Pipelines offers component-level caching: when a step’s inputs and container image match a previous execution, the platform can reuse the earlier output instead of starting a new container. This can cut compute cost and iteration time, but only if you understand when the cache applies and when it does not.
What caching skips, and what it does not
A cached component skips container execution for that step. The pipeline still records the step in the run, but the runtime pulls the prior output from the metadata store instead of running the image. It does not skip the pipeline itself, and it does not skip steps whose inputs or images differ.
Caching is safe for pure transformations: read inputs, write outputs, no external side effects. It is risky for steps that write to a database, call an external API, upload artifacts to object storage, or generate non-deterministic results. Reusing a cached output from such a step can silently skip work your downstream steps depend on.
Version differences you need to check
Kubeflow Pipelines has two major SDK generations. The legacy v1 SDK and the v2 compiler targeting Argo Workflows handle caching differently, and deployments using Tekton instead of Argo may not expose the same semantics. Cache keys are typically derived from component inputs and the container image digest, but the exact flag and location of the setting depend on your installed Kubeflow version.
Because of that variation, treat the following example as a pattern to verify against your SDK documentation, not as a copy-paste specification.
Worked example: enabling caching on a component
In a Python pipeline definition, you generally mark a component as cacheable when you create it or when you submit the pipeline. The snippet below shows the shape of the decision; replace the placeholders with values from your environment.
# Conceptual only; verify against your Kubeflow SDK version
from kfp import dsl
@dsl.component(
base_image="gcr.io//:",
# caching_enabled=True # flag name varies by SDK version
)
def preprocess_data(input_path: str) -> str:
...
@dsl.pipeline(name="training-with-caching")
def training_pipeline(input_path: str = "gs://bucket/data.csv"):
preprocess_data(input_path=input_path)
Where to run: your local development machine or CI environment where the Kubeflow SDK is installed. Permissions: none are needed to author the file; cluster permissions are needed only when you submit the pipeline.
Expected check: after submission, inspect the compiled pipeline YAML or the run details in the Kubeflow UI. Look for a caching-related annotation or field on the component. If you cannot find one, your version may require pipeline-run-level execution options instead.
Risk: enabling caching on the wrong step can skip work that updates external state. Review each component before adding the flag.
Cache keys, staleness, and image digests
A cache key usually combines the component inputs and the container image digest. If you change Python code inside the component but do not rebuild the image or change the inputs, the cache key may stay the same and the old output may be reused. If you change an input even slightly, the key changes and the component should re-execute.
This means caching works well for stable preprocessing with changing hyperparameters downstream, but poorly for iterative development where you edit component code without bumping the image tag.
How to verify a cache hit or miss
- Submit the pipeline with fixed inputs and let it complete.
- Submit the same pipeline again with identical inputs.
- In the Kubeflow UI or Argo workflow view, check whether the cached steps show a skipped or cached status instead of running containers.
- Change one input slightly and submit again. The affected step and any downstream steps depending on it should re-execute.
Where to run diagnostics: a terminal with access to the cluster, or the Kubeflow Pipelines UI.
kubectl -n get pipelineruns -o yaml
Permissions: read access to Kubeflow Pipelines custom resources in the target namespace. Expected checks: step statuses reflect cached or skipped states; container logs are absent for cached steps. Risks: using the wrong namespace confuses runs from different teams, and a "Succeeded" status alone does not prove caching happened.
Limitation: caching can hide bugs
The most practical danger is stale trust. If a preprocessing step had a bug and produced a bad output, caching lets every later run reuse that bad output until the cache key changes. You may spend hours debugging downstream models when the root cause is a reused artifact from two runs ago.
Cached outputs live in the pipeline metadata store. Make sure your retention and backup policy matches your compliance needs, because deleting or losing the store can force every step to re-run.
Actionable closing
Enable caching only for deterministic, side-effect-free components whose outputs are expensive to recreate. Start with one preprocessing step, verify a hit and a miss using the steps above, and expand gradually. If your deployment uses Tekton or an older Kubeflow version, confirm caching support before building pipelines around it.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.