Skip to content

[Experimental Backline] Transport Layer Loader is added#3045

Open
rniczh wants to merge 29 commits into
transport-to-llvm-passfrom
rniczh/tranport-layer-loader
Open

[Experimental Backline] Transport Layer Loader is added#3045
rniczh wants to merge 29 commits into
transport-to-llvm-passfrom
rniczh/tranport-layer-loader

Conversation

@rniczh

@rniczh rniczh commented Jul 20, 2026

Copy link
Copy Markdown
Member

Context:

Description of the Change:

Adds a backend-agnostic transport loader to the runtime:

TransportCAPI.h/.cpp: The ABI the compiler/codegen can emit against.
TransportBackend.h: the plugin factory contract; backends are separate .so the runtime dlopens at session create, selected via backend_lib.

make all -DENABLE_TRANSPORT=ON (default OFF) to build

Benefits:

Possible Drawbacks:

Related GitHub Issues:
[sc-123779]

@rniczh
rniczh requested a review from josephleekl July 20, 2026 19:43
@rniczh rniczh changed the title Transport Layer Loader is added [Experimental Backline] Transport Layer Loader is added Jul 20, 2026
Comment thread runtime/include/Transport.hpp Outdated
* @return `int`
*/
virtual int collect(void *const *outputs, std::size_t n) = 0;
virtual int collect(void *const *outputs, const std::size_t *output_bytes, std::size_t n) = 0;

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.

should we use std::uint64_t maybe? for uniformity it doesn't really matter

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.

I updated it in your PR

Comment thread runtime/include/Transport.hpp

#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

@josephleekl josephleekl left a comment

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.

just some quick comments, looks good! tag me again when addressed. thanks @rniczh !

Comment thread runtime/include/TransportCAPI.h
Comment thread runtime/include/TransportCAPI.h Outdated
void __catalyst__transport__close(CatalystTransportSession *s);
int __catalyst__transport__connect(CatalystTransportSession *s, const char *peer,
uint16_t oob_port);
int __catalyst__transport__alloc_reply(CatalystTransportSession *s, uint64_t size, int32_t mem_kind,

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 alloc_reply? should we add that to transport.hpp?

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.

oh, I forgot to remove this redundancy

@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.

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

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

Comment thread runtime/include/TransportCAPI.h Outdated

// ibverbs access flags for the advertised reply region
enum {
CATALYST_TRANSPORT_ACCESS_REPLY = 7,

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? :)

@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.

Redundant code, now the allocation was handled by the implementation: 060458b

return guard([&] { return s->sess->kick(work_item_idx); });
}

int __catalyst__transport__collect(CatalystTransportSession *s, void *correction,

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 signature here seems a bit different than the frontend UI, is that intentional? see https://github.com/PennyLaneAI/catalyst/pull/3043/changes#diff-01e7d52b33c37ab016a8280744ff88e997d75b4aa2bcaa3d051c921c95742e3dR144

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.

Yes, the current API only supports 1 correction data

int __catalyst__transport__collect(CatalystTransportSession *s, void *correction,
                                   std::uint64_t bytes)
{
    if (!s || !s->sess) {
        return CATALYST_TRANSPORT_ERR;
    }
    return guard([&] {
        void *outputs[1] = {correction};
        std::size_t caps[1] = {static_cast<std::size_t>(bytes)};
        return s->sess->collect(outputs, caps, 1);
    });
}

@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.

I think it's also a design should be changed (as in offline discussion with @josephleekl ), the number of collection should be always 1, I'll update this later

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.

rniczh and others added 8 commits July 20, 2026 18:29
Co-authored-by: Mehrdad Malek <39844030+mehrdad2m@users.noreply.github.com>
Co-authored-by: Mehrdad Malek <39844030+mehrdad2m@users.noreply.github.com>
Co-authored-by: Mehrdad Malek <39844030+mehrdad2m@users.noreply.github.com>
Co-authored-by: Mehrdad Malek <39844030+mehrdad2m@users.noreply.github.com>
Base automatically changed from josephleekl/transport-layer to main July 21, 2026 21:04
@mehrdad2m
mehrdad2m changed the base branch from main to transport-to-llvm-pass July 21, 2026 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants