惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Fortinet All Blogs
S
Secure Thoughts
月光博客
月光博客
美团技术团队
雷峰网
雷峰网
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
N
News and Events Feed by Topic
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Forbes - Security
Forbes - Security
W
WeLiveSecurity
P
Proofpoint News Feed
阮一峰的网络日志
阮一峰的网络日志
爱范儿
爱范儿
G
GRAHAM CLULEY
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
AI
AI
Last Week in AI
Last Week in AI
Google Online Security Blog
Google Online Security Blog
Schneier on Security
Schneier on Security
云风的 BLOG
云风的 BLOG
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Recent Announcements
Recent Announcements
Webroot Blog
Webroot Blog
T
Tor Project blog
Cisco Talos Blog
Cisco Talos Blog
N
News and Events Feed by Topic
罗磊的独立博客
The Register - Security
The Register - Security
Blog — PlanetScale
Blog — PlanetScale
T
Threat Research - Cisco Blogs
博客园 - 【当耐特】
Apple Machine Learning Research
Apple Machine Learning Research
人人都是产品经理
人人都是产品经理
T
The Exploit Database - CXSecurity.com
www.infosecurity-magazine.com
www.infosecurity-magazine.com
B
Blog
腾讯CDC
Microsoft Azure Blog
Microsoft Azure Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Engineering at Meta
Engineering at Meta
Latest news
Latest news
IT之家
IT之家
D
DataBreaches.Net
博客园 - 司徒正美
N
Netflix TechBlog - Medium
V
V2EX
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

Hacker News - Newest: "LLM"

