Skip to content

Conversation

@danbev
Copy link
Member

@danbev danbev commented Sep 10, 2025

This commit fixes the zero padding for odd dimensions in ggml_compute_forward_timestep_embedding_f32.
The motivation for this is that currently if an odd dimension is used, the padding check incorrectly uses the dimension value for indexing. For example, with dim=15:

Elements 0-6 are set to cosine values
Elements 7-13 are set to sine values
Element 14 is left uninitialized (contains garbage)
Element 15 is correctly set to zero

This fix changes embed_data[dim] to embed_data[2 * half] so that element 14 (the first unused element) is properly set to zero as well as the last element.

Resolves: ggml-org/ggml#1324

This commit fixes the zero padding for odd dimensions in
ggml_compute_forward_timestep_embedding_f32.
The motivation for this is that currently if an odd dimension is used,
the padding check incorrectly uses the dimension value for indexing.
For example, with dim=15:

Elements 0-6 are set to cosine values
Elements 7-13 are set to sine values
Element 14 is left uninitialized (contains garbage)
Element 15 is correctly set to zero

This fix changes embed_data[dim] to embed_data[2 * half] so that
element 14 (the first unused element) is properly set to zero as well
as the last element.

Resolves: ggml-org/ggml#1324
@github-actions github-actions bot added the ggml changes relating to the ggml tensor library for machine learning label Sep 10, 2025
@danbev danbev merged commit 9de447d into ggml-org:master Sep 10, 2025
48 checks passed
njsyw1997 pushed a commit to aizip/llama.cpp that referenced this pull request Sep 10, 2025
This commit fixes the zero padding for odd dimensions in
ggml_compute_forward_timestep_embedding_f32.
The motivation for this is that currently if an odd dimension is used,
the padding check incorrectly uses the dimension value for indexing.
For example, with dim=15:

Elements 0-6 are set to cosine values
Elements 7-13 are set to sine values
Element 14 is left uninitialized (contains garbage)
Element 15 is correctly set to zero

This fix changes embed_data[dim] to embed_data[2 * half] so that
element 14 (the first unused element) is properly set to zero as well
as the last element.

Resolves: ggml-org/ggml#1324
danbev added a commit to danbev/llama.cpp that referenced this pull request Sep 11, 2025
This commit fixes the zero padding for odd dimensions in
the timestep embedding kernel similar to the fix that was applied to the
cpu backend in Commit 9de447d
("ggml-cpu : fix padding in ggml_timestep_embedding (ggml-org#15917)").

The motivation for this is that currently if an odd dimension is used,
the padding check incorrectly uses the dimension value for indexing.

For example, with dim=15:
Elements 0-6 are set to cosine values
Elements 7-13 are set to sine values
Element 14 is left uninitialized (contains garbage)
Element 15 is correctly set to zero

This fix changes embed_data[dim] to embed_data[2 * half] so that
element 14 (the first unused element) is properly set to zero as well
as the last element.
danbev added a commit to danbev/llama.cpp that referenced this pull request Sep 11, 2025
This commit fixes the zero padding for odd dimensions in
the timestep embedding kernel similar to the fix that was applied to the
cpu backend in Commit 9de447d
("ggml-cpu : fix padding in ggml_timestep_embedding (ggml-org#15917)").

The motivation for this is that currently if an odd dimension is used,
the padding check incorrectly uses the dimension value for indexing.

For example, with dim=15:
Elements 0-6 are set to cosine values
Elements 7-13 are set to sine values
Element 14 is left uninitialized (contains garbage)
Element 15 is correctly set to zero

This fix changes embed_data[dim] to embed_data[2 * half] so that
element 14 (the first unused element) is properly set to zero as well
as the last element.
danbev added a commit to danbev/llama.cpp that referenced this pull request Sep 11, 2025
This commit fixes the zero padding for odd dimensions in
the timestep embedding kernel similar to the fix that was applied to the
cpu backend in Commit 9de447d
("ggml-cpu : fix padding in ggml_timestep_embedding (ggml-org#15917)").

The motivation for this is that currently if an odd dimension is used,
the padding check incorrectly uses the dimension value for indexing.

For example, with dim=15:
Elements 0-6 are set to cosine values
Elements 7-13 are set to sine values
Element 14 is left uninitialized (contains garbage)
Element 15 is correctly set to zero

This fix changes embed_data[dim] to embed_data[2 * half] so that
element 14 (the first unused element) is properly set to zero as well
as the last element.
danbev added a commit to danbev/llama.cpp that referenced this pull request Sep 11, 2025
This commit fixes the zero padding for odd dimensions in
the timestep embedding kernel similar to the fix that was applied to the
cpu backend in Commit 9de447d
("ggml-cpu : fix padding in ggml_timestep_embedding (ggml-org#15917)").

The motivation for this is that currently if an odd dimension is used,
the padding check incorrectly uses the dimension value for indexing.

For example, with dim=15:
Elements 0-6 are set to cosine values
Elements 7-13 are set to sine values
Element 14 is left uninitialized (contains garbage)
Element 15 is correctly set to zero

