Skip to main content

Request

Struct Request 

Source
pub struct Request {
Show 19 fields pub request_id: String, pub priority: i32, pub arrival_time: f64, pub status: RequestStatus, pub num_prompt_tokens: u32, pub max_output_tokens: u32, pub target_output_tokens: u32, pub num_computed_tokens: u32, pub num_output_tokens: u32, pub num_tokens: u32, pub num_cached_tokens: u32, pub prompt_block_hashes: Vec<u64>, pub kv_blocks: Vec<BlockId>, pub num_preemptions: u32, pub first_token_time: Option<f64>, pub completion_time: Option<f64>, pub token_generation_times: Vec<f64>, pub preempted_time: f64, pub last_preempted_at: Option<f64>,
}
Expand description

Request represents a single inference request in the simulation

Fields§

§request_id: String

Unique request ID

§priority: i32

Client priority (lower = higher priority)

§arrival_time: f64

Arrival time (simulated time)

§status: RequestStatus

Request status

§num_prompt_tokens: u32

Number of input tokens

§max_output_tokens: u32

Maximum number of output tokens to generate

§target_output_tokens: u32

Actual number of output tokens to generate (sampled, may be less than max) This simulates hitting an EOS token

§num_computed_tokens: u32

Number of tokens computed so far

§num_output_tokens: u32

Number of output tokens generated so far

§num_tokens: u32

Total tokens (prompt + output)

§num_cached_tokens: u32

Number of prefix-cached tokens (set by cache manager)

§prompt_block_hashes: Vec<u64>

Synthetic block hashes for prefix caching modeling In synthetic mode: pre-generated hashes (some shared, some unique) In semantic mode: will be computed from actual token content

§kv_blocks: Vec<BlockId>

KV cache blocks allocated to this request

§num_preemptions: u32

Number of times this request has been preempted

§first_token_time: Option<f64>

Time when first token was generated (TTFT tracking)

§completion_time: Option<f64>

Time when request completed

§token_generation_times: Vec<f64>

Per-token generation times

§preempted_time: f64

Time spent preempted (not running)

§last_preempted_at: Option<f64>

Last preemption start time

Implementations§

Source§

impl Request

Source

pub fn new_with_target( request_id: String, priority: i32, arrival_time: f64, num_prompt_tokens: u32, max_output_tokens: u32, target_output_tokens: u32, ) -> Self

Create a new request with a target output length

Source

pub fn new( request_id: String, priority: i32, arrival_time: f64, num_prompt_tokens: u32, max_output_tokens: u32, ) -> Self

Create a new request (target = max)

Source

pub fn get_prompt_block_hashes(&self) -> &[u64]

Get block hashes for the prompt These should be thought of as ‘incremental hashes’ - i.e. the hash of block n is the hash of all the tokens up to that block (not just that block alone). In synthetic mode: returns pre-generated hashes In semantic mode: will compute from actual token content

Source

pub fn is_prefill(&self) -> bool

Check if this is in prefill phase

Source

pub fn tokens_to_process(&self) -> u32

Get number of tokens needed to process

Source

pub fn is_finished(&self) -> bool

Check if request is done

Source

pub fn total_tokens(&self) -> u32

Get total tokens (prompt + max output)

Source

pub fn remaining_tokens(&self) -> u32

Get remaining tokens to process

Source

pub fn kv_cache_size(&self, model: &ModelConfig) -> u64

Calculate KV cache requirement for this request

Source

pub fn record_generated_tokens( &mut self, num_new_tokens: u32, current_time: f64, )

Record that tokens were generated (update output token count and total)

Source

pub fn mark_preempted(&mut self, current_time: f64)

Mark request as preempted

Source

pub fn resume(&mut self, current_time: f64)

Resume a preempted request

Trait Implementations§

Source§

impl Clone for Request

Source§

fn clone(&self) -> Request

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Request

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V