GitHub - lechmazur/position_bias: A benchmark for testing whether LLM judges keep the same preference when two lightly edited versions of the same story are shown in opposite orders. Flex routing (EU and EFTA) Dark Factories: Retooling for LLM Velocity Ask HN: What would be the impact of a LLM output injection attack? GitHub - AronDaron/dataset-generator: No-code desktop app for generating high-quality synthetic datasets to fine-tune LLMs — plan-then-execute pipeline, LLM-as-judge, HuggingFace upload. GitHub - Oaklight/llm-rosetta: Production-ready LLM API translation layer for Python — bidirectional conversion between OpenAI, Anthropic & Google formats via hub-and-spoke IR. Optional API gateway. Streaming & non-streaming. Zero core deps. Contributions welcome! GitHub - browser-use/browser-harness: Self-healing browser harness that enables LLMs to complete any task. GitHub - moeen-mahmud/remen: Remen turns thoughts into something you can return to Analyzing 156 LLM Launch Posts on Hacker News ChatGPT vs Gemini vs Claude: The Best LLM Subscription You Should Buy GitHub - salaamalykum/quran-semantic-search: High-density RAG Semantic Search Engine & Quran Corpus (GEO/SEO Architecture) GitHub - NVIDIA/TensorRT-LLM: TensorRT LLM provides users with an easy-to-use Python API to define Large Language Models (LLMs) and supports state-of-the-art optimizations to perform inference efficiently on NVIDIA GPUs. TensorRT LLM also contains components to create Python and C++ runtimes that orchestrate the inference execution in a performant way. The State of LLM Bug Bounties in 2026 Operational Readiness Criteria for Tool-Using LLM Agents Meshcore: Architecture for a Decentralized P2P LLM Inference Network How an LLM becomes more coherent as we train it GitHub - seetrex-ai/laimark GitHub - Jossifresben/BibCrit: AI-assited biblical textual criticism GitHub - wastedcode/memex: File system based wiki, maintained by Claude 99helpers.com GitHub - cliver-project/AITrigram GitHub - unbody-io/adapt: A self-evolving memory layer for AI agents. GitHub - hb20007/awesome-gen-ai-fails: A list of incidents where reliance on generative AI and LLMs resulted in harm to companies, individuals, or society GitHub - nevenkordic/localmind: Run any local LLM with persistent memory and context. CLI agent over Ollama with SQLite-backed hybrid recall. No cloud. Ask HN: What are the machine requirements for a LLM like Llama-3.1-8B? Faster LLM Inference via Sequential Monte Carlo grpo explained: group relative policy optimization for llm finetuning - cgft Stop comparing price per million tokens: the hidden LLM API costs · TensorZero Andrej Karpathy's LLM Wiki Is a Bad Idea GitHub - GG-QandV/mnemostroma: Offline RAM-first cognitive leer/coprocessor for AI agents and robotics. Solves "Context Abandonment" with 20-80ms latency using a dual-thread biomimetic memory architecture (ONNX + SQLite WAL). mempalace/agent at agent · skorotkiewicz/mempalace GitHub - Nyquest-ai/nyquest-rust-fullstack-pub: Nyquest — Semantic Compression Proxy for LLMs. 350+ rules, local LLM stage, 15-75% token savings. Full Rust stack. GitHub - TheoV823/mneme: Enforce architectural decisions in AI-assisted development. GitHub - klemenvod/TokenBrawl: A 1v1 Bomberman-style game where two LLM agents play autonomously against each other. No human plays — you watch the AIs fight. Each agent receives a text description of the board state, reasons about it, and outputs a move as JSON. The game engine executes it. Introducing the Common AI Provider: LLM and AI Agent Support for Apache Airflow Power Circuit AI: Designing Power Electronic Circuits for Motor Drives with Generative Artificial Intelligence Ask HN: How to program with IDE and LLM on CPU locally? Show HN: Agent-cache – Multi-tier LLM/tool/session caching for Valkey and Redis Bonsai 1-bit WebGPU - a Hugging Face Space by webml-community The LLM Fallacy: Misattribution in AI-Assisted Cognitive Workflows Ask HN: Simple tooling for local LLM code critique without IDE integration? Can a General LLM Diagnose a DICOM Slice? A 10-Case Public Benchmark Charts-of-Thought: Enhancing LLM Visualization Literacy (PDF, 2026) GitHub - Mesh-LLM/mesh-llm: Distributed AI/LLM for the people. Share compute privately or publicly to power your agents and chat. GitHub - seamus-brady/springdrift: A persistent runtime for long-lived LLM agents Writing an LLM from scratch, part 32k -- Interventions: training a better model locally with gradient accumulation Ask HN: Which LLM model and agentic CLI are you using for local development? GitHub - wayneColt/modelcascade: Route local. Escalate smart. Never overspend. Open-source multi-model cascade routing for autonomous agents. LLM pricing is 100x harder than you think GitHub - asakin/llm-primer: Pre-warmed Claude Code sessions in tmux. No startup wait. GitHub - EggerMarc/chat-rs: A multi-provider LLM framework for Rust. GitHub - SynapseKit/SynapseKit: Minimal, async-first Python framework for production LLM apps- 2 hard deps, no magic, no SaaS. A Claude Skill that Makes LLM Paragraphs More Bearable Does Gas Town 'steal' usage from users' LLM credits & paid services to improve itself? What's Claude Code Actually Doing? Open the Black Box with the Arthur Engine Milla Jovovich's New Open Source LLM Memory App and the Dark Code Problem Your intuition of LLM token usage might be wrong Show HN: Bloomberg Terminal for LLM ops – free and open source GitHub - 0xchamin/mcptube: Transform YouTube videos into a compounding knowledge base with transcripts, vision analysis, and agentic search. Works as an MCP server for Claude, Copilot & more. Show HN: Open KB: Open LLM Knowledge Base Your LLM is a compiler, not a runtime GitHub - sapountzis/Unslop: A Web Feed That Deserves You crates.io: Rust Package Registry Beyond Karpathy's LLM-Wiki: The Necessity of Cognitive Governance GitHub - amitshekhariitbhu/llm-internals: Learn LLM internals step by step - from tokenization to attention to inference optimization. GitHub - parallem-ai/parallem: An expressive library for running agents with the Batch API. GitHub - stfurkan/pi-llm LLM-Wiki Show HN: Formal – Formal verification for AI-generated code using Lean 4 LRTS – Regression testing for LLM prompts (open source, local-first) LLM Wiki Skill: Build a Second Brain with Claude Code and Obsidian I built an LLM Wiki and RAG solution: here's a demo for a security KB The biggest advance in AI since the LLM Predict-Rlm: The LLM Runtime That Lets Models Write Their Own Control Flow the-synthetic-library/the-synthetic-mind at main · joshferrer1/the-synthetic-library GitHub - yisding/reviewwiggum GitHub - Donnyb369/mcp-spine: Context Minifier & State Guard — Local-first MCP middleware proxy GitHub - Beledarian/wgpu-llm: A from-scratch LLM inference engine that uses wgpu (the cross-platform WebGPU implementation) to dispatch WGSL compute shaders for every math operation a Transformer needs. No CUDA. No Python. No massive framework dependencies. Just Rust, raw shaders, and your GPU. GitHub - anitiue/Hindsight: An experience-driven self-improvement framework for LLM agents — 基于经验的 LLM Agent 自我改进框架 GitHub - stef41/lmscan: 🔍 Detect AI-generated text and fingerprint which LLM wrote it. Open-source GPTZero alternative. Zero dependencies, works offline. GitHub - alainnothere/AmdPerformanceTesting: Amd Performance Testing Ask HN: Is a purely Markdown-based CRM a terrible idea? Optimized for LLM agents Context Engineering - LLM Memory and Retrieval for AI Agents | Weaviate little_helper_tui/letter.md at main · sleepyeldrazi/little_helper_tui GitHub - EvanZhouDev/umr: The Unified Model Registry for all your local AI apps. GitHub - JordanCT/VigIA-Orchestrator Your Agent Is Mine: Measuring Malicious Intermediary Attacks on the LLM Supply Chain A Taxonomy of RL Environments for LLM Agents Llama LLM Network Feture GitHub - genedeng-ca/ai-mac-migration: AI-powered Mac-to-Mac migration tool - replace Apple Migration Assistant with intelligent, selective transfer using local LLMs GitHub - lunargate-ai/gateway: High-performance self-hosted AI gateway (OpenAI-compatible) with routing, retries, and streaming GitHub - AuthBits/webmcp: A lightweight, prompt-driven MCP web research server for high-quality LLM powered information extraction. Externalization in LLM Agents: A Unified Review of Memory, Skills, Protocols and Harness Engineering Springdrift: An Auditable Persistent Runtime for LLM Agents with Case-Based Memory, Normative Safety, and Ambient Self-Perception High-Stakes Personalization: Rethinking LLM Customization for Individual Investor Decision-Making From Static Templates to Dynamic Runtime Graphs: A Survey of Workflow Optimization for LLM Agents HUOZIIME: An On-Device LLM-enhanced Input Method for Deep Personalization TIDE: Token-Informed Depth Execution for Per-Token Early Exit in LLM Inference Characterizing WebGPU Dispatch Overhead for LLM Inference Across Four GPU Vendors, Three Backends, and Three Browsers LLM Targeted Underperformance Disproportionately Impacts Vulnerable Users
Quantization · Hugging Face
Anon84 · 2026-05-01 · via Hacker News - Newest: "LLM"

Quantization techniques reduce memory and computational costs by representing weights and activations with lower-precision data types like 8-bit integers (int8). This enables loading larger models you normally wouldn’t be able to fit into memory, and speeding up inference. Transformers supports the AWQ and GPTQ quantization algorithms and it supports 8-bit and 4-bit quantization with bitsandbytes.

Quantization techniques that aren’t supported in Transformers can be added with the HfQuantizer class.

Learn how to quantize models in the Quantization guide.

QuantoConfig

class transformers.QuantoConfig

< source >

( weights = 'int8' activations = None modules_to_not_convert: list | None = None **kwargs )

