Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Phase-Ray: A Triton-Accelerated Neural Renderer with Phase-Modulated Fields

Phase-Ray is an experimental framework for 3D view synthesis, inspired by Neural Radiance Fields (NeRF). It introduces a novel neural field architecture that leverages a learnable phase parameter for high-frequency feature modulation and uses a custom, high-performance Triton JIT kernel for rendering. Core Concepts & Theory

The project explores two primary ideas: a new way to represent high-frequency signals in neural networks for graphics and the use of Python-native GPU programming for custom rendering algorithms. Phase-Modulated Neural Fields

A key challenge in coordinate-based neural networks, like NeRF, is their inherent spectral bias, which makes it difficult for a standard MLP to learn functions with fine detail or high-frequency variations.

The common solution is Positional Encoding (PE), where input coordinates x are mapped to a higher-dimensional space using a fixed set of sine and cosine functions: γ(x)=(...,sin(2kπx),cos(2kπx),...) While effective, PE uses a fixed, hand-picked set of frequencies.

Phase-Ray proposes an alternative, learnable approach. It first projects the 3D coordinates x through a simple MLP (self.proj) and then modulates the resulting feature vector with a complex-valued phase vector φ that is a learnable parameter of the model:

field(x)=MLP(x)⊙Real(exp(i⋅ϕ))

Here, φ is a learnable vector (self.phase) of the same dimension as the feature embedding. The term exp(i * φ) creates a sinusoidal signal across the feature dimensions whose frequencies are not fixed but are learned during training.

Hypothesis: By making the phase (and thus, the frequencies) learnable, the model may be able to more efficiently discover the optimal frequency basis needed to represent the specific details of a given 3D scene, potentially leading to better convergence or more compact representations compared to fixed positional encodings. High-Performance Rendering with Triton

Novel rendering algorithms often require custom computational kernels that are not available in standard deep learning libraries. While writing raw CUDA C++ provides maximum performance, it is complex and time-consuming.

Triton offers a powerful solution by allowing developers to write high-performance GPU kernels directly in Python. The syntax is Pythonic, but Triton's JIT compiler produces code that can match or exceed the performance of expertly hand-tuned CUDA.

In Phase-Ray, the render_kernel is a Triton function that implements a simplified volume rendering loop. Each GPU thread is responsible for a single ray. It iterates along the ray's path, loads the corresponding phase-modulated features, calculates a density value, and accumulates color. This approach provides both high performance and the flexibility to experiment with custom, non-standard rendering equations. Code Structure

The project is organized for clarity and modularity:

phase_ray/renderer.py: Contains the PhaseRayRenderer nn.Module, which includes the MLP, the learnable phase parameter, and the Triton JIT kernel.
train.py: A script for training the renderer. It includes a synthetic dataset of a sphere to provide a concrete learning objective and uses argparse for easy configuration of hyperparameters.

Setup and Usage Requirements

Ensure you have a CUDA-enabled GPU. This project relies on Triton, which does not run on CPU. Bash

pip install torch triton

Training

You can train the model on the synthetic sphere dataset by running the training script. Bash

python train.py

To see available training options, use the --help flag: Bash

python train.py --help

Limitations and Future Work

Phase-Ray is a research prototype and has several important limitations:

Physically Inaccurate Rendering Model: The volume rendering equation implemented in the render_kernel is a significant simplification. It does not correctly model light transport, occlusion, or transparency, as seen in the canonical NeRF paper. The "density" and color accumulation logic are placeholders and would need to be replaced with a physically-based model for photorealistic results.
No Positional Encoding Comparison: The current model relies entirely on the learnable phase for high-frequency representation. A rigorous study is needed to compare this approach against standard positional encoding and, more importantly, to investigate any synergistic effects of combining the two.
Evaluation on Benchmarks: The model has only been trained on a simple, procedurally generated sphere. To validate its effectiveness, it must be evaluated on standard academic benchmarks for view synthesis (e.g., the NeRF synthetic dataset, LLFF, etc.).
Kernel Optimization: The Triton kernel is a proof-of-concept. Its performance could likely be improved by further optimizing memory access patterns to ensure full coalescing and by exploring more advanced blocking and scheduling strategies.
Feature Representation: The current implementation uses the feature field from the first step along the ray as representative for the entire ray. A more sophisticated model would incorporate view-dependent effects by conditioning the output color on the ray's direction and would use a more complex function to derive color and density from the feature field at each point.

About

A Triton-Accelerated Neural Renderer with Phase-Modulated Fields

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages