Repository navigation
idol: tf-idol-generate, one picture to a 3DGS PLY end to end on Metal (stacked on #1773, #1774, #1775) - #1780
Conversation
|
Thanks @jayleaton. The noise table settles the PLY question: with the SDK's noise injected, ours lands as close as sampling resolves. It waits on #1773, #1774 and #1775. Once they're on main, please rebase onto main, and we'll run |
|
On I found a picture-layout validation gap. Create a safetensors file with a tensor named The trial merge into main Igor Lessio - AIFLOW LABS |
|
Thanks @AIFlowML for finding the picture-layout gap. Fixed and rebased at
Host checks (Linux): |
|
I retested the picture fix on zig build tf-idol-generate tf-kernel-contract -Dcpu=apple_m1 -Doptimize=ReleaseSafe -j4 --summary allI passed seven synthetic safetensors fixtures to the real Igor Lessio - AIFLOW LABS |
|
Thanks @AIFlowML for the M5 Max retest of the picture fix: 67/67 steps, with valid CHW Rebased onto main c35d9f7. The new head is 6e4d936. #1775 has merged, so this branch now carries only its own four commits. Git resolved the overlaps on its own, the same way your scratch merge did: main's contract notes and GLM prompt registration are kept, and this PR adds Host checks on 6e4d936:
|
|
Confirmed the rebased The seven synthetic safetensors cases from the earlier review still behave as expected through the CLI: both valid layouts reach weight loading, and all five malformed cases are refused before loading. The full checkpoint-to-PLY run remains separate. Igor Lessio - AIFLOW LABS |
|
Thanks for the end-to-end Idol tool and the picture-layout checks, @jayleaton. The recipe says the five camera values are bit-equal to torch's, but the repo has no recorded values for that short draw. Could you add a small regression with torch's values for seed 42 (the
|
|
Thanks for the review. Pushed 8c28d5f, a fast-forward from 6e4d936.
Checks: fmt, |
…oders, the denoiser and the decoders to a PLY Each stage is timed and each model freed after it. The starting noise is torch's CPU-seeded randn, reimplemented; the VAE's posterior noise and the starting noise can be given for parity with the SDK's MPS draws. The recipe's End to end section has the stage timings, memory and PLY comparison against the SDK's own IdolPipeline run.
…as AIFlowML found picture() checked only the element count, so `pixels` as float32 [1024, 1024, 3] (HWC) passed and was then read as CHW: a scrambled image reached both encoders. families/idol/picture.zig now requires `pixels` to be exactly float32 [3, 1024, 1024] and `image` exactly [1024, 1024, 3], and its host test plants the HWC `pixels`, a flat tensor, a bf16 one and a CHW `image`, each refused.
… idol.md under 600 lines; the picture's layouts
… under 600 lines with both encoders
tf-idol-generate's torch CPU generator moves to idol/torch_rng.zig, so its test runs without Metal. It checks the [8192, 16] then [5] draw for seed 42 against torch 2.5.1+cpu's values, produced with ATEN_CPU_CAPABILITY=default (the scalar normal_fill_16 the Mac runs): the camera's 5 values bit for bit, the latent's ends within 3 ulps and its sum, since torch's float logf, cosf and sinf are the platform's libm.
|
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. |
Stacked on #1773, #1774 and #1775 (and through them #1766). This branch merges those three; its own change is the last two commits (
25b6e6f50,883353480). Review after them.What this changes
tf-idol-generate: one SDK-preprocessed picture to a 3DGS PLY and camera, natively on M5 Metal. The steps are DINOv3's feature1 (#1775), the FLUX.2 VAE's feature2 (#1774), the denoiser's condition and 50 guided steps (#1766), then the octree and Gaussian decoders (#1773). Each model loads when its stage starts and is freed when it ends. For #1757; with this, the issue's scope is covered on Metal except background removal. Details: the "End to end" part ofdocs/recipes/idol.md.preprocess) are not ported. The input is the picturepreprocessreturns, as the case tools write it.torch.Generator("cpu").manual_seed(seed)'s randn, reimplemented (mt19937 and Box-Muller). The camera's five values are bit-equal to torch's; 28 of the 131,072 latent values are 1 ulp off, from torch's float cos and sin. The VAE posterior's noise and the octree's draws come from native seeded generators.--noise FILEinjects recorded noise for parity.tools/zig/idol_vae_case.py, as DINOv3's is, so the merged case tool stays under 600 lines.CLI: extended by #1787
tf-idol-generate's arguments, flags, defaults and outputs here are the interface integrations build on. #1787 extends them additively and changes none of them:PICTUREmay also be a.png,.jpg,.jpegor.webpphoto, preprocessed natively (BiRefNet fromSNAPSHOT_DIR/birefnet.safetensors);--mode synthetic|real(defaultsynthetic) and--crop-margin X;OUT_DIR/preprocessed.png;tf-idol-generate.jsonaddspreprocess_sandbirefnet_s, and itsload_sincludes BiRefNet's load.A safetensors PICTURE behaves exactly as in this PR.
On CUDA (#1862) the tool takes the same arguments, flags, defaults and outputs; its JSON's peak key is
cuda_peak_allocated_gbwhere Metal's ismetal_peak_allocated_gb.Kernel contract
There are no new kernels. All of Idol's together, on the merged tree:
Receipt
Environment: Mac Studio M5 Ultra 256 GB, macOS 27; this branch; idol-sdk
4702a7f0IdolPipeline.__call__on torch 2.13.0 (MPS), each stage timed by wrapping its methods withtorch.mps.synchronize(); the avocado example, seed 42, 50 steps, guidance 3, 262,144 Gaussians. The SDK's PLY is byte-identical to an earlier run of it.Stage timings (ours: two fresh processes, weights in the page cache both times):
Memory (
/usr/bin/time -l, the whole process): ours 2.71 GB peak footprint (2.40 GB Metal allocated at most); the SDK 12.88 GB (5.01 GB MPS allocated, 12.64 GB driver).Quality: the PLYs cannot be equal, because the SDK draws both its starting noise and the VAE posterior's noise from MPS's generator. Symmetric nearest-neighbour distance between 4,096-point samples, where two samples of the SDK's own PLY sit 0.00896 apart:
The starting noise, not the port, makes the gap. The SDK's own run with CPU-seeded noise lands as far from its MPS-noise run as ours does, and its sample has cosine 0.479 to that run's. Given the SDK's noises, ours is as close as sampling resolves: sample cosine 0.99835, camera yaw/pitch/fov 1.6956/0.5397/0.1094 against 1.7006/0.5413/0.1096. Every PLY has 262,144 finite Gaussians, and repeated runs of ours are byte-identical. I did not render them side by side.
Parity chain, with the SDK's recorded features and CPU-seeded noise: the sample has cosine 0.999991 to the SDK's from the same inputs, and the camera is within 0.0022. The PLY sits at NN 0.00981 (baseline 0.00944) from the SDK's decode of its own sample. From the picture through our encoders, the sample moves to cosine 0.9944 with native VAE noise and 0.9995 with the SDK's.
Tests:
zig build test test-golden -Dcpu=apple_m1: 585 of 585 steps, 8,958 of 9,011 tests pass, 53 skipped, 0 fail.zig fmt --check build.zig zig: clean.lean_check.py: 424, the same as main.Not run: CUDA (only the denoiser has a CUDA port, idol: Idol's denoiser on CUDA (stacked on #1766) #1767, not yet run on a GPU). 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. (No new kernels; the combined SUMMARY is above.)