基于 272 次生产环境运行数据,预测共享 GPU 集群上的端到端微调时间。
这是我们即将发表的论文《预测生成式语言模型的端到端微调时间》的预览版。完整版本将很快上传至 arXiv。
GPU 是当今 AI 领域最昂贵且最稀缺的资源之一。任何运营共享集群的人每天都要决定哪些作业运行在哪些 GPU 上,以及以何种顺序运行。这个计划的质量完全取决于对每个作业所需时间的估算。当作业提前数小时完成时,GPU 会闲置直到下一个作业被调度;而当作业延迟数小时结束时,所有后续排队的作业都会顺延,实验被迫等待,交付日期也随之推迟。
更准确的时长估算能将这种状况从猜测转变为规划:明确哪些任务在何时运行、需要多少 GPU,从而减少中间的闲置容量。然而,大多数团队使用的估算方法仅仅是基于 FLOP(浮点运算次数)的粗略计算。它预测需要九小时,而作业实际上是在第二天下午才完成。
我们想知道这种数学估算与实际偏差有多大,以及是否能在作业调度之前做出更准确的预测。因此,我们从 NVIDIA H200 GPU 的生产池中选取了 272 个真实的监督微调(SFT)作业,总计约 7,382 个 GPU 小时,并将分析估算值与学习型预测器进行了对比。
简而言之:通常基于 FLOP 的估算对我们观察到的情况解释力很弱(R² = 0.31,平均绝对误差 MAE 为 12.41 小时)。一个仅使用调度前可用信息的 CatBoost 回归模型在 5 折交叉验证中达到了 R² = 0.98 的准确率,平均绝对误差为 1.71 小时,中位误差为 0.51 小时。这种差距源于封闭形式估算无法做到的两件事:回归器能看到更多与训练相关的信号,例如评估频率、检查点策略、每个 GPU 的负载以及微调模式,并且它能从过去的运行中学习这些信号之间的非线性相互作用。
每个人使用的估算是仅基于计算量的
对于密集 Transformer,训练成本大约为 6·P·D 次浮点运算,其中 P 是参数量,D 是训练 token 的数量。将其除以 GPU 能提供的吞吐量,即可得到训练循环的时间:
T_theoretical = (6 · P · D) / (N_GPU · FLOPS_peak · MFU)
这里 N_GPU 是 GPU 的数量,FLOPS_peak 是单张 GPU 规格书上的峰值吞吐量,MFU(模型浮点运算利用率)是训练实际达到的峰值比例。由于内存流量、通信和内核效率问题,真实作业永远无法在峰值状态下运行,因此 MFU 通常介于 30% 到 60% 之间,而针对特定作业的准确值在事前是无法得知的。
这是对优化循环的良好描述。然而,一个作业不仅仅是它的循环。在第一步之前,还有环境设置、模型下载和加载以及分词过程。在训练期间,会有定期的评估和检查点上传。最后,最终模型会被存入对象存储。在多租户集群上,所有这些操作都会与其他作业竞争网络和存储 I/O 资源。
这些开销取决于配置,并且不会随工作量或 GPU 数量呈线性缩放。两个具有相同名义计算量的作业可能会相差数小时完成。
为了保持比较的公平性,我们要测试的 FLOP 基线将调度的评估 token 与训练 token 都计入在内,并且我们在一个广泛的范围内对 MFU 进行扫描。
我们构建了什么
我们将端到端持续时间视为一个监督回归问题。给定由作业配置和模型元数据构建的特征向量,预测从作业获得 GPU 到完成之间的挂钟时间(wall-clock time)。排队时间被排除在外。
两项设计决策塑造了这项工作:
一切在调度前都是已知的。每个输入都来自提交的配置:超参数、数据集大小、模型标识符、GPU 分配。没有运行时日志,也没有部分进度信息。这正是使预测可用于调度的原因。
暴露开销的特性。在原始配置之上,我们推导出诸如 num_eval_data(所有评估周期中处理的样本总数)、num_saves 和 num_params_saved(检查点 I/O)以及每 GPU 的 token 量等数量。FLOP 估计本身,将 MFU 固定为 0.45,作为另一个特征(baseline_time)输入,因此模型从仅计算的数量开始并学习修正值。
我们比较了线性回归、岭回归、XGBoost 和 CatBoost。特征选择结合了相关性过滤、互信息和排列重要性,针对 18 个候选特征集进行筛选,随后以 MAE 为标准进行网格搜索。最终的 CatBoost 模型使用了 24 个特征。
数据
来自企业生产环境操作日志的 272 次 SFT 运行记录,涵盖多个模型家族,参数规模高达 150 亿,包括 LoRA 和全量微调,以及广泛的数据集规模和超参数范围。
共享基础设施。作业在 1、2 或 4 块 GPU 上运行,这些 GPU 从 8 到 32 块 H200 的池中分配,分布在 1 到 4 个节点上,同时处理其他训练和推理工作负载。测量的时间包含了真实的资源争用情况。
持续时间从 1.6 小时到 172.4 小时不等,平均值为 23.43 小时,中位数为 15.29 小时。
技术栈:Hugging Face Transformers 和 Unsloth。我们将技术栈作为分类特征进行建模,并不假设两者之间存在固定的加速比。
272 次运行中端到端持续时间的分布。平均值 23.43 小时,中位数 15.29 小时。
结果
所有数字均来自分层 5 折交叉验证。前四行是分析性的,不涉及拟合。
模型
R²
RMSE (h)
MAE (h)
FLOP 基线 (MFU 30%)
0.31
20.45
12.41
FLOP 基线 (MFU 45%)
0.18
22.38
13.01
FLOP 基线 (MFU 60%)
0.01
24.56
14.62
Calculon
−0.51
30.40
20.36
线性回归
0.69 ± 0.14
13.52 ± 4.23
7.52 ± 0.49
岭回归
0.73 ± 0.09
12.72 ± 3.70
7.23 ± 0.68
XGBoost
0.97 ± 0.01
4.18 ± 1.17
1.95 ± 0.32
CatBoost
0.98 ± 0.01
3.52 ± 0.78
1.71 ± 0.33
有几件事引人注目。
没有一个单一的 MFU 值能固定 FLOP 基线。我们将 MFU 从 0.25 扫描到 0.65。最佳设置 30% 仍然导致平均持续时间为 23 小时的作业的平均误差超过 12 小时。
更详细的分析模型未能缩小差距。作为第二个基线,我们采用了 Calculon(Isaev 等人,SC '23),这是一种来自先前工作的 LLM 训练分析性能模型。它构建了显式的层图,并考虑了计算、内存流量和设备间通信。我们扩展了公共实现以涵盖 LoRA、分组查询注意力、融合注意力、bfloat16 和 SwiGLU。其估计值的中位数仅占观察到的挂钟时间的 11%。这并不意味着 Calculon 作为步骤级工具不好,这正是它的设计用途。这表明生产作业中有多少部分发生在优化步骤之外。
线性模型有帮助,但随后停滞不前。岭回归将 MAE 降低到 7.23 小时。配置与持续时间之间的关系不能被纯线性模型很好地捕捉。
梯度提升承担了繁重的工作。CatBoost 和 XGBoost 在每项指标上都落在彼此的一个标准差范围内。我们保留 CatBoost,因为它在所有方面都具有最低的平均误差。
预测器依赖什么
CatBoost 的特征重要性集中在少数几个特征上。模型和工作负载变量如预期存在,但评估和检查点变量也存在。num_eval_data(作业生命周期中评估处理的样本总数)排名第一,其次是 num_trainable_params、batch_eval_size_percent、num_all_params 和 num_gpus*batch_train_percent,num_params_saved 紧随其后。SHAP 值讲述了同样的故事:高评估量持续推高预测时间,而可训练参数数量具有非线性效应,仅对最大模型才变得显著。
CatBoost 模型在各折中的平均特征重要性(PredictionValuesChange)。
特征重要性并不构成因果主张。尽管如此,该模式与实际工作中时间的分配方式相符。评估的频率、评估集的大小以及保留的检查点数量,连同模型和数据集的规模,都会影响实际运行时间。人们在编写训练配置时,往往凭习惯做出这些选择。
阅读图表时的一个注意事项是:更大的 GPU 分配量对预测时间呈现出正向贡献。在我们的数据中,更大的分配量通常对应于更庞大的任务,因此 num_gpus(GPU 数量)在一定程度上充当了任务规模的代理变量。这并不意味着增加 GPU 会使任务变慢。
误差有多大,以及出现在哪里
查看所有 272 个折外预测结果,中位数绝对误差为 0.51 小时。80% 的预测误差在 2.20 小时以内,90% 的误差在 4.31 小时以内。按任务持续时间细分如下:
任务持续时间(小时)
运行次数
中位数绝对误差(小时)
P90(小时)
1.56 至 5
60
0.30
1.55
5 至 10
63
0.18
1.27
10 至 30
69
0.73
4.17
30 至 60
67
1.06
5.50
60 至 175
13
5.19
18.51
在 60 小时以内,中位数误差保持在约一小时或更低。长尾部分是模型表现不佳的地方,鉴于 60 小时以上的运行仅有 13 次,我们将此视为数据量的限制。
折外绝对误差与实际持续时间的关系图,按持续时间范围着色。误差在 60 小时以下保持较低水平,而在稀疏的长尾部分则变大。
更多的数据仍然会有所帮助。在固定的 20% 测试集上,当训练数据从 85% 增加到 100% 时,平均绝对误差(MAE)从 1.63 小时降至 1.50 小时,且未见明显的平台期。
它的用途何在
在实践中,该预测器能在任务开始前为调度器提供一个可据此规划的时间长度:决定哪些任务可以并行运行、GPU 何时释放资源,以及某次运行是否能在截止日期前完成。
局限性
仅限监督微调(SFT)。我们未包含其他训练和对齐策略,如 RLHF、DPO 或 RLVR。
单一 GPU 类型。每次运行均使用 H200 GPU。拟合的模型已针对该基础设施进行校准,不应期望在不重新训练的情况下将其数值结果直接迁移至其他 GPU 代际。面向混合资源池的预测器还需要硬件描述符,如计算吞吐量、内存容量和带宽,以及互连拓扑结构。
极少超长时间运行。误差在 60 小时以上变大。
可迁移的是方法:感知开销的特征、感知多重共线性的特征选择以及比较协议。完整论文将详细报告特征公式、选择过程、搜索空间和最终超参数,以便在任何具有类似结构的执行日志数据集上重建该流程。
下一步计划:硬件特定描述符及其他 GPU 类型的验证、针对观测值较少配置的学习迁移、其他训练目标,以及更多关于长时间运行的数据。
后续安排
完整论文即将上传至 arXiv。请在 Hugging Face 上关注 Dharma-AI 组织,以便在论文发布时收到通知,并在下方评论区留下您的问题。我们很想了解您如何在自己的集群中估算任务持续时间。
延伸阅读
Dharma-AI 研发 · 我们将 AI 打造为您的模型
Predicting end-to-end fine-tuning time on shared GPU clusters, from 272 production runs.
A preview of our upcoming paper, Predicting End-to-End Fine-Tuning Time for Generative Language Models . The full version will be on arXiv soon.
GPUs are among the most expensive and scarcest resources in AI today. Anyone running a shared cluster has to decide, every day, which jobs go on which GPUs and in what order. That plan is only as good as the estimate of how long each job will take. When a job finishes hours early, GPUs sit idle until the next one is dispatched. When it runs hours late, everything queued behind it slips, experiments wait and delivery dates move.
Better duration estimates turn this into planning instead of guesswork: what runs, when, and on how many GPUs, with less idle capacity in between. Yet the estimate most teams use is a back-of-the-envelope FLOP calculation. It says nine hours, and the job finishes the next afternoon.
We wanted to know how far off that math really is, and whether we could do better before a job is even dispatched. So we took 272 real supervised fine-tuning (SFT) jobs from our production pool of NVIDIA H200 GPUs, about 7,382 GPU-hours in total, and compared analytical estimates against learned predictors.
The short version: the usual FLOP-based estimate explains little of what we observed (R² = 0.31, MAE 12.41 h). A CatBoost regressor that only sees information available before dispatch reaches R² = 0.98, with a mean absolute error of 1.71 h and a median error of 0.51 h in 5-fold cross-validation. The gap comes from two things a closed-form estimate cannot do. The regressor sees more training-specific signals, such as evaluation cadence, checkpoint policy, per-GPU load and fine-tuning regime, and it learns the nonlinear interactions between them from past runs.
The estimate everyone uses is compute-only
For a dense Transformer, training costs roughly 6·P·D floating-point operations, where P is the parameter count and D the number of training tokens. Divide that by what your GPUs can deliver and you get a training-loop time:
T_theoretical = (6 · P · D) / (N_GPU · FLOPS_peak · MFU)
Here N_GPU is the number of GPUs, FLOPS_peak is the peak throughput of one GPU from its spec sheet, and MFU (Model FLOPs Utilization) is the fraction of that peak the training actually achieves. Real jobs never run at peak because of memory traffic, communication and kernel inefficiencies, so MFU typically sits somewhere between 30% and 60%, and the right value for a given job is not known in advance.
This is a good description of the optimization loop. A job is more than its loop, though. Before the first step there is environment setup, model download and loading, and tokenization. During training there are periodic evaluations and checkpoint uploads. At the end, the final model goes to object storage. On a multi-tenant cluster, all of it competes with other jobs for network and storage I/O.
These overheads depend on configuration, and they do not scale neatly with workload or GPU count. Two jobs with the same nominal compute can finish hours apart.
To keep the comparison fair, the FLOP baseline we test counts the scheduled evaluation tokens as well as the training tokens, and we sweep MFU over a wide range.
What we built
We treat end-to-end duration as a supervised regression problem. Given a feature vector built from the job configuration and model metadata, predict the wall-clock time between the moment the job gets its GPUs and the moment it is done. Queue time is excluded.
Two design choices shaped the work:
Everything is known before dispatch. Every input comes from the submitted configuration: hyperparameters, dataset sizes, model identifiers, GPU allocation. No runtime logs, no partial progress. That is what makes the prediction usable for scheduling.
Features that expose the overheads. On top of the raw configuration we derive quantities such as num_eval_data (samples processed across all evaluation cycles), num_saves and num_params_saved (checkpoint I/O), and per-GPU token volumes. The FLOP estimate itself, with MFU fixed at 0.45, goes in as one more feature ( baseline_time ), so the model starts from the compute-only number and learns the corrections.
We compared Linear Regression, Ridge, XGBoost and CatBoost. Feature selection combined correlation filtering, mutual information and permutation importance across 18 candidate feature sets, followed by a grid search with MAE as the criterion. The final CatBoost model uses 24 features.
The data
272 SFT runs from the operational logs of a corporate production environment, covering several model families up to 15 billion parameters, both LoRA and full fine-tuning, and a wide range of dataset sizes and hyperparameters.
Shared infrastructure. Jobs ran on 1, 2 or 4 GPUs drawn from a pool of 8 to 32 H200s across 1 to 4 nodes, alongside other training and inference workloads. The measured times include real contention.
Durations from 1.6 to 172.4 hours , with a mean of 23.43 h and a median of 15.29 h.
Stack: Hugging Face Transformers and Unsloth. We model the stack as a categorical feature and make no assumption about a fixed speedup between the two.
Distribution of end-to-end duration across the 272 runs. Mean 23.43 h, median 15.29 h.
Results
All numbers come from stratified 5-fold cross-validation. The first four rows are analytical and involve no fitting.
Model
R²
RMSE (h)
MAE (h)
FLOP baseline (MFU 30%)
0.31
20.45
12.41
FLOP baseline (MFU 45%)
0.18
22.38
13.01
FLOP baseline (MFU 60%)
0.01
24.56
14.62
Calculon
−0.51
30.40
20.36
Linear Regression
0.69 ± 0.14
13.52 ± 4.23
7.52 ± 0.49
Ridge
0.73 ± 0.09
12.72 ± 3.70
7.23 ± 0.68
XGBoost
0.97 ± 0.01
4.18 ± 1.17
1.95 ± 0.32
CatBoost
0.98 ± 0.01
3.52 ± 0.78
1.71 ± 0.33
A few things stand out.
No single MFU value fixes the FLOP baseline. We swept MFU from 0.25 to 0.65. The best setting, 30%, still leaves a mean error above 12 hours on jobs that last 23 hours on average.
A more detailed analytical model does not close the gap. As a second baseline we took Calculon (Isaev et al., SC '23), an analytical performance model for LLM training from prior work. It builds an explicit layer graph and accounts for compute, memory traffic and inter-device communication. We extended the public implementation to cover LoRA, grouped-query attention, fused attention, bfloat16 and SwiGLU. Its estimates still correspond to a median of only 11% of the observed wall-clock time. That says nothing against Calculon as a step-level tool, which is what it was designed for. It shows how much of a production job happens outside the optimization step.
Linear models help, and then stall. Ridge brings MAE down to 7.23 h. The relationship between configuration and duration is not well captured by a purely linear model.
Gradient boosting does the heavy lifting. CatBoost and XGBoost land within one standard deviation of each other on every metric. We carry CatBoost forward because it has the lowest mean error across the board.
What the predictor relies on
CatBoost's feature importance concentrates in a handful of features. Model and workload variables are there, as expected, but so are evaluation and checkpoint variables. num_eval_data , the total number of samples processed in evaluation over the life of the job, ranks first, followed by num_trainable_params , batch_eval_size_percent , num_all_params and num_gpus*batch_train_percent , with num_params_saved close behind. SHAP values tell the same story: high evaluation volume consistently pushes the predicted time up, while trainable parameter count has a nonlinear effect that only becomes large for the biggest models.
Mean feature importance of the CatBoost model across folds (PredictionValuesChange).
Feature importance is not a causal claim. Still, the pattern lines up with how a job is actually spent. How often you evaluate, how large the evaluation set is and how many checkpoints you persist all shape the wall-clock time, alongside model and dataset scale. These are choices people often make by habit when writing a training config.
One caveat on reading the plots: larger GPU allocations show positive contributions to predicted time. In our data, bigger allocations go with bigger jobs, so num_gpus acts partly as a proxy for job scale. It does not mean adding GPUs makes a job slower.
How wrong is it, and where
Looking at all 272 out-of-fold predictions, the median absolute error is 0.51 h. 80% of predictions are within 2.20 h and 90% are within 4.31 h. Broken down by job duration:
Job duration (h)
Runs
Median abs. error (h)
P90 (h)
1.56 to 5
60
0.30
1.55
5 to 10
63
0.18
1.27
10 to 30
69
0.73
4.17
30 to 60
67
1.06
5.50
60 to 175
13
5.19
18.51
Up to 60 hours, the median error stays at about one hour or less. The long tail is where the model struggles, and with only 13 runs above 60 hours we read that as a data limitation.
Out-of-fold absolute error against real duration, colored by duration range. Errors stay low up to 60 h and widen in the sparse tail.
More data should still help. On a fixed 20% holdout, MAE drops from 1.63 h to 1.50 h when going from 85% to 100% of the training partition, with no clear plateau.
What it is good for
In practice, the predictor gives a scheduler a duration it can plan around before a job starts: which jobs to run together, when GPUs will free up, and whether a run will finish in time for its deadline.
Limitations
SFT only. We did not include other training and alignment strategies such as RLHF, DPO or RLVR.
One GPU type. Every run used H200s. The fitted model is calibrated to that infrastructure and should not be expected to transfer numerically to other GPU generations without retraining. A predictor for mixed pools would also need hardware descriptors such as compute throughput, memory capacity and bandwidth, and interconnect topology.
Few very long runs. Errors widen above 60 hours.
What does transfer is the method: overhead-aware features, multicollinearity-aware selection and the comparison protocol. The full paper will report the feature formulas, the selection procedure, the search spaces and the final hyperparameters in full, so the pipeline can be rebuilt on any execution-log dataset with a similar structure.
Next on our list: hardware-specific descriptors and validation on other GPU types, transfer learning for configurations with few observations, other training objectives, and more data on long runs.
What's next
The full paper is coming to arXiv soon. Follow the Dharma-AI organization on Hugging Face to be notified when it is out, and leave your questions in the comments below. We would like to hear how you estimate job duration on your own clusters.
Further reading
Dharma-AI R&D · We Make AI Your Model
首次收录 · 2026-11-19 · 10.8 分