Skip to main content

Torch-native RayD geometry and multipath primitives.

Project description

RayD Torch

RayD Torch is a Torch-native CUDA/OptiX package for RayD geometry primitives and RayD-style multipath/diffraction kernels.

import rayd.torch as rt

Install the rayd-torch distribution. It owns only rayd/torch/** and can coexist with the independently installed rayd-drjit backend.

Published wheels contain both native backends and do not require an OptiX SDK at runtime. Building this dual-backend distribution from source does require the OptiX SDK headers, even when the target machine will select CUDA at runtime; an SDK-less CUDA-only source-build mode is not currently provided.

Ray-tracing backend selection

Scene() selects OptiX when the current CUDA device and driver expose it and otherwise selects RayD's pure-CUDA triangle and edge BVHs. The resolved choices are available through scene.trace_backend and scene.edge_bvh_backend after build():

scene = rt.Scene()  # trace_backend="auto", edge_bvh_backend="auto"
scene.add_mesh(mesh)
scene.build()
print(scene.trace_backend, scene.edge_bvh_backend)

Pass trace_backend="optix" or "cuda" and edge_bvh_backend="optix" or "cuda" to require a backend. An explicit OptiX request fails if OptiX is unavailable; runtime pipeline, allocation, and CUDA errors are never converted into a fallback. RAYD_DISABLE_OPTIX=1 is the deployment and test kill switch. Both backends use Torch-owned tensors and the current Torch CUDA stream.

The separately governed ADR-0029 exact four-sample axial-edge primitive and ADR-0033 segment-penetration family remain OptiX-only by contract. Requesting either from a CUDA scene raises an explicit unsupported-backend error; RayD does not substitute a numerically different implementation.

Tensor ABI

RayD Torch APIs accept CUDA torch.float32 tensors for vector data and CUDA torch.int32 tensors for index data. Vector tensors are row-major (N, 3) unless otherwise documented, masks are torch.bool, and tensors should be contiguous. Outputs and AD tapes are Torch-owned tensors.

Gradient Contract

Intersection, edge, reflection, EPC, and diffraction operators use a fixed-winner gradient contract where explicit native kernels exist. The discrete primitive, edge, visibility, or path decision selected in the forward pass is treated as non-differentiable; VJP and JVP propagate through the continuous values recomputed from the saved winner and live Torch tensors.

Autograd

The native operators support Torch reverse-mode VJP and forward-mode JVP for the supported continuous inputs where explicit kernels have been implemented. CUDA work is launched on the current Torch CUDA stream.

Native Source Integration

Native downstream projects built in the same CMake/LibTorch graph use the versioned typed C++ surface in rayd/torch/integration.h; they do not load a second RayD Python extension or use a dynamic symbol registry. Solver-neutral RF device math is exposed through rayd/shared/rf/*.cuh. Torch-specific field AD helpers remain under rayd/torch/rf/ because they use Torch complex types.

The rayd-torch wheel also carries a relocatable source bundle at rayd/torch/_source. rayd-source.json records the distribution version, source commit and repository, integration ABI identity, and the SHA-256 of a complete per-file manifest. The bundle contains only the Torch and shared sources needed for a same-graph native build. Downstreams locate this passive resource through importlib.metadata; they must not import rayd.torch, scan an environment prefix, or trust the metadata without pinning and recomputing the full source manifest. An explicit source checkout remains a higher-priority developer input and keeps its Git identity checks. See docs/adr/0034-validated-package-source-discovery.md.

The accepted transmission surface consists of complete primal/backward/JVP families for resident CSR layer-stack evaluation and complete-row Jones field transport. These operations preserve precise-math compilation, row fusion, atomic layer-gradient order, and the no-persistent-tape contract. Inputs are validated before launch, work runs on the caller's current Torch CUDA stream, and invalid shape/dtype/device/ABI state or CUDA failure raises immediately; there is no CPU, Torch-expression, finite-difference, or legacy-dispatch fallback.

RayD owns the numerical primitives and typed native operations, not a downstream application's material encoding, topology selection, solver estimator policy, RNG/MIS, accumulation, metadata, or result schema. A newly merged transmission implementation may remain a dormant candidate until the consumer pins it, switches all callers, proves parity, and deletes its local implementation. See docs/adr/0002-shared-rf-transmission-ownership.md.

The accepted diffraction surface will place the complete fixed-winner pure-wedge field primal/backward/JVP family behind the typed integration header once the dormant RayD candidate is implemented and direct-tested. Channel remains the production numerical owner until it pins, validates, activates, and deletes its local CUDA implementation. The future typed family must preserve optional winner vertices, three separate native entry launches, current-stream execution, output schemas, and the family-local --use_fast_math contract required for order-1 exporter parity. Monte Carlo Sionna accumulation, coupled RD/DD operations, and BDPT estimator policy remain downstream-owned. See docs/adr/0025-diffraction-family-ownership.md.

The accepted generic-scattering surface consists of exactly seventeen typed operations in six complete families: resident table evaluation AD, resident table sampling/PDF, single-bounce ensemble, phase-screen patch integral, chain ensemble, and chain realization. RayD evaluates caller-owned resident CUDA tensors but does not own table construction, cache/version policy, phase-screen seed/lifecycle, topology, estimator, RNG/MIS, accumulation, or result policy. A high-level BSDF/material framework remains out of scope; solver-neutral RF scattering primitives are in scope.

The migration preserves the existing AD asymmetry: chain-ensemble continuous geometry supports JVP but reverse-mode requests fail loudly, while chain-realization supports its existing continuous-geometry VJP and JVP. Complete row fusion, launch count, recomputation/tape lifetime, backward atomics, output schemas, and the source-TU compile split are frozen: table primal/sample/PDF uses default CUDA flags, while the audited table-AD, ensemble, patch, and chain lockstep TUs retain --fmad=false. A merged RayD implementation remains dormant until Channel pins it, switches a complete family with parity evidence, and deletes the local implementation. See docs/adr/0026-generic-scattering-runtime-ownership.md.

The stable source-level boundary is named rayd/torch/integration.h, its exact identity is rayd.torch.integration, and its numeric API version is 6. No integration_v2 forwarding header, CMake target alias, or alternate identity is supported. See docs/adr/0028-stable-typed-integration-naming.md.

API version 3 makes row validity explicit for pure-wedge diffraction, transmission sequences, and all generic scattering requests. The required device boolean tensor is checked before any row payload or ID is read; invalid primal/JVP rows and supported row gradients are bitwise zero and cannot contribute shared-gradient atomics. AD companions inherit the mask from their nested primal request. See docs/adr/0030-typed-capacity-row-validity.md.

API version 4 additionally makes DiffractionPathConfig.active required for order-1 path export. It is a contiguous CUDA boolean tensor with exact shape [state_limit]; an empty state set carries a defined empty mask. The Python Scene.trace_dfr_paths(...) entry requires the keyword, and neither the typed API nor dispatcher accepts omitted, None, broadcast, or strided validity. Diffraction accumulation and coherent-accumulation contracts are unchanged. See docs/adr/0031-required-diffraction-path-validity.md.

The typed boundary also carries a dormant axial-edge visibility candidate for device-resident diffraction state selection. It consumes broadcast TX and contiguous AoS edge tensors, evaluates the four exact binary32 fractions in one separate OptiX launch on the caller's current CUDA stream, and returns a resident boolean state mask. Its traversal inherits the legacy OptiX compile policy while inline PTX locks only point construction to non-FTZ, non-FMA round-to-nearest operations. The legacy visibility dispatcher is unchanged and cannot select this entry. The operation adds no synchronization beyond the existing common launch-parameter staging path; removing that staging path's host event wait is a separate optimization. See docs/adr/0029-typed-axial-edge-visibility.md.

API version 5 adds an explicit DiffractionPathLayout to the typed order-1 exporter. Existing callers retain Compact; same-graph consumers may request SourceLane, where the fixed row is ((tx * rx_count + rx) * state_limit) + state. Rejected lanes remain inert and the CUDA count remains actual-count metadata rather than a storage ordinal. Both layouts use the same traversal and UTD implementation. See docs/adr/0032-source-lane-diffraction-path-layout.md.

API version 6 adds the dormant complete batched segment-penetration family. Each non-empty structurally active forward call submits one OptiX launch and performs its ordered D+1 capacity probe in raygen; an explicit structurally all-inactive call uses only a same-stream CUDA mask consistency check. Results and tapes use fixed [N,D] storage and the caller's shared device failure transaction. Backward/JVP use frozen winners and never retrace. RayD exposes no Python dispatcher for this family, and Channel retains material and wall-product policy. See docs/adr/0033-batched-segment-penetration.md.

RayD Torch carries all seventeen typed operations. Channel has activated the Phase 10A table, sampling, single-bounce ensemble, and patch-integral entries. The six Phase 10B chain entries are source-linked into the native core and direct-tested but remain dormant: no RayD Python binding dispatches them, and Channel remains their production numerical owner until its atomic pin/switch/delete commit.

Current Status

RayD Torch now builds separate native scene, edge, reflection, and diffraction Torch extension bindings. The native build includes OptiX PTX pipelines for scene intersection, edge queries, reflection tracing/EPC/visibility/ accumulation, and diffraction path/accumulation/coherent direct execution.

Current opt-in RayD parity tests cover forward cases for scene intersection, multi-mesh global ids, nearest-edge, visibility, reflection tracing, diffraction paths, direct/Keller/suffix diffraction accumulation, order-2 and order-3 diffraction chains, and coherent direct accumulation. Torch VJP/JVP coverage exists for geometry, edge, reflection trace, EPC, and diffraction accumulation under the fixed-winner contract.

On the recorded same-script benchmark shape (grid 64, 4,096 queries, warm caches), RayD Torch currently measures faster than RayD for scene build, intersect, nearest edge, reflection trace, diffraction paths, and direct diffraction accumulation. Far-from-surface nearest-edge queries use a tiled exact fallback scan instead of the scene-diagonal OptiX tier. Release-size and Nsight-counter-backed runs remain the broader performance gate. See docs/torch_gap_analysis.md and docs/torch_performance.md.

Dependencies

RayD Torch depends on PyTorch, CUDA, and OptiX for native execution. The RayD Torch package path has no Dr.Jit dependency.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

rayd_torch-0.7.0-cp314-cp314-win_amd64.whl (18.0 MB view details)

Uploaded CPython 3.14Windows x86-64

rayd_torch-0.7.0-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (18.4 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

rayd_torch-0.7.0-cp313-cp313-win_amd64.whl (18.1 MB view details)

Uploaded CPython 3.13Windows x86-64

rayd_torch-0.7.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (18.4 MB view details)

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

rayd_torch-0.7.0-cp312-cp312-win_amd64.whl (18.1 MB view details)

Uploaded CPython 3.12Windows x86-64

rayd_torch-0.7.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (18.4 MB view details)

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

rayd_torch-0.7.0-cp311-cp311-win_amd64.whl (18.1 MB view details)

Uploaded CPython 3.11Windows x86-64

rayd_torch-0.7.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (18.4 MB view details)

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

rayd_torch-0.7.0-cp310-cp310-win_amd64.whl (18.1 MB view details)

Uploaded CPython 3.10Windows x86-64

rayd_torch-0.7.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (18.4 MB view details)

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

File details

Details for the file rayd_torch-0.7.0-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: rayd_torch-0.7.0-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 18.0 MB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for rayd_torch-0.7.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 40a86a35783d07e41289f50332c8fe512000048488b8f5956e97cad12fa65e34
MD5 d3097f089f2667754c1db5053edde6e2
BLAKE2b-256 d371accc55aaa350bdeb2d8010fdcd919244f9b5f9f1635f53f502dcb26d77fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for rayd_torch-0.7.0-cp314-cp314-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_torch-0.7.0-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rayd_torch-0.7.0-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7b0daf6768559ac28981b5fc42fe5831fe9fdf070c40bad924db5c6c155af150
MD5 01421d6a5f3e25b13119c77bc48f5881
BLAKE2b-256 e2cd152a650b75086f551fb061b3e0a59687cb0d3b436dad7700865f37f51f83

See more details on using hashes here.

Provenance

The following attestation bundles were made for rayd_torch-0.7.0-cp314-cp314-manylinux_2_24_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_torch-0.7.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: rayd_torch-0.7.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 18.1 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for rayd_torch-0.7.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 8302be14b368010e407d458b1fd64ad86036ad2c8ee394b9c12f1816f204e34c
MD5 f525aaff8278f4968e757f912a848c34
BLAKE2b-256 ca26ac479b85d8a893b0ef6acbd80f0a795dc502db9f4771070e5c8fe20ebeb4

See more details on using hashes here.

Provenance

The following attestation bundles were made for rayd_torch-0.7.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_torch-0.7.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rayd_torch-0.7.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e14b5990661553fe20c75c775486918b7ded78b45722998572dd398a10fc0abe
MD5 7647ef768a34cdb6934c881e803cbedb
BLAKE2b-256 5e9f6103bff1161b296cd24f6738ad08bc602b3b05e975795c062170ebb696e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for rayd_torch-0.7.0-cp313-cp313-manylinux_2_24_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_torch-0.7.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: rayd_torch-0.7.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 18.1 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for rayd_torch-0.7.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 8ecf41ad9d2a6567d7136b214c979a1f082e5cd7e3fb076324c4185e353ebd64
MD5 98a4f59e5cf79d3d478f4c0110e6166d
BLAKE2b-256 198bada6887b063d145ba67109e59710c3e475983828c6d0202197bfa468e186

See more details on using hashes here.

Provenance

The following attestation bundles were made for rayd_torch-0.7.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_torch-0.7.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rayd_torch-0.7.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 307e970df8a673bb5086e56f4fde7ff6ee1223bea93588ed37aa1c322e5951a5
MD5 8aaf5531da889827427d0c2810d7b6d9
BLAKE2b-256 0fb90935c8510ff4f36f5855c8e05bb8f6eb5e680422d126f21d209e07376972

See more details on using hashes here.

Provenance

The following attestation bundles were made for rayd_torch-0.7.0-cp312-cp312-manylinux_2_24_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_torch-0.7.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: rayd_torch-0.7.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 18.1 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for rayd_torch-0.7.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 93a9b44525afbb66551b111c034b27f55fb61afc941194e9d7645fc94e6228a2
MD5 62ff4b45304de942902c66d8c56e551b
BLAKE2b-256 992dd0ca0b6689a2da177077321da1d2158dde5a9a9eacb73d4d7c97f24f64ad

See more details on using hashes here.

Provenance

The following attestation bundles were made for rayd_torch-0.7.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_torch-0.7.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rayd_torch-0.7.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e973e898cc3ceafb9a208d478a9768caacb6ab77923a39639658b8134996d716
MD5 d603d0c830a5d014e6dd366db27baa09
BLAKE2b-256 423f7509e9f46c4e51c65fee9b0c58e34bfbdccc9a317963d21bfa011e8f73f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for rayd_torch-0.7.0-cp311-cp311-manylinux_2_24_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_torch-0.7.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: rayd_torch-0.7.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 18.1 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for rayd_torch-0.7.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e9b364c1c301c9fa5f7e159e60885e38dcf18e4dda471ab10e5f008220da6b18
MD5 645ecec6372493cb790e00c020970ecf
BLAKE2b-256 243e7bffecef9287ffabec3751b2a8777a5142dbc4a0dc7dd991ccb10b76838b

See more details on using hashes here.

Provenance

The following attestation bundles were made for rayd_torch-0.7.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_torch-0.7.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rayd_torch-0.7.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 90ea00a2c6d3053db4f6e4e365c56ab93e91b7505bf176a12fb9355775d89fae
MD5 55313f95f4360635b6ea72b55b993fb2
BLAKE2b-256 51e9af1cfb00d2712c83beb03decb7c3afa5cc5cfdf4bc93ef0d8aa956466d12

See more details on using hashes here.

Provenance

The following attestation bundles were made for rayd_torch-0.7.0-cp310-cp310-manylinux_2_24_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