Parameters

  • weights (str, optional, defaults to "int8") — The target dtype for the weights after quantization. Supported values are (“float8”,“int8”,“int4”,“int2”)
  • activations (str, optional) — The target dtype for the activations after quantization. Supported values are (None,“int8”,“float8”)
  • modules_to_not_convert (list, optional, default to None) — The list of modules to not quantize, useful for quantizing models that explicitly require to have some modules left in their original precision (e.g. Whisper encoder, Llava encoder, Mixtral gate layers).

This is a wrapper class about all possible attributes and features that you can play with a model that has been loaded using quanto.

Safety checker that arguments are correct

AqlmConfig

class transformers.AqlmConfig

< source >

( in_group_size: int = 8 out_group_size: int = 1 num_codebooks: int = 1 nbits_per_codebook: int = 16 linear_weights_not_to_quantize: list[str] | None = None **kwargs )

Parameters

  • in_group_size (int, optional, defaults to 8) — The group size along the input dimension.
  • out_group_size (int, optional, defaults to 1) — The group size along the output dimension. It’s recommended to always use 1.
  • num_codebooks (int, optional, defaults to 1) — Number of codebooks for the Additive Quantization procedure.
  • nbits_per_codebook (int, optional, defaults to 16) — Number of bits encoding a single codebook vector. Codebooks size is 2**nbits_per_codebook.
  • linear_weights_not_to_quantize (Optional[list[str]], optional) — List of full paths of nn.Linear weight parameters that shall not be quantized.
  • kwargs (dict[str, Any], optional) — Additional parameters from which to initialize the configuration object.

This is a wrapper class about aqlm parameters.

Safety checker that arguments are correct - also replaces some NoneType arguments with their default values.

VptqConfig

class transformers.VptqConfig

< source >

( enable_proxy_error: bool = False config_for_layers: dict = {} shared_layer_config: dict = {} modules_to_not_convert: list | None = None **kwargs )

Parameters

  • enable_proxy_error (bool, optional, defaults to False) — calculate proxy error for each layer
  • config_for_layers (Dict, optional, defaults to {}) — quantization params for each layer
  • shared_layer_config (Dict, optional, defaults to {}) — shared quantization params among layers
  • modules_to_not_convert (list, optional, default to None) — The list of modules to not quantize, useful for quantizing models that explicitly require to have some modules left in their original precision (e.g. Whisper encoder, Llava encoder, Mixtral gate layers).
  • kwargs (dict[str, Any], optional) — Additional parameters from which to initialize the configuration object.

This is a wrapper class about vptq parameters.

Safety checker that arguments are correct

AwqConfig

class transformers.AwqConfig

< source >

( bits: int = 4 group_size: int = 128 zero_point: bool = True backend: AwqBackend = <AwqBackend.AUTO: 'auto'> modules_to_not_convert: list | None = None **kwargs )

Parameters

  • bits (int, optional, defaults to 4) — The number of bits to quantize to.
  • group_size (int, optional, defaults to 128) — The group size to use for quantization. Recommended value is 128 and -1 uses per-column quantization.
  • zero_point (bool, optional, defaults to True) — Whether to use zero point quantization.
  • backend (AwqBackend, optional, defaults to AwqBackend.AUTO) — The quantization backend.
  • modules_to_not_convert (list, optional, default to None) — The list of modules to not quantize, useful for quantizing models that explicitly require to have some modules left in their original precision (e.g. Whisper encoder, Llava encoder, Mixtral gate layers). Note you cannot quantize directly with transformers, please refer to AutoAWQ documentation for quantizing HF models.

This is a wrapper class about all possible attributes and features that you can play with a model that has been loaded using auto-awq library awq quantization relying on auto_awq backend.

EetqConfig

class transformers.EetqConfig

< source >

( weights: str = 'int8' modules_to_not_convert: list | None = None **kwargs )

Parameters

  • weights (str, optional, defaults to "int8") — The target dtype for the weights. Supported value is only “int8”
  • modules_to_not_convert (list, optional, default to None) — The list of modules to not quantize, useful for quantizing models that explicitly require to have some modules left in their original precision.

This is a wrapper class about all possible attributes and features that you can play with a model that has been loaded using eetq.

Safety checker that arguments are correct

GPTQConfig

class transformers.GPTQConfig

< source >

( bits: int tokenizer: typing.Any = None dataset: list[str] | str | None = None group_size: int = 128 damp_percent: float = 0.1 desc_act: bool = False act_group_aware: bool = True sym: bool = True true_sequential: bool = True format: str = 'gptq' meta: dict[str, typing.Any] | None = None backend: str | None = None model_seqlen: int | None = None block_name_to_quantize: str | None = None module_name_preceding_first_block: list[str] | None = None batch_size: int = 1 pad_token_id: int | None = None max_input_length: int | None = None cache_block_outputs: bool = True modules_in_block_to_quantize: list[list[str]] | None = None **kwargs )

