Skip to content

Support Llama 3.2 1B instruct#319

Merged
minghuaw merged 4 commits intooxiglade:mainfrom
LYZJU2019:lyzju2019/support-llama
Mar 27, 2026
Merged

Support Llama 3.2 1B instruct#319
minghuaw merged 4 commits intooxiglade:mainfrom
LYZJU2019:lyzju2019/support-llama

Conversation

@LYZJU2019
Copy link
Copy Markdown
Contributor

@LYZJU2019 LYZJU2019 commented Feb 16, 2026

This PR attempts to support meta-llama/Llama-3.2-1B-Instruct

Reference implementation: https://github.com/ml-explore/mlx-examples/blob/main/llms/llama/llama.py

To test, run hf download meta-llama/Llama-3.2-1B-Instruct and the model folder should appear in ~/.cache/huggingface/hub/models--meta-llama--Llama-3.2-1B-Instruct/snapshots/<commit_hash>

@minghuaw minghuaw self-requested a review March 2, 2026 00:38
}
}

impl mlx_rs::module::ModuleParameters for Llama3Rope {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This can be derived

}
}

let freqs_array = Array::from_slice(&scaled_freqs, &[half_dims]);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Instead of converting to mlx array at the end, it might be better to start using mlx ops from the beginning

Llama3(Llama3Rope),
}

impl mlx_rs::module::ModuleParameters for RopeVariant {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

todo: support derive ModuleParameters for enum

@LYZJU2019 LYZJU2019 force-pushed the lyzju2019/support-llama branch from c591a5d to 6c4016c Compare March 2, 2026 01:31
// TODO: support derive ModuleParameters for enum
impl mlx_rs::module::ModuleParameters for RopeVariant {
fn num_parameters(&self) -> usize {
0
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It's better to just call the implementation of the variant like

match self {
    RopeVariant::Default(rope) => rope.num_parameters(),
    RopeVariant::Llama3(rope) => rope.num_parameters(),
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same thing for other functions in this trait

Copy link
Copy Markdown
Collaborator

@minghuaw minghuaw left a comment

Choose a reason for hiding this comment

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

Just a minor comment. Then it'll be ready to merge

@minghuaw minghuaw merged commit f4aa309 into oxiglade:main Mar 27, 2026
3 checks 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