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

add solar pro support #9541

Closed
wants to merge 1 commit into from
Closed

add solar pro support #9541

wants to merge 1 commit into from

Conversation

mxyng
Copy link

@mxyng mxyng commented Sep 18, 2024

solar pro introduces block skip connections where blocks are connected to other, non-sequential blocks with a scale multiple

this change adds 4 new keys to store the skip connections and one new tensor to store the scalar. the scalar is implemented as a 1-dimensional tensor with 2 elements derived from the model's bskcn_tv configuration. in general, the values are (bskcn_tv, 1 - bskcn_tv)

solar pro introduces block skip connections where blocks are connected
to other, non-sequential blocks with a scale multiple

this change adds 4 new keys to store the skip connections and one new
tensor to store the scalar. the scalar is implemented a 1-dimensional
tensor with 2 elements dervied from the model's bskcn_tv configuration.
in general, the values are (bskcn_tv, 1 - bskcn_tv)
@github-actions github-actions bot added the python python script changes label Sep 18, 2024
@@ -2538,6 +2565,14 @@ struct llama_hparams {
return ssm_d_state * ssm_d_inner;
}
}

bool n_bskcn(uint32_t n, uint32_t il = 0) const {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The n_ prefix implies that this returns an integer, however it returns a boolean.

@SteelPh0enix
Copy link

is this PR active and maintained?
it'd be nice to see this merged

Copy link

@vignesh1507 vignesh1507 left a comment

Choose a reason for hiding this comment

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

I agree with the changes.

Comment on lines +4094 to +4099
def prepare_tensors(self):
if bskcn_tv := self.find_hparam(['bskcn_tv'], optional=True):
# use bskcn_tv[1] for inference since bskcn_tv[0] is for training
self.gguf_writer.add_tensor(self.format_tensor_name(gguf.MODEL_TENSOR.BSKCN_TV), np.array([bskcn_tv[1], 1 - bskcn_tv[1]], dtype=np.float32))

super().prepare_tensors()
Copy link
Collaborator

@compilade compilade Oct 6, 2024

Choose a reason for hiding this comment

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

I think this should override generate_extra_tensors instead of prepare_tensors. Otherwise LoRA conversion will not work properly, at least since #9396.

if (hparams.n_bskcn(2, il)) {
inpSA = ggml_add(
ctx0,
ggml_mul(ctx0, bskcn_1, ggml_view_1d(ctx0, model.layers[il].bskcn_tv, 1, 0)),
Copy link
Collaborator

Choose a reason for hiding this comment

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

bskcn_1 is not necessarily initialized here, because a model file could be crafted to make hparams.n_bskcn(2, il) return true while making hparams.n_bskcn(1, il) always return false.

Comment on lines +4089 to +4092
for i, bskcn in enumerate(self.hparams[k] for k in self.hparams.keys() if k.startswith("bskcn_") and k != 'bskcn_tv'):
# store the skip connections as a layer index where a non-zero value indicates a skip connection
# this approach simplifies lookup at inference time
self.gguf_writer.add_block_skip_connection(i, [1 if n in bskcn else 0 for n in range(self.block_count)])
Copy link
Collaborator

Choose a reason for hiding this comment

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

This assumes bskcn_{n} are in the correct order in config.json. Why not instead iterate them by their names?

@Nexesenex
Copy link
Contributor

@mxyng Is this PR still on?

@mxyng mxyng closed this by deleting the head repository Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python python script changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants