lc_runtime

Implements GPU compute workflows using LuisaCompute runtime APIs for devices, streams, buffers, and ray tracing.

1.0k|108|Updated Nov 20, 2020
One-click install
npx skills add https://github.com/LuisaGroup/LuisaCompute --skill lc-runtime
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: lc_runtime
Source: https://github.com/LuisaGroup/LuisaCompute/tree/main/.agents/skills/lc_runtime
Command: npx skills add https://github.com/LuisaGroup/LuisaCompute --skill lc-runtime

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing correct GPU compute code with LuisaCompute requires knowing the exact runtime API surface—Context, Device, Stream, Buffer, Image, ray tracing, and rasterization classes—plus subtle build-mode constraints like SAFE-mode buffer transfer rules. This Skill provides the correct API patterns and code examples so you avoid compile errors and misuse.

Core Features & Use Cases

  • Device and Resource Management: Create contexts, devices (CUDA, DX, CPU, Metal), buffers, images, volumes, bindless arrays, and swapchains with correct call signatures.
  • Execution and Synchronization: Submit kernels via streams, batch commands with CommandList, and coordinate multi-stream work with events and timeline events.
  • Ray Tracing and Rasterization: Build meshes, curves, and acceleration structures, write intersection kernels, and set up raster scenes with depth buffers.
  • SAFE-Mode Compatibility: Learn which buffer copy overloads are excluded under LUISA_ENABLE_SAFE_MODE and how to use BufferView and luisa::span alternatives.
  • Use Case: You are writing a CUDA path tracer with LuisaCompute and need to create an Accel, dispatch an intersection kernel, and read back results without triggering SAFE-mode compile errors.

Quick Start

Ask the assistant to write a LuisaCompute program that creates a CUDA device, fills a float buffer with a kernel, and copies the results back to the host in SAFE-mode-compatible style.

Frequently Asked Questions about lc_runtime

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a device and dispatch a kernel in LuisaCompute?

Create a Context from argv[0], call ctx.create_device("cuda"), then compile a Kernel1D with device.compile and submit it via stream << shader(args).dispatch(n) << synchronize(). The runtime handles JIT code generation for the selected backend.

How to copy buffer data between GPU and host in LuisaCompute?

Use stream << buf.copy_from(luisa::span{host_vec}) for uploads and buf.copy_to(luisa::span{host_vec}) for downloads. Span-based overloads work in both normal and SAFE build modes, unlike raw-pointer overloads.

Which backends does LuisaCompute support?

LuisaCompute supports CUDA, DirectX, CPU, and Metal backends, selected by name in ctx.create_device(). You can enumerate installed backends with ctx.installed_backends() and query per-backend device names.

Why does buffer copy_from fail to compile in SAFE mode?

In SAFE mode (LUISA_ENABLE_SAFE_MODE), Buffer<T> raw-pointer and BufferView copy overloads are excluded by preprocessor guards. Route copies through BufferView, e.g. dst.view().copy_from(src), or use luisa::span overloads instead.

How do I build and use a ray tracing acceleration structure in LuisaCompute?

Create a Mesh from vertex and triangle buffers, create an Accel, emplace mesh instances with transforms, then submit mesh.build() and accel.build() on a stream. In kernels, call accel.intersect(ray, {}) to obtain a TriangleHit.

How do I synchronize multiple streams in LuisaCompute?

Create an Event with device.create_event(), then submit event.signal() on one stream and event.wait() on another. For frame-based pipelining, use TimelineEvent with signal(frame) and synchronize(frame) calls.