Parameters

  • bits (int) — The number of bits to quantize to, supported numbers are (2, 3, 4, 8).
  • tokenizer (str or PreTrainedTokenizerBase, optional) — The tokenizer used to process the dataset. You can pass either:
    • A custom tokenizer object.
    • A string, the model id of a predefined tokenizer hosted inside a model repo on huggingface.co.
    • A path to a directory containing vocabulary files required by the tokenizer, for instance saved using the save_pretrained() method, e.g., ./my_model_directory/.
  • dataset (Union[list[str]], optional) — The dataset used for quantization. You can provide your own dataset in a list of string or just use the original datasets used in GPTQ paper [‘wikitext2’,‘c4’,‘c4-new’]
  • group_size (int, optional, defaults to 128) — The group size to use for quantization. Recommended value is 128 and -1 uses per-column quantization.
  • damp_percent (float, optional, defaults to 0.1) — The percent of the average Hessian diagonal to use for dampening. Recommended value is 0.1.
  • desc_act (bool, optional, defaults to False) — Whether to quantize columns in order of decreasing activation size. Setting it to False can significantly speed up inference but the perplexity may become slightly worse. Also known as act-order.
  • act_group_aware (bool, optional, defaults to True) — Use GAR (group aware activation order) during quantization. Has measurable positive impact on quantization quality. Only applicable when desc_act = False. Will forced to be False when desc_act = True.
  • sym (bool, optional, defaults to True) — Whether to use symmetric quantization.
  • true_sequential (bool, optional, defaults to True) — Whether to perform sequential quantization even within a single Transformer block. Instead of quantizing the entire block at once, we perform layer-wise quantization. As a result, each layer undergoes quantization using inputs that have passed through the previously quantized layers.
  • format (str, optional, defaults to "gptq") — GPTQ weight format. gptq (v1) is supported by gptqmodel. gptq_v2 is gptqmodel only.
  • meta (dict[str, any], optional) — Properties, such as tooling:version, that do not directly contributes to quantization or quant inference are stored in meta. i.e. meta.quantizer: [“optimum:version”, “gptqmodel:version”]
  • backend (str, optional) — Controls which kernel to use. Valid values for gptqmodel are auto, auto_trainable and more. Ref gptqmodel backends: https://github.com/ModelCloud/GPTQModel/blob/main/gptqmodel/utils/backend.py
  • model_seqlen (int, optional) — The maximum sequence length that the model can take.
  • block_name_to_quantize (str, optional) — The transformers block name to quantize. If None, we will infer the block name using common patterns (e.g. model.layers)
  • module_name_preceding_first_block (list[str], optional) — The layers that are preceding the first Transformer block.
  • batch_size (int, optional, defaults to 1) — The batch size used when processing the dataset
  • pad_token_id (int, optional) — The pad token id. Needed to prepare the dataset when batch_size > 1.
  • max_input_length (int, optional) — The maximum input length. This is needed to initialize a buffer that depends on the maximum expected input length. It is specific to the exllama backend with act-order.
  • cache_block_outputs (bool, optional, defaults to True) — Whether to cache block outputs to reuse as inputs for the succeeding block.
  • modules_in_block_to_quantize (list[list[str]], optional) — List of list of module names to quantize in the specified block. This argument is useful to exclude certain linear modules from being quantized. The block to quantize can be specified by setting block_name_to_quantize. We will quantize each list sequentially. If not set, we will quantize all linear layers. Example: modules_in_block_to_quantize =[["self_attn.k_proj", "self_attn.v_proj", "self_attn.q_proj"], ["self_attn.o_proj"]]. In this example, we will first quantize the q,k,v layers simultaneously since they are independent. Then, we will quantize self_attn.o_proj layer with the q,k,v layers quantized. This way, we will get better results since it reflects the real input self_attn.o_proj will get when the model is quantized.

This is a wrapper class about all possible attributes and features that you can play with a model that has been loaded using optimum api for GPTQ quantization relying on the gptqmodel backend.

Get compatible class with optimum gptq config dict

Safety checker that arguments are correct

Get compatible dict for optimum gptq config

BitsAndBytesConfig

class transformers.BitsAndBytesConfig

< source >

( load_in_8bit = False load_in_4bit = False llm_int8_threshold = 6.0 llm_int8_skip_modules = None llm_int8_enable_fp32_cpu_offload = False llm_int8_has_fp16_weight = False bnb_4bit_compute_dtype = None bnb_4bit_quant_type = 'fp4' bnb_4bit_use_double_quant = False bnb_4bit_quant_storage = None **kwargs )

Parameters

  • load_in_8bit (bool, optional, defaults to False) — This flag is used to enable 8-bit quantization with LLM.int8().
  • load_in_4bit (bool, optional, defaults to False) — This flag is used to enable 4-bit quantization by replacing the Linear layers with FP4/NF4 layers from bitsandbytes.
  • llm_int8_threshold (float, optional, defaults to 6.0) — This corresponds to the outlier threshold for outlier detection as described in LLM.int8() : 8-bit Matrix Multiplication for Transformers at Scale paper: https://huggingface.co/papers/2208.07339 Any hidden states value that is above this threshold will be considered an outlier and the operation on those values will be done in fp16. Values are usually normally distributed, that is, most values are in the range [-3.5, 3.5], but there are some exceptional systematic outliers that are very differently distributed for large models. These outliers are often in the interval [-60, -6] or [6, 60]. Int8 quantization works well for values of magnitude ~5, but beyond that, there is a significant performance penalty. A good default threshold is 6, but a lower threshold might be needed for more unstable models (small models, fine-tuning).
  • llm_int8_skip_modules (list[str], optional) — An explicit list of the modules that we do not want to convert in 8-bit. This is useful for models such as Jukebox that has several heads in different places and not necessarily at the last position. For example for CausalLM models, the last lm_head is kept in its original dtype.
  • llm_int8_enable_fp32_cpu_offload (bool, optional, defaults to False) — This flag is used for advanced use cases and users that are aware of this feature. If you want to split your model in different parts and run some parts in int8 on GPU and some parts in fp32 on CPU, you can use this flag. This is useful for offloading large models such as google/flan-t5-xxl. Note that the int8 operations will not be run on CPU.
  • llm_int8_has_fp16_weight (bool, optional, defaults to False) — This flag runs LLM.int8() with 16-bit main weights. This is useful for fine-tuning as the weights do not have to be converted back and forth for the backward pass.
  • bnb_4bit_compute_dtype (torch.dtype or str, optional, defaults to torch.float32) — This sets the computational type which might be different than the input type. For example, inputs might be fp32, but computation can be set to bf16 for speedups.
  • bnb_4bit_quant_type (str, optional, defaults to "fp4") — This sets the quantization data type in the bnb.nn.Linear4Bit layers. Options are FP4 and NF4 data types which are specified by fp4 or nf4.
  • bnb_4bit_use_double_quant (bool, optional, defaults to False) — This flag is used for nested quantization where the quantization constants from the first quantization are quantized again.
  • bnb_4bit_quant_storage (torch.dtype or str, optional, defaults to torch.uint8) — This sets the storage type to pack the quantized 4-bit params.
  • kwargs (dict[str, Any], optional) — Additional parameters from which to initialize the configuration object.

