Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
5ae18e5
Define runtime transport layer interface for backline backends
josephleekl Jul 20, 2026
5e76333
update changelog
josephleekl Jul 20, 2026
279a2b4
comments
josephleekl Jul 20, 2026
a319b39
update changelog
josephleekl Jul 20, 2026
0bb4b19
Merge branch 'main' into josephleekl/transport-layer
josephleekl Jul 20, 2026
c523f67
Transport Layer Loader is added
rniczh Jul 20, 2026
2b88bd4
Merge branch 'main' into josephleekl/transport-layer
josephleekl Jul 20, 2026
8dccc62
update interface
rniczh Jul 20, 2026
fc399e9
Merge branch 'josephleekl/transport-layer' into rniczh/tranport-layer…
rniczh Jul 20, 2026
cdee60b
coprocessor backend interface is added
rniczh Jul 20, 2026
da41e92
chagne type
rniczh Jul 20, 2026
2b6c1e9
Merge branch 'josephleekl/transport-layer' into rniczh/tranport-layer…
rniczh Jul 20, 2026
6e942a9
remove redundancy
rniczh Jul 20, 2026
4408322
add start
rniczh Jul 20, 2026
5282f5a
update comment
rniczh Jul 20, 2026
2b36a11
Merge branch 'josephleekl/transport-layer' into rniczh/tranport-layer…
rniczh Jul 20, 2026
32fc6f2
update changelog
rniczh Jul 20, 2026
2fc50c3
update
rniczh Jul 20, 2026
4d211ce
update
rniczh Jul 20, 2026
060458b
remove redundancy
rniczh Jul 20, 2026
246a4b7
number of collection is always 1
rniczh Jul 20, 2026
22cd621
update interface
rniczh Jul 20, 2026
5b57ef4
Merge branch 'josephleekl/transport-layer' into rniczh/tranport-layer…
rniczh Jul 20, 2026
7630570
Update runtime/include/Transport.hpp
rniczh Jul 21, 2026
da12f30
Apply suggestion from @mehrdad2m
rniczh Jul 21, 2026
5490f08
Apply suggestion from @mehrdad2m
rniczh Jul 21, 2026
5d639c5
Apply suggestion from @mehrdad2m
rniczh Jul 21, 2026
30ebdf0
Merge branch 'josephleekl/transport-layer' into rniczh/tranport-layer…
rniczh Jul 21, 2026
e04d7b2
Merge branch 'transport-to-llvm-pass' into rniczh/tranport-layer-loader
mehrdad2m Jul 21, 2026
b09fcc5
Merge branch 'transport-to-llvm-pass' into rniczh/tranport-layer-loader
mehrdad2m Jul 22, 2026
6b84b8c
Merge branch 'transport-to-llvm-pass' into rniczh/tranport-layer-loader
mehrdad2m Jul 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion doc/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

