Discovering and Using
Wolfram Language Kernels

Roman E. Maeder, Wolfram Research

Join the Conversation #WolframTechConf

Abstract

Kernel Connection Manager is a system for finding, configuring, and launching Wolfram Language kernels in any network and cloud environment and for performing computations with these kernels. It allows working with local and remote kernels for parallel computing and controlling individual devices, scheduling tasks, and reading sensors.

Kernel Connection Manager consists of a wide range of kernel launchers that implement different ways to discover and connect to kernels on the network and in the cloud.
There are launchers that allow initiating connections to devices and launch kernels on remote computers and HPC clusters, and those that allow the passive discovery of available resources that use the Wolfram Launch Service.

The Wolfram Launch Service is an optional component of a kernel installation that can make available kernels easily discoverable by the Kernel Connection Manager, without requiring any configuration (much like finding available printers or media devices on the network).

Technology Preview

This presentation is a preview of things to come.
Not all features discussed in this talk are currently available in the released versions of the Wolfram Language.

History

Parallel Tools and SubKernels

The Parallel Computing Toolkit became a part of Mathematica over ten years ago.

It supports master/slave parallelism, where the master kernel is connected, via MathLink, to each subkernel.

The SubKernels interface provides different methods for connecting to subkernels:

Local kernels

What was expensive then is now commonplace: multi-core workstations

Kernels launched via remote login

This method was provided mostly for accessing ad-hoc collections of available machines

Kernels on managed clusters

Cluster and job management systems have evolved greatly

Kernels advertised through the Wolfram Lightweight Grid

Limitations

As usage of Parallel Tools becomes more widespread, some of its limitations become apparent:

Master/slave parallelism is not optimized for broadcast and scatter/gather operations

Symmetric multiprocessing requires direct communication among subkernels

The Internet of Things requires new discovery technologies

Connectionless technologies, such as cloud computing, become available

KCM: More Than a Facelift

The first step in modernizing Parallel Tools deals with connections to Wolfram Language kernels.

The Kernel Connection Manager (under development) addresses these new technologies.

New Connection Methods

Ssh is the de-facto standard for remote login. It now supports TCP connection tunneling and multiplexing, which make traversing NAT routers and firewalls easier.

Transaction-based (non-persistent) connection methods are becoming more important (Using web protocols and others).

New Discovery Methods

DNS Service Discovery (AKA avahi, zeroconf, bonjour) is widespread for discovering useful devices on a LAN, such as printers and multi-media  devices.

We use it to discover machines with available Wolfram Language computing resources (Mathematica, Wolfram engine).
Some computers even come with Mathematica pre-installed (such as the Raspberry Pi).

New Communication Models

High-performance symmetric networks, such as MPI, become available in supercomputers and clusters.

Supercomputers and cloud computing infrastructures may support extremely fast shared and distributed file systems.
File-based data transfer is an alternative to MathLink for massive data transfer, including broadcast and gather operations.

Cloud, etc.

Cloud computing, such as the Wolfram Cloud, offer connectionless and stateless computations.
The hosting data centers provide for thousands of CPUs that we may want to use for distributed computing.

Network-enabled devices are another source of ephemeral computing resources.

Kernel Connection Manager

This is very much a WIP, and the various elements have not gone through design polishing.
None of these sample inputs will evaluate in the currently released version of Mathematica.

ConfigureKernelLaunchers[]

Concepts

KCM provides two new object types: Kernel Launchers, and Kernels (including groups of kernels).

Kernel Launcher Packages provide for different methods of configuring, discovering, and launching kernels.
The system is easily extensible with new launcher packages.

Features of Kernels

Kernels maintained by KCM can be used for individual evaluations or combined for parallel computing.

Kernels can be persistent, or ephemeral.

A persistent kernel maintains state between evaluations

This method is the traditional one used by the current Parallel Tools.

An ephemeral kernel does not require an open connection

Each evaluation is a separate unit, that may be evaluated in a different running process (in the cloud, for example).
State is maintained by KCM.

Cloud credentials established in the master kernel can be automatically forwarded to subkernels so that they can access the same cloud account directly.

Types of Kernel Launchers

Local Kernel Launcher

localLauncher

FindKernels[localLauncher]

Remote Login Kernel Launchers

remoteLauncher

FindKernels[remoteLauncher]

Launch Service Kernel Launcher

See below for more information on service kernels.

Cluster Kernel Launchers

Specialized launchers for job management software, or for massive launching of hundreds of kernels in supercomputers or cloud infrastructure.

DIY

The kernel launcher interface is public and you can write your own tailored launchers.

This is already possible with the current SubKernels. If you want to access large clusters or supercomputers today, talk to us!

Walkthrough: The Life of a Kernel

$KernelLaunchers

kernels=FindKernels[$KernelLaunchers]

LaunchKernel[kernels];

(And also the resurrection of a kernel)

Use of Kernels

Individual

KernelEvaluate[$MachineName,$RunningKernels]

Close/@$RunningKernels;

Distributed Computation Framework

KCM will replace the current SubKernel interface to support the continued use of Parallel Tools with these new kernel launchers.

It will support maintaining separate parallel computing environments with different sets of kernels.

Wolfram Launch Service

The Launch Service Daemon

The Launch Service Daemon is an optional component that can be installed with a desktop product.
Once running, it will advertise the available resources (type and number of kernels) on the LAN.

This works in much the same way as printers or multi-medial devices advertise themselves.

Service Discovery

The corresponding service kernel launcher listens for kernel advertisements and allows to choose which ones to use.

To launch these kernels, a request is sent to the launch service daemon to start a kernel and provide the network connection details back to the launcher, which can the connect to the new kernel.

serviceLauncher

Going Beyond MathLink

Stateless Kernels

Commands such as CloudEvaluate[] send an evaluation request to a cloud service (such as the Wolfram Cloud). The cloud service acquires an available kernel and performs the evaluation.

Asynchronous versions of these evaluation commands do not require to wait for the results before proceeding (they do not block), and so can be used for concurrent evaluations by submitting many evaluations, and only then wait for the results to come back.

No state is kept between successive evaluations.

State information, such as definitions for functions, needs to be maintained by the master kernel and provided with each evaluation.

This mode of computation is important for cloud parallelism, and for the Internet of Things, where one does not want to maintain persistent connections to running kernels.

Broadcast and SMP

Tightly coupled clusters and supercomputers provide for very efficient symmetric networking, that is often not TCP/IP based.
Our current communication technology (WSTP) cannot take advantage of all such networks.

However, the same type of network can usually be accessed also via shared, distributed file systems.
Using DumpSave/DumpGet, we can take advantage of these efficient broadcast and gather infrastructure using existing technology. See below for a demo.

Massive Parallelism

Supercomputers

We had access during the pre-production phase of a novel supercomputer at the Texas Advanced Computing Center, which allows interactive access, so that code development in the comfortable Mathematica FrontEnd was possible. This machine has very fast shared and distributed file systems.

Here is a demo of using shared files for efficient broadcast and gathering of Wolfram Language data, using only features of the latest released version of the Wolfram Language.

Cloud Computing Environments

KCM will support two models of concurrent cloud computing:

Using cloud kernels to parallelize computations initiated on your desktop

Easily go into the cloud for a large computation set up on the desktop and receive the results back on your desktop.

Providing larger number of parallel kernels for cloud computing products (Wolfram Cloud or private clouds).

Here, the master kernel itself is also in the cloud, allowing for lower latency between master and subkernels.

Summary

Kernel Connection Manager is the foundation for the next step in distributed and concurrent computation in the Wolfram Language.