This is a wrapper class about all possible attributes and features that you can play with a model that has been loaded using bitsandbytes.

Currently only supports LLM.int8(), FP4, and NF4 quantization. If more methods are added to bitsandbytes, then more arguments will be added to this class.

Returns True if the model is quantizable, False otherwise.

Safety checker that arguments are correct - also replaces some NoneType arguments with their default values.

This method returns the quantization method used for the model. If the model is not quantizable, it returns None.

to_diff_dict

< source >

( ) dict[str, Any]

Returns

dict[str, Any]

Dictionary of all the attributes that make up this configuration instance,

Removes all attributes from config which correspond to the default config attributes for better readability and serializes to a Python dictionary.

HfQuantizer

class transformers.quantizers.HfQuantizer

< source >

( quantization_config: QuantizationConfigMixin **kwargs )

Abstract class of the HuggingFace quantizer. Supports for now quantizing HF transformers models for inference and/or quantization. This class is used only for transformers.PreTrainedModel.from_pretrained and cannot be easily used outside the scope of that method yet.

Attributes quantization_config (transformers.utils.quantization_config.QuantizationConfigMixin): The quantization config that defines the quantization parameters of your model that you want to quantize. requires_calibration (bool): Whether the quantization method requires to calibrate the model before using it.

adjust max_memory argument for infer_auto_device_map() if extra memory is needed for quantization

Potentially dequantize the model to retrieve the original model, with some loss in accuracy / performance. Note not all quantization schemes support this.

Override this method if you want to adjust the param_name.

Get state dict and metadata. Useful when we need to modify a bit the state dict due to quantization

param_needs_quantization

< source >

( model: PreTrainedModel param_name: str **kwargs )

Check whether a given param needs to be quantized.

postprocess_model

< source >

( model: PreTrainedModel **kwargs )

Parameters

  • model (~transformers.PreTrainedModel) — The model to quantize
  • kwargs (dict, optional) — The keyword arguments that are passed along _process_model_after_weight_loading.

Post-process the model post weights loading. Make sure to override the abstract method _process_model_after_weight_loading.

preprocess_model

< source >

( model: PreTrainedModel dtype = None **kwargs )

Parameters

  • model (~transformers.PreTrainedModel) — The model to quantize
  • kwargs (dict, optional) — The keyword arguments that are passed along _process_model_before_weight_loading.

Setting model attributes and/or converting model before weights loading. At this point the model should be initialized on the meta device so you can freely manipulate the skeleton of the model in order to replace modules in-place. Make sure to override the abstract method _process_model_before_weight_loading.

Remove the quantization config from the model.

update_device_map

< source >

( device_map: dict[str, typing.Any] | None )

Parameters

  • device_map (Union[dict, str], optional) — The device_map that is passed through the from_pretrained method.

