Hectiq Lab

Stages

A stage is a named phase of a run: loading the data, one epoch, the evaluation. Stages nest, and the web app shows them as a tree, with a bar for the ones that count.

A stage needs an open run. Opening one without a run raises.

Open a stage

There are three ways, and they differ in how the stage closes:

import hectiqlab as hl

with hl.stage("evaluate"):   # closes at the end of the block
    ...

@hl.stage                    # each call is a stage named after the function
def preprocess():
    ...

hl.stage("load")             # closes when the next stage opens
hl.stage("train")

A stage opened with with or a decorator nests inside whatever is open. A stage opened without either replaces the one before it.

NameTypeDefaultDescription
namestrWhat the phase is.
totalintNoneWhat the stage counts up to. Without one there is a count and no bar.
descriptionstrNoneA longer description.

A stage ends completed, or failed when its block raises.

Walk a loop

hl.each walks an iterable and counts it against the stage it runs in:

with hl.stage("train"):
    for batch in hl.each(loader):             # advances the bar of "train"
        ...

    for epoch in hl.each(range(3), "epoch"):  # each item is a stage: epoch-0, epoch-1, epoch-2
        ...
NameTypeDefaultDescription
iterableIterableWhat to walk. Nothing is read ahead.
namestr or a functionNoneA prefix for name-0, name-1…, or a function naming each item's stage. Without one, the loop only counts.
totalintNoneWhat to count up to, when len can't say.

Read a run's stages

stages = hl.runs.stages(42).unwrap()

The stages come in the order they started. Each carries parent, the id of the stage it sits in.

On this page