Skip to content

Restore DPM_Solver.sample_mask for inpainting - #599

Open
0z5a wants to merge 1 commit into
NVlabs:mainfrom
0z5a:restore-sample-mask
Open

0z5a wants to merge 1 commit into
NVlabs:mainfrom
0z5a:restore-sample-mask

Conversation

@0z5a

@0z5a 0z5a commented Nov 20, 2026

Copy link
Copy Markdown

Summary

Refs #356.

app/sana_pipeline_inpaint.py calls scheduler.sample_mask(...) on the flow_dpm-solver path. DPM_Solver no longer has that method, so inpainting with that sampler stops with:

AttributeError: 'DPM_Solver' object has no attribute 'sample_mask'

This PR adds sample_mask() back to diffusion/model/dpm_solver.py, unchanged from 48ec430 (the inpainting PR, #296).

Why

The method was added in #296 and dropped in #313, when sample_frame_aware() was added. Nothing else calls it, so the inpaint app was the only thing left without it. The parts it uses (inverse(), get_time_steps(), multistep_dpm_solver_update()) are still there. inverse() is the same as in 48ec430.

I put it back as it was, rather than rewriting it, so the inpaint output should match what #296 gave.

How I found it

I read the open issue and checked the call against the solver. git log -S'def sample_mask' shows the two commits above.

Where this can show up in practice

Anyone who runs the inpaint demo (app/app_sana_inpaint.py) or SanaPipelineInpaint with flow_dpm-solver. That is the default vis_sampler, and the demo's default config uses it. The run stops at the sampling step with the error above. flow_euler does not use this method. My estimate; I have not seen a field report.

Testing

A small CPU script loads diffusion/model/dpm_solver.py on its own, with a toy noise model and the same arguments the inpaint pipeline passes (order=2, skip_type="time_uniform_flow", method="multistep", flow_shift=3.0, 10 steps, latents [1, 4, 8, 8]):

  • On main (27303b8): AttributeError: 'DPM_Solver' object has no attribute 'sample_mask'.
  • With this change:
    • latent_mask all zeros: the output equals img_latent exactly (max abs difference 0.0).
    • latent_mask = 1 on the left half: the right half equals img_latent. The left half is sampled and finite.

I did not run the full inpaint pipeline with a checkpoint, since I do not have the weights on this machine.

macOS arm64, CPU only, Python 3.11, torch 2.15.0.

app/sana_pipeline_inpaint.py calls scheduler.sample_mask(), but the
method was dropped from diffusion/model/dpm_solver.py when
sample_frame_aware() was added, so the flow_dpm-solver inpaint path
stops with AttributeError. Bring back the method as it was in 48ec430.
inverse() and the multistep updates it uses are unchanged since then.

Refs NVlabs#356

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant