Skip to content

RecursionError when using enable_sequential_cpu_offload with FP8 wrapper #8

@JVSCHANDRADITHYA

Description

@JVSCHANDRADITHYA

Using enable_sequential_cpu_offload() together with the FP8 optimization wrapper leads to a RecursionError during inference.

This occurs in videox_fun/utils/fp8_optimization.py.

Reproduction

in notebook.ipynb:

pipe.enable_sequential_cpu_offload()

with torch.no_grad():
    pipe(...)

ERROR :

RecursionError: maximum recursion depth exceeded

ATTACHMENTS :

Image

PROBABLE CAUSE :

The FP8 wrapper (in videox_fun/utils/fp8_optimization.py) overrides forward and performs .to() inside the forward pass.

When combined with accelerate hooks used in sequential CPU offloading:

  • .to() triggers recursive module traversal
  • wrapped forward functions are re-entered
  • leading to infinite recursion

Additionaally, original_forward may capture an already wrapped forward function, further contributing to recursion.

RUN ENVIRONMENT :

  • Platform: Linux (Ubuntu)
  • PyTorch: provided version [req.txt]
  • accelerate: provided version [req.txt]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions