From d70b6de0722568fc34add91c37bfe2eba88fcf0f Mon Sep 17 00:00:00 2001 From: Wenwen Gao <94138584+snowmanwwg@users.noreply.github.com> Date: Tue, 5 Aug 2025 10:30:24 -0700 Subject: [PATCH 1/2] Update bridge-guide.md Signed-off-by: Wenwen Gao <94138584+snowmanwwg@users.noreply.github.com> --- docs/bridge-guide.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/bridge-guide.md b/docs/bridge-guide.md index c412db232d..28abd8bca7 100644 --- a/docs/bridge-guide.md +++ b/docs/bridge-guide.md @@ -1,10 +1,10 @@ -# Megatron <-> HuggingFace Bridge User Guide +# Megatron <-> 🤗Hugging Face Bridge User Guide -Megatron Bridge provides seamless bidirectional conversion between HuggingFace Transformers and Megatron Core model formats. This guide covers the main APIs for loading models, checking compatibility, and converting between formats. +Megatron Bridge provides seamless bidirectional conversion between 🤗Hugging Face Transformers and Megatron Core model formats. This guide covers the main APIs for loading models, checking compatibility, and converting between formats. -## Loading a HuggingFace Model into Megatron Implementation +## Loading a 🤗Hugging Face Model into Megatron Implementation -The easiest way to load a HuggingFace model is using `AutoBridge.from_hf_pretrained()`, which automatically detects the model architecture and selects the appropriate bridge. You can then use `AutoBridge.to_megatron_model()` to initialize the Megatron model from the HuggingFace configuration and load HuggingFace weights. +The easiest way to load a 🤗Hugging Face model is using `AutoBridge.from_hf_pretrained()`, which automatically detects the model architecture and selects the appropriate bridge. You can then use `AutoBridge.to_megatron_model()` to initialize the Megatron model from the 🤗Hugging Face configuration and load 🤗HuggingFace weights. ### Basic Usage @@ -71,7 +71,7 @@ The provider pattern is especially useful when you need to: Before loading a model, you can check if it's supported by Megatron Bridge. -You can list all supported HuggingFace model architectures with the following: +You can list all supported 🤗Hugging Face model architectures with the following: ```python from megatron.bridge import AutoBridge @@ -100,9 +100,9 @@ if AutoBridge.can_handle("custom/model", trust_remote_code=True): bridge = AutoBridge.from_hf_pretrained("custom/model", trust_remote_code=True) ``` -## Converting back to HuggingFace +## Converting back to 🤗Hugging Face -After training or modifying a Megatron model, you can convert it back to HuggingFace format for deployment or sharing. The bridge provides several methods for this conversion depending on your needs. +After training or modifying a Megatron model, you can convert it back to 🤗Hugging Face format for deployment or sharing. The bridge provides several methods for this conversion depending on your needs. To save the complete model including configuration, tokenizer, and weights: @@ -110,7 +110,7 @@ To save the complete model including configuration, tokenizer, and weights: # Save the complete model (config, tokenizer, weights) bridge.save_hf_pretrained(megatron_model, "./my-fine-tuned-llama") -# The saved model can be loaded with HuggingFace +# The saved model can be loaded with 🤗Hugging Face from transformers import AutoModelForCausalLM hf_model = AutoModelForCausalLM.from_pretrained("./my-fine-tuned-llama") ``` From 7e54212c671ab0e78d62cb1b939fb03fa6e481fc Mon Sep 17 00:00:00 2001 From: Maanu Grover <109391026+maanug-nv@users.noreply.github.com> Date: Tue, 5 Aug 2025 13:21:28 -0700 Subject: [PATCH 2/2] update doc title Signed-off-by: Maanu Grover <109391026+maanug-nv@users.noreply.github.com> --- docs/bridge-guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/bridge-guide.md b/docs/bridge-guide.md index 28abd8bca7..a5c74e0722 100644 --- a/docs/bridge-guide.md +++ b/docs/bridge-guide.md @@ -1,4 +1,4 @@ -# Megatron <-> 🤗Hugging Face Bridge User Guide +# Bridge with 🤗Hugging Face Megatron Bridge provides seamless bidirectional conversion between 🤗Hugging Face Transformers and Megatron Core model formats. This guide covers the main APIs for loading models, checking compatibility, and converting between formats.