-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update NeuralChat README/Tutorial/Jupyter Notebook documents (#243)
- Loading branch information
Showing
10 changed files
with
1,466 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ on: | |
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
286 changes: 82 additions & 204 deletions
286
intel_extension_for_transformers/neural_chat/README.md
Large diffs are not rendered by default.
Oops, something went wrong.
80 changes: 80 additions & 0 deletions
80
...ral_chat/docker/inference/0001-fix-lm-head-overriden-issue-move-it-from-checkpoint-.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
From d89a5eeb2884d3f392f8b49b5b959f2f3a5a9a1e Mon Sep 17 00:00:00 2001 | ||
From: "Wang, Yi A" <yi.a.wang@intel.com> | ||
Date: Thu, 31 Aug 2023 07:09:03 +0530 | ||
Subject: [PATCH] fix lm head overriden issue, move it from checkpoint in-loop | ||
loading to out loop | ||
|
||
Signed-off-by: Wang, Yi A <yi.a.wang@intel.com> | ||
--- | ||
deepspeed/module_inject/load_checkpoint.py | 7 ------- | ||
deepspeed/module_inject/replace_module.py | 22 ++++++++++++++-------- | ||
2 files changed, 14 insertions(+), 15 deletions(-) | ||
|
||
diff --git a/deepspeed/module_inject/load_checkpoint.py b/deepspeed/module_inject/load_checkpoint.py | ||
index 5c2835f..3b225c6 100644 | ||
--- a/deepspeed/module_inject/load_checkpoint.py | ||
+++ b/deepspeed/module_inject/load_checkpoint.py | ||
@@ -255,13 +255,6 @@ def load_model_with_checkpoint(r_module, | ||
|
||
load_module_recursive(r_module) | ||
|
||
- embedding_weight = None | ||
- | ||
- for n, p in r_module.named_parameters(): | ||
- if "word_embeddings." in n or "embed_tokens." in n or "wte." in n: | ||
- embedding_weight = p | ||
- if embedding_weight is not None and r_module.lm_head.weight.is_meta: | ||
- r_module.lm_head.weight = embedding_weight | ||
for sd_ in sd: | ||
del sd_ | ||
sd = None | ||
diff --git a/deepspeed/module_inject/replace_module.py b/deepspeed/module_inject/replace_module.py | ||
index 7844d2f..316c2c6 100644 | ||
--- a/deepspeed/module_inject/replace_module.py | ||
+++ b/deepspeed/module_inject/replace_module.py | ||
@@ -548,6 +548,13 @@ def replace_transformer_layer(orig_layer_impl, model, checkpoint_dict, config, m | ||
checkpoint=checkpoint[i]) | ||
pbar.update(1) | ||
gc.collect() | ||
+ embedding_weight = None | ||
+ for n, p in replaced_module.named_parameters(): | ||
+ if "word_embeddings." in n or "embed_tokens." in n or "wte." in n: | ||
+ embedding_weight = p | ||
+ if embedding_weight is not None and hasattr(replaced_module, "lm_head") and hasattr( | ||
+ replaced_module.lm_head, "weight") and replaced_module.lm_head.weight.is_meta: | ||
+ replaced_module.lm_head.weight = embedding_weight | ||
else: | ||
replaced_module = replace_module(model=model, | ||
orig_class=orig_layer_impl, | ||
@@ -626,6 +633,13 @@ def replace_transformer_layer(orig_layer_impl, model, checkpoint_dict, config, m | ||
container=container_g) | ||
sds = [None for _ in sds] | ||
gc.collect() | ||
+ embedding_weight = None | ||
+ for n, p in replaced_module.named_parameters(): | ||
+ if "word_embeddings." in n or "embed_tokens." in n or "wte." in n: | ||
+ embedding_weight = p | ||
+ if embedding_weight is not None and hasattr(replaced_module, "lm_head") and hasattr( | ||
+ replaced_module.lm_head, "weight") and replaced_module.lm_head.weight.is_meta: | ||
+ replaced_module.lm_head.weight = embedding_weight | ||
print(f"checkpoint loading time at rank {rank}: {time.time()-start_time} sec") | ||
|
||
if config.save_mp_checkpoint_path is not None: | ||
@@ -794,14 +808,6 @@ def replace_module(model, orig_class, replace_fn, _replace_policy, checkpoint=No | ||
"You can find some samples here: https://github.com/microsoft/DeepSpeed/blob/master/deepspeed/module_inject/replace_policy.py" | ||
|
||
replaced_module, _ = _replace_module(model, policy, state_dict=sd) | ||
- if checkpoint != None: | ||
- embedding_weight = None | ||
- for n, p in replaced_module.named_parameters(): | ||
- if "word_embeddings." in n or "embed_tokens." in n or "wte." in n: | ||
- embedding_weight = p | ||
- if embedding_weight is not None and hasattr(replaced_module, "lm_head") and hasattr( | ||
- replaced_module.lm_head, "weight") and replaced_module.lm_head.weight.is_meta: | ||
- replaced_module.lm_head.weight = embedding_weight | ||
return replaced_module | ||
|
||
|
||
-- | ||
2.39.3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.