Skip to content

fix(notebook): resolve execution-order dependency for optimized_models_dict in SD3 Torch.FX notebook#3365

Open
Aadik1ng wants to merge 2 commits intoopenvinotoolkit:latestfrom
Aadik1ng:fix-stable-diffusion-v3-torch-fx-lint
Open

fix(notebook): resolve execution-order dependency for optimized_models_dict in SD3 Torch.FX notebook#3365
Aadik1ng wants to merge 2 commits intoopenvinotoolkit:latestfrom
Aadik1ng:fix-stable-diffusion-v3-torch-fx-lint

Conversation

@Aadik1ng
Copy link

Description

Fixes an execution-order dependency issue in the Stable Diffusion v3 Torch.FX notebook where optimized_models_dict was used before being defined, causing a potential NameError during quantization workflows.

Changes

  • Moved initialization of optimized_models_dict into the quantization section (Cell 19) under the conditional %%skip not $to_quantize.value block
  • Removed the duplicate/late initialization from Cell 21
  • Restored missing numpy import to ensure downstream cells execute correctly
  • Cleaned up minor linting issues (unused/misplaced imports)

Impact

  • Prevents runtime errors during quantization flow
  • Aligns variable scope with the notebook’s conditional execution design
  • Improves robustness for interactive and non-linear notebook execution

Type of Change

  • Bug fix
  • Code quality improvement

Validation

  • Verified logical execution flow for both quantized and non-quantized paths
  • Confirmed no undefined variable usage remains
  • Ensured required dependencies are imported before use

Notes

This change preserves the original intent of conditional execution while ensuring the notebook behaves reliably in typical interactive usage scenarios.

- Relocated initialization of 'optimized_models_dict' to ensure it's defined before first usage in calibration data collection.
- Ensured 'optimized_models_dict' is correctly scoped within the quantization-only sections to avoid NameErrors.
- Restored necessary 'numpy' imports and removed unused/redundant imports found by nbqa flake8.
- Improved overall notebook robustness for non-linear execution.
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

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