Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions mlir/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ add_subdirectory(QecLogical)
add_subdirectory(QecPhysical)
add_subdirectory(Quantum)
add_subdirectory(QRef)
add_subdirectory(Remote)
add_subdirectory(RTIO)
add_subdirectory(Test)
1 change: 1 addition & 0 deletions mlir/include/Remote/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(IR)
3 changes: 3 additions & 0 deletions mlir/include/Remote/IR/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
add_mlir_dialect(RemoteOps remote)
add_mlir_doc(RemoteDialect RemoteDialect Remote/ -gen-dialect-doc)
add_mlir_doc(RemoteOps RemoteOps Remote/ -gen-op-doc)
21 changes: 21 additions & 0 deletions mlir/include/Remote/IR/RemoteDialect.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// 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.

#pragma once

#include "mlir/Bytecode/BytecodeOpInterface.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/OpDefinition.h"

#include "Remote/IR/RemoteOpsDialect.h.inc"
48 changes: 48 additions & 0 deletions mlir/include/Remote/IR/RemoteDialect.td
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// 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.

#ifndef REMOTE_DIALECT
#define REMOTE_DIALECT

include "mlir/IR/OpBase.td"
include "mlir/IR/DialectBase.td"

//===----------------------------------------------------------------------===//
// Remote Dialect Definition
//===----------------------------------------------------------------------===//

def Remote_Dialect : Dialect {
let summary = "Operations for dispatching kernels and calling symbols in a remote executor.";
let description = [{
The `remote` dialect models a small set of operations that describe how a host program
interacts with a remote executor service:

* Opening a session with a remote endpoint
* Shipping a cross-compiled kernel object file or assets to that endpoint
* Dispatching a previously-shipped qnode kernel
* Invoking an arbitrary symbol in a remote shared library
}];

let name = "remote";
let cppNamespace = "::catalyst::remote";
}

//===----------------------------------------------------------------------===//
// Remote Operation Base
//===----------------------------------------------------------------------===//

class Remote_Op<string mnemonic, list<Trait> traits = []> :
Op<Remote_Dialect, mnemonic, traits>;

#endif // REMOTE_DIALECT
25 changes: 25 additions & 0 deletions mlir/include/Remote/IR/RemoteOps.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// 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.

#pragma once

#include "mlir/Bytecode/BytecodeOpInterface.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"

#include "Remote/IR/RemoteDialect.h"

#define GET_OP_CLASSES
#include "Remote/IR/RemoteOps.h.inc"
119 changes: 119 additions & 0 deletions mlir/include/Remote/IR/RemoteOps.td
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
// 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.

#ifndef REMOTE_OPS
#define REMOTE_OPS

include "mlir/IR/OpBase.td"
include "mlir/IR/BuiltinAttributes.td"
include "Remote/IR/RemoteDialect.td"

//===----------------------------------------------------------------------===//
// remote.open
//===----------------------------------------------------------------------===//

def Remote_OpenOp : Remote_Op<"open"> {
let summary = "Open a session with a remote executor.";
let description = [{
Establish a connection to the remote executor reachable at `address`
Subsequent remote operations targeting the same `address` reuse this session.
}];

let arguments = (ins StrAttr:$address);

let assemblyFormat = [{
`(` $address `)` attr-dict
}];
}

//===----------------------------------------------------------------------===//
// remote.send_binary
//===----------------------------------------------------------------------===//

def Remote_SendBinaryOp : Remote_Op<"send_binary"> {
let summary = "Ship a compiled kernel object file to the remote executor.";
let description = [{
Transfer the compiled binary at `binary_path` to the remote executor at `address`.
The remote loads the file and exposes all of its symbols.
`format` selects the wire encoding which is handled by the runtime.
}];

let arguments = (ins
StrAttr:$address,
StrAttr:$binary_path,
DefaultValuedAttr<I32Attr, "0">:$format
);

let assemblyFormat = [{
`(` $address `,` $binary_path `)` attr-dict
}];
}

//===----------------------------------------------------------------------===//
// remote.launch
//===----------------------------------------------------------------------===//

def Remote_LaunchOp : Remote_Op<"launch"> {
let summary = "Dispatch a remote-compiled kernel and receive its results.";
let description = [{
Invoke the kernel previously registered via `remote.send_binary`.
The `inputs` operand list mirrors the original host-side `func.call`
to the kernel; `results` mirrors the kernel's return values.
}];

let arguments = (ins
Variadic<AnyType>:$inputs,
StrAttr:$address,
StrAttr:$kernel_callee
);

let results = (outs Variadic<AnyType>:$results);

let assemblyFormat = [{
`(` $kernel_callee `,` $address `)` `(` $inputs `)` attr-dict
`:` functional-type($inputs, $results)
}];
}

