-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[fix]: fix moe.hpp load from file bug. #1780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -32,8 +32,6 @@ class AMX_MOE_TP : public AMX_MOE_BASE<T, AMX_MOE_TP<T>> { | |
| using Base::down_bc_; | ||
| using Base::m_local_num_; | ||
|
|
||
| std::filesystem::path prefix; | ||
|
|
||
| void* gate_proj_; // [expert_num * intermediate_size * hidden_size ( /32 if | ||
| // quantized)] | ||
| void* up_proj_; // [expert_num * intermediate_size * hidden_size ( /32 if | ||
|
|
@@ -144,7 +142,7 @@ class AMX_MOE_TP : public AMX_MOE_BASE<T, AMX_MOE_TP<T>> { | |
| auto& load = config_.load; | ||
| auto& save = config_.save; | ||
|
|
||
| prefix = config_.path; | ||
| std::filesystem::path prefix = config_.path; | ||
| prefix = prefix / ("_layer_" + std::to_string(config_.layer_idx)) / ("_numa_" + std::to_string(tp_part_idx)); | ||
| if (save) { | ||
| std::cout << "Creating " << prefix << std::endl; | ||
|
|
@@ -260,6 +258,9 @@ class AMX_MOE_TP : public AMX_MOE_BASE<T, AMX_MOE_TP<T>> { | |
| } else { | ||
| int nth = T::recommended_nth(config_.intermediate_size); | ||
| static uint8_t mat_type_all = 3, mat_split = 1; | ||
| std::filesystem::path prefix = config_.path; | ||
| prefix = prefix / ("_layer_" + std::to_string(config_.layer_idx)) / ("_numa_" + std::to_string(tp_part_idx)); | ||
|
|
||
| if (config_.load) { | ||
| std::cout << "Loading from " << prefix << std::endl; | ||
| for (int task_id = 0; task_id < config_.expert_num * mat_type_all * mat_split; task_id++) { | ||
|
|
@@ -335,7 +336,7 @@ class AMX_MOE_TP : public AMX_MOE_BASE<T, AMX_MOE_TP<T>> { | |
| if (config_.save) { | ||
| pool->do_work_stealing_job( | ||
| config_.expert_num * mat_type_all, nullptr, | ||
| [this, physical_to_logical_map](int task_id) { | ||
| [this, physical_to_logical_map, prefix](int task_id) { | ||
| int64_t expert_idx = task_id / mat_type_all; | ||
| expert_idx = expert_map(physical_to_logical_map, expert_idx); | ||
| uint8_t mat_class = task_id % mat_type_all; | ||
|
|
@@ -426,7 +427,7 @@ class TP_MOE<AMX_MOE_TP<K>> : public TP_MOE<AMX_MOE_BASE<K, AMX_MOE_TP<K>>> { | |
|
|
||
| this->weights_loaded = true; | ||
| } else if (config.path != "") { | ||
| printf("TP Load from file\n"); | ||
| printf("TP Load from file %s\n", config.path.c_str()); | ||
|
||
| DO_TPS_LOAD_WEIGHTS(pool); | ||
| this->weights_loaded = true; | ||
| } else { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic to construct the
prefixpath is duplicated from lines 145-146 within the same function. To improve maintainability and avoid redundancy, consider defining and initializing theprefixvariable once at the beginning of theload_weightsfunction, before theif (config_.quant_config.bits == 0)block.