Subject: Bypassing std::vector re-allocation in Catalyst Lightning C++ backend via custom CXL/L3 pointers?

Hi Catalyst Team,

We are benchmarking ultra-low-latency execution pipelines for high-dimensional state vectors in Catalyst (v0.18+).

Currently, the Lightning C++ backend re-allocates state vectors via standard heap allocators during JIT execution, introducing microsecond-level memory allocation jitter. Is there an officially supported interface or MLIR lowering hook to pass a pre-allocated/fixed L3 cache pointer (e.g., CXL.mem zero-copy memory region) directly into LightningStateVector without triggering dynamic memory allocation?

Best,

Peter Jang | Kenosian

Hi Peter, thanks for reaching out!

Are you doing a one-off allocation of the statevector, or do your workflows before perform dynamic qubit allocations that would then result in repeated allocation/deallocation of the statevector?

Hi David,

Thanks for following up!

To answer directly: our workflows perform a one-off, fixed-size allocation at initialization. We strictly avoid dynamic qubit allocations or dynamic register resizing during execution.

The issue we are encountering is that even with static circuits, Catalyst’s JIT pipeline and Lightning C++ backend default to allocating their own heap memory (LightningStateVector) upon execution. This introduces microsecond-level memory allocation jitter into what should be a fully deterministic execution loop.

To give you context on our setup: we stream high-dimensional state vectors directly from QPU event streams (SNSPD + ps-TDC → AMD Alveo FPGA PCIe DMA) into a pre-allocated zero-copy memory region (e.g., CXL.mem / NUMA-pinned memory) on our AMD bare-metal backline, bound to our OpenTTT AWS AMI Edge time-sealing engine (IETF spec).

Because these state vectors must be cryptographically time-sealed at line-rate without standard heap allocation overhead, any dynamic reallocation in the host pipeline breaks our sub-microsecond timing bounds.

What we are looking for is an officially supported MLIR lowering hook, or a runtime C-API descriptor in Catalyst (v0.18+), that allows us to pass a pre-allocated raw pointer (uintptr_t) directly into the Lightning backend effectively overriding the default memref.alloc behavior.

Does the current Catalyst pipeline expose a way to plug in a custom memory descriptor or override the statevector allocation pass?

Best,

Peter Jang

Lead Architect, Kenosian

Thank you for providing more details.

Does the current Catalyst pipeline expose a way to plug in a custom memory descriptor or override the statevector allocation pass?

Unfortunately, I don’t think there is a hook for this at the moment. I also can’t promise that it will be released in Catalyst in the near-term either. Perhaps you could modify Lightning directly to suit your needs?

Hi David,

Thanks for the candid and practical guidance. Pivoting directly to the pennylane-lightning C++ runtime layer makes total sense—it completely bypasses Catalyst’s MLIR lowering constraints and gives us the deterministic control we need immediately.

By targeting Lightning directly, our goal is two-fold:

  1. Eliminate the deterministic loop breakage and microsecond-level jitter caused by std::vector dynamic heap reallocations.
  2. Align the causal time-axis between physical QPU events and simulated statevectors using an open, vendor-neutral standard (the IETF TTTPS specification).

To give you clearer visibility into why we require this specific zero-copy path on the AMD bare-metal backline, our architecture addresses four hardware-level constraints where standard std::vector acts as an anti-pattern:

  1. Cryptographic Attestation Beyond Clock Sync:
    While our AMD Alveo FPGA provides onboard IEEE 1588 PTP (/dev/ptpX), physical clock synchronization alone lacks cryptographic attestation. Standard PTP counters can be spoofed or replayed at the kernel/driver level. For verifiable quantum benchmarking—specifically proving state transitions occurred strictly within physical coherence windows without pre-computation spoofing, we bind an O(1) line-rate cryptographic seal (180-byte atomic record) directly to the event stream.

  2. Resolving Heterogeneous Bus Drift in Hybrid Loops:
    Our data path spans multiple clock domains: Photonic QPU (SNSPD/ps-TDC) ──► AMD Alveo FPGA (PCIe QDMA) ──► Host CXL/DDR5 ──► PennyLane-Lightning. In closed-loop hybrid workloads (VQE, QAOA), microsecond-level bus drift breaks causal ordering between physical QPU detection events and simulated statevectors. A standardized time-sealed header guarantees deterministic ordering across these disparate bus boundaries.

  3. Vendor-Neutral Open Standard (IETF Specification):
    Rather than building a proprietary FPGA logging wrapper that locks the stack into a single hardware silo, we are aligning with the open IETF TTTPS specification. This ensures PennyLane-Lightning remains verifiable and vendor-neutral across AMD bare-metal, AWS, or multi-tenant HPC environments, a strict prerequisite for DoE and enterprise compliance.

Technical Question on pennylane-lightning Memory Abstraction:
To interface our external AMD Alveo DMA ring-buffer directly with Lightning, std::vector’s exclusive ownership model forces unnecessary memcpy operations and introduces four critical bottlenecks:
• Heap Allocation Jitter & Lock Contention: Ptmalloc heap metadata overhead and page faults in real-time execution loops.
• Ownership & Zero-Copy Violation: Inability to wrap pre-allocated external DMA physical memory (uintptr_t) without taking ownership or copying multi-gigabyte statevectors.
• SIMD Cache-Line Misalignment: Failure to strictly guarantee 64-byte alignment, forcing unaligned AVX-512 vector loads (_mm512_loadu_pd) and degrading vectorized gate throughput.
• NUMA Remote Node Penalties: Allocation across disparate sockets, causing catastrophic cross-die Infinity Fabric latency penalties.

Given this, what is the cleanest extension point in pennylane-lightning to inject an external, non-owning, 64-byte aligned raw pointer into StateVectorBase (e.g., custom allocator specialization vs. extending DataBuffer) without triggering dynamic reallocations or breaking AVX-512 SIMD dispatch?

Once we benchmark this pipeline on our AMD Alveo backline, we would be very glad to contribute an open PR / reference implementation for non-owning memory descriptor hooks back to the PennyLane community.

Best,
Peter Jang
Lead Architect, Kenosian

Given this, what is the cleanest extension point in pennylane-lightning to inject an external, non-owning, 64-byte aligned raw pointer into StateVectorBase (e.g., custom allocator specialization vs. extending DataBuffer) without triggering dynamic reallocations or breaking AVX-512 SIMD dispatch?

This class would be a good starting point, since it construct a statevector from existing memory: pennylane-lightning/pennylane_lightning/core/simulators/lightning_qubit/StateVectorLQubitRaw.hpp at cf9c83bf8c2839a8a76808a62f3dd535b78bdb2e · PennyLaneAI/pennylane-lightning · GitHub
You might have to implement some additional plumbing to use it from Catalyst though.

Once we benchmark this pipeline on our AMD Alveo backline, we would be very glad to contribute an open PR / reference implementation for non-owning memory descriptor hooks back to the PennyLane community.

That’s a fantastic idea, looking forward to it! :slight_smile:

Adding onto David’s helpful tips – thanks again for your interest, Peter!

Glad to see your excitement and wanting to push forward with a PR! However, as our teams are limited in capacity, I would suggest that you make your own fork and build on top of PennyLane via your own repo. This can let you build at your own pace and show off your very own project!

Please feel free to share updates as you and your team make major advances!

Best,

Ben

Hi Ben

I delete the article

Because no one interested it