Skip to content
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

Minicpm enabling #1342

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Conversation

pi314ever
Copy link
Contributor

What does this PR do?

Enables MiniCPM3 model for Causal LM. Follows #1133 in optimizing remote code. The following changes were added:

  • htcore.mark_step() between each decoder layer to reduce graph size
  • Add token_idx support passthrough to Attention implementations. (Currently incomplete, missing reset of cache)

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

@pi314ever
Copy link
Contributor Author

pi314ever commented Sep 20, 2024

Performance benchmark
Command:

python run_generation.py --model_name_or_path openbmb/MiniCPM3-4B  --max_new_tokens 512 --prompt "推荐5个北京的景点。" --batch_size 1 --temperature 0.7 --do_sample --top_p 0.7 --use_kv_cache --use_chat_template --use_hpu_graphs [--bf16] 
throughput (tokens/s) A100 Gaudi 2 (Graph mode)
BF 16 20.09 65.16
FP 32 23.89 44.46

# See the License for the specific language governing permissions and
# limitations under the License.
"""
MiniCPM model configuration. Copied from https://huggingface.co/openbmb/MiniCPM3-4B/tree/6fcf8b4e629d01a435b96e898899e0b6d9bddb7a
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you list what the change in each section?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The files with "Copied from..." did not have any changes, while the files with "Adapted from..." have changes. In modeling_minicpm.py, I added docstrings for each method that I changed with what I modified. Is this sufficient? Or should I add a generic summary on the file docstring as well?

@yao-matrix
Copy link

yao-matrix commented Nov 15, 2024

@pi314ever , you need to add jsonschema and datamodel_code_generator into requirements. Or remove custom tokenizer since the model owner already switch back to Llama tokenizer, as here https://huggingface.co/openbmb/MiniCPM3-4B/commit/e8a65f63cd4e4eff91571e603a2a34e50628ff67#d2h-846292

Signed-off-by: Daniel Huang <[email protected]>
@pi314ever
Copy link
Contributor Author

pi314ever commented Nov 15, 2024

@yao-matrix I have removed the tokenizer and validated it to run with default requirements.txt. There are no performance differences from basic testing.

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.

3 participants