MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / decoder_layer_with_static_cache_tail

Function decoder_layer_with_static_cache_tail

src/models/vevo2/ar.cpp:374–420  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

372 return token == tokenizer_eos;
373}
374
375void apply_repetition_penalty(
376 std::vector<float> & logits,
377 const std::vector<int32_t> & history,
378 float penalty,
379 SamplerScratch & scratch) {
380 if (penalty == 1.0F) {
381 return;
382 }
383 if (!(penalty > 0.0F)) {
384 throw std::runtime_error("Vevo2 AR repetition penalty must be positive");
385 }
386 if (scratch.seen_marks.size() < logits.size()) {
387 scratch.seen_marks.assign(logits.size(), 0);
388 scratch.seen_stamp = 1;
389 } else if (scratch.seen_stamp == std::numeric_limits<uint32_t>::max()) {
390 std::fill(scratch.seen_marks.begin(), scratch.seen_marks.end(), 0);
391 scratch.seen_stamp = 1;
392 }
393 const uint32_t stamp = scratch.seen_stamp++;
394 for (const int32_t token : history) {
395 if (token < 0 || static_cast<size_t>(token) >= logits.size()) {
396 continue;
397 }
398 const size_t index = static_cast<size_t>(token);
399 if (scratch.seen_marks[index] == stamp) {
400 continue;
401 }
402 scratch.seen_marks[index] = stamp;
403 float & value = logits[index];
404 value = value < 0.0F ? value * penalty : value / penalty;
405 }
406}
407
408void mask_min_new_token_eos(std::vector<float> & logits, int generated_tokens, int32_t eos_token) {
409 if (generated_tokens >= kMinNewTokens || eos_token < 0 || static_cast<size_t>(eos_token) >= logits.size()) {
410 return;
411 }
412 logits[static_cast<size_t>(eos_token)] = -std::numeric_limits<float>::infinity();
413}
414
415int32_t sample_token(
416 const std::vector<float> & logits,
417 int top_k,
418 float top_p,
419 float temperature,
420 uint64_t seed,
421 int step,
422 const TorchCudaSamplingPolicy & sampling_policy,
423 SamplerScratch & scratch) {

Callers 1

Vevo2ARDecodeGraphMethod · 0.70

Calls 15

ar_head_dimFunction · 0.85
RMSNormModuleClass · 0.85
LinearModuleClass · 0.85
RoPEModuleClass · 0.85
ggml_cpyFunction · 0.85
TransposeModuleClass · 0.85
wrap_tensorFunction · 0.85
ggml_contFunction · 0.85
reshape_tensorFunction · 0.85
reshape_headsFunction · 0.70

Tested by

no test coverage detected