---
title: "Stream"
sidebar_label: "Stream"
description: "The clika_runtime Stream class."
---

<!-- Generated by tools/api_reference/generate_api_docs.py. Do not edit. -->

An execution stream: an ordered queue of device work. Operations submitted to it run in order, asynchronously of the host. A created stream pipelines submission and overlaps independent work; the per-device default stream dispatches on the calling thread instead.

## `device` (property)

The device this stream runs on.

## `__init__`

```python
__init__(self, /, *args, **kwargs)
```

Initialize self.  See help(type(self)) for accurate signature.

## `create`

```python
createcreate(device: clika_runtime._core.Device) -> clika_runtime._core.Stream
```

create(device: clika_runtime._core.Device) -> clika_runtime._core.Stream

Allocate a fresh non-default stream on `device` (for overlapping work).

## `default_stream`

```python
default_streamdefault_stream(device: clika_runtime._core.Device) -> clika_runtime._core.Stream
```

default_stream(device: clika_runtime._core.Device) -> clika_runtime._core.Stream

The per-device default stream; always valid.

## `from_native_handle`

```python
from_native_handlefrom_native_handle(device: clika_runtime._core.Device, native_handle: int) -> clika_runtime._core.Stream
```

from_native_handle(device: clika_runtime._core.Device, native_handle: int) -> clika_runtime._core.Stream

Adopt a native stream you own (the integer handle of a `cudaStream_t`, such as `torch.cuda.Stream().cuda_stream`) as a stream on `device`. Work placed on it runs on that native stream, and the runtime never destroys it. Adopting the same native stream on the same device again returns the same stream. An adopted stream is not released before the process ends. The runtime may synchronize it, query it and reclaim memory on it at any point until then, so keep the native stream alive until the process ends. A handle of 0 raises InvalidArgumentError. It is CUDA's legacy default stream (torch's current stream until one is set), which the runtime cannot order against its own streams, so pass a stream you created. A device whose backend cannot adopt a native stream raises UnsupportedError.

## `is_default`

```python
is_defaultis_default(self) -> bool
```

is_default(self) -> bool

True if this is the device's default stream.

## `query_idle`

```python
query_idlequery_idle(self) -> bool
```

query_idle(self) -> bool

True if the stream currently has no work in flight (a hint, not a barrier).

## `synchronize`

```python
synchronizesynchronize(self) -> None
```

synchronize(self) -> None

Block until all work submitted on this stream has completed.