Override this method if you want to pass a override the existing device map with a new one. E.g. for bitsandbytes, since accelerate is a hard requirement, if no device_map is passed, the device_map is set to `“auto”“

update_dtype

< source >

( dtype: torch.dtype )

Parameters

  • dtype (torch.dtype) — The input dtype that is passed in from_pretrained

Some quantization methods require to explicitly set the dtype of the model to a target dtype. You need to override this method in case you want to make sure that behavior is preserved

updates the tp plan for the scales

updates the tp plan for the scales

This method is used to potentially check for potential conflicts with arguments that are passed in from_pretrained. You need to define it for all future quantizers that are integrated with transformers. If no explicit check are needed, simply return nothing.

HiggsConfig

class transformers.HiggsConfig

< source >

( bits: int = 4 p: int = 2 modules_to_not_convert: list[str] | None = None hadamard_size: int = 512 group_size: int = 256 tune_metadata: dict[str, typing.Any] | None = None **kwargs )

Parameters

  • bits (int, optional, defaults to 4) — Number of bits to use for quantization. Can be 2, 3 or 4. Default is 4.
  • p (int, optional, defaults to 2) — Quantization grid dimension. 1 and 2 are supported. 2 is always better in practice. Default is 2.
  • modules_to_not_convert (list, optional, default to [“lm_head”]) — List of linear layers that should not be quantized.
  • hadamard_size (int, optional, defaults to 512) — Hadamard size for the HIGGS method. Default is 512. Input dimension of matrices is padded to this value. Decreasing this below 512 will reduce the quality of the quantization.
  • group_size (int, optional, defaults to 256) — Group size for the HIGGS method. Can be 64, 128 or 256. Decreasing it barely affects the performance. Default is 256. Must be a divisor of hadamard_size.
  • tune_metadata (‘dict’, optional, defaults to {}) — Module-wise metadata (gemm block shapes, GPU metadata, etc.) for saving the kernel tuning results. Default is an empty dictionary. Is set automatically during tuning.

HiggsConfig is a configuration class for quantization using the HIGGS method.

Safety checker that arguments are correct - also replaces some NoneType arguments with their default values.

HqqConfig

class transformers.HqqConfig

< source >

( nbits: int = 4 group_size: int = 64 view_as_float: bool = False axis: int | None = None dynamic_config: dict | None = None skip_modules: list = ['lm_head'] **kwargs )

Parameters

  • nbits (int, optional, defaults to 4) — Number of bits. Supported values are (8, 4, 3, 2, 1).
  • group_size (int, optional, defaults to 64) — Group-size value. Supported values are any value that is divisible by weight.shape[axis]).
  • view_as_float (bool, optional, defaults to False) — View the quantized weight as float (used in distributed training) if set to True.
  • axis (Optional[int], optional) — Axis along which grouping is performed. Supported values are 0 or 1.
  • dynamic_config (dict, optional) — Parameters for dynamic configuration. The key is the name tag of the layer and the value is a quantization config. If set, each layer specified by its id will use its dedicated quantization configuration.
  • skip_modules (list[str], optional, defaults to ['lm_head']) — List of nn.Linear layers to skip.
  • kwargs (dict[str, Any], optional) — Additional parameters from which to initialize the configuration object.

This is wrapper around hqq’s BaseQuantizeConfig.

Override from_dict, used in AutoQuantizationConfig.from_dict in quantizers/auto.py

Safety checker that arguments are correct - also replaces some NoneType arguments with their default values.

to_diff_dict

< source >

( ) dict[str, Any]

Returns

dict[str, Any]

Dictionary of all the attributes that make up this configuration instance,

Removes all attributes from config which correspond to the default config attributes for better readability and serializes to a Python dictionary.

MetalConfig

class transformers.MetalConfig

< source >

( bits: int = 4 group_size: int = 64 modules_to_not_convert: list | None = None dequantize: bool = False **kwargs )

Configuration class for Metal affine quantization targeting Apple Silicon (MPS) devices.

This quantization method uses the mlx-quantization-metal-kernels Metal kernels from the Hugging Face Hub to perform affine quantization (scales + qbiases) with configurable bit-width and group size. The quantized weights are packed into uint32 tensors and the forward pass uses fused dequantization + matmul Metal kernels.

Mxfp4Config

class transformers.Mxfp4Config

< source >

( modules_to_not_convert: list | None = None dequantize: bool = False **kwargs )

Parameters

  • modules_to_not_convert (list, optional, default to None) — The list of modules to not quantize, useful for quantizing models that explicitly require to have some modules left in their original precision.
  • dequantize (bool, optional, default to False) — Whether we dequantize the model to bf16 precision or not

This is a wrapper class about all possible attributes and features that you can play with a model that has been loaded using mxfp4 quantization.

FbgemmFp8Config

class transformers.FbgemmFp8Config

< source >

( activation_scale_ub: float = 1200.0 modules_to_not_convert: list | None = None **kwargs )

Parameters

  • activation_scale_ub (float, optional, defaults to 1200.0) — The activation scale upper bound. This is used when quantizing the input activation.
  • modules_to_not_convert (list, optional, default to None) — The list of modules to not quantize, useful for quantizing models that explicitly require to have some modules left in their original precision.

This is a wrapper class about all possible attributes and features that you can play with a model that has been loaded using fbgemm fp8 quantization.

CompressedTensorsConfig

class transformers.CompressedTensorsConfig

< source >

( config_groups: dict[str, typing.Union[ForwardRef('QuantizationScheme'), list[str]]] | None = None format: str = 'dense' quantization_status: QuantizationStatus = 'initialized' kv_cache_scheme: typing.Optional[ForwardRef('QuantizationArgs')] = None global_compression_ratio: float | None = None ignore: list[str] | None = None sparsity_config: dict[str, typing.Any] | None = None quant_method: str = 'compressed-tensors' run_compressed: bool = True **kwargs )

Parameters

  • config_groups (typing.dict[str, typing.Union[ForwardRef('QuantizationScheme'), typing.list[str]]], optional) — dictionary mapping group name to a quantization scheme definition
  • format (str, optional, defaults to "dense") — format the model is represented as. Set run_compressed True to execute model as the compressed format if not dense
  • quantization_status (QuantizationStatus, optional, defaults to "initialized") — status of model in the quantization lifecycle, ie ‘initialized’, ‘calibration’, ‘frozen’
  • kv_cache_scheme (typing.Union[QuantizationArgs, NoneType], optional) — specifies quantization of the kv cache. If None, kv cache is not quantized.
  • global_compression_ratio (typing.Union[float, NoneType], optional) — 0-1 float percentage of model compression
  • ignore (typing.Union[typing.list[str], NoneType], optional) — layer names or types to not quantize, supports regex prefixed by ‘re:’
  • sparsity_config (typing.dict[str, typing.Any], optional) — configuration for sparsity compression
  • quant_method (str, optional, defaults to "compressed-tensors") — do not override, should be compressed-tensors
  • run_compressed (bool, optional, defaults to True) — alter submodules (usually linear) in order to emulate compressed model execution if True, otherwise use default submodule

This is a wrapper class that handles compressed-tensors quantization config options. It is a wrapper around compressed_tensors.QuantizationConfig

from_dict

< source >

( config_dict return_unused_kwargs = False **kwargs ) QuantizationConfigMixin

Parameters

  • config_dict (dict[str, Any]) — Dictionary that will be used to instantiate the configuration object.
  • return_unused_kwargs (bool,optional, defaults to False) — Whether or not to return a list of unused keyword arguments. Used for from_pretrained method in PreTrainedModel.
  • kwargs (dict[str, Any]) — Additional parameters from which to initialize the configuration object.

Returns

QuantizationConfigMixin

The configuration object instantiated from those parameters.

Instantiates a CompressedTensorsConfig from a Python dictionary of parameters. Optionally unwraps any args from the nested quantization_config

Quantization config to be added to config.json

Serializes this instance to a Python dictionary. Returns: dict[str, Any]: Dictionary of all the attributes that make up this configuration instance.

to_diff_dict

< source >

( ) dict[str, Any]

Returns

dict[str, Any]

Dictionary of all the attributes that make up this configuration instance,

Removes all attributes from config which correspond to the default config attributes for better readability and serializes to a Python dictionary.

TorchAoConfig

class transformers.TorchAoConfig

< source >

( quant_type: AOBaseConfig modules_to_not_convert: list | None = None include_input_output_embeddings: bool = False untie_embedding_weights: bool = False **kwargs )

Parameters

  • quant_type (AOBaseConfig) — A torchao AOBaseConfig instance specifying the quantization type, e.g. Int4WeightOnlyConfig(group_size=32), Int8WeightOnlyConfig(), Int8DynamicActivationInt8WeightConfig(), Float8WeightOnlyConfig(), etc.
  • modules_to_not_convert (list, optional, default to None) — The list of modules to not quantize, useful for quantizing models that explicitly require to have some modules left in their original precision.
  • include_input_output_embeddings (bool, optional, defaults to False) — Whether to include embedding in quantization or not, input embedding will be removed from the module_not_to_convert list as well if this flag is set.
  • untie_embedding_weights (bool, optional, defaults to False) — Whether to untie the weights when we are quantizing input embedding weights that is tied to other weights.

Config class for torchao quantization/sparsity techniques.

Example:

from torchao.quantization import Int4WeightOnlyConfig

quantization_config = TorchAoConfig(Int4WeightOnlyConfig(group_size=32))
model = AutoModelForCausalLM.from_pretrained(
    model_id, device_map="cuda", torch_dtype=torch.bfloat16, quantization_config=quantization_config
)

from_dict

< source >

( config_dict return_unused_kwargs = False **kwargs )

Create configuration from a dictionary.

Return the quantization config to apply.

Validate configuration and set defaults.

Convert configuration to a dictionary.

BitNetQuantConfig

class transformers.BitNetQuantConfig

< source >

( modules_to_not_convert: list | None = None linear_class: str = 'bitlinear' quantization_mode: str = 'offline' use_rms_norm: bool = False rms_norm_eps: float | None = 1e-06 **kwargs )

Parameters

  • modules_to_not_convert (Optional[List], optional) — Optionally, provides a list of full paths of nn.Linear weight parameters that shall not be quantized. Defaults to None.
  • linear_class (str, optional, defaults to "bitlinear") — The type of linear class to use. Can be either bitlinear or autobitlinear.
  • quantization_mode (str, optional, defaults to "offline") — The quantization mode to use. Can be either online or offline. In online mode, the weight quantization parameters are calculated dynamically during each forward pass (e.g., based on the current weight values). This can adapt to weight changes during training (Quantization-Aware Training - QAT). In offline mode, quantization parameters are pre-calculated before inference. These parameters are then fixed and loaded into the quantized model. This generally results in lower runtime overhead compared to online quantization.
  • use_rms_norm (bool, optional, defaults to False) — Whether to apply RMSNorm on the activations before quantization. This matches the original BitNet paper’s approach of normalizing activations before quantization/packing.
  • rms_norm_eps (float, optional, defaults to 1e-06) — The epsilon value used in the RMSNorm layer for numerical stability.
  • kwargs (dict[str, Any], optional) — Additional keyword arguments that may be used by specific quantization backends or future versions.

Configuration class for applying BitNet quantization.

Safety checker that arguments are correct

SpQRConfig

class transformers.SpQRConfig

< source >

( bits: int = 3 beta1: int = 16 beta2: int = 16 shapes: dict[str, int] | None = None modules_to_not_convert: list[str] | None = None **kwargs )

Parameters

  • bits (int, optional, defaults to 3) — Specifies the bit count for the weights and first order zero-points and scales. Currently only bits = 3 is supported.
  • beta1 (int, optional, defaults to 16) — SpQR tile width. Currently only beta1 = 16 is supported.
  • beta2 (int, optional, defaults to 16) — SpQR tile height. Currently only beta2 = 16 is supported.
  • shapes (Optional, optional) — A dictionary holding the shape of each object. We need this because it’s impossible to deduce the exact size of the parameters just from bits, beta1, beta2.
  • modules_to_not_convert (Optional[list[str]], optional) — Optionally, provides a list of full paths of nn.Linear weight parameters that shall not be quantized. Defaults to None.
  • kwargs (dict[str, Any], optional) — Additional parameters from which to initialize the configuration object.

This is a wrapper class about spqr parameters. Refer to the original publication for more details.

Safety checker that arguments are correct - also replaces some NoneType arguments with their default values.

FineGrainedFP8Config

class transformers.FineGrainedFP8Config

< source >

( activation_scheme: str = 'dynamic' weight_block_size: tuple = (128, 128) dequantize: bool = False modules_to_not_convert: list | None = None **kwargs )

Parameters

  • activation_scheme (str, optional, defaults to "dynamic") — The scheme used for activation, the defaults and only support scheme for now is “dynamic”.
  • weight_block_size (typing.tuple[int, int], optional, defaults to (128, 128)) — The size of the weight blocks for quantization, default is (128, 128).
  • dequantize (bool, optional, defaults to False) — Whether to dequantize the model during loading.
  • modules_to_not_convert (list, optional) — A list of module names that should not be converted during quantization.

FineGrainedFP8Config is a configuration class for fine-grained FP8 quantization used mainly for deepseek models.

Safety checker that arguments are correct

QuarkConfig

class transformers.QuarkConfig

< source >

( **kwargs )

FourOverSixConfig

class transformers.FourOverSixConfig

< source >

( activation_dtype: str | None = None activation_scale_rule: str | None = None dtype: str = 'nvfp4' gradient_dtype: str | None = None gradient_scale_rule: str | None = None keep_master_weights: bool = False matmul_backend: str | None = None output_dtype: str | None = 'bfloat16' quantize_backend: str | None = None scale_rule: str = 'mse' weight_dtype: str | None = None weight_scale_2d: bool = False weight_scale_rule: str | None = None module_config_overrides: dict[str, dict[str, typing.Any]] | None = None modules_to_not_convert: list[str] | None = ['lm_head'] **kwargs )

Parameters

  • activation_dtype (str, optional) — Data type to use when quantizing activation tensors. If not provided, dtype is used.
  • activation_scale_rule (str, optional) — Scaling rule to use when selecting a scale for blocks in activation tensors. If not provided, scale_rule is used.
  • dtype (str, default “nvfp4”, optional, defaults to "nvfp4") — The data type to use for the layer’s weights, activations, and tensors. Can be "nvfp4" or "mxfp4".
  • gradient_dtype (str, optional) — Data type to use when quantizing gradient tensors. If not provided, dtype is used.
  • gradient_scale_rule (str, optional) — Scaling rule to use when selecting a scale for blocks in gradient tensors. If not provided, scale_rule is used.
  • keep_master_weights (bool, default False, optional, defaults to False) — Whether to keep the master weights. If True, high-precision weights are kept at all times and weights are quantized online in each forward pass. This is useful for quantized training.
  • matmul_backend (str, optional) — The backend to use for matrix multiplications. Can be "cutlass" or "pytorch". If not provided, CUTLASS will be used if available and PyTorch will be used otherwise.
  • output_dtype (str, optional, defaults to "bfloat16") — The data type to use for the output of the layer. Can be "bfloat16" or "float16".
  • quantize_backend (str, optional) — The backend to use for quantization. Can be "cuda", "triton", or "pytorch". If not provided, the fastest backend will be selected based on your environment, and based on the options supported by each backend. Typically, "cuda" will be used for inference, "triton" will be used for training, and "pytorch" will be used on non-CUDA devices.
  • scale_rule (str, default “mse”, optional, defaults to "mse") — Rule to use when selecting block scales. Can be "mse", "mae", or "abs_max" for Four Over Six, "static_6" for default NVFP4 quantization, or "static_4" to scale all blocks to a maximum value of 4.
  • weight_dtype (str, optional) — Data type to use when quantizing weight tensors. If not provided, dtype is used.
  • weight_scale_2d (bool, default False, optional, defaults to False) — Whether to compute scale factors on weight tensors in 2D blocks. This should be done during training.
  • weight_scale_rule (str, optional) — Scaling rule to use when selecting a scale for blocks in weight tensors. If not provided, scale_rule is used.
  • module_config_overrides (dict[str, dict[str, Any]], optional) — A dictionary of module-specific configuration overrides. Keys should be module names, and values should be dictionaries containing the quantization configuration for that module. This can be used to override the default configuration for specific modules.
  • modules_to_not_convert (list[str], optional, defaults to ['lm_head']) — The list of modules to exclude from quantization. By default, the lm_head is excluded.

This is a wrapper class containing all options for quantization with fouroversix. In brief, Four Over Six is a modification to NVFP4 quantization which adaptively scales the largest value in each block of 16 FP4 values to either 4 or 6. Selecting a scale of 6 uses the full range of FP4 values, but selecting a scale of 4 allows for a more uniform distribution of quantization error. Refer to the original publication for more details: https://arxiv.org/abs/2512.02010.

FPQuantConfig

class transformers.FPQuantConfig

< source >

( forward_dtype: str = 'nvfp4' forward_method: str = 'abs_max' backward_dtype: str = 'bf16' store_master_weights: bool = False hadamard_group_size: int | None = None pseudoquantization: bool = False transform_init: str = 'hadamard' modules_to_not_convert: list[str] | None = None **kwargs )

Parameters

  • forward_dtype (str, optional, defaults to "nvfp4") — The dtype to use for the forward pass.
  • forward_method (str, optional, defaults to "abs_max") — The scaling to use for the forward pass. Can be "abs_max" or "quest". "abs_max" is better for PTQ, "quest" is better for QAT.
  • backward_dtype (str, optional, defaults to "bf16") — The dtype to use for the backward pass.
  • store_master_weights (bool, optional, defaults to False) — Whether to store the master weights. Needed for QAT over layer weights.
  • hadamard_group_size (int, optional) — The group size for the hadamard transform before quantization for "quest" it matches the MXFP4 group size (32). If None, it will be set to 16 for "nvfp4" and 32 for "mxfp4".
  • pseudoquantization (bool, optional, defaults to False) — Whether to use Triton-based pseudo-quantization. Is mandatory for non-Blackwell GPUs. Doesn’t provide any speedup. For debugging purposes.
  • transform_init (str, optional, defaults to "hadamard") — a method to initialize the pre-processing matrix with. Can be "hadamard", "identity" or "gsr".
  • modules_to_not_convert (list, optional) — The list of modules to not quantize, useful for quantizing models that explicitly require to have some modules left in their original precision.

FPQuantConfig is a configuration class for quantization using the FPQuant method.

Safety checker that arguments are correct - also replaces some NoneType arguments with their default values.

AutoRoundConfig

class transformers.AutoRoundConfig

< source >

( bits: int = 4 group_size: int = 128 sym: bool = True backend: str = 'auto' **kwargs )

Parameters

  • bits (int, optional, defaults to 4) — The number of bits to quantize to, supported numbers are (2, 3, 4, 8).
  • group_size (int, optional, defaults to 128) — Group-size value
  • sym (bool, optional, defaults to True) — Symmetric quantization or not
  • backend (str, optional, defaults to "auto") — The kernel to use, e.g., ipex,marlin, exllamav2, triton, etc. Ref. https://github.com/intel/auto-round?tab=readme-ov-file#specify-backend

This is a wrapper class about all possible attributes and features that you can play with a model that has been loaded AutoRound quantization.

Safety checker that arguments are correct.

SinqConfig

class transformers.SinqConfig

< source >

( nbits: int = 4 group_size: int = 64 tiling_mode: str = '1D' method: str = 'sinq' modules_to_not_convert: list[str] | None = None **kwargs: typing.Any )

Parameters

  • nbits (int, default 4) — Quantization bits for weights.
  • group_size (int, default 64) — Group size used in SINQ weight quantization (must be multiple of 8).
  • tiling_mode (str, default “1D”) — Tiling mode for SINQ (typically “1D”; “2D” if supported in your backend).
  • method (str, default “sinq”) — “sinq” – calibration-free weight-only SINQ “asinq” – A-SINQ (activation-aware), not supported in Hugging Face. Please refer to the official SINQ repository.
  • modules_to_not_convert (list[str], optional) — List of module names/prefixes to keep in full precision.
  • **kwargs — Extra user arguments (kept in _extra_kwargs for round-tripping).

Quantization config for SINQ / A-SINQ.

Pass this to:

AutoModel.from_pretrained(…, quantization_config=SinqConfig(…))

Update on GitHub