> For the complete documentation index, see [llms.txt](https://docs.valohai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.valohai.com/executions/advanced-features/time-limits.md).

# Time Limits

Time limits help you control costs and prevent runaway executions. Valohai provides two timeout mechanisms:

* **Time Limit** — Maximum total execution duration
* **No Output Timeout** — Stop if execution produces no logs for a period

Both can be configured in the web UI or in your `valohai.yaml`.

## Time Limit

Set a maximum duration for your execution. When the time limit is reached, Valohai terminates the execution.

**Use cases:**

* Prevent forgotten executions from running indefinitely
* Enforce budget constraints on expensive GPU instances
* Ensure batch jobs complete within a scheduling window

### Set in Web UI

1. Create a new execution
2. Scroll to the **Runtime** section
3. Check **Set a Time Limit**
4. Enter the maximum duration in hours and minutes

> Not setting a time limit allows the execution to run indefinitely. This is the default behavior.

### Set in valohai.yaml

Define a default time limit for a step:

```yaml
- step:
    name: train-model
    image: tensorflow/tensorflow:2.13.0-gpu
    time-limit: 1h  # 1 hour
    command:
      - python train.py {parameters}
```

The `time-limit` value supports human-readable formats like `1h 30m 5s`, or you can specify seconds as an integer (e.g., `3600`).

***

## No Output Timeout

Stop executions that become unresponsive. If your execution produces no logs or output for the specified duration, Valohai terminates it.

**Use cases:**

* Detect and stop hung processes
* Catch infinite loops that produce no output
* Identify network or I/O blocking issues

### Set in Web UI

1. Create a new execution
2. Scroll to the **Runtime** section
3. Check **Set a No Output Timeout**
4. Enter the timeout duration in hours and minutes

> Not setting this will default to about 8 hours.

### Set in valohai.yaml

Define a default no-output timeout for a step:

```yaml
- step:
    name: train-model
    image: tensorflow/tensorflow:2.13.0-gpu
    no-output-timeout: 30m  # 30 minutes
    command:
      - python train.py {parameters}
```

The `no-output-timeout` value supports human-readable formats like `1h 30m 5s`, or you can specify seconds as an integer (e.g., `1800`).

***

## Example: Complete Step Configuration

Combine time limits with other step settings:

```yaml
- step:
    name: train-model
    image: tensorflow/tensorflow:2.13.0-gpu
    time-limit: 4h              # 4 hours max
    no-output-timeout: 30m      # 30 min no-output timeout
    command:
      - pip install -r requirements.txt
      - python train.py {parameters}
    parameters:
      - name: epochs
        default: 100
        type: integer
```

***

## Best Practices

**Set reasonable defaults in YAML.** Define time limits in your `valohai.yaml` so all team members use consistent settings. Override in the UI when needed.

**Use no-output timeout to catch hangs.** Long-running jobs should periodically log progress. If your training loop runs for hours without output, it may be stuck.

**Account for setup time.** Time limits include dependency installation, data download, and model initialization. Give enough buffer for these steps.

**Combine with early stopping.** For training jobs, consider using [early stopping](/tasks/early-stopping.md) based on metrics in addition to time limits.

***

## Troubleshooting

### Execution stopped unexpectedly

Check the execution logs for timeout messages. Common causes:

* **Time limit reached** — Increase the limit or optimize your code
* **No output timeout** — Add periodic logging to your training loop

***

## Related

* [Early Stopping](/tasks/early-stopping.md) — Stop based on metadata conditions
* [Spot Instances](/executions/advanced-features/spot-instances.md) — Handle interruptions for cost savings
* [Run Basic Execution](/executions/run-basic-execution.md) — Creating and running executions


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.valohai.com/executions/advanced-features/time-limits.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
