OpenDLSS-NR README

The project's README from github.com/maanHimself/OpenDLSS-NR. As one markdown file: README.md.

OpenDLSS-NR

A Vulkan reimplementation of NVIDIA's DLSS 5 Neural Rendering network, bit-exact against the original.

The same 71-block Swin / ViT network as DLSS-NR build 310.8.0, running FP8 on the tensor cores. The intermediates match too, not just the final image: all 75 block boundaries, byte for byte.

ports/browser-webgpu/ is a second, independent implementation: the same bytes in a browser, with no tensor cores and no FP8.

You supply the weights, as a model directory in the layout described below.

The network

A U-net of shifted-window transformer blocks with a global ViT at the bottom: 71 blocks over six pooling levels, FP8 (E4M3) activations with FP16 accumulation, 141 MiB of weights. It is a generative neural rendering network (NVIDIA's term): it re-renders the frame the engine already drew, generating detail from injected noise and adjusting tone, structure and skin under a style setting. Input and output are the same resolution; it is not an upscaler.

The same frame with neural rendering off (left) and on (right)

The WebGPU port at 2048x1152, NR off on the left and on on the right. Scene: Cowboy Gramps by Muhammed Ismayil, CC0.

It takes one rendered frame (a low dynamic range proxy of it, three lanes of Gaussian noise, the previous frame's output reprojected, and five conditioning scalars) and produces four f32 channels per pixel: an RGB residual and one temporal-blend logit. docs/network.md is the graph in full. NVIDIA describes the model in its report, DLSS 5: Generative Neural Rendering (project page).

Build and run

powershell -File scripts\fetch_tools.ps1 [-Npm]     # once: tools\ (glslang, Vulkan-Headers, volk, CMake, Ninja)
powershell -File scripts\build.ps1                  # shaders, PTX, build\dlss5vk.exe
powershell -File scripts\fetch_filament.ps1         # once, for the demo: third_party\filament (+ the patch)
powershell -File scripts\build_filament.ps1         # once, for the demo: third_party\filament-install
powershell -File scripts\build_demo.ps1             # build\demo\dlss5-demo.exe
build\dlss5vk.exe bench   --model <dir> --width 768 --height 768
build\dlss5vk.exe profile --model <dir> --width 768 --height 768   # per-dispatch timings
build\dlss5vk.exe parity  --model <dir> --fixture <dir>            # bit-exactness against a fixture
build\dlss5vk.exe verify  --model <dir> --fixture <dir>            # block-0 kernel-by-kernel bisect
python scripts\ptx\test_fast_divmod.py                             # the PTX divider, over every n < 2^24 (numpy)

The demo can be double-clicked. It lists every scene under build\scenes in the Demo scene dropdown and starts on the first one, or loads the glTF given on the command line. The model directory is --model <dir>, else DLSS5VK_MODEL, else models\nr next to this README. See demo/README.md for the renderer, the keys, the scenes and view.json.

Performance

RTX 4070 SUPER, whole network per frame, minimum over 40 frames. 241 dispatches at every resolution.

resolution time
768x768 2.8 ms
1920x1080 7.8 ms
2560x1440 12.6 ms
3840x2160 29.3 ms

The GPU alternates between two clock states under sustained load, so medians run a few percent higher. Compare minima.

What is here

Part Files Notes
Host src/ (C++20) Vulkan context, model loading and weight re-layout, kernel wrappers, the network graph, a CPU reference of the arithmetic, the dlss5vk tool
GLSL kernels shaders/ The reference route: cooperative-matrix FP8 GEMMs, fused 32-channel block, fused QKV + window attention, expert MLP, global attention, elementwise ops. Exact and complete on their own.
PTX kernels scripts/ptx/ Python generators emitting PTX for the fast route: mma.sync E4M3 with f16 accumulation, cp.async rings, barrier-free chaining through device counters, split-K GEMMs, streamed global attention. Generated into build/ptx by the build.
Demo demo/, third_party/filament.patch The network inside a Filament (Apache-2.0) frame: Filament patched for per-object motion vectors and a Vulkan interop hook, glTF scenes through gltfio, ImGui controls.
WebGPU port ports/browser-webgpu/ The same network in a browser, bit-exact against the same captures, with no tensor core, no FP8, no fusion between blocks and no chaining: the exactness is in the specification, not in the hardware. 72 ms at 512x512 against 2.7 ms here.

Not implemented: DLSS-SR, which is a different network. The temporal path is implemented, but in the demo: the network's history input lanes and its per-pixel blend logit drive a reprojected feedback loop (docs/frame.md). The dlss5vk tool runs single frames with no history, which is what the reference captures were made with.

Requirements

Model directory

nr::Model reads manifest.json: a stages array (each entry: id, file relative to the directory, packedByteLength, sha256) and a tensors array (each entry: name, block, layer, parameter, stage, stageOffset, byteLength). Stage files hold the E4M3 weights as packed bytes; the host re-lays them out into the matrix forms the kernels consume (src/nr_model.cpp). Nothing in this repository produces such a directory.

The graph is the 71-block network of 310.8.0 and nothing else: a model with a different block count is refused at load.

Fixtures

parity compares against recorded captures of the original, which are not part of this repository. A fixture is a directory with a manifest.json:

key
sourceDimensions, fullDimensions the valid size and the padded field
proxy or inputFeatures the input: an RGBA f32 image (with conditioning, seed, autoMask), or the f32 features themselves
checks what the fixture gates, any of "boundaries", "head", "output"; required and never empty
blocks, transitions "boundaries": E4M3 references (block / id, width, height, channels, file)
omittedBoundaries "boundaries": {name: reason} for each comparable boundary the fixture has no reference for
referenceHead "head": the f32 RGBA head
nativeOutput "output": the composed image, dtype "f32" (RGBA halves, needs proxy) or "u8" (an 8-bit capture)

Everything is validated before the GPU runs, and a fixture that fails any of it is refused: a declared check without its reference, a reference that is missing, short or names nothing in the graph, a reference no declared check uses, or a comparable boundary (blocks 0-69, the five encoder transitions) with neither a reference nor a reason. Verdicts are bit-exact (the pass), equal only up to the sign of zero (a failure), within one code (the 8-bit capture only, reported apart) or a mismatch; see docs/numerics.md. The head and the output are compared on the production schedule, resubmitted --repeat times (default 3), which must also agree with the same graph under barriers; the boundaries come from an instrumented run, whose head must agree with production's. verify additionally needs inputFeatures and a block-0 reference.

Tuning switches

All default to the fast, exact route. Every switch keeps the output byte-identical, and parity under each of them is part of the gate. Any switch that sends a kernel back to GLSL also turns counter chaining off, because only the PTX kernels take part in it.

Documentation

docs/README.md is the index: network.md is the graph, numerics.md the exactness contract, weights.md the layouts, execution.md the scheduling, and frame.md the demo's frame.

Not affiliated with NVIDIA

This project is not affiliated with, endorsed by, or supported by NVIDIA. It contains no NVIDIA software, weights, headers, or instructions for obtaining them. No rights under any NVIDIA intellectual property are granted or implied by this repository or its license, and you are responsible for the licenses that apply to whatever model data you use with it.

License

MIT for everything in this repository (LICENSE). Third-party components are listed in NOTICE.

OpenDLSS-NR (maanHimself/OpenDLSS-NR)

Searching Database…

这是什么?OpenDLSS-NR 是对 NVIDIA DLSS 5 神经渲染网络从零开始的 Vulkan 重实现,与原版做到位级完全一致——不仅是最终图像,连每个内部块的边界都一致。
它是像其他 DLSS 模式那样的超分辨率放大器吗?不是。它在输入分辨率不变的情况下重新渲染帧,从注入的噪声中生成细节,并在风格设定下调整色调、结构和皮肤;它不改变分辨率。
怎么运行演示程序?构建完成后,直接双击演示程序即可;它会在下拉列表中列出 build\scenes 下找到的所有场景,默认从第一个启动,你也可以在命令行传入一个 glTF 文件。
构建和运行它需要什么?一台装有 NVIDIA Ada 或更新 GPU 的 Windows 机器,驱动需暴露特定的 cooperative-matrix 和 FP8 Vulkan 扩展;此外还需要 Visual Studio 2022 的 C++ x64 工具集、git、Python 3,以及用于场景转换器的 Node.js 和 npm。
它附带真正的 DLSS 权重吗?不附带。你必须按文档规定的目录结构自行提供权重模型目录;仓库中不包含任何 NVIDIA 权重、软件或获取指引,其中也没有任何东西会生成这样的目录。
WebGPU 移植版在没有 NVIDIA GPU 的情况下也能运行吗?可以,ports/browser-webgpu/ 中的浏览器移植版运行同样的字节码,不使用张量核心和 FP8,与同样的采集结果位级一致,但速度慢得多(512x512 分辨率下为 72 毫秒,原生 Vulkan 为 2.7 毫秒)。
演示程序中 Filament 的用途是什么?Filament(Apache-2.0)提供演示程序的渲染框架;它经过补丁修改以支持逐物体运动矢量和 Vulkan 互操作钩子,通过 gltfio 加载 glTF 场景,并暴露 ImGui 控件。
位级一致性究竟是如何验证的?测试夹具是原网络的录制采集结果,「一致性(parity)」检查会在每个块边界、网络头部和最终输出处将 Vulkan 实现与之比较,结果报告为位级一致、仅零的符号不同、误差在一个编码值以内或不匹配。
这个网络运行速度有多快?在 RTX 4070 SUPER 上,完整的 71 块网络在 1920x1080 下约需 7.8 毫秒,在 3840x2160 下约需 29.3 毫秒;测量方式为每帧 241 次 GPU dispatch、取 40 帧中的最小值。
Size
5.1 MB
Stars
929
Updated
CommitSep 21
Age
27d
Commits · 90 Days