* A new runtime transport layer for remote/local executors is introduced.
[(#3043)](https://github.com/PennyLaneAI/catalyst/pull/3043)
[(#3045)](https://github.com/PennyLaneAI/catalyst/pull/3045)

* A `BufferizableOpInterface` implementation is now added for `catalyst.launch_kernel` operation and it is now bufferizable.
[(#3024)](https://github.com/PennyLaneAI/catalyst/pull/3024)
Expand Down Expand Up @@ -478,4 +479,5 @@ Mehrdad Malekmohammadi,
River McCubbin,
Shuli Shu,
Paul Haochen Wang,
Jake Zaia.
Jake Zaia,
Hongsheng Zheng.
1 change: 1 addition & 0 deletions runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ option(RUNTIME_ENABLE_WARNINGS "Enable -Wall and -Werror" ON)

option(ENABLE_OPENQASM "Build OpenQasm backend device" OFF)
option(ENABLE_OQD "Build OQD backend device" OFF)
option(ENABLE_TRANSPORT "Build the backend-agnostic transport loader (rt_transport)" OFF)

set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
Expand Down
76 changes: 76 additions & 0 deletions runtime/include/TransportBackend.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Copyright 2026 Xanadu Quantum Technologies Inc.

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

// http://www.apache.org/licenses/LICENSE-2.0

// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// The plugin ABI for out-of-tree transport backends.
//
// A transport backend is a shared library that implements a TransportSession role (controller or
// coprocessor) and exports the matching factory symbol.

#pragma once
#ifndef TRANSPORTBACKEND_H
#define TRANSPORTBACKEND_H

#include <cstdio>
#include <exception>

#include "Transport.hpp"

#define CATALYST_TRANSPORT_CONTROLLER_FACTORY_SYMBOL "CatalystTransportControllerFactory"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need one for coprocessor too? or can they be united?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I don't know how the coprocessor works in this design, do you have any idea of this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the coprocessor is just the same as the controller, it will also have a .so

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, let me add it

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done cdee60b

#define CATALYST_TRANSPORT_COPROCESSOR_FACTORY_SYMBOL "CatalystTransportCoprocessorFactory"

// The factory signatures backends must export with C linkage.
extern "C" {
using CatalystTransportControllerFactoryFn = catalyst::transport::ControllerSession *(const char *);
using CatalystTransportCoprocessorFactoryFn =
catalyst::transport::CoprocessorSession *(const char *);
}

// A helper template macro to generate the <IDENTIFIER>Factory function.
// e.g. GENERATE_TRANSPORT_CONTROLLER_FACTORY(CatalystTransportController, make_controller)
// where `make_controller(const std::string &config) -> ControllerSession*`.
#define GENERATE_TRANSPORT_CONTROLLER_FACTORY(IDENTIFIER, BUILDER) \
extern "C" catalyst::transport::ControllerSession *IDENTIFIER##Factory(const char *config) \
{ \
try { \
return (BUILDER)(config ? std::string(config) : std::string()); \
} \
catch (const std::exception &e) { \
std::fprintf(stderr, "[transport] controller factory failed: %s\n", e.what()); \
return nullptr; \
} \
catch (...) { \
std::fprintf(stderr, "[transport] controller factory failed: unknown exception\n"); \
return nullptr; \
} \
}

// e.g. GENERATE_TRANSPORT_COPROCESSOR_FACTORY(CatalystTransportCoprocessor, make_coprocessor)
// where `make_coprocessor(const std::string &config) -> CoprocessorSession*`.
#define GENERATE_TRANSPORT_COPROCESSOR_FACTORY(IDENTIFIER, BUILDER) \
extern "C" catalyst::transport::CoprocessorSession *IDENTIFIER##Factory(const char *config) \
{ \
try { \
return (BUILDER)(config ? std::string(config) : std::string()); \
} \
catch (const std::exception &e) { \
std::fprintf(stderr, "[transport] coprocessor factory failed: %s\n", e.what()); \
return nullptr; \
} \
catch (...) { \
std::fprintf(stderr, "[transport] coprocessor factory failed: unknown exception\n"); \
return nullptr; \
} \
}

#endif // TRANSPORTBACKEND_H
91 changes: 91 additions & 0 deletions runtime/include/TransportCAPI.h

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I forgot this 4408322 (this PR)

@rniczh rniczh Jul 20, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But on my side, the implementation of start is empty now, would be useful in the future if we need something to setup like warmup

Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// Copyright 2026 Xanadu Quantum Technologies Inc.

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

// http://www.apache.org/licenses/LICENSE-2.0

// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// TransportCAPI.h - C entry points the Catalyst compiler emits to drive a transport session.
//
// The backend is a separate plugin `.so` the runtime dlopen's at session create (see
// TransportBackend.h)

#pragma once
#ifndef TRANSPORTCAPI_H
#define TRANSPORTCAPI_H

#include <stddef.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

// Opaque transport session handle
typedef struct CatalystTransportSession CatalystTransportSession;

// Return codes: 0 == success; negative == error
Comment thread
josephleekl marked this conversation as resolved.
enum {
CATALYST_TRANSPORT_OK = 0,
CATALYST_TRANSPORT_ERR = -1, // Generic exception
CATALYST_TRANSPORT_ERR_MEMORY = -2, // Memory error
CATALYST_TRANSPORT_ERR_TIMEOUT = -3, // Timeout error
CATALYST_TRANSPORT_ERR_STUCK = -4, // Something got stuck
};

// DataPath enum (mirrors catalyst::transport::DataPath)
enum {
CATALYST_TRANSPORT_PATH_CPU_VERBS = 0,
CATALYST_TRANSPORT_PATH_GPU_ENGINE = 1,
CATALYST_TRANSPORT_PATH_OTHER = 2,
};

// MemKind enum (mirrors catalyst::transport::MemKind)
enum {
CATALYST_TRANSPORT_MEM_CPU_RAM = 0,
CATALYST_TRANSPORT_MEM_GPU_HBM = 1,
CATALYST_TRANSPORT_MEM_DDR = 2,
CATALYST_TRANSPORT_MEM_OTHER = 3,
};

// Remote peer region descriptor
typedef struct {
uint32_t rkey;
uint64_t remote_addr;
uint64_t size;
} CatalystTransportPeerRef;

// Create a controller session from a named backend plugin `.so` (dlopen'd by the runtime).
// `config` is the backend's "key=value;..." string. Returns NULL on failure.
CatalystTransportSession *__catalyst__transport__controller_create(const char *backend_lib,
const char *config);

void __catalyst__transport__close(CatalystTransportSession *s);
int __catalyst__transport__connect(CatalystTransportSession *s, const char *peer,
uint16_t oob_port);
int __catalyst__transport__exchange_keys(CatalystTransportSession *s,
CatalystTransportPeerRef *out);
int __catalyst__transport__establish_channel(CatalystTransportSession *s, int32_t data_path,
const CatalystTransportPeerRef *peer);
int __catalyst__transport__commit_work_item(CatalystTransportSession *s, uint32_t work_item_idx,
uint64_t in_bytes, uint64_t out_bytes);
void *__catalyst__transport__data_slot(CatalystTransportSession *s);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's for return the data slot for cpu to place the data

void __catalyst__transport__start(CatalystTransportSession *s);
int __catalyst__transport__kick(CatalystTransportSession *s, uint32_t work_item_idx);
int __catalyst__transport__collect(CatalystTransportSession *s, void *correction, uint64_t bytes);
uint64_t __catalyst__transport__last_rtt_ns(CatalystTransportSession *s);
void __catalyst__transport__stop(CatalystTransportSession *s);
void __catalyst__transport__destroy(CatalystTransportSession *s);

#ifdef __cplusplus
} // extern "C"
#endif

#endif // TRANSPORTCAPI_H
4 changes: 4 additions & 0 deletions runtime/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,7 @@ add_subdirectory(QEC)
if(ENABLE_OQD)
add_subdirectory(OQDcapi)
endif()

if(ENABLE_TRANSPORT)
add_subdirectory(transport)
endif()
19 changes: 19 additions & 0 deletions runtime/lib/transport/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
###############################################
# library rt_transport #
###############################################

add_library(rt_transport SHARED TransportCAPI.cpp)

target_include_directories(rt_transport
PUBLIC
${runtime_includes}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/lib/backend/common # DynamicLibraryLoader.hpp
)

target_link_libraries(rt_transport PRIVATE
${CMAKE_DL_LIBS} # dlopen/dlsym for backend plugins
)

set_property(TARGET rt_transport PROPERTY POSITION_INDEPENDENT_CODE ON)
Loading
Loading