pub struct ContextBucket {
pub task_kind: TaskKind,
pub prompt_bucket_coarse: u32,
}Expand description
The context bucket that keys the bandit’s per-arm statistics.
Coarsened to keep the arm count dense: prompt_bucket_coarse = prompt_token_bucket / 2
halves the bucket resolution (floor(log2(n)) → floor(log2(n)/2) in effect), trading
granularity for faster warm-up.
ponytail: the ladder identity is not part of the key — in practice a given (TaskKind, prompt size) routes to the same ladder via the first-match routing rule. Would need to be included if operators run overlapping routes for the same context.
Fields§
§task_kind: TaskKindCoarse task classification from the request feature vector.
prompt_bucket_coarse: u32features.prompt_token_bucket / 2 — halved for denser arms.
Implementations§
Source§impl ContextBucket
impl ContextBucket
Sourcepub fn from_features(f: &Features) -> Self
pub fn from_features(f: &Features) -> Self
Derive a context bucket from a request’s feature vector.
Sourcepub fn representative_prompt_tokens(&self) -> u64
pub fn representative_prompt_tokens(&self) -> u64
A representative prompt size for this bucket, in tokens.
features::token_bucket is floor(log2(n)) and this key halves it, so the bucket covers
[2^(2b), 2^(2b+2)). The geometric midpoint of that band is 2^(2b+1), which is the
least-wrong single number to stand in for it — and the ordering that matters
(bigger bucket ⇒ bigger estimate) is exactly preserved.
This exists because start-rung selection needs the request’s size, not just its shape. The raw count is deliberately never stored (privacy), but the band already is, and the band carries the signal.
Trait Implementations§
Source§impl Clone for ContextBucket
impl Clone for ContextBucket
Source§impl Debug for ContextBucket
impl Debug for ContextBucket
impl Eq for ContextBucket
Source§impl Hash for ContextBucket
impl Hash for ContextBucket
Source§impl PartialEq for ContextBucket
impl PartialEq for ContextBucket
impl StructuralPartialEq for ContextBucket
Auto Trait Implementations§
impl Freeze for ContextBucket
impl RefUnwindSafe for ContextBucket
impl Send for ContextBucket
impl Sync for ContextBucket
impl Unpin for ContextBucket
impl UnsafeUnpin for ContextBucket
impl UnwindSafe for ContextBucket
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more