Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: Do not rely on model.device if model could be partially loaded #7529

Merged
merged 1 commit into from
Jan 8, 2025

Conversation

RyanJDick
Copy link
Collaborator

@RyanJDick RyanJDick commented Jan 7, 2025

Summary

Given the recent introduction of partial model loading, the meaning of model.device has changed. It could return the "cpu" device even if the model is partially loaded and should be passed a "cuda" input. This PR makes a best effort to go through and clean up places where we access model.device.

Related Issues / Discussions

Original bug report: https://discord.com/channels/1020123559063990373/1149506274971631688/1326245764258861117

QA Instructions

Smoke test all of the modified code paths:

  • SD1 / SDXL inference
  • SD T2I Adapter
  • SD ControlNet Model
  • FLUX inference
  • FLUX IP-Adapter
  • SD3 inference
  • Spandrel upscaling
  • Upscaling job (w/ multi-diffusion)

I was also able to reproduce the error reported in Discord by manually loading models to the same level as OP (in a debugger). I confirmed that this changes fixed that particular issue.

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Tests added / updated (if applicable)
  • Documentation added / updated (if applicable)
  • Updated What's New copy (if doing a release after this PR)

@github-actions github-actions bot added python PRs that change python files invocations PRs that change invocations backend PRs that change backend files labels Jan 7, 2025
Copy link
Collaborator

@psychedelicious psychedelicious left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not test myself, only read through the changes - LGTM.

@hipsterusername hipsterusername force-pushed the ryan/do-no-rely-on-model-device branch from 5d36c1c to 163b04e Compare January 8, 2025 00:14
@hipsterusername hipsterusername enabled auto-merge (rebase) January 8, 2025 00:14
@hipsterusername hipsterusername merged commit 607d19f into main Jan 8, 2025
15 checks passed
@hipsterusername hipsterusername deleted the ryan/do-no-rely-on-model-device branch January 8, 2025 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend PRs that change backend files invocations PRs that change invocations python PRs that change python files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants