Skip to content

fix temperature flag so it takes effect - #981

Merged
copybara-service[bot] merged 3 commits into
google:devfrom
RaviTriv:fix-softmax-temperature
Aug 21, 2026
Merged

fix temperature flag so it takes effect#981
copybara-service[bot] merged 3 commits into
google:devfrom
RaviTriv:fix-softmax-temperature

Conversation

@RaviTriv

@RaviTriv RaviTriv commented Aug 16, 2026

Copy link
Copy Markdown

Currently the temperature flag is not taking effect since its applied to the exponentiated logits and cancels against the normalization. Updating to divide the logits by temperature before exp so it affects the output.

Current

Temperature 0
image

Temperature 2
image

Updated

Temperature 0
image

Temperature 2
image

image

@RaviTriv
RaviTriv force-pushed the fix-softmax-temperature branch from 47d498d to ff1572b Compare August 16, 2026 17:02
@RaviTriv
RaviTriv marked this pull request as ready for review August 18, 2026 01:35
@RaviTriv RaviTriv changed the title divide logits by temperature before exp fix temperature flag so it takes effect Aug 19, 2026

@jan-wassenberg jan-wassenberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for fixing. We generally run with deterministic mode because our sampler is very basic, but good to fix this. One nit:

Comment thread ops/ops-inl.h Outdated
const SMOptions& sm_options = {}) {
GCPP_ZONE(ctx, worker, Zones::kOpsSoftmax);
HWY_DASSERT(logits.size() != 0);
HWY_ASSERT(temperature >= 0.0f);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This runs quite often, so prefer HWY_DASSERT.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

good catch

@jan-wassenberg jan-wassenberg added the copybara-import Trigger Copybara for merging pull requests label Aug 21, 2026
@copybara-service
copybara-service Bot merged commit 4b2ef2e into google:dev Aug 21, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

copybara-import Trigger Copybara for merging pull requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants