Skip to content

[bug]: diffusers pipeline should run with autocast disabled #2345

@keturn

Description

@keturn

We currently have some code in generator.base that turns on autocast when float16 is in use:

def choose_autocast(precision):
'''Returns an autocast context or nullcontext for the given precision string'''
# float16 currently requires autocast to avoid errors like:
# 'expected scalar type Half but found Float'
if precision == 'autocast' or precision == 'float16':
return autocast

We do not want to be using autocast while executing the diffusers pipeline.

Ideally we can take that out entirely, but if it's required for some of the legacy ckpt_generator code, we may be able to work around it by either moving the autocast further down to that code, or protecting the diffusers code by wrapping it in with autocast(enabled=False).

Code that fails with type errors when autocast is disabled (e.g. Input type (float) and bias type (c10::Half) should be the same) needs to be cleaned up so the tensors are their correct types. Preferably as early to their creation as possible, instead of converting them on every access.

Additional context

This is related to and possibly blocking other issues:

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions