fix(notebook): resolve execution-order dependency for optimized_models_dict in SD3 Torch.FX notebook#3365
Conversation
- 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.
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
|
This PR will be closed in a week because of 2 weeks of no activity. |
|
Thank you for the contribution! However, I don't think this change is correct — it would actually break the quantization flow. The original code is intentional and works correctly. All cells using optimized_models_dict are guarded by %%skip not $to_quantize.value, so they execute sequentially when quantization is enabled, and the dict is defined in Cell 21 before it's used in Cell 22. There is no execution-order issue. The PR removes critical lines. By deleting these three assignments from Cell 21: the dict only contains the "transformer" key, so Cell 22 would immediately crash with a KeyError when accessing optimized_models_dict["text_encoder"]. Closing as the change fixes a problem that doesn't exist and introduces a regression. The README casing fix ("Openvino" → "OpenVINO") is valid though — feel free to open a separate small PR for that! |
Description
Fixes an execution-order dependency issue in the Stable Diffusion v3 Torch.FX notebook where
optimized_models_dictwas used before being defined, causing a potentialNameErrorduring quantization workflows.Changes
optimized_models_dictinto the quantization section (Cell 19) under the conditional%%skip not $to_quantize.valueblocknumpyimport to ensure downstream cells execute correctlyImpact
Type of Change
Validation
Notes
This change preserves the original intent of conditional execution while ensuring the notebook behaves reliably in typical interactive usage scenarios.