| 1 | package Langertha::Runtime::Knobs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Immutable self-hosted runtime knobs with per-server conversion | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 39 | our $VERSION = '0.505'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 39 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 39 | ▶ | use Carp qw( croak ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 39 | ▶ | use JSON::MaybeXS qw( JSON ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 39 | has prefix_cache_salt => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | predicate => 'has_prefix_cache_salt', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 39 | has cache_prompt => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | isa => 'Bool', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | predicate => 'has_cache_prompt', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 39 | has n_cache_reuse => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | isa => 'Int', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | predicate => 'has_n_cache_reuse', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 39 | has id_slot => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | isa => 'Int', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | predicate => 'has_id_slot', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 39 | has priority => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | isa => 'Int', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | predicate => 'has_priority', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 39 | has return_cached_tokens_details => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | isa => 'Bool', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | predicate => 'has_return_cached_tokens_details', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 39 | has extra_key => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | isa => 'Str', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | predicate => 'has_extra_key', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 6 | ▶ | sub to_vllm { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_vllm: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 6 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 6 | ▶ | return () unless $self->has_prefix_cache_salt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 4 | return ( cache_salt => $self->prefix_cache_salt ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 4 | ▶ | sub to_sglang { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_sglang: called CC=10 SCAR=26.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 4 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 4 | ▶ | return () unless $self->has_prefix_cache_salt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
$self->has_prefix_cache_salt or $self->has_extra_key or $self->has_priority or $self->has_return_cached_tokens_details
$self->has_prefix_cache_salt or $self->has_extra_key or $self->has_priority
$self->has_prefix_cache_salt or $self->has_extra_key
MC/DC25%1/4
$self->has_prefix_cache_salt or $self->has_extra_key or $self->has_priority or $self->has_return_cached_tokens_details
$self->has_prefix_cache_salt
$self->has_extra_key
$self->has_priority
$self->has_return_cached_tokens_details
Truth table40%2/5
A or B or C or D
A= $self->has_prefix_cache_saltB= $self->has_extra_keyC= $self->has_priorityD= $self->has_return_cached_tokens_details
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | || $self->has_extra_key | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | || $self->has_priority | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | || $self->has_return_cached_tokens_details; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 2 | ▶ | ( $self->has_prefix_cache_salt ? ( cache_salt => $self->prefix_cache_salt ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | ( $self->has_extra_key ? ( extra_key => $self->extra_key ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | ( $self->has_priority ? ( priority => $self->priority ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | ( $self->has_return_cached_tokens_details | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | ? ( return_cached_tokens_details => $self->return_cached_tokens_details ? JSON->true : JSON->false ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 4 | ▶ | sub to_llamacpp { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_llamacpp: called CC=8 SCAR=22.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 4 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 4 | ▶ | return () unless $self->has_cache_prompt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$self->has_cache_prompt or $self->has_n_cache_reuse or $self->has_id_slot
$self->has_cache_prompt or $self->has_n_cache_reuse
MC/DC33%1/3
$self->has_cache_prompt or $self->has_n_cache_reuse or $self->has_id_slot
$self->has_cache_prompt
$self->has_n_cache_reuse
$self->has_id_slot
Truth table50%2/4
A or B or C
A= $self->has_cache_promptB= $self->has_n_cache_reuseC= $self->has_id_slot
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | || $self->has_n_cache_reuse | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | || $self->has_id_slot; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 2 | ▶ | ( $self->has_cache_prompt ? ( cache_prompt => $self->cache_prompt ? JSON->true : JSON->false ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | ( $self->has_n_cache_reuse ? ( n_cache_reuse => $self->n_cache_reuse ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | ( $self->has_id_slot ? ( id_slot => $self->id_slot ) : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | # Maps a knob_wire_format tag to the per-format serializer method. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 39 | my %TO_METHOD = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | vllm => 'to_vllm', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | sglang => 'to_sglang', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | llamacpp => 'to_llamacpp', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 15 | ▶ | sub to { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to: called CC=4 SCAR=14.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 15 | my ( $self, $fmt ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 15 | ▶ | my $method = $TO_METHOD{ $fmt // '' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%2/4
$fmt // ""
$fmt // ""
MC/DC0%0/1
$fmt // ""
$fmt
MC/DC0%0/1
$fmt // ""
$fmt
Truth table50%1/2
A
A= $fmt
Truth table50%1/2
A
A= $fmt
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | or croak "Langertha::Runtime::Knobs: unknown knob wire format '" . ( $fmt // '' ) . "'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 14 | return $self->$method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 39 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 39 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||