Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def gemm_with_dynamic_quant_fake(
dispatch_key=current_platform.dispatch_key,
)

except ImportError:
except (ImportError, AttributeError):
dynamic_mxfp4_quant = gemm_afp4wfp4 = None
Comment on lines +100 to 101
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

While adding AttributeError correctly fixes the crash on AMD, this try-except block has a latent bug. It is too broad, covering lines 26 to 98, but the except block only handles dynamic_mxfp4_quant and gemm_afp4wfp4.

If an ImportError or AttributeError occurs during the import of other symbols like shuffle_weight, or the conditional imports of gemm_a4w4 and per_1x32_f4_quant_hip, they will be undefined. This can lead to a NameError later when they are used, for example in process_weights_after_loading or gemm_with_dynamic_quant.

A more robust approach would be to refactor this. A good approach would be to have smaller, more focused try-except blocks for different sets of imports (e.g., common, ROCm-specific, CUDA-specific) and ensure all imported symbols are properly handled in their respective except blocks. This would also require adding checks in QuarkW4A4MXFP4.__init__ to ensure the required kernels are available for the selected execution path.


__all__ = ["QuarkW4A4MXFP4"]
Expand Down