Skip to content

[Remote 1.3] Add remote runtime#2915

Open
rniczh wants to merge 4 commits into
rniczh/add-remote-to-llvmfrom
rniczh/add-remote-runtime
Open

[Remote 1.3] Add remote runtime#2915
rniczh wants to merge 4 commits into
rniczh/add-remote-to-llvmfrom
rniczh/add-remote-runtime

Conversation

@rniczh

@rniczh rniczh commented Jun 4, 2026

Copy link
Copy Markdown
Member

Context:

The remote dialect and its convert-remote-to-llvm lowering emit calls to a set of __catalyst__remote__* symbols, but nothing implements them yet. This PR adds the host-side runtime that backs those symbols.

The things we need to have:

  1. TCP connection to a executor on the remote
  2. Ships kernel objects into the remote ORC JIT
  3. Marshals memref arguments and results across the wire
  4. Manages session lifetime

Description of the Change:

Adds a new runtime component in runtime/include/RemoteCAPI.h for implementing __catalyst__remote__open,
__catalyst__remote__send_binary, __catalyst__remote__launch, 1__catalyst__remote__call_wrapperand __catalyst__remote__close()`

Two processes, one TCP socket, ORC v2 EPC as the wire protocol. The host running the qjit-compiled program, and the remote catalyst executor process listening on a TCP port. Everything between them is carried by LLVM's ORC JIT v2 EPC protocol.

The host walks through five stages, top to bottom:
Open Sessions. The host connects to one or more executor addresses. Each successful connect produces RemoteSession that owns its half of the EPC channel, its ObjectLinkingLayer, and a 1 GB slab (Currently, we fix it to 1GB) reserved on the remote side. The session also resolves four "exported" symbols from the executor that the rest of the stages will need.

  1. Send Binaries (.o or assets). For each qnode, the host pushes the cross-compiled object file across the channel, ORC JITLink lays it into the slab and applies relocations on the remote. The same path also handles assets (data files the kernel will read by path), we use it for .hsa in the future, which is via catalyst_remote_store_asset. The executor writes those to ${tmp}/catalyst-assets/.
  2. Remote Lib Calls. Direct invocations of plugin function in .so, which is used when you need to orchestrate something from the host and require to apply the change on the target device.
  3. Remote Launch. The qnode invocation, broken into three sub-steps:
    • Prepare arguments. For every input memref, the host calls catalyst_remote_alloc once for the data buffer and once for the descriptor remotely, then write the host-side data to the target.
    • Remote Invoke. The host calls catalyst_remote_invoke which takes in the remote entry address, remote return value address, remote argument address as inputs. The executor dispatches to catalyst_pyface symbol. - The kernel runs in the executor’s address space. Any references to .so are resolved by remote dlsym(RTLD_DEFAULT,...) against the loaded libraries.
    • Get the result from the remote. For each output memref the host does allocation then uses Remote Read to copy the kernel-produced data back. The descriptor's pointer slots are rewritten with the host addresses so downstream LLVM IR can dereference them as ordinary memrefs.

Benefits:

Possible Drawbacks:

Related GitHub Issues:
[sc-119223]
[sc-119310]

@rniczh rniczh changed the title Add remote runtime [Remote 1.3] Add remote runtime Jun 4, 2026
@codecov

codecov Bot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.90%. Comparing base (42a2991) to head (586b5d1).

Additional details and impacted files
@@                      Coverage Diff                      @@
##           rniczh/add-remote-to-llvm    #2915      +/-   ##
=============================================================
- Coverage                      96.90%   96.90%   -0.01%     
=============================================================
  Files                            166      166              
  Lines                          19012    19015       +3     
  Branches                        1760     1761       +1     
=============================================================
+ Hits                           18424    18426       +2     
- Misses                           433      434       +1     
  Partials                         155      155              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant