Runtime and capabilities (Dr.Jit)

Module-level functions, constants, rays, and ray flags of rayd.drjit - device selection, OptiX probing, capability reports, and the API manifest.

This page covers the module-level API of rayd.drjit: device control, capability reports, constants, and the ray types every query takes.

import rayd.drjit as rd

All arrays are Dr.Jit CUDA arrays from drjit.cuda (detached) or drjit.cuda.ad (differentiable).

Devices#

set_device#

set_device(device: int, initialize_optix: bool = True) -> int

Sets the current thread's CUDA device for RayD. Call it before you create meshes, scenes, or Dr.Jit arrays that you use with them.

deviceintrequired

CUDA device index, from 0 to device_count() - 1.

initialize_optixbooldefault True

Also initialize the OptiX device context when OptiX is available. With False, only CUDA-based operation is prepared.

Returns the device index.

Do not reuse scenes or OptiX resources across a device switch in the same process.

device_count#

device_count() -> int

Returns the number of Dr.Jit-compatible CUDA devices visible to RayD.

current_device#

current_device() -> int

Returns the current thread's active Dr.Jit CUDA device index.

optix_available#

optix_available() -> bool

Returns True when a usable OptiX driver is present. It never raises, so it is safe on machines without OptiX. Set the environment variable RAYD_DISABLE_OPTIX=1 to force False and exercise the CUDA fallback on an OptiX-capable machine.

print(rd.optix_available())   # True on a recent NVIDIA driver

Capability reports#

backend_capabilities#

backend_capabilities() -> dict

Returns a flat mapping of feature names to booleans, for example "intersect", "reflection_trace", "reverse_ad". A True entry means the backend has the feature at all; per-operation AD support is in api_manifest().

api_manifest#

api_manifest() -> dict

Returns the classified public API with stability, aliases, typing, and derivative metadata. Top-level keys: version, schema_sha256, backend, typing, naming_conventions, derivative_statuses, derivatives, capabilities, apis, aliases, trace.

derivatives[family][operation] has primal, note, and input_domains, a mapping from input domain to {"vjp": status, "jvp": status}. See Differentiation.

status = rd.api_manifest()["derivatives"]

native_launch_audit#

native_launch_audit() -> dict
native_launch_audit_clear() -> None

native_launch_audit() returns counters of RayD's native kernel launches, grouped by operation. native_launch_audit_clear() resets them. Use them to check how many launches a piece of code triggers.

Constants#

NameValueUsed by
REFLECTION_EXPORT_FULL0ReflectionTraceOptions.export_mode: all fields (default)
REFLECTION_EXPORT_MINIMAL1ReflectionTraceOptions.export_mode: a reduced field set
REFLECTION_EXPORT_COUNT_ONLY2ReflectionTraceOptions.export_mode: bounce counts only
RAYD_DFR_DIRECT1DfrOptions.strategy_mask, DfrPathOptions.strategy_mask
RAYD_DFR_KELLER2DfrOptions.strategy_mask
RAYD_DFR_SUFFIX_REFL4DfrOptions.strategy_mask
RAYD_DFR_HASH0DfrOptions.sample_sequence: hash-based sample sequence (default)
RAYD_DFR_SOBOL1DfrOptions.sample_sequence: Sobol sequence
RAYD_DFR_MATCHED_ISO0receiver_model of the diffraction options: matched isotropic receiver (default)

Ray#

Ray()
Ray(o: drjit.cuda.Array3f, d: drjit.cuda.Array3f, /)

A batch of detached rays. Both arguments are positional.

odrjit.cuda.Array3fdefault (0, 0, 0)

Ray origins, one per lane.

ddrjit.cuda.Array3fdefault (0, 0, 1)

Ray directions. They do not need to be normalized; distances t are measured in units of d.

Attributes o, d, and tmax are writable. tmax (a Float, default inf) limits the search distance. reversed() returns a ray with the direction flipped.

from drjit.cuda import Array3f, Float
ray = rd.Ray(Array3f([0, 0], [0, 0], [1, 1]), Array3f([0, 0], [0, 0], [-1, 1]))
ray.tmax = Float([10.0, 10.0])

RayAD#

RayAD()
RayAD(o: drjit.cuda.ad.Array3f, d: drjit.cuda.ad.Array3f, /)

The differentiable ray. Same attributes and defaults as Ray, with AD arrays. Passing a RayAD to a query selects the differentiable overload, which returns the ...AD result record.

RayFlags#

class RayFlags(enum.IntFlag)

Selects which fields Scene.intersect and MixedScene.intersect compute.

MemberFields
Geometrict, p, barycentric, ids, geo_n
ShadingNn
UVuv
Allall of the above (default)
Noneno optional fields (in 0.8.0 t, p, and the ids are still filled)

None is a Python keyword, so reach that member as rd.RayFlags["None"] or rd.RayFlags(0). Combine members with |.