Iris Class#

Factory Function#

Prefer using the convenience factory over calling the constructor directly:

Core Methods#

Logging Helpers#

Use Iris-aware logging that automatically annotates each message with the current rank and world size. This is helpful when debugging multi-rank programs.

set_logger_level(level)[source]#

Set the logging level for the iris logger.

Parameters:

level – Logging level (iris.DEBUG, iris.INFO, iris.WARNING, iris.ERROR)

Example

>>> ctx = iris.iris()
>>> iris.set_logger_level(iris.DEBUG)
>>> ctx.debug("This will now be visible")  # [Iris] [0/1] This will now be visible

Utility Functions#

do_bench(fn, barrier_fn=<function <lambda>>, preamble_fn=<function <lambda>>, n_warmup=25, n_repeat=100, quantiles=None, return_mode='mean')[source]#

Benchmark a function by timing its execution.

Parameters:
  • fn (callable) – Function to benchmark.

  • barrier_fn (callable, optional) – Function to call for synchronization. Default: no-op.

  • preamble_fn (callable, optional) – Function to call before each execution. Default: no-op.

  • n_warmup (int, optional) – Number of warmup iterations. Default: 25.

  • n_repeat (int, optional) – Number of timing iterations. Default: 100.

  • quantiles (list, optional) – Quantiles to return instead of summary statistic. Default: None.

  • return_mode (str, optional) – Summary statistic to return (“mean”, “min”, “max”, “median”, “all”). Default: “mean”.

Returns:

Timing result(s) in milliseconds.

Return type:

float or list

Example

>>> import iris
>>> iris_ctx = iris.iris(1 << 20)
>>> def test_fn():
>>>     tensor = iris_ctx.zeros(1000, 1000)
>>> time_ms = iris.do_bench(test_fn, barrier_fn=iris_ctx.barrier)

Broadcast Helper#

Broadcast data from a source rank to all ranks. This method automatically detects whether the value is a tensor/array or a scalar and uses the appropriate broadcast mechanism.