interplane.Get Omega
Read in your language

aien-sovereign-core-mv

AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.

Brought by drakestapleton

perf(own30b): replace full-vocabulary top-K sort in HTTP sampler

Closed · #623 · open 2026-10-17 11:37 UTC · closed 2026-10-22 12:38 UTC (reason completed)

Imported from GitHub aien-dev/aien-sovereign-core-mv#623, by drakestapleton

drakestapleton wrote on 2026-10-17 11:37 UTC

Priority: P1 — quick CPU-path improvement
Agent ownership: crates/aien-serve-http/src/sampling.rs and sampling-specific tests/benchmark only
Estimated engineering effort: a few hours, plus benchmark time

Goal

Remove unnecessary full-vocabulary sorting from OWN-30B HTTP sampling without changing any token decisions or sampling receipts.

Observed on main (rechecked 2026-10-17)

  • crates/aien-serve-http/src/sampling.rs::top_k_mask builds an index vector for the entire logits array, sorts it, and retains only K entries.
  • SamplingObserver::sample uses this for 0 < top_k < vocab with non-greedy temperature; ServerConfig defaults to top_k=20.
  • Vocabulary is ~152k logits. This is unnecessary CPU work; no end-to-end throughput gain has been measured.

Agent implementation

  1. Keep a test-only reference version of the current full-sort behavior.
  2. Replace the production full sort with exact top-K partial selection (bounded heap or select_nth_unstable_by, sorting K winners only when needed).
  3. Preserve rank semantics for finite logits (higher value first, lower token ID on exact ties); excluded logits remain negative infinity.
  4. Preserve greedy sampling, top_k=0, k>=vocab, seed/top-p behavior; explicitly test infinities, NaNs, ties at the cutoff and all-equal vectors. Do not silently change nonfinite semantics.
  5. Introduce a narrowly scoped sampler microbenchmark without a dependency or HTTP server rewrite.

Acceptance criteria

  • Optimized and reference masks agree for deterministic random finite vectors and K = 0, 1, 20, 100, vocab-1, vocab; include negative values and ties.
  • Selected token IDs, seeded replay and all SamplingRecord fields match before/after (kept-set metrics, probability/logprob metrics, etc.).
  • Nonfinite-value behavior is regression-tested and any comparator ambiguity documented.
  • cargo test --locked -p aien-serve-http passes; cargo clippy --locked -p aien-serve-http --all-targets -- -D warnings clean, or blockers explained.
  • Include reproducible before/after CPU microbenchmarks at ~152k vocab and K=1,20,100 with same host/compiler/profile, medians and spread.
  • If idle GB10 available, matched HTTP A/B measures real service throughput; do not claim tokens/sec gain based solely on microbenchmarks.
  • Small independent PR with rollback path, no unrelated changes.

Coordination / excluded scope

Can start immediately. Do not edit omega_engine.rs, server.rs, qwen3_moe_omega.rs, decode graph or GPU-lock scripts. Existing PR #595 touches HTTP server internals.

Source: https://github.com/aien-dev/aien-sovereign-core-mv/blob/main/crates/aien-serve-http/src/sampling.rs

No comments.

Sign in to comment