Skip to content

perf(sampling): bound top-logprob candidate storage by requested count - #183

Open
Afloat16 wants to merge 1 commit into
Edge0-AI:mainfrom
Afloat16:afloat/20261111-next-bounded-logprob-candidates
Open

Afloat16 wants to merge 1 commit into
Edge0-AI:mainfrom
Afloat16:afloat/20261111-next-bounded-logprob-candidates

Conversation

@Afloat16

Copy link
Copy Markdown

What & why

Small top-logprob requests allocated a token-index vector for the entire vocabulary on every call, even for count=0.

Keep at most the requested candidates in a heap and allocate none for zero. Preserve descending-logit/ascending-token ties, log-sum-exp and the selected token logprob.

Area

Engine, CLI or server (edge0-infer/).

How was it tested?

moe_test_sampling_rules

The target, sampling oracle and RNG checks pass. A 262144-token regression compares candidates with a full ordering. Largest measured allocations for counts 0/1/20 are 0/48/960 bytes; main allocates 1048576 bytes even for zero and fails the bound. This measures allocation, not end-to-end generation throughput.

All 14 L0 checks passed in a local integration with the other focused fixes. git diff --check passed.

Local C++ environment: Linux x86_64, GCC 14.2, CPU preset. Targeted builds downgrade pre-existing ignored-attributes, dangling-reference, range-loop-construct and misleading-indentation warnings (plus maybe-uninitialized in the existing diagnostics source); these accommodations are not source changes. The all-target build is blocked by existing assets_test.cpp use of std::count_if without . A clean full L0/L1 result, GPU tests and model-asset execution are not claimed.

Checklist

  • Full ctest --preset cpu -L "L0|L1" passes locally
  • Added/updated focused regressions and ran the affected target
  • No public interface/configuration change requiring additional documentation

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.

1 participant