Fine-Tuning 3D Generation Models with LoRA and TRELLIS.2
Fine Tuning 3D Generation Models with LoRA and TRELLIS.2 Published November 12, 2026 Overview This guide describes a workflow for fine tuning TRELLIS.2 on a specialized 3D asset...
By Software Development Team
Fine-Tuning 3D Generation Models with LoRA and TRELLIS.2
Published November 12, 2026
Overview
This guide describes a workflow for fine-tuning TRELLIS.2 on a specialized 3D asset dataset. The experiment uses LoRA adapters to improve footwear geometry while leaving the model's material-generation stage unchanged. The workflow can run locally with Docker or as containerized workloads on Hugging Face Jobs.
The experiment uses 188 footwear objects from the Google Scanned Objects (GSO) dataset. The pretrained model generally generated shoes with plausible overall forms, but their soles were often inaccurate. The goal was to determine whether LoRA fine-tuning could improve that part of the geometry.
Why fine-tune a 3D model?
3D generation is used in robotics, simulation, media, and entertainment. These applications often require consistent representations and accurate details. 3D assets can use formats such as GLB and PLY, as well as representations such as neural radiance fields (NeRFs) and 3D Gaussian splatting (3DGS).
TRELLIS introduced a unified latent representation. Its decoders convert that internal representation into different 3D output formats, reducing the need for separate models for every representation. TRELLIS.2 followed with improvements to 3D structural representation, but neither model provides a task-specific adaptation automatically.
A general-purpose model can produce acceptable objects while missing details that matter for a particular category. In this experiment, the target was footwear geometry, especially the shape of the soles.
LoRA and the TRELLIS.2 pipeline
LoRA
LoRA, or low-rank adaptation, trains small adapter matrices while keeping the original model weights frozen. This reduces the number of trainable parameters and the memory required for gradients and optimizer state. The experiment uses the Hugging Face PEFT library to insert and train the adapters.
TRELLIS.2 stages
TRELLIS.2 generates an object through five main stages:
- Remove the image background.
- Encode the input image.
- Predict the object's coarse structure.
- Generate detailed geometry.
- Generate materials and textures.
The result is exported as a textured mesh.
BiRefNet removes the background from the input image. DINOv3-L then converts the image into feature tokens that guide the generation models.
Sparse-structure generation
The sparse-structure flow DiT predicts the object's coarse shape. It produces a latent with dimensions 16³ × 8, which a variational autoencoder (VAE) decoder converts into a 64 × 64 × 64 occupancy grid. Each voxel indicates whether a location belongs to the object.
A LoRA adapter is added to this DiT because its output guides the later geometry stage.
O-Voxel and structured sparse latents
O-Voxel is TRELLIS.2's sparse voxel format. It stores only voxels on the object's surface. Each retained voxel includes local geometry, such as a mesh vertex, and material attributes. A CPU can convert a mesh into O-Voxel in seconds, and a GPU can convert O-Voxel back into a mesh in seconds.
Structured sparse latents store 3D information in sparse tensors. The model uses approximately 10% of the voxels in the grid, avoiding computation on empty regions. The shape-flow and texture-flow DiTs are sparse transformers, while the sparse-structure-flow DiT is dense.
Geometry generation
The shape-flow DiT uses the occupancy grid and DINOv3 feature tokens to produce a geometry latent. A second VAE decoder converts that latent into O-Voxel geometry at 512 × 512 × 512 resolution.
LoRA adapters are added to this DiT because it controls the object's detailed shape.
Materials and mesh creation
The texture-flow DiT receives the shape latent and DINOv3 features. It generates material and texture information for the surface. A VAE decoder converts the latent into base-color, metallic, roughness, and alpha values for each voxel.
The experiment does not fine-tune this stage. The dataset contains diffuse color maps with baked lighting, but it does not provide the separate material maps required for training. In addition, the base model already produced suitable colors and textures, while the experiment targeted shape accuracy.
The pipeline combines geometry and material attributes and exports the result as a GLB file.
Planning the fine-tuning experiment
Components to train
LoRA adapters are added only to:
- The sparse-structure flow DiT
- The shape flow DiT
These components control structure and geometry. The texture-flow DiT remains frozen so that its existing capabilities are preserved.
Training the texture stage on diffuse maps with baked lighting could cause the model to treat lighting as a surface property. It could also overwrite useful capabilities learned during pretraining, a problem known as catastrophic forgetting.
Why use LoRA?
The selected subset contains 188 shoes from the 1,030 objects in GSO. For a dataset of this size, full fine-tuning would require substantially more compute and could overwrite useful pretrained behavior.
The configuration trains approximately 9.3 million adapter parameters across the two target DiTs:
- Rank 8 adapters in the attention and feed-forward (MLP) layers of the sparse-structure flow DiT
- Rank 16 adapters in the attention layers of the shape flow DiT
The rank determines the size of the adapter matrices. A higher rank gives the adapter greater capacity to learn.
Running the workflow
The setup uses two Docker images: one for preprocessing and one for fine-tuning. They can run on Hugging Face Jobs or on a local GPU machine.
Before starting, the following are required:
- An
HF_TOKEN, available from the Hugging Face token settings - Access to DINOv3, which is a gated model
- A dataset of meshes uploaded to the Hugging Face Hub, if using a custom dataset
The workflow consists of these steps:
- Provide the containers with access to the mesh data.
- Set the task parameters.
- Run the preprocessing container.
- Run the fine-tuning container.
- Upload adapter checkpoints to the Hub if required.
Running on Hugging Face Jobs
Preprocessing
The preprocessing container uses Blender to render 16 views of each object. These views become conditioning images during LoRA training. Blender runs without a display through xvfb-run. The container also converts each object through the TRELLIS.2 preprocessing pipeline.
For the 188-object footwear dataset, preprocessing took approximately one hour on an a100-large job.
export HF_TOKEN=hf_xxx
## Replace your-username with your Hugging Face username
hf jobs run -d --flavor a100-large --timeout 6h --secrets HF_TOKEN \
cr.hf.co/suvadityamuk/trellis2-finetuning-prep:latest \
trellis2-prep \
--meshes your-username/my-meshes \
--push-to your-username/my-meshes-trellis2 \
--private --holdout 0.05 \
--views 16 --workers 8
Important options include:
| Option | Meaning |
|---|---|
-d | Detach from the job after printing its ID and URL. Logs can be followed with hf jobs logs -f <id>. |
--flavor a100-large | Selects an 80 GB A100 machine. |
--timeout 6h | Stops the job after six hours. Preprocessing skips completed objects, and training resumes from the newest checkpoint in --push-to. |
--secrets HF_TOKEN | Passes the token as an encrypted environment variable without writing it into the image. |
cr.hf.co/...:latest | Specifies the container image. Text after the image name is the command executed inside the container. |
LoRA fine-tuning
The training container loads the prepared dataset and a configuration preset or file. It records metrics with Trackio. The ss configuration trains the sparse-structure flow DiT, while shape trains the shape-flow DiT.
export HF_TOKEN=hf_xxx
hf jobs run -d --flavor a100-large --timeout 12h --secrets HF_TOKEN \
cr.hf.co/suvadityamuk/trellis2-finetuning-train:latest \
trellis2-train --config ss \
--latents your-username/my-meshes-trellis2 \
--push-to your-username/my-trellis2-lora \
--run-name ss_lora \
--push-path ss_lora \
--trackio-space your-username/trellis2-trackio
hf jobs run -d --flavor a100-large --timeout 12h --secrets HF_TOKEN \
cr.hf.co/suvadityamuk/trellis2-finetuning-train:latest \
trellis2-train --config shape \
--latents your-username/my-meshes-trellis2 \
--push-to your-username/my-trellis2-lora \
--run-name shape_lora \
--push-path shape_lora \
--trackio-space your-username/trellis2-trackio \
--set max_steps=3000 i_save=500
The --push-to option uploads adapter checkpoints to the Hub. The same workflow can use the already-preprocessed dataset suvadityamuk/gso-footwear-trellis2-latents:
export HF_TOKEN=hf_xxx
## Sparse-Structure Flow DiT
hf jobs run -d --flavor a100-large --timeout 12h --secrets HF_TOKEN \
cr.hf.co/suvadityamuk/trellis2-finetuning-train:latest \
trellis2-train \
--config ss \
--latents suvadityamuk/gso-footwear-trellis2-latents \
--push-to your-username/trellis2-footwear-lora \
--run-name ss_lora \
--push-path ss_lora \
--trackio-space your-username/trellis2-trackio \
--set max_steps=3000 i_save=500
## Shape Flow DiT
hf jobs run -d --flavor a100-large --timeout 12h --secrets HF_TOKEN \
cr.hf.co/suvadityamuk/trellis2-finetuning-train:latest \
trellis2-train \
--config shape \
--latents suvadityamuk/gso-footwear-trellis2-latents \
--push-to your-username/trellis2-footwear-lora \
--run-name shape_lora \
--push-path shape_lora \
--trackio-space your-username/trellis2-trackio \
--set max_steps=3000 i_save=500
Running locally with Docker
The container commands use the same training arguments as Hugging Face Jobs. The Docker options provide GPU access, shared memory, cache storage, and a working directory.
Preprocessing
docker run --gpus all --rm --shm-size 16g -e HF_TOKEN=hf_xxx \
-v hf-cache:/root/.cache/huggingface -v "$PWD/work":/workspace/work \
cr.hf.co/suvadityamuk/trellis2-finetuning-prep:latest \
trellis2-prep --meshes your-username/my-meshes \
--push-to your-username/my-meshes-trellis2
Fine-tuning
## Sparse-Structure Flow DiT
docker run --gpus all --rm --shm-size 16g \
-v hf-cache:/root/.cache/huggingface -v "$PWD/work":/workspace/work \
cr.hf.co/suvadityamuk/trellis2-finetuning-train:latest \
trellis2-train --config ss \
--latents your-username/my-meshes-trellis2 \
--push-to your-username/my-trellis2-lora \
--trackio-space your-username/trellis2-trackio
## Shape Flow DiT
docker run --gpus all --rm --shm-size 16g \
-v hf-cache:/root/.cache/huggingface -v "$PWD/work":/workspace/work \
cr.hf.co/suvadityamuk/trellis2-finetuning-train:latest \
trellis2-train --config shape \
--latents your-username/my-meshes-trellis2 \
--push-to your-username/my-trellis2-lora \
--trackio-space your-username/trellis2-trackio
Inside the training pipeline
Preparing training latents
TRELLIS.2's frozen encoders convert the input meshes into the latent representations used for training. Saving these latents prevents later runs from encoding the meshes again.
The preprocessing step also renders 16 views of every object in Blender. During training, one view is selected randomly for each sample as the conditioning image.
Nine of the 188 objects are held out for evaluation. The remaining 179 objects are used for training. The held-out objects test whether the adapters improve generation for objects not seen during training.
The data loader selects the configuration based on the training mode:
ssusesss_latents/ss_enc_conv3d_16l8_fp16_64shapeusesshape_latents/shape_enc_next_dc_f16c32_fp16_512
A batch size of 4 with four gradient-accumulation steps produces an effective batch size of 16. The held-out objects are removed from the training dataset before batches are created.
Preparing LoRA adapters
The PEFT library inserts adapters into the selected model layers. Because TRELLIS.2 uses a custom forward pass, the standard PeftModel() wrapper is not used. Instead, inject_adapter_in_model() inserts the adapters directly while preserving the model's custom interface.
The adapter weights remain in 32-bit floating point (fp32) for numerical stability. The forward pass uses bfloat16 (bf16) autocasting to reduce memory use for supported operations. The frozen backbone weights are not changed by autocasting.
model = models.from_pretrained(cfg["ckpt"])
for block in model.blocks:
block.use_checkpoint = True
inject_adapter_in_model(
LoraConfig(
r=cfg["rank"],
lora_alpha=cfg["alpha"],
target_modules=cfg["lora_targets"]
),
model,
)
params = []
for name, p in model.named_parameters():
p.requires_grad_("lora_" in name)
if p.requires_grad:
p.data = p.data.float()
params.append(p)
model.cuda().train()
Training objective
The experiment uses rectified flow matching, the same objective used during TRELLIS.2 pretraining. Only LoRA parameters in the sparse-structure and shape DiTs are updated. All original model weights remain frozen.
The optimizer is AdamW, and DINOv3 extracts features from the conditioning images:
opt = torch.optim.AdamW(
params,
lr=cfg["lr"],
weight_decay=cfg["weight_decay"],
betas=(0.9, 0.95)
)
dino = DinoV3FeatureExtractor(
cfg["image_cond_model"],
image_size=cfg["image_size"]
).cuda()
For each batch, the training loop:
- Samples a timestep
t. The sparse-structure flow uses a logit-normal schedule, while the shape flow uses a uniform schedule according to the TRELLIS.2 configuration. - Generates noise with the same shape as the input data.
- Mixes clean data and noise according to
t, wheret = 0is minimally noisy data andt = 1is pure noise. - Predicts velocity at
t × 1000to match pretraining conditions. - Computes mean squared error between the predicted velocity and the target velocity.
def flow_loss(x0, cond):
s = cfg["t_schedule"]
t = (
torch.rand(x0.shape[0])
if s["name"] == "uniform"
else torch.sigmoid(
torch.randn(x0.shape[0]) * s["args"]["std"]
+ s["args"]["mean"]
)
)
t = t.cuda()
noise = (
x0.replace(torch.randn_like(x0.feats))
if cfg["sparse"]
else torch.randn_like(x0)
)
tv = t.view(-1, *[1] * (len(x0.shape) - 1))
x_t = (1 - tv) * x0 + (
cfg["sigma_min"] + (1 - cfg["sigma_min"]) * tv
) * noise
pred, target = model(x_t, t * 1000, cond), (
1 - cfg["sigma_min"]
) * noise - x0
return (
F.mse_loss(pred.feats, target.feats)
if cfg["sparse"]
else F.mse_loss(pred, target)
)
Gradient accumulation adds gradients from four smaller batches before each optimizer update. Gradient checkpointing saves GPU memory by recomputing selected intermediate values during backpropagation.
For each batch, DINOv3 encodes the conditioning image. Classifier-free guidance dropout sets the conditioning features to zero for a random fraction of samples. The loss is then calculated with bfloat16 autocasting. Gradients are clipped before the optimizer update. The workflow logs loss every 10 steps and saves an adapter checkpoint every 500 steps.
Results
Two adapters were trained, one for the sparse-structure DiT and one for the shape DiT. Each run used one 80 GB A100 on Hugging Face Jobs.
- Sparse-structure run: 7.2 hours
- Shape run: 3.6 hours
The sparse-structure training loss dropped quickly at first and then declined more gradually. The shape-flow loss remained approximately level. These curves describe changes in the training objective, but they do not directly measure generated geometry quality.
Evaluation was performed on the nine held-out objects. The comparison included the input image, the base model output, a rotation-adjusted base output, the output using the footwear adapters, and the reference scan. In the examples, the fine-tuned model generated soles that were closer to the scans.
Geometry metrics
| Metric | Meaning |
|---|---|
| Chamfer distance | The bidirectional distance between points on one surface and their nearest points on the other surface. Lower is better. |
| F-score @ 0.02 | Combines precision and recall using a matching threshold equal to 2% of the scan's bounding-box diagonal. Higher is better. |
| Normal consistency | Measures how closely the surface normals agree. Higher is better. |
Across the nine-object comparison:
- Mean F-score increased from
0.276for the base model to0.803with the footwear adapters. - Chamfer distance decreased from
0.174to0.033. - Normal consistency increased from
0.530to0.804. - The model with both adapters achieved a higher F-score on all nine held-out objects.
Future directions
This experiment fine-tuned TRELLIS.2 for footwear generation by adapting the two components responsible for structure and geometry, while freezing the texture stage. The data was prepared once, the two adapters were trained in separate jobs, and the results were evaluated on held-out objects.
The central design decision was to align the training target with both the application and the available data. Because the dataset provided suitable geometry information but lacked separate material maps, the structure and shape stages were selected while the texture stage remained unchanged.
The same approach could be investigated with other 3D generation models, including Pixal3D and UniLat3D. Gaussian-splat and world-generation models such as HunyuanWorld 2.0 and NVIDIA Lyra 2.0 could require different representations and training procedures.