This fix changes embed_data[dim] to embed_data[2 * half] so that
element 14 (the first unused element) is properly set to zero as well
as the last element.
danbev added a commit to danbev/llama.cpp that referenced this pull request Sep 11, 2025
This commit fixes the zero padding for odd dimensions in
the timestep embedding kernel similar to the fix that was applied to the
cpu backend in Commit 9de447d
("ggml-cpu : fix padding in ggml_timestep_embedding (ggml-org#15917)").

The motivation for this is that currently if an odd dimension is used,
the padding check incorrectly uses the dimension value for indexing.

For example, with dim=15:
Elements 0-6 are set to cosine values
Elements 7-13 are set to sine values
Element 14 is left uninitialized (contains garbage)
Element 15 is correctly set to zero

This fix changes embed_data[dim] to embed_data[2 * half] so that
element 14 (the first unused element) is properly set to zero as well
as the last element.
danbev added a commit to danbev/llama.cpp that referenced this pull request Sep 16, 2025
This commit fixes the zero padding for odd dimensions in
the timestep embedding kernel similar to the fix that was applied to the
cpu backend in Commit 9de447d
("ggml-cpu : fix padding in ggml_timestep_embedding (ggml-org#15917)").

The motivation for this is that currently if an odd dimension is used,
the padding check incorrectly uses the dimension value for indexing.

For example, with dim=15:
Elements 0-6 are set to cosine values
Elements 7-13 are set to sine values
Element 14 is left uninitialized (contains garbage)
Element 15 is correctly set to zero

This fix changes embed_data[dim] to embed_data[2 * half] so that
element 14 (the first unused element) is properly set to zero as well
as the last element.
danbev added a commit to danbev/llama.cpp that referenced this pull request Sep 16, 2025
This commit fixes the zero padding for odd dimensions in
the timestep embedding kernel similar to the fix that was applied to the
cpu backend in Commit 9de447d
("ggml-cpu : fix padding in ggml_timestep_embedding (ggml-org#15917)").

The motivation for this is that currently if an odd dimension is used,
the padding check incorrectly uses the dimension value for indexing.

For example, with dim=15:
Elements 0-6 are set to cosine values
Elements 7-13 are set to sine values
Element 14 is left uninitialized (contains garbage)
Element 15 is correctly set to zero

This fix changes embed_data[dim] to embed_data[2 * half] so that
element 14 (the first unused element) is properly set to zero as well
as the last element.
danbev added a commit to danbev/llama.cpp that referenced this pull request Sep 16, 2025
This commit fixes the zero padding for odd dimensions in
the timestep embedding kernel similar to the fix that was applied to the
cpu backend in Commit 9de447d
("ggml-cpu : fix padding in ggml_timestep_embedding (ggml-org#15917)").

The motivation for this is that currently if an odd dimension is used,
the padding check incorrectly uses the dimension value for indexing.

For example, with dim=15:
Elements 0-6 are set to cosine values
Elements 7-13 are set to sine values
Element 14 is left uninitialized (contains garbage)
Element 15 is correctly set to zero

This fix changes embed_data[dim] to embed_data[2 * half] so that
element 14 (the first unused element) is properly set to zero as well
as the last element.
danbev added a commit to danbev/llama.cpp that referenced this pull request Sep 16, 2025
This commit fixes the zero padding for odd dimensions in
the timestep embedding kernel similar to the fix that was applied to the
cpu backend in Commit 9de447d
("ggml-cpu : fix padding in ggml_timestep_embedding (ggml-org#15917)").

The motivation for this is that currently if an odd dimension is used,
the padding check incorrectly uses the dimension value for indexing.

For example, with dim=15:
Elements 0-6 are set to cosine values
Elements 7-13 are set to sine values
Element 14 is left uninitialized (contains garbage)
Element 15 is correctly set to zero

This fix changes embed_data[dim] to embed_data[2 * half] so that
element 14 (the first unused element) is properly set to zero as well
as the last element.
danbev added a commit to danbev/llama.cpp that referenced this pull request Sep 16, 2025
This commit fixes the zero padding for odd dimensions in
the timestep embedding kernel similar to the fix that was applied to the
cpu backend in Commit 9de447d
("ggml-cpu : fix padding in ggml_timestep_embedding (ggml-org#15917)").

The motivation for this is that currently if an odd dimension is used,
the padding check incorrectly uses the dimension value for indexing.

For example, with dim=15:
Elements 0-6 are set to cosine values
Elements 7-13 are set to sine values
Element 14 is left uninitialized (contains garbage)
Element 15 is correctly set to zero

This fix changes embed_data[dim] to embed_data[2 * half] so that
element 14 (the first unused element) is properly set to zero as well
as the last element.
@danbev danbev deleted the ggml-timestep-embedding-padding branch September 24, 2025 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ggml changes relating to the ggml tensor library for machine learning

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: test-timestep_embedding fails on MSYS2/Windows

2 participants