November 2026: This submit was reviewed and up to date for accuracy.
Underneath the EU AI Act, organizations that fine-tune massive language fashions (LLMs) can in some instances change into suppliers of the modified mannequin, with obligations of their very own. The European Fee’s pointers use coaching compute, measured in floating-point operations (FLOPs), as an indicative criterion for when this occurs. As prospects more and more fine-tune LLMs for domain-specific use instances, we hear a standard query: how do I do know if my coaching job triggers new regulatory obligations?
Amazon SageMaker AI offers a managed machine studying (ML) service for constructing, coaching, and deploying fashions. This answer makes use of Amazon SageMaker Coaching jobs to run fine-tuning workloads on absolutely managed infrastructure. SageMaker Coaching jobs deal with useful resource provisioning, scaling, and cluster administration, with built-in assist for distributed coaching, integration with AWS CloudTrail and Amazon CloudWatch for governance, and automated decommissioning of compute sources after coaching completes. The High quality-Tuning FLOPs Meter extends these capabilities with purpose-built compliance monitoring that integrates into your current SageMaker AI pipelines.
On this submit, we present you arrange FLOPs monitoring throughout LLM fine-tuning utilizing the open supply High quality-Tuning FLOPs Meter toolkit on Amazon SageMaker AI. You learn to measure the coaching compute of a fine-tuning job with a single configuration flag, evaluate it with the thresholds within the Fee’s pointers, and hold a JSON file of the outcomes.
EU AI Act and FLOPs monitoring necessities
The EU AI Act obligations for suppliers of general-purpose synthetic intelligence (GPAI) fashions have utilized since August 2, 2025. The European Fee can implement them, together with by way of fines, from August 2, 2026. Suppliers of fashions positioned available on the market earlier than August 2, 2025 have till August 2, 2027 to conform. When you’re fine-tuning an LLM, contemplate whether or not your modifications may change your function from a downstream consumer (a company that makes use of an current mannequin with out substantial modification) to a GPAI mannequin supplier (a company legally answerable for a mannequin’s compliance). The Act itself doesn’t specify when this occurs, however the European Commission’s guidelines on the scope of GPAI obligations, printed in July 2025, give indicative standards.
In line with the rules, a modifier turns into the supplier provided that the modification considerably modifications the mannequin’s generality, capabilities, or systemic threat. As an indicative criterion, the rules use the compute spent on the modification: greater than one-third of the compute used to coach the unique mannequin, usually referred to as the one-third rule. The rules aren’t legally binding, however the Fee states that it’ll base its enforcement on them. The thresholds on this submit come from these pointers, not from the Act itself. The Fee has additionally assessed the voluntary Common-Function AI Code of Apply, printed in July 2025, as an ample method for suppliers to show compliance. Most organizations use state of affairs 2 within the following desk as a result of mannequin suppliers not often publish actual coaching FLOPs. Until you may have documented pretraining compute out of your mannequin supplier, the rules give a default threshold of three.3×10²² FLOPs. The Fee’s pointers describe three eventualities and thresholds:
| State of affairs | Threshold |
| Pretraining compute is understood and ≥ 10²³ FLOPs | 30% of the particular pretraining compute |
| Pretraining compute is unknown or < 10²³ FLOPs | Default threshold of three.3×10²² FLOPs |
| Systemic Threat Fashions (Pre-training FLOPs ≥ 10²⁵ FLOPs) | 3.3×10²⁴ FLOPs (if base compute is unknown) |
The High quality-Tuning FLOPs Meter routinely determines which state of affairs applies based mostly on whether or not you present the PRETRAIN_FLOPS setting variable. That will help you shortly decide which threshold path applies, use the next determination circulation:
Step 1: Are you aware your base mannequin’s pretraining FLOPs?
- No: Proceed on to the Default Threshold of three.3×10²² FLOPs.
- Sure: Transfer to the following analysis step.
Step 2: Consider pretraining compute scale
If you already know your pretraining compute, evaluate it towards the next orders of magnitude:
-
Is pretraining compute ≥ 10²⁵ FLOPs?
- Sure: You fall beneath the Systemic Threat Threshold. Use a threshold of three.3×10²⁴ FLOPs.
- No: Transfer to the following query.
-
Is pretraining compute ≥ 10²³ FLOPs?
- Sure: Use a Relative Threshold of 30% of precise pretraining compute.
- No: Proceed to the Default Threshold of three.3×10²² FLOPs.
For instance, fine-tuning Llama-3-70B (pretrained with an estimated minimal of 1.5×10²⁴ FLOPs) units the brink at 4.5×10²³ FLOPs. Underneath the Fee’s pointers, exceeding this threshold is a sign that you could be change into the supplier of the modified mannequin. For what to contemplate in that case, see What for those who exceed the brink? later on this submit.
The AI Act units fines in two locations. Article 99 units tiered most fines for operators of AI methods. Every tier is the upper of a set quantity and a share of worldwide annual turnover: as much as €35 million or 7% for prohibited AI practices, as much as €15 million or 3% for many different obligations, and as much as €7.5 million or 1% for supplying incorrect, incomplete, or deceptive info to notified our bodies or nationwide authorities. Decrease caps apply to small and medium-sized enterprises (SMEs) and small mid-cap enterprises. Fines for suppliers of GPAI fashions are set individually in Article 101: the European Fee can impose fines of as much as €15 million or 3% of worldwide annual turnover, whichever is larger, from August 2, 2026.
The problem of handbook FLOPs monitoring
These thresholds current three compliance challenges:
- FLOPs formulation are advanced and differ relying on whether or not you’re doing full fine-tuning or utilizing parameter-efficient strategies (coaching approaches like Low-Rank Adaptation (LoRA) that replace solely a small subset of mannequin parameters).
- The relevant threshold is tough to find out as a result of pretraining compute figures are not often printed.
- Sustaining an audit path (a everlasting file of compliance metrics for regulatory overview) throughout a number of coaching jobs provides operational overhead.
Incorrect calculations can result in the mistaken conclusion about whether or not your job exceeds the brink. The High quality-Tuning FLOPs Meter automates the monitoring course of, addressing these challenges.
Resolution overview
The High quality-Tuning FLOPs Meter is an open supply toolkit, out there within the Amazon SageMaker Generative AI recipes repository, that integrates into Hugging Face coaching workflows on Amazon SageMaker AI. It tracks computational sources throughout all the fine-tuning lifecycle. The next diagram illustrates the compliance workflow.
The toolkit covers three phases of the fine-tuning lifecycle, with runtime monitoring because the core functionality.
First stage: an non-obligatory pre-training estimation utility that you could run to match anticipated FLOPs throughout coaching strategies (LoRA, Spectrum, Full) earlier than you launch a job.
Second stage: runtime monitoring, the principle function, makes use of a Hugging Face TrainerCallback to calculate FLOPs in actual time throughout coaching utilizing each architecture-based analytics and hardware-based GPU monitoring by way of NVIDIA Administration Library (NVML).
Third stage: a post-training audit path routinely shops full compliance metrics in JSON format. You possibly can persist outcomes to Amazon Easy Storage Service (Amazon S3) or Amazon DynamoDB.
You possibly can choose in with a single configuration line (compute_flops: true). The FLOPs Meter consists of parameter-efficient consciousness utilizing an enhanced method to precisely estimate for full, LoRA, and Spectrum fine-tuning approaches. It writes the compute metrics to a JSON file, and it performs automated threshold comparability that helps decide the relevant threshold and flags whether or not your fine-tuning job exceeds it.
Technical implementation
The next subsections cowl how FLOPs are calculated and the way the monitoring integrates along with your coaching workflow on Amazon SageMaker AI.
Conditions
It’s essential to full the next stipulations earlier than you possibly can run the FLOPs Meter walkthrough:
-
Make the next quota improve request for SageMaker AI. For this use case, you want a minimal of 1 ml.g5.4xlarge occasion (with 1 x NVIDIA A10G GPU). On the Service Quotas console, request the SageMaker AI quota G5 cases (ml.g5.4xlarge) for coaching job utilization: 1.
-
Create an AWS Identification and Entry Administration (IAM) [role](https://docs.aws.amazon.com/sagemaker/newest/dg/sagemaker-roles.html#:~:textual content=thepercent20followingpercent20procedures.-%5BpercentE2percent80percentA6percent5Dxecutionpercent20role,-Usepercent20thepercent20followingpercent20() with managed insurance policies
AmazonSageMakerFullAccessandAmazonS3FullAccessto present required entry to SageMaker AI to run the examples. -
Assign the next coverage as a belief relationship to your IAM function:
-
(Non-obligatory) Create an Amazon SageMaker Studio area (consult with Use fast setup for Amazon SageMaker AI) to entry Jupyter notebooks with the previous function. You may also use JupyterLab in your native setup.
These permissions grant broad entry and usually are not really helpful to be used in manufacturing environments. For steerage on defining extra fine-grained permissions, consult with the SageMaker AI Developer Information.
FLOPs calculation formulation
For compliance reporting, use the analytical methodology (Flops_architecture) as your main metric. The toolkit additionally calculates a hardware-based higher certain for conservative reporting. Each strategies run routinely. The next sections describe the implementation particulars.
The Fee’s pointers (Part A.2.1) describe two approaches for estimating coaching compute:
- Structure-based strategy (analytical):
The Fee’s pointers give the next approximation for dense transformers:
C ≈ 6 × P × D
The place P is the variety of parameters and D is the variety of coaching tokens. This assumes full fine-tuning, the place all parameters are trainable.
An enhanced method accounts for parameter-efficient strategies:
F_ft = (4 × N_total + 2 × N_trainable) × tokens_processed
Right here’s the breakdown:
- 4 ×
N_total— ahead go (2×) plus backward go gradient computation by way of every layer (2×), together with frozen ones. - 2 ×
N_trainable— gradient computation with respect to trainable weights solely.
For full fine-tuning the place N_total = N_trainable, this reduces to 6 × N × D, which is equal to the method within the pointers. For LoRA or Spectrum, it offers a extra correct (and decrease) estimate, reflecting that fewer parameters obtain gradient updates.
- {Hardware}-based strategy (higher certain):
This strategy makes use of the next method:
C = N_gpus × L × H × U
The place N_gpus is the variety of GPUs, L is coaching period in seconds, H is peak theoretical efficiency (FLOPs), and U is utilization. The FLOPs Meter makes use of U = 1.0 (100% utilization) to supply a conservative higher certain by way of NVML GPU monitoring.
Threshold logic
The toolkit implements the brink logic from the Fee’s pointers in determine_compliance_threshold():
Integration with SageMaker Coaching jobs
The FLOPs Meter works as a Hugging Face TrainerCallback. To activate monitoring, add a single line within the recipe YAML:
At coaching launch, the coaching script (sft.py) checks this flag and, if activated, initializes the FlopsMeterCallback with mannequin parameter counts and an non-obligatory PRETRAIN_FLOPS setting variable. A customized TokenCountingSFTTrainer replaces the usual SFTTrainer to depend non-padding tokens at every coaching step.
At coaching completion, the callback computes each analytical and {hardware} FLOPs, determines the relevant threshold, and writes a flops_meter.json file to /choose/ml/output/. The pipeline’s ProcessTrainingOutputs step then uploads the outcomes to Amazon S3 and persists them to Amazon DynamoDB for audit path functions.
Walkthrough
The next walkthrough makes use of meta-llama/Llama-3.2-3B-Instruct (3.21 billion parameters). As a result of Meta has not printed actual pretraining FLOPs for this mannequin, the walkthrough doesn’t set PRETRAIN_FLOPS, and the instrument makes use of the default threshold from the Fee’s pointers: 3.3×10²² FLOPs.
Pre-training estimation (non-obligatory)
A standalone estimation utility (estimate_flops.py) compares anticipated FLOPs throughout coaching strategies (LoRA, Spectrum, and full fine-tuning) earlier than you launch a job. That is helpful for planning: it reveals prematurely whether or not a deliberate job’s compute would exceed the brink from the Fee’s pointers. The estimation utility is separate from the core runtime monitoring and you’ll run it independently in a pocket book.
Runtime monitoring
Throughout coaching, the FlopsMeterCallback tracks FLOPs in actual time. That is the place the precise compliance measurement occurs. When coaching begins (on_train_begin), the callback captures mannequin parameter counts (N_total, N_trainable), begins an NVML GPU monitoring thread, and data the beginning timestamp. As coaching progresses, the callback counts non-padding tokens per batch at every substep (on_substep_end) and aggregates them throughout GPUs in distributed coaching. When coaching completes (on_train_end), the callback computes architecture-based FLOPs from the collected token depend. It then stops NVML monitoring to calculate the {hardware} higher certain, determines the relevant threshold, and writes the entire metrics to flops_meter.json.
A recipe configuration for Llama-3.2-3B with LoRA and FLOPs monitoring activated:
In your Amazon SageMaker AI pocket book or Python script, use the ModelTrainer class from the SageMaker Python SDK v3 to launch the coaching job as a SageMaker Coaching job:
As a result of pretraining FLOPs usually are not identified for this mannequin, the PRETRAIN_FLOPS setting variable is omitted. The default threshold is utilized routinely.
Compliance documentation
At coaching completion, the callback generates a flops_meter.json file containing the coaching compute metrics:
Use Flops_architecture as your main compliance metric. It precisely displays your precise coaching configuration. Flops_hardware offers a conservative higher certain and might function a security margin for extra-cautious reporting.
Different key fields embody threshold_type, which signifies which threshold rule was utilized (default_3.3e22 since pretraining FLOPs are unknown), exceeds_30pct as a boolean flag that reveals whether or not the job’s compute exceeds the brink, and Flops_original, which is null when pretraining FLOPs usually are not supplied.
The pipeline routinely uploads this file to Amazon S3 and shops it in Amazon DynamoDB, making a persistent audit path throughout coaching runs.
What for those who exceed the brink?
If exceeds_30pct is true, your job’s compute is above the brink that the Commission’s guidelines use as an indicative criterion. This alone doesn’t decide whether or not you change into the supplier of a GPAI mannequin. The rules state {that a} case-by-case evaluation is at all times crucial. Concerns for that evaluation could embody the obligations for GPAI mannequin suppliers in Article 53(1) of the AI Act (technical documentation, info for downstream suppliers, a copyright coverage, and a public abstract of coaching content material), and the extra obligations for GPAI fashions with systemic threat. We suggest consulting authorized counsel aware of EU AI regulation.
Scaling to manufacturing workloads
This instance used a small dataset for demonstration functions (2,150 tokens). In manufacturing, you sometimes course of tens of millions of tokens. For instance, fine-tuning Llama-3.2-3B on 1 million tokens with LoRA ends in roughly 6.7×10¹⁸ FLOPs, nonetheless properly under the three.3×10²² threshold. Nevertheless, full fine-tuning on the identical dataset consumes roughly 1.9×10¹⁹ FLOPs, bringing you nearer to the brink.
For many LoRA fine-tuning jobs on fashions beneath 10B parameters, you stay properly under the brink even with tens of millions of coaching tokens.
Getting began
The FLOPs Meter is on the market as a part of the Amazon SageMaker Generative AI recipes repository.
What you want
Earlier than you start, be sure to have:
- An AWS account with Amazon SageMaker AI entry.
- AWS Command Line Interface (AWS CLI) configured with acceptable credentials.
- Python 3.11 or later put in.
- Familiarity with Hugging Face Transformers and PyTorch.
Allow FLOPs monitoring
To begin FLOPs monitoring:
-
Clone the repository:
-
Open your recipe configuration file (for instance,
hf_recipes/meta-llama/Llama-3.2-3B-Instruct--vanilla-peft-qlora.yaml) and add the next line: -
(Non-obligatory) If you already know the pretraining FLOPs on your base mannequin, set the setting variable:
-
Launch your coaching job on Amazon SageMaker AI:
- Open your SageMaker AI pocket book or Python script.
- Configure the
PyTorch Estimator(see the code instance within the Walkthrough part). - Run
estimator.match()to begin the coaching job.
-
After coaching completes, overview the generated
flops_meter.jsonfile in your Amazon S3 output location. You must see a JSON file containing FLOPs metrics and the brink comparability.
For a deeper have a look at the implementation, see the source code for flops_meter.py.
Clear up
To keep away from ongoing prices, delete the sources you created:
-
Cease operating SageMaker AI coaching jobs:
-
Delete Amazon S3 outputs:
- Open the Amazon S3 console.
- Navigate to your coaching output bucket.
- Choose the
flops_meter.jsoninformation and select Delete. - Or delete all the bucket for those who created it particularly for this walkthrough.
-
Delete the Amazon DynamoDB desk for those who created one particularly for this walkthrough:
-
Take away SageMaker AI endpoints for those who deployed your fine-tuned mannequin.
Conclusion
On this submit, we confirmed you implement FLOPs monitoring throughout LLM fine-tuning on Amazon SageMaker AI. You discovered how the High quality-Tuning FLOPs Meter calculates computational sources utilizing each analytical and hardware-based strategies, the way it applies the one-third rule from the Fee’s pointers to match your job’s compute with the relevant threshold, and file the ends in a JSON file with a single configuration flag.
With this tooling, you possibly can deal with constructing fashions whereas sustaining full transparency into your computational footprint.
To get began, clone the repository and run the pre-training estimation instrument along with your deliberate mannequin and dataset. For extra details about constructing compliance-aligned AI methods on AWS, see the Amazon SageMaker AI documentation.
Concerning the authors

