November 2026: This put up was reviewed and up to date for accuracy.
Underneath the EU AI Act, organizations that fine-tune giant language fashions (LLMs) can in some circumstances develop into suppliers of the modified mannequin, with obligations of their very own. The European Fee’s tips use coaching compute, measured in floating-point operations (FLOPs), as an indicative criterion for when this occurs. As clients more and more fine-tune LLMs for domain-specific use circumstances, we hear a typical 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 resolution 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 Effective-Tuning FLOPs Meter extends these capabilities with purpose-built compliance monitoring that integrates into your present SageMaker AI pipelines.
On this put up, we present you the way to arrange FLOPs monitoring throughout LLM fine-tuning utilizing the open supply Effective-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 tips, and hold a JSON document 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 fines, from August 2, 2026. Suppliers of fashions positioned in the marketplace earlier than August 2, 2025 have till August 2, 2027 to conform. When you’re fine-tuning an LLM, take into account whether or not your modifications may change your position from a downstream consumer (a corporation that makes use of an present mannequin with out substantial modification) to a GPAI mannequin supplier (a corporation legally chargeable for a mannequin’s compliance). The Act itself doesn’t specify when this occurs, however the European Fee’s tips on the scope of GPAI obligations, revealed in July 2025, give indicative standards.
In keeping with the rules, a modifier turns into the supplier provided that the modification considerably adjustments 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, typically 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 put up come from these tips, not from the Act itself. The Fee has additionally assessed the voluntary Normal-Goal AI Code of Observe, revealed in July 2025, as an satisfactory means for suppliers to display compliance. Most organizations use state of affairs 2 within the following desk as a result of mannequin suppliers hardly ever publish precise coaching FLOPs. Except you might have documented pretraining compute out of your mannequin supplier, the rules give a default threshold of three.3×10²² FLOPs. The Fee’s tips describe three situations and thresholds:
| State of affairs | Threshold |
| Pretraining compute is thought and ≥ 10²³ FLOPs | 30% of the particular pretraining compute |
| Pretraining compute is unknown or < 10²³ FLOPs | Default threshold of three.3×10²² FLOPs |
| Systemic Danger Fashions (Pre-training FLOPs ≥ 10²⁵ FLOPs) | 3.3×10²⁴ FLOPs (if base compute is unknown) |
The Effective-Tuning FLOPs Meter mechanically determines which state of affairs applies primarily based on whether or not you present the PRETRAIN_FLOPS atmosphere variable. That will help you shortly decide which threshold path applies, use the next resolution movement:
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 your pretraining compute, evaluate it in opposition to the next orders of magnitude:
-
Is pretraining compute ≥ 10²⁵ FLOPs?
- Sure: You fall underneath the Systemic Danger 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 edge at 4.5×10²³ FLOPs. Underneath the Fee’s tips, exceeding this threshold is a sign that you could be develop into the supplier of the modified mannequin. For what to contemplate in that case, see What if you happen to exceed the edge? later on this put up.
The AI Act units fines in two locations. Article 99 units tiered most fines for operators of AI techniques. Every tier is the upper of a hard and fast 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 guide 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 hardly ever revealed.
- Sustaining an audit path (a everlasting document of compliance metrics for regulatory evaluation) 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 edge. The Effective-Tuning FLOPs Meter automates the monitoring course of, addressing these challenges.
Resolution overview
The Effective-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 your entire fine-tuning lifecycle. The next diagram illustrates the compliance workflow.
The toolkit covers three levels of the fine-tuning lifecycle, with runtime monitoring because the core functionality.
First stage: an elective pre-training estimation utility you can run to check 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 NVIDIA Administration Library (NVML).
Third stage: a post-training audit path mechanically shops full compliance metrics in JSON format. You may persist outcomes to Amazon Easy Storage Service (Amazon S3) or Amazon DynamoDB.
You may choose in with a single configuration line (compute_flops: true). The FLOPs Meter contains parameter-efficient consciousness utilizing an enhanced components 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 together with your coaching workflow on Amazon SageMaker AI.
Stipulations
You should full the next conditions earlier than you possibly can run the FLOPs Meter walkthrough:
-
Make the next quota enhance 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 situations (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 provide required entry to SageMaker AI to run the examples. -
Assign the next coverage as a belief relationship to your IAM position:
-
(Non-compulsory) Create an Amazon SageMaker Studio area (confer with Use fast setup for Amazon SageMaker AI) to entry Jupyter notebooks with the previous position. You can even use JupyterLab in your native setup.
These permissions grant broad entry and are usually not really useful to be used in manufacturing environments. For steerage on defining extra fine-grained permissions, confer with the SageMaker AI Developer Information.
FLOPs calculation formulation
For compliance reporting, use the analytical technique (Flops_architecture) as your major metric. The toolkit additionally calculates a hardware-based higher sure for conservative reporting. Each strategies run mechanically. The next sections describe the implementation particulars.
The Fee’s tips (Part A.2.1) describe two approaches for estimating coaching compute:
- Structure-based strategy (analytical):
The Fee’s tips 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 components 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 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 components within the tips. For LoRA or Spectrum, it offers a extra correct (and decrease) estimate, reflecting that fewer parameters obtain gradient updates.
- {Hardware}-based strategy (higher sure):
This strategy makes use of the next components:
C = N_gpus × L × H × U
The place N_gpus is the variety of GPUs, L is coaching length in seconds, H is peak theoretical efficiency (FLOPs), and U is utilization. The FLOPs Meter makes use of U = 1.0 (100% utilization) to provide a conservative higher sure by NVML GPU monitoring.
Threshold logic
The toolkit implements the edge logic from the Fee’s tips 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 elective PRETRAIN_FLOPS atmosphere 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 revealed precise pretraining FLOPs for this mannequin, the walkthrough doesn’t set PRETRAIN_FLOPS, and the software makes use of the default threshold from the Fee’s tips: 3.3×10²² FLOPs.
Pre-training estimation (elective)
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 edge from the Fee’s tips. The estimation utility is separate from the core runtime monitoring and you may 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 information 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 sure, determines the relevant threshold, and writes the whole 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 are usually not recognized for this mannequin, the PRETRAIN_FLOPS atmosphere variable is omitted. The default threshold is utilized mechanically.
Compliance documentation
At coaching completion, the callback generates a flops_meter.json file containing the coaching compute metrics:
Use Flops_architecture as your major compliance metric. It precisely displays your precise coaching configuration. Flops_hardware offers a conservative higher sure and may function a security margin for extra-cautious reporting.
Different key fields embrace 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 edge, and Flops_original, which is null when pretraining FLOPs are usually not offered.
The pipeline mechanically uploads this file to Amazon S3 and shops it in Amazon DynamoDB, making a persistent audit path throughout coaching runs.
What if you happen to exceed the edge?
If exceeds_30pct is true, your job’s compute is above the edge that the Fee’s tips use as an indicative criterion. This alone doesn’t decide whether or not you develop into the supplier of a GPAI mannequin. The rules state {that a} case-by-case evaluation is all the time needed. Concerns for that evaluation could embrace 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 acquainted with 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 nicely under the three.3×10²² threshold. Nonetheless, full fine-tuning on the identical dataset consumes roughly 1.9×10¹⁹ FLOPs, bringing you nearer to the edge.
For many LoRA fine-tuning jobs on fashions underneath 10B parameters, you stay nicely under the edge even with tens of millions of coaching tokens.
Getting began
The FLOPs Meter is obtainable as a part of the Amazon SageMaker Generative AI recipes repository.
What you want
Earlier than you start, ensure you 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 start out 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-compulsory) If the pretraining FLOPs on your base mannequin, set the atmosphere 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, evaluation the generated
flops_meter.jsonfile in your Amazon S3 output location. You must see a JSON file containing FLOPs metrics and the edge comparability.
For a deeper take a look at the implementation, see the supply code for flops_meter.py.
Clear up
To keep away from ongoing costs, 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.jsonrecordsdata and select Delete. - Or delete your entire bucket if you happen to created it particularly for this walkthrough.
-
Delete the Amazon DynamoDB desk if you happen to created one particularly for this walkthrough:
-
Take away SageMaker AI endpoints if you happen to deployed your fine-tuned mannequin.
Conclusion
On this put up, we confirmed you the way to implement FLOPs monitoring throughout LLM fine-tuning on Amazon SageMaker AI. You realized how the Effective-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 tips to check your job’s compute with the relevant threshold, and the way to document the ends in a JSON file with a single configuration flag.
With this tooling, you possibly can concentrate on constructing fashions whereas sustaining full transparency into your computational footprint.
To get began, clone the repository and run the pre-training estimation software together with your deliberate mannequin and dataset. For extra details about constructing compliance-aligned AI techniques on AWS, see the Amazon SageMaker AI documentation.
Concerning the authors


