| 667 | } |
| 668 | |
| 669 | bool Dflash2Drafter::clone_bind(const Dflash2Drafter& parent, std::string& err) { |
| 670 | if (!parent.bound_ || !blob_shared_) { err = "dflash2: the parent drafter is not bound"; return false; } |
| 671 | const OnDevice on_device(device_); |
| 672 | embed_ = parent.embed_; head_w_ = parent.head_w_; head_type_ = parent.head_type_; n_dvocab_ = parent.n_dvocab_; |
| 673 | dvocab_ = parent.dvocab_; dhead_ = parent.dhead_; dhead_shared_ = true; |
| 674 | ndraft_ = parent.ndraft_; |
| 675 | if (cudaMalloc((void**) &logits_, (size_t) kDrafts * (size_t) n_dvocab_ * 4) != cudaSuccess) { err = "dflash2: the slot drafter's draft logits do not fit"; return false; } |
| 676 | vram_ += (uint64_t) kDrafts * (uint64_t) n_dvocab_ * 4; |
| 677 | bound_ = true; |
| 678 | return true; |
| 679 | } |
| 680 | |
| 681 | bool Dflash2Drafter::copy_state_from(Dflash2Drafter& src, std::string& err) { |
| 682 | if (src.device_ != device_ || src.L_ != L_ || src.NKV_ != NKV_) { err = "dflash2: the two drafters are not alike"; return false; } |