0
0
MLOpsdevops~5 mins

Promoting models between stages in MLOps - Time & Space Complexity

Choose your learning style9 modes available
Time Complexity: Promoting models between stages
O(models x stages)
Understanding Time Complexity

When moving machine learning models from one stage to another, like from testing to production, it's important to know how the time needed grows as more models or stages are involved.

We want to understand how the process time changes when handling more models or stages.

Scenario Under Consideration

Analyze the time complexity of the following code snippet.


for model in models:
    for stage in stages:
        promote_model(model, stage)

This code promotes each model through all defined stages one by one.

Identify Repeating Operations

Identify the loops, recursion, array traversals that repeat.

  • Primary operation: Calling promote_model for each model and stage combination.
  • How many times: Once for every model times every stage (models x stages).
How Execution Grows With Input

As the number of models or stages increases, the total promotions grow by multiplying these counts.

Input Size (models x stages)Approx. Operations
10 models x 3 stages30 promotions
100 models x 3 stages300 promotions
100 models x 10 stages1000 promotions

Pattern observation: The total work grows by multiplying the number of models and stages.

Final Time Complexity

Time Complexity: O(models x stages)

This means the time needed grows proportionally with both the number of models and the number of stages.

Common Mistake

[X] Wrong: "Promoting models only depends on the number of models, not stages."

[OK] Correct: Each model must be promoted through every stage, so stages multiply the total work, not just models alone.

Interview Connect

Understanding how tasks multiply when combining two lists, like models and stages, helps you explain real-world automation steps clearly and confidently.

Self-Check

"What if we promoted only models that passed tests instead of all models? How would the time complexity change?"