Skip to main content

RayD: Dr.Jit-native GPU primitives for differentiable ray geometry and multipath simulation.

Project description

RayD

PyPI Downloads Code Size Total Lines License

RayD is a Dr.Jit-native GPU library for differentiable ray geometry and multipath simulation primitives built on OptiX.

pip install rayd

RayD is not a full renderer. It exposes low-level scene, ray, edge, visibility, and reflection-path queries for building custom renderers, RF simulators, acoustic tools, and inverse-design systems without adopting a material-light-integrator framework.

Scope

RayD focuses on geometry and wave-propagation primitives:

  • differentiable ray-mesh intersection
  • scene-level GPU acceleration through OptiX
  • nearest-edge queries through a scene-global edge BVH
  • primary-edge sampling support for edge-based gradient terms
  • segment visibility and multipath reflection primitives
  • Dr.Jit arrays and Dr.Jit autodiff as the public Python API

RayD intentionally does not provide:

  • a material or BSDF system
  • emitters
  • integrators
  • scene loading
  • image I/O
  • a complete path-tracing runtime
  • alternate Python frontend wrappers

Why RayD?

RayD is for users who need fast differentiable geometry queries, but do not want a full rendering framework.

Mitsuba is excellent for physically based rendering, but it can be too high-level when the main workload is RF propagation, acoustics, sonar, visibility analysis, or custom wave simulation. In those settings, direct control over ray-scene queries, edge queries, reflection paths, and geometry gradients is often more useful than a complete renderer.

RayD keeps the API surface small: meshes, scenes, rays, intersections, edges, and multipath query results.

Core API

  • Mesh: triangle geometry, transforms, UVs, and edge topology
  • Scene: a container of meshes plus OptiX acceleration structures
  • scene.intersect(ray): differentiable ray-mesh intersection
  • scene.shadow_test(ray): occlusion testing
  • scene.nearest_edge(query): nearest-edge queries for points and rays
  • scene.set_edge_mask(mask) / scene.edge_mask(): scene-global filtering for secondary-edge queries
  • scene.trace_reflections(...): specular reflection-path tracing
  • scene.visible(...): batched segment visibility queries
  • scene.trace_reflection_epc(...): equivalent-path correction primitives for reflection paths

Feature Overview

Each core query, what it computes, its input/output, and how it behaves under Dr.Jit autodiff (AD):

API What it computes Input → Output AD
scene.intersect(ray) Closest-hit ray–mesh intersection rays → Intersection (t, point, normal, uv, ids) Diff.
scene.shadow_test(ray) Any-hit occlusion test rays → boolean mask Boolean
scene.nearest_edge(point) Nearest scene edge to each point points → NearestPointEdge (distance, points, edge id) Diff.
scene.nearest_edge(ray) Nearest scene edge to each ray (segment on [0, tmax] when tmax is finite) rays → NearestRayEdge Diff.
scene.nearest_edges_topk(point, k) k nearest scene edges per point (k ≤ 16) points → NearestEdgesTopK Diff.
scene.visible(start, end) Mutual visibility between two segment endpoints endpoints → SegmentVisibility Boolean
scene.visible_pair / visible_chain / visible_axial_edge Shared-origin pair, polyline-chain, and edge-sample visibility segments → segment/chain/axial-edge visibility Boolean
scene.trace_reflections(ray, max_bounces) Specular reflection paths with image sources rays → ReflectionChain (hit points, normals, image sources, ids) Diff.
scene.trace_reflection_epc(ray, receiver, ...) Equivalent-path-correction reflection toward a receiver rays + receiver → ReflectionEpcResult Detached
scene.trace_reflection_epc_field(...) EPC trace returning the complex reflected field rays/tx + receiver → ReflectionEpcFieldResult (complex E-field) Detached
scene.accumulate_reflections(...) Accumulate reflected field/power onto a grid rays + grid + material → accumulation result Detached

AD legend:

  • Diff. — differentiable: geometric outputs carry gradients with respect to mesh vertices and transforms; the discrete hit/edge/path selection runs detached.
  • Boolean — returns occlusion/visibility booleans and is not differentiable.
  • Detached — native fast path: runs detached only and rejects AD inputs.

Minimal Example

The example below traces one ray against one triangle and backpropagates the hit distance to the vertex positions.

import drjit as dr
import rayd as rd


mesh = rd.Mesh(
    dr.cuda.Array3f([0.0, 1.0, 0.0],
                    [0.0, 0.0, 1.0],
                    [0.0, 0.0, 0.0]),
    dr.cuda.Array3i([0], [1], [2]),
)

verts = dr.cuda.ad.Array3f(
    [0.0, 1.0, 0.0],
    [0.0, 0.0, 1.0],
    [0.0, 0.0, 0.0],
)
dr.enable_grad(verts)
mesh.vertex_positions = verts

scene = rd.Scene()
scene.add_mesh(mesh)
scene.build()

ray = rd.Ray(
    dr.cuda.ad.Array3f([0.25], [0.25], [-1.0]),
    dr.cuda.ad.Array3f([0.0], [0.0], [1.0]),
)

