MCPcopy Create free account
hub / github.com/antirez/llama.cpp-deepseek-v4-flash / opt_epoch

Method opt_epoch

src/llama-context.cpp:2868–2914  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2866}
2867
2868void llama_context::opt_epoch(
2869 ggml_opt_dataset_t dataset,
2870 ggml_opt_result_t result_train,
2871 ggml_opt_result_t result_eval,
2872 int64_t idata_split,
2873 ggml_opt_epoch_callback callback_train,
2874 ggml_opt_epoch_callback callback_eval) {
2875 const uint32_t n_ctx = this->n_ctx();
2876 const uint32_t n_batch = std::min(cparams.n_batch, n_ctx);
2877 const uint32_t n_ubatch = std::min(cparams.n_ubatch, n_batch);
2878 const int64_t ndata = ggml_opt_dataset_ndata(dataset);
2879
2880 GGML_ASSERT(idata_split >= 0);
2881 GGML_ASSERT(idata_split <= ndata);
2882
2883 const uint32_t ubatch_per_ctx = n_ctx / n_ubatch;
2884
2885 struct llama_batch batch = llama_batch_init(n_batch, 0, 1);
2886 std::vector<llama_token> tokens(n_ctx);
2887 std::vector<llama_token> labels_sparse(n_ctx);
2888
2889 int64_t idata = 0;
2890
2891 int64_t t_loop_start = ggml_time_us();
2892 int64_t ndata_in_loop = idata_split*ubatch_per_ctx;
2893 for (; idata < idata_split; ++idata) {
2894 constexpr bool train = true;
2895 const int64_t idata_in_loop = idata*ubatch_per_ctx;
2896
2897 ggml_opt_dataset_get_batch_host(dataset, tokens.data(), n_ctx*sizeof(llama_token), labels_sparse.data(), idata);
2898 opt_epoch_iter(dataset, result_train, tokens, labels_sparse, batch,
2899 callback_train, train, idata_in_loop, ndata_in_loop, t_loop_start);
2900 }
2901
2902 t_loop_start = ggml_time_us();
2903 ndata_in_loop = (ndata - idata_split)*ubatch_per_ctx;
2904 for (; idata < ndata; ++idata) {
2905 constexpr bool train = false;
2906 const int64_t idata_in_loop = (idata - idata_split)*ubatch_per_ctx;
2907
2908 ggml_opt_dataset_get_batch_host(dataset, tokens.data(), n_ctx*sizeof(llama_token), labels_sparse.data(), idata);
2909 opt_epoch_iter(dataset, result_eval, tokens, labels_sparse, batch,
2910 callback_eval, train, idata_in_loop, ndata_in_loop, t_loop_start);
2911 }
2912
2913 llama_batch_free(batch);
2914}
2915
2916//
2917// interface implementation

Callers 1

llama_opt_epochFunction · 0.80

Calls 8

n_ctxMethod · 0.95
minFunction · 0.85
ggml_opt_dataset_ndataFunction · 0.85
llama_batch_initFunction · 0.85
ggml_time_usFunction · 0.85
llama_batch_freeFunction · 0.85
dataMethod · 0.45

Tested by

no test coverage detected