Repository navigation
idol: the octree and Gaussian decoders on Metal, to the 3DGS PLY (stacked on #1766) - #1773
Merged
Merged
Conversation
jayleaton
added a commit
to jayleaton/TensorFold
that referenced
this pull request
Oct 31, 2026
This was referenced Oct 31, 2026
Owner
|
Thanks @jayleaton. This is a clear receipt: counts equal at all eight levels given the SDK's probabilities, PLY rows equal to the SDK's, and the two NaN/infinity fixes that gate 1 found. It waits on #1766. Once #1766 lands, please rebase onto main, since the branch still carries #1766's pre-rebase commits. We'll then run |
3 of 13 tasks
ashhart
pushed a commit
to jayleaton/TensorFold
that referenced
this pull request
Nov 19, 2026
ashhart
force-pushed
the
idol-decoders
branch
from
November 19, 2026 00:09
7824bf6 to
ae76463
Compare
ashhart
added a commit
to jayleaton/TensorFold
that referenced
this pull request
Nov 19, 2026
ashhart
added a commit
to jayleaton/TensorFold
that referenced
this pull request
Nov 19, 2026
ashhart
marked this pull request as ready for review
November 19, 2026 00:28
9 tasks done
4 tasks done
ashhart
force-pushed
the
idol-decoders
branch
from
November 19, 2026 08:02
ae76463 to
4908d41
Compare
ashhart
pushed a commit
to jayleaton/TensorFold
that referenced
this pull request
Nov 19, 2026
ashhart
force-pushed
the
idol-decoders
branch
from
November 20, 2026 04:32
4908d41 to
8e04d9b
Compare
ashhart
pushed a commit
to jayleaton/TensorFold
that referenced
this pull request
Nov 20, 2026
The octree decoder (4 blocks) and Gaussian decoder (16 blocks) run natively on Metal from the released checkpoint. Host-side pieces: systematic resampling with a pluggable RNG (native PRNG, or the SDK's recorded draws), compaction, leaves and jitter, activations, the PLY writer and the camera JSON. tf-idol-decode decodes a latent and gates it against an idol_case.py `decode` case. New kernels live in idol_decoder.metal: the point embedding, K/V and head packing, an fp32 attention for <= 8 query rows, and a copy of the idol attention whose P.V uses an fp16 hi/lo split. This removes the -2^-12 per-pass bias that fp32 P picks up on the tensor unit. Gates are measured against fp32, allowing twice the worst of: the SDK's own distance, the fp16 floor, and seeded nudged SDK reruns. Further gates: per-block teacher-forced checks, counts identical given the SDK's probabilities and draws, activated fields, the PLY's columns, the camera, and byte-identical repeats. The comparators are covered by plant-a-mismatch unit tests. idol_case.py gains `decode`, which pins decoder.py, gaussian.py and camera.py by sha256 and records levels, draws, counts, fields, the PLY and timings.
metal_idol_decoder*.zig registers dec_embed, dec_half, dec_kv, dec_heads,
dec_attention_few and dec_attention_{00,01,10,11} as "metal idol decoder
...", against float64 at idol-sdk's fp32 and fp16 points. Fifteen controls
each go red at their gate: an added or dropped rounding point, fp16 sums,
P's lo half dropped (caught on heads built so O is P's fp16 remainder
alone), keys past Lk unmasked, an input written, and the two NaN rules
below undone. Gate-5 records are in idol_records.zig; the common Lib is now
generic over a source and its launchers.
Gate 1 found two real rule breaks, fixed with finite outputs unchanged
(the 262k and 32k decode cases give byte-identical PLYs and gate lines):
dec_heads clamped its norm by max, dropping a NaN; and the tiled attention
gave NaN for an infinite value, because an fp16 lo of 0 or of the opposite
sign met the infinity. The lo half now meets the values clamped to fp16's
finite range (about 2% at 262k, 7% at 1M).
docs/recipes/idol.md gains a Decoders part with the precision, gates,
run-a-case commands, measurements and the contract SUMMARY.
…pported probes, as 5a4583c asks
ashhart
force-pushed
the
idol-decoders
branch
from
November 20, 2026 13:44
8e04d9b to
3e66e46
Compare
Owner
|
Thank you @jayleaton. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #1766 (Idol's denoiser on Metal). This branch holds #1766's commits too; its own change is the last two commits. Independent of #1767 (CUDA).
What this changes
Idol's octree and Gaussian decoders on Metal, from the denoiser's final latent to the 3DGS PLY and the camera JSON, with
tf-idol-decodeand anidol_case.py decodecase recorded from idol-sdk's owndecode(sha256-pinneddecoder.py,gaussian.py,camera.py). For #1757. Details: the "Decoders" part ofdocs/recipes/idol.md.systematic_samplebetween them, leaf expansion and jitter; Gaussian decoder (16 blocks: self attention over up to 32,768 anchors, cross attention to the latent, MLP) to 480 outputs an anchor;gaussian.py's activations, the PLY and the camera on the host.zig/kernels/metal/idol_decoder.metal, Idol's own: the fp32 stem and point embedding, the fp16 cast,to_kv, MultiHeadRMSNorm, and attention whose P meets V as fp16 hi + lo halves (a single fp32 P is truncated on the tensor units, M5 tensor units truncate fp32 operands to 10 mantissa bits: gemm_nax<float> is not fp32, and attention_nax's outputs are biased low #1772). The blocks reuse the denoiser'sid_linear,id_norm,id_gate_add,id_norm32andid_gemm32. No shared kernel changes.Precision
The SDK's own split: fp16 block linears with fp32 sums; fp32 stem, head and the latent's rows before the blocks; fp32 scores, softmax and sums in attention; at 8 query rows or fewer the attention runs fp32 throughout, as torch's MPS vector kernel does. The point embedding's frequencies are torch's CPU
powvalues bit for bit (6 of 170 differ from correctly rounded ones).Kernel contract
zig/tests/contract/metal_idol_decoder*.zigregisters all 9 pipelines, namedmetal idol decoder .... Gate 1 found two bugs, fixed here:dec_headsdropped a NaN norm (asid_qkdid in #1766), and the tiled attention gave NaN for an infinite value where float64 gives the infinity (P's lo half times infinity); the lo product now takes values clamped to fp16's finite range. Finite outputs are byte-identical before and after (same PLYs, same gate lines); the clamp costs 2-7% of decode time.tf-kernel-contract --only "metal idol", M5 Ultra (the denoiser's kernels and these):Offline:
dec_embed,dec_half,dec_kv,dec_headsanddec_attention_fewbuild for M1 and M2 at 256 threads; the tiled attention forms need the tensor units, as the denoiser's do.Gates
On the SDK's own inputs, each compared against the same decoder in fp32 and allowed twice the worst of three distances: the SDK's own, the fp16 floor (fp32 with its last rows rounded once), and the SDK rerun with 1% of its first block's fp16 inputs nudged one ulp (three seeds). The nudged reruns are there because the 16-block chain amplifies tiny input differences: in the SDK itself, that nudge moves level 8's worst row from 0.0415 to 0.0488. Plus counts row for row, levels 1-3 block by block, the activated fields, the PLY against the SDK's, the camera, and byte-identical repeats.
decode_reference.zig's tests plant a mismatch each gate must fail.The free run (our own probabilities, the SDK's draws) is reported, not gated:
systematic_sampleis discontinuous, so a probability 1e-5 off can move one point to a sibling cell, and once a cell empties or fills, every later level follows. Its topology leaves the SDK's at level 6 of the 262k case (1 row differs at level 1, 20 at level 8). Given the SDK's probabilities, every count matches.Receipt
Environment: Mac Studio M5 Ultra 256 GB, macOS 27; this branch on idol: Idol's denoiser as a native Metal family #1766's
94a039249; idol-sdk4702a7f0on torch 2.13.0 (MPS);speridlabs/idol@2731c229; the avocado case's final sample, seed 42.Exactness, 262,144 Gaussians unless noted:
1 - cos4.5e-6 (the SDK 0.211 and 8.1e-6). At 32,768: 0.0213 against the SDK's 0.0072, within the bound (nudged 0.0305);Speed and memory, warm, against the SDK's warm decode; peak process footprint by
/usr/bin/time -l:Prompt speed: n/a, no token path.
Tests:
zig build test test-golden -Dcpu=apple_m1: 585 of 585 steps, 5,783 of 5,827 tests pass, 44 skipped, 0 fail (before the rebase onto94a039249, a docs-only change; after it, plainzig build248 of 248).zig fmt --check build.zig zig: clean.lean_check.py: 424, the same as main.Not run: CUDA (none in this PR). Metal M1 to M4: refused at load (no tensor units).
Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (n/a.)SUMMARYline is in the receipt.