its = scene.intersect(ray)
loss = dr.sum(its.t)
dr.backward(loss)

print("t =", its.t)
print("grad z =", dr.grad(verts)[2])

Edge Queries

RayD provides a scene-level edge acceleration structure for nearest-edge and edge-sampling workloads.

This is useful for:

  • edge sampling
  • nearest-edge queries
  • visibility-boundary terms
  • geometric diffraction models

Scene.set_edge_mask(mask) filters the secondary-edge BVH in scene-global edge index space. It does not modify scene.edge_info(), scene.edge_topology(), or scene.mesh_edge_offsets().

Multipath Queries

RayD includes low-level reflection and visibility primitives for custom wave simulators:

  • trace_reflections(...) for specular reflection chains
  • visible(...), visible_pair(...), visible_chain(...), and visible_axial_edge(...) for segment and polyline-chain visibility
  • trace_reflection_epc(...) and trace_reflection_epc_field(...) for equivalent-path correction workflows
  • accumulate_reflections(...) for grid accumulation workloads

These APIs expose primitives, not a complete propagation simulator. Callers own the source model, receiver model, material policy, objective, and optimization loop.

Examples

Performance

The chart below was generated on March 25, 2026 on an NVIDIA GeForce RTX 5080 and AMD Ryzen 7 9800X3D, comparing RayD (0.1.2) against Mitsuba 3.8.0 with the cuda_ad_rgb variant.

Raw benchmark data is stored in docs/performance_benchmark.json.

  • RayD is consistently faster on static forward and static gradient workloads across all three scene sizes.
  • Dynamic reduced forward reaches parity or better from the medium scene onward, and dynamic full is effectively tied on the largest case.
  • On the largest 192x192 mesh / 384x384 ray benchmark, RayD vs Mitsuba average latency in milliseconds is: static full 0.162 vs 0.190, static reduced 0.124 vs 0.224, dynamic full 0.741 vs 0.740, dynamic reduced 0.689 vs 0.714, gradient static 0.411 vs 0.757, gradient dynamic 1.324 vs 1.413.
  • Correctness stayed aligned throughout the sweep: forward mismatch counts remained 0, and the largest static gradient discrepancy was 9.54e-7.

RayD vs Mitsuba performance benchmark

Device Selection

RayD follows Dr.Jit's current-thread CUDA device selection. Choose a GPU before constructing RayD resources:

import rayd as rd

rd.set_device(0)

Existing RayD scenes, OptiX pipelines, and BVHs should not be reused across device switches in the same process.

Building Locally

RayD is a Python package with a C++/CUDA extension.

You need Python >=3.10, CUDA Toolkit >=11.0, CMake, a C++17 compiler, drjit==1.3.1, nanobind==2.9.2, and scikit-build-core.

On Windows, use Visual Studio 2022 with Desktop C++ tools. On Linux, use GCC or Clang with C++17 support.

Recommended environment:

conda create -n myenv python=3.10 -y
conda activate myenv
python -m pip install -U pip setuptools wheel
python -m pip install cmake scikit-build-core nanobind==2.9.2
python -m pip install drjit==1.3.1

Install from the repository root:

python -m pip install .

For editable development builds:

python -m pip install --no-build-isolation -ve .

Repository Layout

Testing

python -m unittest tests.drjit.test_geometry -v
python -m unittest tests.drjit.test_visibility_topk -v
python -m unittest tests.drjit.test_reflection_epc -v
python -m unittest tests.drjit.test_reflection_accumulation -v
python -m unittest tests.test_project_metadata -v

The default development environment used by this repository is:

conda activate witwin3

Credits

RayD is developed with reference to:

Citation

@inproceedings{chen2026rfdt,
  title     = {Physically Accurate Differentiable Inverse Rendering
               for Radio Frequency Digital Twin},
  author    = {Chen, Xingyu and Zhang, Xinyu and Zheng, Kai and
               Fang, Xinmin and Li, Tzu-Mao and Lu, Chris Xiaoxuan
               and Li, Zhengxiong},
  booktitle = {Proceedings of the 32nd Annual International Conference
               on Mobile Computing and Networking (MobiCom)},
  year      = {2026},
  doi       = {10.1145/3795866.3796686},
  publisher = {ACM},
  address   = {Austin, TX, USA},
}

License

