Skip to content

Conversation

@Datta0
Copy link
Collaborator

@Datta0 Datta0 commented Dec 10, 2025

As @rolandtannous noticed, fbgemm 1.3.0 causes issues (Seg fault and bad alloc) so force 1.4.0 or newer if it is installed.
Note that even though one might not be using fp8, mere existence of fbgemm can cause issues with vllm importing it

So we check this before almost anything else

Sample error

❯ python -c 'import unsloth'
Unsloth: Patching protobuf.MessageFactory.GetPrototype
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "https://github.com/home/datta0/unsloth/unsloth/__init__.py", line 23, in <module>
    check_fbgemm_gpu_version()
  File "https://github.com/home/datta0/unsloth/unsloth/import_fixes.py", line 246, in check_fbgemm_gpu_version
    raise ImportError(
ImportError: Unsloth: fbgemm_gpu version 1.3.0 detected. It might cause unexpected issues. Please update to 1.4.0 or newer!

Successful case

Unsloth: fbgemm_gpu version 1.4.1+cu126 detected.

No fbgemm

Unsloth: fbgemm_gpu not found, skipping version check.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Datta0, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses critical stability concerns by implementing a proactive version check for the fbgemm_gpu library. It ensures that unsloth only operates with fbgemm_gpu versions 1.4.0 or newer, thereby mitigating known issues like segmentation faults and memory allocation errors. This validation is integrated early in the import sequence to prevent system instability from older fbgemm_gpu installations, even when its features are not directly utilized.

Highlights

  • Fbgemm Version Enforcement: Introduced a mandatory version check for the fbgemm_gpu library, requiring version 1.4.0 or newer.
  • Preventing Stability Issues: This check aims to prevent known issues such as segmentation faults and bad memory allocations that occur with older fbgemm_gpu versions (e.g., 1.3.0), even if fp8 is not explicitly used.
  • Early Initialization Check: The fbgemm_gpu version validation is now performed very early in the unsloth initialization process to catch potential problems before other modules are imported.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a version check for fbgemm_gpu to avoid segmentation faults and allocation errors caused by older versions. The change correctly identifies and flags incompatible versions. However, the current implementation will cause unsloth to fail on import if fbgemm_gpu is not installed at all. I've provided a critical review comment with a suggested fix to first check if the package exists before attempting to retrieve its version, which will prevent this crash.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@Datta0 Datta0 force-pushed the fbgemm_version_check branch from 793c5d0 to 7b96903 Compare December 10, 2025 11:17
@Datta0
Copy link
Collaborator Author

Datta0 commented Dec 10, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces two important version checks to prevent runtime issues: one for fbgemm_gpu and another for torchvision compatibility with torch. The changes are well-structured and address the issue described.

My review includes one high-severity feedback on unsloth/import_fixes.py. There is an inconsistency in the package name used for the fbgemm_gpu check, which could lead to incorrect behavior and user confusion. I've provided a code suggestion to correct the package name to fbgemm-gpu-genai consistently and to simplify the error message for better user experience. The new torchvision_compatibility_check function is well-implemented.

Comment on lines 249 to 256
fbgemm_gpu_version = importlib_version("fbgemm_gpu")
# We noticed some SegFault or bad alloc errors on lower versions of fbgemm_gpu.
if Version(fbgemm_gpu_version) < Version("1.4.0"):
raise ImportError(
f"Unsloth: fbgemm_gpu=={fbgemm_gpu_version} detected. It might cause unexpected issues. Please uninstall the current one by doing `pip uninstall fbgemm-gpu-genai && pip install fbgemm-gpu-genai` and install fbgemm-gpu-genai==1.4.0 or newer!"
)
elif UNSLOTH_ENABLE_LOGGING:
print(f"Unsloth: fbgemm_gpu=={fbgemm_gpu_version} detected.")
Copy link
Contributor

Choose a reason for hiding this comment

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

high

There's an inconsistency in the package name. importlib_version is called with "fbgemm_gpu", but the error message refers to fbgemm-gpu-genai for the pip command. importlib_version should be called with the distribution package name (e.g., fbgemm-gpu-genai).

Additionally, the error message is a bit long and the upgrade instructions could be simplified. Using pip install --upgrade is more direct than uninstall followed by install.

Finally, the success log message should also be consistent with the package name.

Suggested change
fbgemm_gpu_version = importlib_version("fbgemm_gpu")
# We noticed some SegFault or bad alloc errors on lower versions of fbgemm_gpu.
if Version(fbgemm_gpu_version) < Version("1.4.0"):
raise ImportError(
f"Unsloth: fbgemm_gpu=={fbgemm_gpu_version} detected. It might cause unexpected issues. Please uninstall the current one by doing `pip uninstall fbgemm-gpu-genai && pip install fbgemm-gpu-genai` and install fbgemm-gpu-genai==1.4.0 or newer!"
)
elif UNSLOTH_ENABLE_LOGGING:
print(f"Unsloth: fbgemm_gpu=={fbgemm_gpu_version} detected.")
fbgemm_gpu_version = importlib_version("fbgemm-gpu-genai")
# We noticed some SegFault or bad alloc errors on lower versions of fbgemm_gpu.
if Version(fbgemm_gpu_version) < Version("1.4.0"):
raise ImportError(
f"Unsloth: fbgemm-gpu-genai=={fbgemm_gpu_version} detected. It might cause unexpected issues. "
f"Please upgrade to version 1.4.0 or newer by running: `pip install --upgrade fbgemm-gpu-genai`"
)
elif UNSLOTH_ENABLE_LOGGING:
print(f"Unsloth: fbgemm-gpu-genai=={fbgemm_gpu_version} detected.")

Copy link
Contributor

Choose a reason for hiding this comment

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

@Datta0 see it works

@danielhanchen danielhanchen merged commit 3f92868 into unslothai:main Dec 10, 2025
1 check passed
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.

2 participants