Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
32 lines
1.6 KiB
Rust
32 lines
1.6 KiB
Rust
//! CPU reference of the Original Strata sampler (`engine/strata`), in safe Rust.
|
|
//!
|
|
//! This crate is a *literal transcription* of the Original host/device sampler
|
|
//! logic, not a re-design:
|
|
//!
|
|
//! * [`philox`] - the counter-based uniform draw (`philox_uniform` in `sampler.cu`).
|
|
//! * [`chain`] - penalties -> top_k -> top_p -> min_p -> temperature -> inverse-CDF
|
|
//! pick (`sampler_kernel`, `sampled_tail_warp`, `sampler_greedy_kernel`).
|
|
//! * [`coupled`] - coupled-draft counter/ring arithmetic (`coupled_draft.hpp`),
|
|
//! `penalty_rows` (`sampler.hpp`), the draft-side sampling with its
|
|
//! probability output, and the exact-match acceptance rule.
|
|
//! * [`serve`] - the serve loop's per-request sampling plumbing (window staging, draft history, acceptance).
|
|
//! * [`params`] - request-level sampling parameters: validation, the Original's
|
|
//! defaults, and the `GEN` wire keys (`serve/server.py` `sampling_keys`).
|
|
//!
|
|
//! Float-ordering assumptions are documented on the functions that depend on
|
|
//! them. Everything integer/RNG (Philox, counters, list ordering, tie-breaks,
|
|
//! window layout) is bit-exact against the Original by construction and by the
|
|
//! committed oracle fixtures; the `f64::exp` / `f32::ln` calls use the platform
|
|
//! libm exactly as the Original host reference does (see `docs/sampler-reference.md`).
|
|
//!
|
|
//! Nothing here claims a speed or model-quality result.
|
|
|
|
pub mod chain;
|
|
pub mod coupled;
|
|
pub mod params;
|
|
pub mod philox;
|
|
pub mod serve;
|
|
|
|
pub use chain::{SamplerError, SamplerParams, sample_tokens};
|
|
pub use params::{FixedPoint, RequestSampling, SamplingError, SamplingParams};
|