BSD 3-Clause. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rayd-0.4.0.tar.gz (2.0 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

rayd-0.4.0-cp313-cp313-win_amd64.whl (3.9 MB view details)

Uploaded CPython 3.13Windows x86-64

rayd-0.4.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

rayd-0.4.0-cp312-cp312-win_amd64.whl (3.9 MB view details)

Uploaded CPython 3.12Windows x86-64

rayd-0.4.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

rayd-0.4.0-cp311-cp311-win_amd64.whl (3.9 MB view details)

Uploaded CPython 3.11Windows x86-64

rayd-0.4.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

rayd-0.4.0-cp310-cp310-win_amd64.whl (3.9 MB view details)

Uploaded CPython 3.10Windows x86-64

rayd-0.4.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file rayd-0.4.0.tar.gz.

File metadata

  • Download URL: rayd-0.4.0.tar.gz
  • Upload date:
  • Size: 2.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rayd-0.4.0.tar.gz
Algorithm Hash digest
SHA256 8f7200618dc2a11901a6434fd33d3f79238d357206a3eab25a395cb3ebbb5870
MD5 110fe27daae732e48857f277c6931385
BLAKE2b-256 4fea1d27f335376d85e382774a0a61277d3243ecc8abb04fe794d18c76fda10f

See more details on using hashes here.

Provenance

The following attestation bundles were made for rayd-0.4.0.tar.gz:

Publisher: pypi.yml on Asixa/RayD

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rayd-0.4.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: rayd-0.4.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 3.9 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rayd-0.4.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 7b050e5d85ff291282ab80445ebbb214cfc38c606a548cf11ac52135a07f2957
MD5 e5e3a66bd3a6f58732ddc11eb43a8b15
BLAKE2b-256 49c005faea3e000f453214243aa316d8070ba9a68369e2f94d1f26e460ba8e06

See more details on using hashes here.

Provenance

The following attestation bundles were made for rayd-0.4.0-cp313-cp313-win_amd64.whl:

Publisher: pypi.yml on Asixa/RayD

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rayd-0.4.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rayd-0.4.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f1a2bbd99b825df28f6ad3ab638fb3b0cb2f8067e426e45a9d3ad28aa20ba411
MD5 52bf08067b3814f1b57b564705a41d5f
BLAKE2b-256 b25c191b01187cc9ab267eadb8883857c0868966cb0915434bc2b30abe5daa6a

See more details on using hashes here.

Provenance

The following attestation bundles were made for rayd-0.4.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: pypi.yml on Asixa/RayD

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rayd-0.4.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: rayd-0.4.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 3.9 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rayd-0.4.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3bb57cbfe1ee5236f4248f0ff3a6176c3adb4f8d81e2b67d43c7cdd61920c134
MD5 3881f7fc3916fbf4b1e796f35ad62a27
BLAKE2b-256 94cdf0f59f76f5836b3b2eae9a0d23e6cdc6912bfbb55f2e0ee4bf00478f3b4d

See more details on using hashes here.

Provenance

The following attestation bundles were made for rayd-0.4.0-cp312-cp312-win_amd64.whl:

Publisher: pypi.yml on Asixa/RayD

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rayd-0.4.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rayd-0.4.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1df2a85fa4a73284643c4e29ef639a338e3bf14615ff7618b9eda013e9d4c3fc
MD5 1913f4d2308152051d41d3234afe7207
BLAKE2b-256 8fc967b4cb5667062eaa2778ac1c44926487b5721380174bfc3fd869536dba10

See more details on using hashes here.

Provenance

The following attestation bundles were made for rayd-0.4.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: pypi.yml on Asixa/RayD

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rayd-0.4.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: rayd-0.4.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 3.9 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rayd-0.4.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 2300cd40e3075cf064584291b28a227e67e2f97b6d7fb02a96de022d7d25d85d
MD5 e473a678273b5db2bf4a16b7622561ad
BLAKE2b-256 740c1ebce1c5c6f66efbec234f6b6b522f5550eba87bf37b21d70c362a263497

See more details on using hashes here.

Provenance

The following attestation bundles were made for rayd-0.4.0-cp311-cp311-win_amd64.whl:

Publisher: pypi.yml on Asixa/RayD

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rayd-0.4.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rayd-0.4.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8699aa3688e0c5a1d01a547a6cd2d962b2cc8fa72494625a4ce13af2c7ba3920
MD5 6e35e43b9c441e921608f30e7af60599
BLAKE2b-256 6dac50b3fe447586f0cac28118ef37d565956a91fa46fd512835be86f6d91543

See more details on using hashes here.

Provenance

The following attestation bundles were made for rayd-0.4.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: pypi.yml on Asixa/RayD

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rayd-0.4.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: rayd-0.4.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 3.9 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rayd-0.4.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 66e953f4f88bdfb75310d26b34f72b6c543c5fc4c193e8024d1fb3a6699baf60
MD5 74e52abb4028ec017b02cc6f86e5a793
BLAKE2b-256 853eced968ff1103eee6a83f8ee46798de62f146bdf9d33dd5aef877ad2a68ab

See more details on using hashes here.

Provenance

The following attestation bundles were made for rayd-0.4.0-cp310-cp310-win_amd64.whl:

Publisher: pypi.yml on Asixa/RayD

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rayd-0.4.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rayd-0.4.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e183ce387ebd0e8a2cdb4f49040d15cc93a1906e782c85ddfb2eca6b0c53e4d8
MD5 63f88b524e77f6df1bb81ec627f06b7c
BLAKE2b-256 76c4e592294737ae0480d16755cc6f12bc1704e6df546cf64dafd05f21f4f842

See more details on using hashes here.

Provenance

The following attestation bundles were made for rayd-0.4.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: pypi.yml on Asixa/RayD

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page