Repository navigation
feat(models): add IDOL (idol) image to 3D Gaussian splats in mlxcel predict - #3731
Open
Jaeyeong-CHOI wants to merge 1 commit into
Open
Jaeyeong-CHOI wants to merge 1 commit into
Jaeyeong-CHOI wants to merge 1 commit into
Conversation
…redict Port Sperid Labs' IDOL (speridlabs/idol) from mlx-vlm as the dense family `idol`: BiRefNet background removal, DINOv3-H+ (on the SAM 3D Body tower, loaded from the Hugging Face layout) and FLUX.2 VAE conditioning, the rectified-flow denoiser over the object latent and camera token, the octree point sampler and the Gaussian decoder. `mlxcel predict` writes gaussian.ply (y-up 3DGS), input.png, camera.json, result.safetensors and meta.json. The checkpoint has no model_type; its config layout is detected as `idol`. Flux2Vae gains moments(), the shared Pillow resampler gains Lanczos and RGBA resizing, DenseOutput gains image and JSON attachments, and the architecture registry gains the gaussian_splats output kind. Closes lablup#3232.
This branch has not been deployed
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.
Summary
Closes #3232.
Adds Sperid Labs' IDOL (
speridlabs/idol) tomlxcel predictas the dense familyidol: one object photo becomes a standard 3D Gaussian Splattinggaussian.ply, with the preparedinput.png, the predictedcamera.json, the sampledlatentandcamerainresult.safetensors, andmeta.json. Ported from mlx-vlm'smlx_vlm/models/idol(Neywa-Labs/mlx-vlm#2644,92e07596), which adapts speridlabs/idol-sdk.Before this change
mlxcel predict -m <speridlabs/idol>failed withmodel_type not found in .../config.json, andmlxcel archdid not listidol.What changed
src/vision/dense/idol/(new):config.rs,options.rs: the publishedconfig.jsonand the--optssurface (mode,num_gaussians,steps,guidance,rescale_t,seed,crop_margin,batch_cfg,dinov3,flux2_vae,dinov3_dtype,background_removal), validated with upstream's messages.preprocess.rs:preprocess_imageon 8-bit pixels as Pillow computes it: Lanczos resize of the short side to 1024 (premultiplied RGBA), BiRefNet when the alpha is not real, a 3x3 minimum filter with replicated edges, the square crop around the alpha bounding box (crop_margin1.2 forsynthetic, 1.7 forreal, Pythoninttruncation, transparent padding), a second Lanczos resize andDIV255compositing on black.birefnet.rs,birefnet_swin.rs,deform_conv.rs: BiRefNet in f32: the Swin-L backbone (shifted windows, relative position bias, patch merging) on the full and half-resolution image, the ASPP blocks with modulated deformable convolutions (bilinear gathers, one kernel row at a time), and the multi-scale decoder.conditioning.rs: DINOv3-H+ runs on the SAM 3D Body DINOv3 tower, loaded from the Hugging FaceDINOv3ViTModellayout through a key map (layer.*ormodel.layer.*, gated MLP tow1/w2/w3, LayerScalelambda1, register tokens, RoPE periods fromrope_theta); the parameter-free LayerNorm then givesfeature1 [1, 4101, 1280]. FLUX.2-dev runs on the sharedFlux2Vaeencoder in bf16: the posterior is sampled, 2x2-patchified with channel order(C, py, px), batch-norm normalized and prefixed with five zero tokens (feature2 [1, 4101, 128]).layers.rs,denoiser.rs,sampler.rs:LatentSeqMMFlowModelwith upstream's dtypes (transformer linears f16, everything else f32, explicit casts at each boundary): RePo learned rotary positions, modulated and unmodulated unified blocks, the joint[latent, condition, camera]blocks and the output modulation; Euler rectified-flow sampling with therescale_ttime warp and guidance against a zero condition, sequential or batched (batch_cfg).octree.rs,gaussian.rs,camera.rs: the octree decoder withsystematic_sample(CDF rounding, one offset per cell) and host-side packing once per level, the Gaussian decoder and its activations, the y-up PLY transform with IDOL's clamps, anddecode_camera. Random draws come from MLX's global generator, seeded after the encoders load as upstream does; tests can inject recorded draws.checkpoint_model_typereturnsidolfor a config withoutmodel_typewhose denoiser isLatentSeqMMFlowModeland that hasdecoder_gsandimage_encoders;idolis inKNOWN_MODEL_TYPESandFAMILIES. The generation-side detector reportsdense prediction checkpoint (idol): use mlxcel predictfor the same layout instead ofmodel_type not found.idolStandaloneArchitectureFamily(categorydense_prediction, image input) with a new output kindgaussian_splats.sam3d_body/backbone.rs:forward_tokensreturns every normalized token (CLS, storage, patches) for any float input dtype;forwardkeeps its F32 check and slices the patches as before. After RoPE, q and k return to the value dtype (a no-op for the F32 Body tower).imagegen/vae/model.rs:Flux2Vae::moments()returns the posterior mean and the log-variance clipped to[-30, 20];encodenow calls it, unchanged in result.dense/preprocess.rs:PillowResizeFilter::Lanczosandresize_pillow_rgba8(Pillow'sRGBaround trip; a resize to the current size returns a copy, asImage.resizedoes, so translucent pixels keep their exact values). The two passes are now generic over the band count as a const parameter (3 for RGB, 4 for RGBA);resize_pillow_rgb8output is unchanged. ItsUsed by:note now lists every caller (git grep -ln 'resize_pillow_rgb8(' -- src).dense/predictor.rs,dense/output.rs:DenseOutputgainsimagesanddocuments, which the shared writer saves as<name>.pngand<name>.json(names restricted toinputandcamera). Each attachment replaces only a file or symlink of its own name when it is written. Neither name is on the shared stale-artifact list, so a run of any other family leaves a user'sinput.pngorcamera.jsonin the output directory alone; IDOL writes both on every run.supported-models.md,dense-prediction.mdwith the gated-encoder instructions,vision-model-scope.md,environment-variables.mdfor the test variables),NOTICE(mlx-vlm, Idol SDK, diffusers Wan; the encoder weights keep their own licenses) andCHANGELOG.mdunder## [Unreleased].Deviations from the issue
batch_cfgguidance compute the same thing at batch 1 and batch 2, and on the same seeded inputs their 4-step results differ by 1.08e-2 in the latent and 5.4e-3 in the camera (computed from the committed fixture,sample.*againstsample_batch_cfg.*). mlxcel's sequential path is 3.8e-3 / 3.6e-3 from mlx-vlm's sequential result, inside that gap, and itsbatch_cfgpath is bit-identical to mlx-vlm's.x * x * xorder; one f16 ulp on 30 of 8,193 values) moves its guided 4-step latent by 8.9e-3 and the camera by 1.3e-2, and the unguided latent by 9.7e-4; running its denoiser in f32 moves the guided latent by 2.5e-2. Guidance 3 multiplies the difference of two passes by four.batch_cfgpaths are was not isolated.decodewith the recorded offsets and uniforms. The Gaussian decoder on upstream's points is compared over the recorded Gaussians, and the octree is compared one level at a time on upstream's cells with its offsets, allowing one percent of the cells to split differently (6 of 2,804 measured, at levels 3 to 5). The chained decode is not compared cell for cell because the split of a cell on a systematic-sampling boundary is not reproducible even within mlx-vlm: an mlx-vlm script that replays the same per-level loop with the same latent and recorded offsets reached 65 cells at level 4, where the run that produced the reference reached 64, and every later level then differs. On that replay's cells mlxcel's per-level split probabilities are bit-identical to mlx-vlm's at all eight levels (its logits at levels 3 to 5 differ by about 1e-3 relative, the others are bit-identical). The cause of the boundary differences was not isolated. The full chained decode still runs in the test with MLX's generator and is checked for anchor count and finite output.nn.GELU(approx="tanh")is MLX's compiledgelu_approx; IDOL uses the shared compiled port (compiled_objects_gelu_tanh, which keeps thePower(x, 3)primitive) because the op-by-op formula differs in the last bit on 30 of 8,193 f16 values, and the 24-block f16 denoiser carries that into the latent (the replacement experiment above). A unit test pins it bit for bit against the recorded mlx.nn table.dinov3/flux2_vaein--opts, the repository ids inimage_encodersare looked up in./models, the Hugging Face cache and the mlxcel store without downloading, rather than resolved with an automatic download: the encoders are gated, and an automatic fetch ofblack-forest-labs/FLUX.2-devwould pull far more than itsvae/. A miss names the gated repository and the option.crop_margin, now stops with an error before an intermediate image passes 8192 x 8192 pixels, and a crop box that saturates the pixel range is an error instead of an overflow.stepsis capped at 10,000.mlxcel archreports the newgaussian_splatsoutput kind foridol; the existing kinds had no Gaussian-only entry (SAM 3D Objects, which also writes meshes, staysmesh).Verification
GB10 (sm_121, 121 GB unified memory), CUDA 13,
MLX_ENABLE_TF32=0. The reference is mlx-vlm ate8035ae3(contains Neywa-Labs/mlx-vlm#2644,92e07596) with mlx 0.32.4. Checkpoints:speridlabs/idol2731c2291fc65a797c5cb627a5e5526fc1490902,facebook/dinov3-vith16plus-pretrain-lvd1689mand thevae/folder ofblack-forest-labs/FLUX.2-dev.Before (main
ac5716b8f).mlxcel predict -m <speridlabs/idol> --image castle.webp --task gaussian -o outfails withload model: classify checkpoint: model_type not found in .../config.json;mlxcel archhas noidol. The new tests referencevision::dense::idol, which does not exist on main.Unit tests (
cargo test --profile test-fast --features cuda --lib vision::dense::idol): 46 passed, 3 ignored (the real-checkpoint tests below). They cover the published-config detection and its negatives (nomodel_typeand missingdecoder_gs,image_encodersor the denoiser name still fail withmodel_type not found; an explicitmodel_typewins);systematic_sampleagainst values printed by mlx-vlm for nine cases (zero, one and 1,000,000 points, all-zero and negative probabilities, a 1e-30 ratio, fixed offsets 0, 0.5 and 0.999); octree point conservation at every level and recorded-draw shape checks;RePo3DRotaryEmbeddingandPcdAbsolutePositionEmbedder/v2against hand-computed values; the Gaussian activations and the y-up PLY transform on two points, including the written bytes and a NaN scale that must not passmax(s, 1e-6);decode_cameraperspective, orthographic and zero-direction cases; Pillow Lanczos RGBA resizes (premultiplied, upscale, a resize to the same size, which Pillow returns as a copy, and a tall image whose vertical pass runs first) and mlx-vlm'spreprocess_imagefor both modes on two sources, one of them a translucent 24x16 image whose short side is already 16 and whose synthetic crop is exactly 16 square, byte for byte against Pillow 13.0.0 output (tests/fixtures/idol/pillow_cases.txt); crop geometry, erosion, compositing, half-to-even rounding and the size limits; the deformable convolution against a direct DCNv2 on a 6x6 input for 1x1, 3x3 and 7x7 kernels with offsets past the border; the Body DINOv3 tower against a direct Hugging Face DINOv3 forward with shared random weights (layer.*andmodel.layer.*, max difference under 1e-4, bf16 cosine above 0.999); the sampler time grid, guidance and batched guidance; the tanh GELU bit for bit against mlx.nn on 8,193 f16 values; options with upstream's messages; encoder path lookup that never downloads.Real-checkpoint parity (
MLXCEL_TEST_IDOL_DIR=... cargo test ... vision::dense::idol::real_tests -- --ignored, referencetests/fixtures/idol/reference.safetensors):batch_cfg: latent / cameraWith the gated encoders (
MLXCEL_TEST_IDOL_ENCODER_REFERENCE, generated locally bygenerate_reference.py --encoders, not committed): BiRefNet alpha on mlx-vlm's resized RGB image differs by at most 1 level (140 and 141 of 2,097,152 pixels in two runs); DINOv3feature1cosine 0.99992 over all 4,101 tokens (lowest single token 0.979); FLUX.2 VAE posterior mean relative error 1.04e-2 (bound 3e-2) andfeature2with the recorded posterior noise 9.5e-3 (bound 3e-2). The full preprocessing of an RGB photo (BiRefNet included) gives aninput.pngwithin 2 levels of mlx-vlm's prepared image (93 of 1,048,576 pixels differ). For the reference only, mlx-vlm's BiRefNet convolutions that the mlx 0.32.4 wheel finds no cuDNN plan for (MLX_ENABLE_TF32=0) run on its CPU stream; mlxcel's MLX falls back to the gemm convolution for those (#2739).End to end (
mlxcel predict, release-styletest-fastbuild):speridlabs/idol's gallery composited on white, 640x320), background removed by BiRefNet, defaults (50 steps, guidance 3.0, 262,144 Gaussians): 2 min wall clock including model loading (meta.jsontiming_ms118,357 for the prediction), 2.6 GB peak RSS. Itsinput.pngis within 2 levels of mlx-vlm's prepared image (93 of 1,048,576 pixels differ; the BiRefNet alpha differs by at most 1 level, see above).gaussian.plyis 17,826,208 bytes: 262,144 vertices, the 17 standard fields in order (x y z nx ny nz f_dc_0..2 opacity scale_0..2 rot_0..3), binary little-endian, all finite, zero normals, quaternion norms 1 +- 3e-7, opacity logits within logit(1e-6) on both sides, log scales -7.01 to -1.73.input.pngis 1024x1024,camera.jsonholds yaw, pitch, radius and fov,result.safetensorsholdslatent [1, 8192, 16]andcamera [1, 1, 5], andmeta.jsonthe seed, steps, guidance,rescale_t,num_gaussians, mode, crop margin andbackground_removed: true.mode: real, 32,768 Gaussians, 25 steps,batch_cfg: 50 s, 32,768 finite vertices. Itsinput.pngis byte-identical to mlx-vlm'spreprocess_imageon the same file with Pillow 13.0.0.input.pngbyte-identical to mlx-vlm'spreprocess_imageon the same file. Taking the premultiplied round trip there, which Pillow skips at the same size, changes 25,486 of 1,048,576 pixels by up to 3 levels.background_removal: falsewith the RGB photo:An RGB input needs background removal; pass an RGBA image or enable BiRefNet.num_gaussians: 32769:num_gaussians must be a multiple of 32 between 32768 and 1048576. No encoder options and no local copy: the error namesfacebook/dinov3-vith16plus-pretrain-lvd1689mand thedinov3option.mlxcel archlistsidol;mlxcel arch --jsonreports it asdense_prediction, runtimepredict, outputgaussian_splats.Gates (the committed tree):
cargo fmt --all -- --check: pass.cargo clippy --locked --workspace --all-targets --features cuda -- -D warnings: pass.python3 scripts/ci/check_used_by.py,bash scripts/ci/check_used_by_test.sh,python3 scripts/ci/check_env_var_docs.py,python3 scripts/ci/check_binary_assets.py,python3 scripts/ci/check_kernel_dtype_keys.py: pass.check_cross_repo_refs.pyran without a GitHub token; the bare references it lists (#3232, and the existing#3604,#3612on an edited comment line) are lablup/mlxcel numbers.vision::dense::registry11,vision::dense::preprocess8,vision::dense::geometry_io5,vision::dense::output12 (three new: a run of another family leaves an existinginput.pngandcamera.jsonuntouched; attachments replace a symlink of their own name without writing through it; unsupported, duplicate and empty attachments are refused before any earlier output is removed),vision::dense::sam3d_body20,imagegen::vae32 (1 ignored),models::registry22, and the detection redirect test: all pass.make verify-test-cuda(--test-threads=1): 18,943 passed, 2 failed, 581 ignored. The two failures fail the same way on unmodifiedmain(9402cf893) in the same build directory:mlx_test_guard_coverage::mlx_evaluating_lib_tests_take_mlx_test_guardlists onlysrc/vision/encoders/nemotron_h_nano_omni_tests.rs:276 pos_embed_resample_runs_in_f32, andstep3p7_parity::text_decode_delegates_sequence_local_native_batchingfails attests/step3p7_parity.rs:519; both are [nightly-verify] main is red #3652.main(9402cf893) and merges cleanly (git merge-tree).Limits
/v1/meshesjob API, mesh extraction and text conditioning are out of scope, as the issue says. Video input is refused.