Skip to main content
This lesson shows how to pass simple scalar values between components in a Kubeflow Pipelines (KFP) v2 pipeline using parameters. Parameters are intended for small, simple values — for example hyperparameters, evaluation metrics, or scalar flags. For large or complex outputs (models, datasets, binary files), use artifacts instead. What you’ll learn:
  • How to return a scalar value from one component.
  • How to pass that scalar value as an input parameter to another component.
  • Best practices and when to use parameters vs artifacts.

Overview of the example

We implement two components:
  • train_model: performs (mock) training and returns a scalar accuracy (float).
  • evaluate_model: receives the accuracy and an optional threshold and prints whether the model passed.
Pattern: return the scalar from the training task, then pass train_task.output to the evaluation component.

Example implementation (KFP v2 DSL)

Notes on the code
  • Annotate train_model with -> float so the component output type matches the returned value.
  • evaluate_model declares accuracy and an optional threshold (default 0.92).
  • Inside the pipeline, capture the task returned by train_model() and pass train_task.output to evaluate_model(...).
  • The compiler produces a pipeline specification YAML (passing-data-parameters.yaml) you can upload to the Kubeflow UI.

Quick reference: component responsibilities

Compile and run (high-level steps)

  1. Save the Python script (e.g., pipeline.py) containing the example above.
  2. Run the script locally to compile the pipeline:
    • python pipeline.py will generate passing-data-parameters.yaml.
  3. Upload the YAML to the Kubeflow Pipelines UI:
    • In the UI, choose “Upload pipeline” → select passing-data-parameters.yaml → create a run.
  4. Inspect the run once it finishes:
    • View each step’s Inputs / Outputs panels to verify the scalar parameter was passed correctly.
A Kubeflow Central Dashboard "New Pipeline" page is visible with a macOS file-open dialog overlaid, showing files like parameters.yaml and several .py scripts. The Kubeflow navigation menu is shown on the left.

What to expect in the UI

Once the run completes, open the execution details for the evaluation step. You should see the scalar passed as an input parameter for that step (for this example, 0.92) and the usual executor logs under output artifacts. Example UI-style summary (simplified):

Best practices and guidance

  • Use parameters for small scalar values (hyperparameters, thresholds, scalar metrics).
  • Use artifacts to pass models, datasets, or other large/complex outputs.
  • Always type your component outputs (e.g., -> float) so the compiler generates the correct component schema.
Use parameters only for small, simple data such as hyperparameters or scalar metrics. For models, datasets, or any large/complex outputs, use artifacts instead.
Do not use parameters to pass large data. Attempting to serialize large objects as parameters can lead to failures or timeouts. Use artifact storage (e.g., MinIO/GCS) for models, datasets, and other heavy outputs.

Watch Video