//===----------------------------------------------------------------------===//
// remote.call
//===----------------------------------------------------------------------===//

def Remote_CallOp : Remote_Op<"call"> {
let summary = "Invoke a symbol in a previously-loaded shared library.";
let description = [{
Invoke `symbol` in a shared library already loaded on the remote executor.

The operand list packs input buffers followed by output buffers.
`num_input_args`, when present, marks the boundary: operands `[0, num_input_args)`
are inputs and the remainder are output buffers to be filled by the callee.
Without `num_input_args` all operands are treated as inputs.
}];

let arguments = (ins
Variadic<AnyType>:$inputs,
StrAttr:$address,
StrAttr:$symbol,
OptionalAttr<I32Attr>:$num_input_args
);

let results = (outs Variadic<AnyType>:$results);

let assemblyFormat = [{
`(` $symbol `,` $address `)` `(` $inputs `)` attr-dict
`:` functional-type($inputs, $results)
}];
}

#endif // REMOTE_OPS
1 change: 1 addition & 0 deletions mlir/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ add_subdirectory(QecLogical)
add_subdirectory(QecPhysical)
add_subdirectory(QRef)
add_subdirectory(Quantum)
add_subdirectory(Remote)
add_subdirectory(RTIO)
add_subdirectory(Test)
1 change: 1 addition & 0 deletions mlir/lib/Driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ set(LIBS
ion-transforms
MLIRRTIO
rtio-transforms
MLIRRemote
MLIRCatalystTest
${ENZYME_LIB}
fmt::fmt
Expand Down
3 changes: 3 additions & 0 deletions mlir/lib/Driver/CompilerDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@

#include "RegisterAllPasses.h"

#include "Remote/IR/RemoteDialect.h"

using namespace mlir;
using namespace catalyst;
using namespace catalyst::driver;
Expand Down Expand Up @@ -181,6 +183,7 @@ void registerAllCatalystDialects(DialectRegistry &registry)
registry.insert<mbqc::MBQCDialect>();
registry.insert<ion::IonDialect>();
registry.insert<rtio::RTIODialect>();
registry.insert<remote::RemoteDialect>();
registry.insert<gradient::GradientDialect>();
registry.insert<mitigation::MitigationDialect>();
registry.insert<pauli_frame::PauliFrameDialect>();
Expand Down
1 change: 1 addition & 0 deletions mlir/lib/Remote/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(IR)
10 changes: 10 additions & 0 deletions mlir/lib/Remote/IR/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
add_mlir_library(MLIRRemote
RemoteDialect.cpp
RemoteOps.cpp

ADDITIONAL_HEADER_DIRS
${PROJECT_SOURCE_DIR}/include/Remote

DEPENDS
MLIRRemoteOpsIncGen
)
34 changes: 34 additions & 0 deletions mlir/lib/Remote/IR/RemoteDialect.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// 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.

#include "Remote/IR/RemoteDialect.h"

#include "Remote/IR/RemoteOps.h"

using namespace mlir;
using namespace catalyst::remote;

//===----------------------------------------------------------------------===//
// Remote Dialect
//===----------------------------------------------------------------------===//

#include "Remote/IR/RemoteOpsDialect.cpp.inc"

void catalyst::remote::RemoteDialect::initialize()
{
addOperations<
#define GET_OP_LIST
#include "Remote/IR/RemoteOps.cpp.inc"
>();
}
30 changes: 30 additions & 0 deletions mlir/lib/Remote/IR/RemoteOps.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// 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.

#include "Remote/IR/RemoteOps.h"

#include "mlir/IR/Builders.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/IR/PatternMatch.h"

using namespace mlir;
using namespace catalyst::remote;

//===----------------------------------------------------------------------===//
// Remote Operations
//===----------------------------------------------------------------------===//

#define GET_OP_CLASSES
#include "Remote/IR/RemoteOps.cpp.inc"
1 change: 1 addition & 0 deletions mlir/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ set(TEST_SUITES
PauliFrame
cli
PBC
Remote
RTIO
QecLogical
QecPhysical
Expand Down
Loading
Loading