Chain step j (1..max_t-2): one row at the cell staged in step row `max_t + j - 1`, from the previous step's residual and token (left in Rin_[0] / tok_[0] by mtp_select); draft j and its probability to the mapped outputs.
| 1642 | // Chain step j (1..max_t-2): one row at the cell staged in step row `max_t + j - 1`, from the previous step's |
| 1643 | // residual and token (left in Rin_[0] / tok_[0] by mtp_select); draft j and its probability to the mapped outputs. |
| 1644 | bool MtpDrafter::capture_step(int j, bool coupled, std::string& err) { |
| 1645 | cudaGraphExec_t& exec = coupled ? step_exec_c_[j] : step_exec_[j]; |
| 1646 | if (exec) return true; |
| 1647 | using namespace strata::kernels; |
| 1648 | const int64_t HCN = g_->hc * g_->n_embd; |
| 1649 | const int row = max_t_ + j - 1; |
| 1650 | g_mp.init(); |
| 1651 | if (cudaStreamBeginCapture(cs_, cudaStreamCaptureModeThreadLocal) != cudaSuccess) { err = "mtp: begin capture"; return false; } |
| 1652 | const MappedCopy in[2] = {{step_ + row * 4, m_step_ + row * 4, 4}, |
| 1653 | {pos_ + row * g_->n_head, m_pos_ + row * g_->n_head, g_->n_head}}; |
| 1654 | copy_from_mapped_multi(in, 2, cs_); |
| 1655 | coupled_rec_ = coupled; |
| 1656 | coupled_j_ = j; |
| 1657 | g_mp.base = j < kMpGraphs ? j : -1; |
| 1658 | bool ok = record_forward(1, row, cs_, err); |
| 1659 | coupled_rec_ = false; |
| 1660 | if (ok) mtp_select(R_, HCN, out_ids_, row_ + 1, Rin_, tok_, m_out_, j, cs_, probs_, m_prob_); |
| 1661 | if (ok) g_mp.stamp(16, cs_); |
| 1662 | g_mp.base = -1; |
| 1663 | if (ok && force_on_ && !coupled) force_token(tok_, m_force_, j, cs_); // chain_launch: step j+1's input |
| 1664 | return finish_capture(cs_, ok, exec, coupled ? "step (coupled)" : "step", err); |
| 1665 | } |
| 1666 | |
| 1667 | void MtpDrafter::kv_restore(int64_t upto) { |
| 1668 | const OnDevice on_device(device_); |
nothing calls this directly
no test coverage detected