RayD: minimalist differentiable ray tracing package wrapping Dr.Jit and OptiX.
Project description
RayD
RayD is a minimalist differentiable ray tracing package built on top of Dr.Jit and OptiX.
pip install rayd
RayD is not a full renderer. It is a thin wrapper around Dr.Jit and OptiX for building your own renderers and simulators.
The goal is simple: expose differentiable ray-mesh intersection on the GPU without bringing in a full graphics framework.
Why RayD?
RayD is for users who want OptiX acceleration and autodiff, but do not want a full renderer.
Why not Mitsuba? Mitsuba is excellent for graphics rendering, but often too high-level for RF, acoustics, sonar, or custom wave simulation. In those settings, direct access to ray-scene queries and geometry gradients is usually more useful than a full material-light-integrator stack.
RayD keeps only the geometric core:
- differentiable ray-mesh intersection
- scene-level GPU acceleration through OptiX
- edge acceleration structures for nearest-edge queries
- primary-edge sampling support for edge-based gradient terms
For intersection workloads, RayD targets Mitsuba-level performance and matching results with a much smaller API surface.
What RayD Provides
Mesh: triangle geometry, transforms, UVs, and edge topologyScene: a container of meshes plus OptiX accelerationscene.intersect(ray): differentiable ray-mesh intersectionscene.nearest_edge(query): nearest-edge queries for points and rays- edge acceleration data that is useful for edge sampling and edge diffraction methods
PyTorch Wrapper
RayD also provides an optional rayd.torch module implemented at the Python package layer.
rayd.torch mirrors the core rayd API:
rayd.torch.Meshrayd.torch.Scenerayd.torch.Camerarayd.torch.Ray/rayd.torch.RayDetached- the same intersection and nearest-edge result types
Key conventions:
- array inputs and outputs use CUDA
torch.Tensor - vectors use shape
(N, 3)or(N, 2);(3,)and(2,)are accepted as batch size1 - index tensors use shape
(F, 3) - images use shape
(H, W) - transforms use shape
(4, 4) - CPU tensors are rejected;
rayd.torchdoes not do implicit device transfers
The original rayd Dr.Jit API remains unchanged and does not depend on PyTorch.
Quick Examples
If you only want to see the package in action, start here:
examples/basics/ray_mesh_intersection.py: custom rays against a meshexamples/basics/nearest_edge_query.py: nearest-edge queriesexamples/basics/camera_edge_sampling_gradient.py: camera-driven edge-sampling gradientsdocs/slang_interop.md: Slangcpptarget interop for host-side RayD scene queries
Build meshes, put them in a scene, launch rays, define a loss, and backpropagate through geometry.
Minimal Differentiable Ray Tracing Example
The example below traces a single ray against one triangle and backpropagates the hit distance to the vertex positions.
import rayd as rd
import drjit as dr
import drjit.cuda as cuda
import drjit.cuda.ad as ad
mesh = rd.Mesh(
cuda.Array3f([0.0, 1.0, 0.0],
[0.0, 0.0, 1.0],
[0.0, 0.0, 0.0]),
cuda.Array3i([0], [1], [2]),
)
verts = 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.configure()
ray = rd.Ray(
ad.Array3f([0.25], [0.25], [-1.0]),
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])
This is the core RayD workflow. Replace the single ray with your own batched rays, RF paths, acoustic paths, or edge-based objectives.
Edge Acceleration Structure
RayD also provides a scene-level edge acceleration structure.
This is useful for:
- edge sampling
- nearest-edge queries
- visibility-boundary terms
- geometric edge diffraction models
In other words, RayD is not limited to triangle hits. It also gives you direct access to edge-level geometry queries, which are important in many non-graphics simulators.
Compiling 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.0, nanobind==2.11.0, 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.11.0
python -m pip install "drjit>=1.3.0"
Install
conda activate myenv
python -m pip install .
Dependencies
RayD depends on:
- Python
3.10+ - Dr.Jit
1.3.0+ - OptiX
8+
RayD does not include:
- BSDFs
- emitters
- integrators
- scene loaders
- image I/O
- path tracing infrastructure
That is by design.
Repository Layout
include/rayd/: public C++ headerssrc/: C++ and CUDA implementationsrc/rayd.cpp: Python bindingsinclude/rayd/slang/interop.h: C++ POD/handle bridge for Slanginclude/rayd/slang/rayd.slang: Slang declarations for the C++ interop layerexamples/: basic and renderer-side examplestests/test_geometry.py: geometry regression testsdocs/api_reference.md: Python API referencedocs/slang_interop.md: Slang interop notes and examples
Testing
python -m unittest tests.test_geometry -v
Optional PyTorch wrapper tests:
python -m unittest tests.test_torch_geometry -v
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
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rayd-0.1.0.tar.gz.
File metadata
- Download URL: rayd-0.1.0.tar.gz
- Upload date:
- Size: 103.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3059a4c0a7753a6ed6d74da6b8c143e400a620855b892c685df4e59fee40097a
|
|
| MD5 |
19105d3c7e01213193b4c603868844eb
|
|
| BLAKE2b-256 |
d3d271e591a2254610523b7fe6334b5d8379d17e97f7e71e6223d912149c0700
|
Provenance
The following attestation bundles were made for rayd-0.1.0.tar.gz:
Publisher:
pypi.yml on Asixa/RayD
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rayd-0.1.0.tar.gz -
Subject digest:
3059a4c0a7753a6ed6d74da6b8c143e400a620855b892c685df4e59fee40097a - Sigstore transparency entry: 1178007477
- Sigstore integration time:
-
Permalink:
Asixa/RayD@f4cf1a0b13de89288da77dc93a9b38d38f0fc062 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Asixa
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@f4cf1a0b13de89288da77dc93a9b38d38f0fc062 -
Trigger Event:
release
-
Statement type:
File details
Details for the file rayd-0.1.0-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: rayd-0.1.0-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 2.4 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13e199d5ece506991757031d42ce98e0e37b0f48603a6e0730f7031e86128516
|
|
| MD5 |
d8bb006b00eeb7a24847fd36a1616591
|
|
| BLAKE2b-256 |
357241111fde8f6baa17ea91b3b1befe1c36d70089377b03f40cbb2bc3175999
|
Provenance
The following attestation bundles were made for rayd-0.1.0-cp313-cp313-win_amd64.whl:
Publisher:
pypi.yml on Asixa/RayD
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rayd-0.1.0-cp313-cp313-win_amd64.whl -
Subject digest:
13e199d5ece506991757031d42ce98e0e37b0f48603a6e0730f7031e86128516 - Sigstore transparency entry: 1178007532
- Sigstore integration time:
-
Permalink:
Asixa/RayD@f4cf1a0b13de89288da77dc93a9b38d38f0fc062 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Asixa
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@f4cf1a0b13de89288da77dc93a9b38d38f0fc062 -
Trigger Event:
release
-
Statement type:
File details
Details for the file rayd-0.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: rayd-0.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.13, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68e5ea715aa638a0505c135a41bf7e6743aad1a59988de5b076b5d91ebc1bd21
|
|
| MD5 |
07e74758580365521dd0853ee9983394
|
|
| BLAKE2b-256 |
6a5af771976fe3c42023b17e9863991b2cb31bf8194be6092d26bbbc3b3d1578
|
Provenance
The following attestation bundles were made for rayd-0.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
pypi.yml on Asixa/RayD
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rayd-0.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
68e5ea715aa638a0505c135a41bf7e6743aad1a59988de5b076b5d91ebc1bd21 - Sigstore transparency entry: 1178007522
- Sigstore integration time:
-
Permalink:
Asixa/RayD@f4cf1a0b13de89288da77dc93a9b38d38f0fc062 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Asixa
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@f4cf1a0b13de89288da77dc93a9b38d38f0fc062 -
Trigger Event:
release
-
Statement type:
File details
Details for the file rayd-0.1.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: rayd-0.1.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 2.4 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4aa8e19c9976056e05c2b7f2a761a5227bb624f4a09d1e0111fb16ab971dafda
|
|
| MD5 |
b62e67d90d13cf963b0d52b9ffdf4a50
|
|
| BLAKE2b-256 |
d94f98b861fa644ca522f07176dc65f2de10c6653ecf056ef56e5c2c193191fb
|
Provenance
The following attestation bundles were made for rayd-0.1.0-cp312-cp312-win_amd64.whl:
Publisher:
pypi.yml on Asixa/RayD
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rayd-0.1.0-cp312-cp312-win_amd64.whl -
Subject digest:
4aa8e19c9976056e05c2b7f2a761a5227bb624f4a09d1e0111fb16ab971dafda - Sigstore transparency entry: 1178007498
- Sigstore integration time:
-
Permalink:
Asixa/RayD@f4cf1a0b13de89288da77dc93a9b38d38f0fc062 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Asixa
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@f4cf1a0b13de89288da77dc93a9b38d38f0fc062 -
Trigger Event:
release
-
Statement type:
File details
Details for the file rayd-0.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: rayd-0.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.12, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3454858f8949fdfc3c0ad5fd633e7c387bd1290384d775f05cae9b00d6940417
|
|
| MD5 |
1b5d66306dd21225f6b298bd4e478560
|
|
| BLAKE2b-256 |
5b628d784f3e4ba662f13037ff172d845649033b8a2ae6b76775b22d2cc128b2
|
Provenance
The following attestation bundles were made for rayd-0.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
pypi.yml on Asixa/RayD
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rayd-0.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
3454858f8949fdfc3c0ad5fd633e7c387bd1290384d775f05cae9b00d6940417 - Sigstore transparency entry: 1178007501
- Sigstore integration time:
-
Permalink:
Asixa/RayD@f4cf1a0b13de89288da77dc93a9b38d38f0fc062 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Asixa
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@f4cf1a0b13de89288da77dc93a9b38d38f0fc062 -
Trigger Event:
release
-
Statement type:
File details
Details for the file rayd-0.1.0-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: rayd-0.1.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 2.4 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2db04cf5b4e2d962d98c396c5c8d25fd559526f5e9dcfb46690de368e71ae9e3
|
|
| MD5 |
497d3e821e7afecf7843ab820733fa43
|
|
| BLAKE2b-256 |
9c3c23dd6b6f9d763954598719bff7b655f1a6d59c4383d88053c38f11761532
|
Provenance
The following attestation bundles were made for rayd-0.1.0-cp311-cp311-win_amd64.whl:
Publisher:
pypi.yml on Asixa/RayD
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rayd-0.1.0-cp311-cp311-win_amd64.whl -
Subject digest:
2db04cf5b4e2d962d98c396c5c8d25fd559526f5e9dcfb46690de368e71ae9e3 - Sigstore transparency entry: 1178007509
- Sigstore integration time:
-
Permalink:
Asixa/RayD@f4cf1a0b13de89288da77dc93a9b38d38f0fc062 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Asixa
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@f4cf1a0b13de89288da77dc93a9b38d38f0fc062 -
Trigger Event:
release
-
Statement type:
File details
Details for the file rayd-0.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: rayd-0.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.11, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0e3dbbf357f5900c0f3f801291e3b060507f2f5740d95b391a0c0d9246926cf
|
|
| MD5 |
38269708521a2d6b1135111638306225
|
|
| BLAKE2b-256 |
8335bb5cdc1905e824eef73dc9d233e33b7b54d13c7bf4ec351c9035cbcfcb66
|
Provenance
The following attestation bundles were made for rayd-0.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
pypi.yml on Asixa/RayD
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rayd-0.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
c0e3dbbf357f5900c0f3f801291e3b060507f2f5740d95b391a0c0d9246926cf - Sigstore transparency entry: 1178007528
- Sigstore integration time:
-
Permalink:
Asixa/RayD@f4cf1a0b13de89288da77dc93a9b38d38f0fc062 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Asixa
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@f4cf1a0b13de89288da77dc93a9b38d38f0fc062 -
Trigger Event:
release
-
Statement type:
File details
Details for the file rayd-0.1.0-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: rayd-0.1.0-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 2.4 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4d20eedeaf59ecdd91c63e61be93402a67abed3862c4e9f68d171dab8139d0c
|
|
| MD5 |
f13811b06d15674a097cdb1eacb646da
|
|
| BLAKE2b-256 |
cc8f6886672e0df60e36bb4304b8713733841719cd5c15f344e7d4d68099c0ee
|
Provenance
The following attestation bundles were made for rayd-0.1.0-cp310-cp310-win_amd64.whl:
Publisher:
pypi.yml on Asixa/RayD
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rayd-0.1.0-cp310-cp310-win_amd64.whl -
Subject digest:
d4d20eedeaf59ecdd91c63e61be93402a67abed3862c4e9f68d171dab8139d0c - Sigstore transparency entry: 1178007490
- Sigstore integration time:
-
Permalink:
Asixa/RayD@f4cf1a0b13de89288da77dc93a9b38d38f0fc062 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Asixa
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@f4cf1a0b13de89288da77dc93a9b38d38f0fc062 -
Trigger Event:
release
-
Statement type:
File details
Details for the file rayd-0.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: rayd-0.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 1.7 MB
- Tags: CPython 3.10, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c2157d118dd2d853e73800f4f97faa0bcd0cd9d03b60c6a2193b1ce42adf076
|
|
| MD5 |
cf1dad98c37f28f308e20a4e64c341a4
|
|
| BLAKE2b-256 |
9b6cf7592c27d6970502b148cff9f21b8acdaa76aab9abba25a0566eadf13c7c
|
Provenance
The following attestation bundles were made for rayd-0.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
pypi.yml on Asixa/RayD
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rayd-0.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
6c2157d118dd2d853e73800f4f97faa0bcd0cd9d03b60c6a2193b1ce42adf076 - Sigstore transparency entry: 1178007485
- Sigstore integration time:
-
Permalink:
Asixa/RayD@f4cf1a0b13de89288da77dc93a9b38d38f0fc062 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Asixa
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@f4cf1a0b13de89288da77dc93a9b38d38f0fc062 -
Trigger Event:
release
-
Statement type: