From a3aa5bf849b3b7150df8fc84172870077cba03b8 Mon Sep 17 00:00:00 2001 From: kimura-keiji Date: Thu, 6 Aug 2026 22:52:53 +0900 Subject: [PATCH 01/13] Define v1-3-2 --- CHANGELOG.md | 2 ++ onecomp/__version__.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 556995d1..85119d87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Change log +## [v1.3.2] 2026-08-dd + ## [v1.3.1] 2026-08-06 ### Bug Fix diff --git a/onecomp/__version__.py b/onecomp/__version__.py index f21c7223..0919865f 100644 --- a/onecomp/__version__.py +++ b/onecomp/__version__.py @@ -6,4 +6,4 @@ """ -__version__ = "1.3.1" +__version__ = "1.3.2" From 622dae0d2408ff70748d64f6758b615534ec1750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kimura=2C=20Keiji/=E6=9C=A8=E6=9D=91=20=E5=9C=AD=E5=85=90?= Date: Tue, 18 Aug 2026 01:49:40 +0000 Subject: [PATCH 02/13] Modify timelimit in test_cli.py --- tests/onecomp/test_cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/onecomp/test_cli.py b/tests/onecomp/test_cli.py index 9676d64e..9b21465a 100644 --- a/tests/onecomp/test_cli.py +++ b/tests/onecomp/test_cli.py @@ -23,7 +23,7 @@ MODEL_ID = "TinyLlama/TinyLlama-1.1B-intermediate-step-1431k-3T" -TIMEOUT = 1200 +TIMEOUT = 3600 # 1 hour _skip_variant = pytest.mark.skipif( not os.environ.get("RUN_CLI_VARIANT_TESTS"), From 5e8dc73aad4673d71d107402b64f96177e1d2d81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kimura=2C=20Keiji/=E6=9C=A8=E6=9D=91=20=E5=9C=AD=E5=85=90?= Date: Tue, 18 Aug 2026 04:58:47 +0000 Subject: [PATCH 03/13] Add GitLab-CI-Job to check confict-markers --- .gitlab-ci.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8f076434..6b75917c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -23,6 +23,18 @@ variables: GIT_DEPTH: "1" PYTEST_MARKERS: "not slow" +lint:conflict-markers: + stage: lint + tags: + - lint + variables: + # The MR diff base may be outside the default shallow clone. + GIT_DEPTH: "0" + rules: + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + script: + - git diff --check "${CI_MERGE_REQUEST_DIFF_BASE_SHA}" "${CI_COMMIT_SHA}" + lint:format: extends: .skip_docs_only stage: lint From 2a4455b06efccdf39477dfc62a6baa183ddac389 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kimura=2C=20Keiji/=E6=9C=A8=E6=9D=91=20=E5=9C=AD=E5=85=90?= Date: Tue, 18 Aug 2026 05:02:15 +0000 Subject: [PATCH 04/13] fix: remove duplicate MoE unfuse call in load_quantized_model --- CHANGELOG.md | 4 +++ onecomp/quantized_model_loader.py | 25 +++++++++---------- .../test_quantized_model_loader_moe_unfuse.py | 6 +++-- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85119d87..892282fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## [v1.3.2] 2026-08-dd +### Bug Fix + +- Fixed `QuantizedModelLoader.load_quantized_model()` calling `unfuse_moe_experts()` twice on non-fused MoE checkpoints. An earlier unconditional unfuse (run right after building the empty model) was left in place when the checkpoint-aware unfuse (added for gpt-oss fused-MoE support) was introduced. The redundant unconditional call was removed, and the checkpoint-aware unfuse now runs before `_remap_state_dict_keys()` so key remapping still aligns against the unfused per-expert module paths. This also prevents wrongly unfusing gpt-oss fused-MoE checkpoints, whose fused 3D expert tensors must be loaded as-is (`quantized_model_loader.py`). + ## [v1.3.1] 2026-08-06 ### Bug Fix diff --git a/onecomp/quantized_model_loader.py b/onecomp/quantized_model_loader.py index 33e65c14..d885b258 100644 --- a/onecomp/quantized_model_loader.py +++ b/onecomp/quantized_model_loader.py @@ -101,22 +101,14 @@ def load_quantized_model( torch_dtype = torch.bfloat16 model = cls._build_empty_model_from_config(config_dict, torch_dtype) - # Mirror the unfuse step performed before quantization/save (see - # Runner.save_quantized_model) so per-expert module names such as - # "model.layers.0.mlp.experts.0.down_proj" resolve against the - # freshly-built model instead of its fused 3D expert parameters. - if unfuse_moe_experts(model, logger): - logger.info("Unfused MoE expert tensors for quantized model load") - # Load state_dict from safetensors state_dict = cls._load_state_dict_from_dir(save_directory) - # Align checkpoint key prefixes with the empty model built from config. - # Gemma3 VLMs are a common case: weights saved from from_pretrained - # use model.language_model.model.layers. (language_model is a - # ForCausalLM wrapper) while from_config exposes - # model.language_model.layers.* directly. - state_dict = cls._remap_state_dict_keys(state_dict, model) + # Decide, from the checkpoint alone, whether the empty model must be + # unfused into per-expert nn.Linear modules. This must happen before + # _remap_state_dict_keys so remapping aligns checkpoint keys against the + # unfused module paths; fused-MoE checkpoints (e.g. gpt-oss) keep the + # fused 3D parameters and skip unfuse. from .utils.unfuse_moe import ( _checkpoint_uses_fused_moe, _expand_deduped_moe_keys, @@ -131,6 +123,13 @@ def load_quantized_model( elif unfuse_moe_experts(model, logger): logger.info("Unfused MoE expert tensors for quantized model load") + # Align checkpoint key prefixes with the empty model built from config. + # Gemma3 VLMs are a common case: weights saved from from_pretrained + # use model.language_model.model.layers. (language_model is a + # ForCausalLM wrapper) while from_config exposes + # model.language_model.layers.* directly. + state_dict = cls._remap_state_dict_keys(state_dict, model) + # Replace quantized layers with empty modules and align quantized # tensor keys with the actual module names in the model built from # config. This is required when the saved checkpoint and the diff --git a/tests/onecomp/test_quantized_model_loader_moe_unfuse.py b/tests/onecomp/test_quantized_model_loader_moe_unfuse.py index b2c84adf..871da6df 100644 --- a/tests/onecomp/test_quantized_model_loader_moe_unfuse.py +++ b/tests/onecomp/test_quantized_model_loader_moe_unfuse.py @@ -21,7 +21,9 @@ def test_unfuse_moe_experts_runs_before_state_dict_is_loaded(self, tmp_path): # only resolve if the empty model's fused gate_up_proj/down_proj # parameters have already been unfused into per-expert nn.Linear # modules, so unfuse_moe_experts must run before the state_dict is - # materialized against the model. + # materialized against the model. The unfuse decision is made after the + # checkpoint is read from disk (so fused-MoE checkpoints can skip it), + # but still before model.load_state_dict materializes the tensors. fake_model = MagicMock(name="empty_model") call_order = [] @@ -66,7 +68,7 @@ def test_unfuse_moe_experts_runs_before_state_dict_is_loaded(self, tmp_path): mock_unfuse.assert_called_once() assert mock_unfuse.call_args[0][0] is fake_model - assert call_order == ["build", "unfuse", "load_state_dict"] + assert call_order == ["build", "load_state_dict", "unfuse"] class _FakeMoEExpertsBlock(nn.Module): From 34facf3cdd24b09f46d0833f2f67c27197e579cf Mon Sep 17 00:00:00 2001 From: katari Date: Tue, 18 Aug 2026 17:40:20 +0900 Subject: [PATCH 05/13] [fix] Use canonical WikiText dataset ID --- CHANGELOG.md | 7 +++++++ docs/user-guide/examples.md | 2 +- docs/user-guide/post-process.md | 8 ++++---- example/post_process/example_lora_sft.py | 2 +- onecomp/runner.py | 4 ++-- onecomp/utils/perplexity.py | 4 ++-- 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 556995d1..4e705d84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Change log +## [v1.3.2(WIP)+fix/wikitext-hf-dataset-id] 2026-08-18 + +### Bug Fix + +- Fix WikiText dataset loading in clean environments by using the canonical + `Salesforce/wikitext` dataset ID for perplexity evaluation and LoRA SFT examples. + ## [v1.3.1] 2026-08-06 ### Bug Fix diff --git a/docs/user-guide/examples.md b/docs/user-guide/examples.md index fb988aed..cc7aee89 100644 --- a/docs/user-guide/examples.md +++ b/docs/user-guide/examples.md @@ -578,7 +578,7 @@ model_config = ModelConfig( gptq = GPTQ(wbits=4, groupsize=128) post_process = PostProcessLoraSFT( - dataset_name="wikitext", + dataset_name="Salesforce/wikitext", dataset_config_name="wikitext-2-raw-v1", train_split="train", text_column="text", diff --git a/docs/user-guide/post-process.md b/docs/user-guide/post-process.md index 45459a38..4dca6376 100644 --- a/docs/user-guide/post-process.md +++ b/docs/user-guide/post-process.md @@ -354,7 +354,7 @@ model_config = ModelConfig( gptq = GPTQ(wbits=4, groupsize=128) post_process = PostProcessLoraSFT( - dataset_name="wikitext", + dataset_name="Salesforce/wikitext", dataset_config_name="wikitext-2-raw-v1", train_split="train", text_column="text", @@ -512,7 +512,7 @@ model, tokenizer = load_quantized_model_pt( ```python PostProcessLoraSFT( - dataset_name="wikitext", + dataset_name="Salesforce/wikitext", dataset_config_name="wikitext-2-raw-v1", train_split="train", text_column="text", @@ -560,7 +560,7 @@ Teacher distillation aligns the quantized model's output distribution with a ful ```python post_process = PostProcessLoraSFT( - dataset_name="wikitext", + dataset_name="Salesforce/wikitext", dataset_config_name="wikitext-2-raw-v1", train_split="train", text_column="text", @@ -591,7 +591,7 @@ Intermediate block alignment adds a loss term that aligns hidden states at selec ```python post_process = PostProcessLoraSFT( - dataset_name="wikitext", + dataset_name="Salesforce/wikitext", dataset_config_name="wikitext-2-raw-v1", train_split="train", text_column="text", diff --git a/example/post_process/example_lora_sft.py b/example/post_process/example_lora_sft.py index 1bf962eb..03d0c7a4 100644 --- a/example/post_process/example_lora_sft.py +++ b/example/post_process/example_lora_sft.py @@ -66,7 +66,7 @@ def generate_text(model, tokenizer, prompt, device, max_new_tokens=64): gptq = GPTQ(wbits=4, groupsize=128) post_process = PostProcessLoraSFT( - dataset_name="wikitext", + dataset_name="Salesforce/wikitext", dataset_config_name="wikitext-2-raw-v1", train_split="train", text_column="text", diff --git a/onecomp/runner.py b/onecomp/runner.py index b869ef3a..2ffa41d8 100644 --- a/onecomp/runner.py +++ b/onecomp/runner.py @@ -1260,7 +1260,7 @@ def calculate_perplexity( original_model=False, dequantized_model=False, quantized_model=True, - dataset_name="wikitext", + dataset_name="Salesforce/wikitext", dataset_config="wikitext-2-raw-v1", split="test", max_samples=None, @@ -1342,7 +1342,7 @@ def benchmark_perplexity( original_model=True, dequantized_model=False, quantized_model=True, - dataset_name="wikitext", + dataset_name="Salesforce/wikitext", dataset_config="wikitext-2-raw-v1", split="test", max_samples=None, diff --git a/onecomp/utils/perplexity.py b/onecomp/utils/perplexity.py index 8c8742b3..d26c701f 100644 --- a/onecomp/utils/perplexity.py +++ b/onecomp/utils/perplexity.py @@ -41,7 +41,7 @@ def calculate_perplexity( model=None, tokenizer=None, model_config=None, - dataset_name="wikitext", + dataset_name="Salesforce/wikitext", dataset_config="wikitext-2-raw-v1", split="test", max_samples=None, @@ -53,7 +53,7 @@ def calculate_perplexity( Based on https://huggingface.co/docs/transformers/perplexity Args: - dataset_name (str): Dataset name (e.g. "wikitext", "allenai/c4"). + dataset_name (str): Dataset name (e.g. "Salesforce/wikitext", "allenai/c4"). dataset_config (str): Dataset configuration. - For WikiText: "wikitext-2-raw-v1" - For C4: "en/c4-train.00001-of-01024.json.gz" (treated as data_files) From 96609a1a21fcfbbfd9df56cd2cbfd06ccc574507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoshida=2C=20Akihiro/=E5=90=89=E7=94=B0=20=E6=98=8E?= =?UTF-8?q?=E5=BA=83?= Date: Thu, 20 Aug 2026 14:18:58 +0000 Subject: [PATCH 06/13] Clarify CVE-2026-73325 --- CHANGELOG.md | 4 ++-- SECURITY.md | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 892282fc..ca37d95c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -100,11 +100,11 @@ ### Security -- **Unsafe deserialization hardening (CWE-502)**: `QuantizedModelLoader.load_quantized_model_pt()` (alias `onecomp.load_quantized_model_pt()`) previously called `torch.load(model.pt, weights_only=False)` unconditionally, allowing arbitrary code execution when loading a malicious `.pt` checkpoint. It now refuses to load unless the caller explicitly opts in via `allow_unsafe_deserialization=True`, and emits a strong warning when it does load. For untrusted models, use the safetensors-based `load_quantized_model()`, which does not execute code. +- **Unsafe deserialization hardening (CVE-2026-73325, CWE-502)**: `QuantizedModelLoader.load_quantized_model_pt()` (alias `onecomp.load_quantized_model_pt()`) previously called `torch.load(model.pt, weights_only=False)` unconditionally, allowing arbitrary code execution when loading a malicious `.pt` checkpoint. It now refuses to load unless the caller explicitly opts in via `allow_unsafe_deserialization=True`, and emits a strong warning when it does load. For untrusted models, use the safetensors-based `load_quantized_model()`, which does not execute code. - **Breaking change**: existing callers of `load_quantized_model_pt()` must pass `allow_unsafe_deserialization=True` for trusted `.pt` files. - **`Quantizer.load_results()` / `ResultLoader`**: same hardening applied. Loading with `weights_only=False` now requires `allow_unsafe_deserialization=True` (added as a `ResultLoader` field), and logs a warning. The safe `weights_only=True` path is unchanged. - Updated docstrings, docs, and the LoRA SFT example to document the risk and the required opt-in. -- **Credit**: this unsafe deserialization issue (CWE-502) was responsibly disclosed by **Nir Yehoshua, Cipher Security Labs**. Thank you for the report. +- **Credit**: this unsafe deserialization issue (CVE-2026-73325, CWE-502) was responsibly disclosed by **Nir Yehoshua, Cipher Security Labs**. Thank you for the report. ## [v1.2.0] 2026-06-08 diff --git a/SECURITY.md b/SECURITY.md index 8d5ec4d7..b930d76a 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -6,7 +6,7 @@ Security updates are provided for the latest release line of Fujitsu One Compres | Version | Supported | | ------- | ------------------ | -| 1.2.2 | :white_check_mark: | +| 1.2.2 >= | :white_check_mark: | | < 1.2.2 | :x: | We recommend always upgrading to the latest release before reporting an issue. @@ -38,8 +38,20 @@ Please make a good-faith effort to avoid privacy violations, data destruction, a Thank you for helping keep OneComp and its users safe. +## Resolved Security Issues + +### CVE-2026-73325 — Unsafe Deserialization + +An unsafe deserialization vulnerability (CWE-502) was identified in +`QuantizedModelLoader.load_quantized_model_pt()`. + +- **Affected versions:** v1.2.0 and earlier +- **Fixed version:** v1.2.1 +- **CVE:** CVE-2026-73325 +- **Resolution:** The issue was addressed in v1.2.1. Users should upgrade to the latest supported release. + ## Security Acknowledgments We thank the following researchers for responsibly disclosing security issues in OneComp: -- **Nir Yehoshua, Cipher Security Labs** — unsafe deserialization in `QuantizedModelLoader.load_quantized_model_pt()` (CWE-502), fixed in v1.2.1. +- **Nir Yehoshua, Cipher Security Labs** — unsafe deserialization in `QuantizedModelLoader.load_quantized_model_pt()` (CVE-2026-73325, CWE-502), affecting OneComp versions through v1.2.0 and fixed in v1.2.1. From 140410de51d0c8d23350c15996a4939f0309e179 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yano=2C=20Yuhki/=E7=9F=A2=E9=87=8E=20=E9=9B=84=E5=9F=BA?= Date: Mon, 24 Aug 2026 01:36:52 +0000 Subject: [PATCH 07/13] Modify gemlite for CPU inference --- CHANGELOG.md | 2 ++ onecomp/quantizer/gemlite.py | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 892282fc..a1418df7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ ### Bug Fix +- Fixed GemLite AssertionError during CPU inference execution for OneComp with Llama.cpp. + - Fixed `QuantizedModelLoader.load_quantized_model()` calling `unfuse_moe_experts()` twice on non-fused MoE checkpoints. An earlier unconditional unfuse (run right after building the empty model) was left in place when the checkpoint-aware unfuse (added for gpt-oss fused-MoE support) was introduced. The redundant unconditional call was removed, and the checkpoint-aware unfuse now runs before `_remap_state_dict_keys()` so key remapping still aligns against the unfused per-expert module paths. This also prevents wrongly unfusing gpt-oss fused-MoE checkpoints, whose fused 3D expert tensors must be loaded as-is (`quantized_model_loader.py`). ## [v1.3.1] 2026-08-06 diff --git a/onecomp/quantizer/gemlite.py b/onecomp/quantizer/gemlite.py index e50b5114..4e79b487 100644 --- a/onecomp/quantizer/gemlite.py +++ b/onecomp/quantizer/gemlite.py @@ -16,13 +16,15 @@ import torch.nn.functional as F # Optional GemLite/HQQ imports -try: - from gemlite.core import DType, GemLiteLinearTriton - from hqq.core.quantize import BaseQuantizeConfig, HQQLinear +HAS_GEMLITE = False +if torch.cuda.is_available(): + try: + from gemlite.core import DType, GemLiteLinearTriton + from hqq.core.quantize import BaseQuantizeConfig, HQQLinear - HAS_GEMLITE = True -except (ImportError, AttributeError): - HAS_GEMLITE = False + HAS_GEMLITE = True + except (ImportError, AttributeError, AssertionError): + pass # Constants From 5479db156abf88c212c6fdee1559cc3db17b4daf Mon Sep 17 00:00:00 2001 From: Yuhki Yano <30323722+y-vectorfield@users.noreply.github.com> Date: Mon, 24 Aug 2026 15:32:14 +0900 Subject: [PATCH 08/13] Fix data type arguments for Transformers (#55) * Fix data type arguments for Transformers * Update CHANGELOG --------- Co-authored-by: FKKimura <50981196+FKKimura@users.noreply.github.com> --- CHANGELOG.md | 5 ++--- notebook/01_tutorial.ipynb | 2 +- onecomp/cpu/export/dequantize.py | 2 +- onecomp/pre_process/prepare_rotated_model.py | 2 +- onecomp/pre_process/train_rotation.py | 4 ++-- onecomp/quantized_model_loader.py | 4 ++-- onecomp/utils/vram_estimator.py | 2 +- tests/onecomp/pre_process/test_save_load_pipeline_qwen3.py | 4 ++-- .../onecomp/pre_process/test_save_load_pipeline_tinyllama.py | 4 ++-- 9 files changed, 14 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ed7ee59..831af9dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,12 @@ # Change log -## [v1.3.2(WIP)+fix/wikitext-hf-dataset-id] 2026-08-18 +## [v1.3.2] 2026-08-24 ### Bug Fix - Fix WikiText dataset loading in clean environments by using the canonical `Salesforce/wikitext` dataset ID for perplexity evaluation and LoRA SFT examples. - -## [v1.3.2] 2026-08-dd +- Fix warning regarding the data type arguments of Transformers. ## [v1.3.1] 2026-08-06 diff --git a/notebook/01_tutorial.ipynb b/notebook/01_tutorial.ipynb index d55c887e..4f824b99 100644 --- a/notebook/01_tutorial.ipynb +++ b/notebook/01_tutorial.ipynb @@ -76,7 +76,7 @@ "DEVICE = \"cuda:0\" if torch.cuda.is_available() else \"cpu\"\n", "\n", "tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)\n", - "model = AutoModelForCausalLM.from_pretrained(MODEL_ID, torch_dtype=torch.float16).to(DEVICE)\n", + "model = AutoModelForCausalLM.from_pretrained(MODEL_ID, dtype=torch.float16).to(DEVICE)\n", "model.eval()\n", "\n", "n_params = sum(p.numel() for p in model.parameters())\n", diff --git a/onecomp/cpu/export/dequantize.py b/onecomp/cpu/export/dequantize.py index 6a47ea4b..5493c9bd 100644 --- a/onecomp/cpu/export/dequantize.py +++ b/onecomp/cpu/export/dequantize.py @@ -98,7 +98,7 @@ def dequantize_to_hf( pass logger.info("Building empty dense model from config (%s)", config.model_type) - model = AutoModelForCausalLM.from_config(config, torch_dtype=torch_dtype) + model = AutoModelForCausalLM.from_config(config, dtype=torch_dtype) state: Dict[str, torch.Tensor] = {} for shard in sorted(glob(os.path.join(save_directory, "*.safetensors"))): diff --git a/onecomp/pre_process/prepare_rotated_model.py b/onecomp/pre_process/prepare_rotated_model.py index 8d0b74c8..50c05b06 100644 --- a/onecomp/pre_process/prepare_rotated_model.py +++ b/onecomp/pre_process/prepare_rotated_model.py @@ -319,7 +319,7 @@ def prepare_rotated_model( t0 = time.time() model = AutoModelForCausalLM.from_pretrained( model_path, - torch_dtype="auto", + dtype="auto", device_map="cpu", low_cpu_mem_usage=True, ) diff --git a/onecomp/pre_process/train_rotation.py b/onecomp/pre_process/train_rotation.py index 4bfacfdf..e3f0b32d 100644 --- a/onecomp/pre_process/train_rotation.py +++ b/onecomp/pre_process/train_rotation.py @@ -321,7 +321,7 @@ def _convert_model_structure(config, model_type, model_path, use_sdpa=False): if is_llama: quant_model = QLlamaFC.from_pretrained( model_path, - torch_dtype="auto", + dtype="auto", device_map="cpu", low_cpu_mem_usage=True, config=config, @@ -329,7 +329,7 @@ def _convert_model_structure(config, model_type, model_path, use_sdpa=False): elif is_qwen3: quant_model = QQwen3FC.from_pretrained( model_path, - torch_dtype="auto", + dtype="auto", device_map="cpu", low_cpu_mem_usage=True, config=config, diff --git a/onecomp/quantized_model_loader.py b/onecomp/quantized_model_loader.py index 33e65c14..95a3d170 100644 --- a/onecomp/quantized_model_loader.py +++ b/onecomp/quantized_model_loader.py @@ -568,11 +568,11 @@ def _build_empty_model_from_config( config_cls = CONFIG_MAPPING[model_type] model_config = config_cls.from_dict(clean_config) try: - return AutoModelForCausalLM.from_config(model_config, torch_dtype=dtype) + return AutoModelForCausalLM.from_config(model_config, dtype=dtype) except (ValueError, KeyError): from transformers import AutoModelForImageTextToText - return AutoModelForImageTextToText.from_config(model_config, torch_dtype=dtype) + return AutoModelForImageTextToText.from_config(model_config, dtype=dtype) @staticmethod def _set_module_by_name( diff --git a/onecomp/utils/vram_estimator.py b/onecomp/utils/vram_estimator.py index 7320c38e..d38fbfb0 100644 --- a/onecomp/utils/vram_estimator.py +++ b/onecomp/utils/vram_estimator.py @@ -312,7 +312,7 @@ def estimate_wbits_from_vram( config = AutoConfig.from_pretrained(model_id) with torch.device("meta"): - model = AutoModelForCausalLM.from_config(config, torch_dtype=torch.float16) + model = AutoModelForCausalLM.from_config(config, dtype=torch.float16) return estimate_target_bitwidth( model, diff --git a/tests/onecomp/pre_process/test_save_load_pipeline_qwen3.py b/tests/onecomp/pre_process/test_save_load_pipeline_qwen3.py index abd7f8be..bfc52648 100644 --- a/tests/onecomp/pre_process/test_save_load_pipeline_qwen3.py +++ b/tests/onecomp/pre_process/test_save_load_pipeline_qwen3.py @@ -89,7 +89,7 @@ def test_save_load(self, model_id, quant_type, save_type, tmp_path): else: model_before = AutoModelForCausalLM.from_pretrained( rotated_config.path, - torch_dtype=torch.float16, + dtype=torch.float16, device_map="cpu", ) runner.update_model_weights(model_before) @@ -111,7 +111,7 @@ def test_save_load(self, model_id, quant_type, save_type, tmp_path): else: model = AutoModelForCausalLM.from_pretrained( save_dir, - torch_dtype=torch.float16, + dtype=torch.float16, device_map=device, ) tokenizer = AutoTokenizer.from_pretrained(save_dir) diff --git a/tests/onecomp/pre_process/test_save_load_pipeline_tinyllama.py b/tests/onecomp/pre_process/test_save_load_pipeline_tinyllama.py index 61d3d6a9..f19aa367 100644 --- a/tests/onecomp/pre_process/test_save_load_pipeline_tinyllama.py +++ b/tests/onecomp/pre_process/test_save_load_pipeline_tinyllama.py @@ -89,7 +89,7 @@ def test_save_load(self, model_id, quant_type, save_type, tmp_path): else: model_before = AutoModelForCausalLM.from_pretrained( rotated_config.path, - torch_dtype=torch.float16, + dtype=torch.float16, device_map="cpu", ) runner.update_model_weights(model_before) @@ -111,7 +111,7 @@ def test_save_load(self, model_id, quant_type, save_type, tmp_path): else: model = AutoModelForCausalLM.from_pretrained( save_dir, - torch_dtype=torch.float16, + dtype=torch.float16, device_map=device, ) tokenizer = AutoTokenizer.from_pretrained(save_dir) From b1ab82a5db8896c16e315a0180053d1dbf307968 Mon Sep 17 00:00:00 2001 From: Yuhki Yano <30323722+y-vectorfield@users.noreply.github.com> Date: Mon, 24 Aug 2026 15:34:49 +0900 Subject: [PATCH 09/13] Add troubleshooting information for running OneComp with Llama.cpp on macOS (#53) --- .gitignore | 1 + CHANGELOG.md | 4 +++ docs/user-guide/cpu-inference.md | 53 ++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) diff --git a/.gitignore b/.gitignore index d51a2c31..602abe78 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ site/ debug_code/ .pytest_cache/ *.pt +**/.env # Large test data (download separately if needed for regression tests) tests/onecomp/quantizer/jointq/data/model_layers_0_self_attn_k_proj.pth .uv-sync.lock diff --git a/CHANGELOG.md b/CHANGELOG.md index 831af9dd..9a1a9c18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ `Salesforce/wikitext` dataset ID for perplexity evaluation and LoRA SFT examples. - Fix warning regarding the data type arguments of Transformers. +### Documentation + +- Add troubleshooting information for running OneComp with Llama.cpp on macOS. + ## [v1.3.1] 2026-08-06 ### Bug Fix diff --git a/docs/user-guide/cpu-inference.md b/docs/user-guide/cpu-inference.md index 860a32d9..81b87058 100644 --- a/docs/user-guide/cpu-inference.md +++ b/docs/user-guide/cpu-inference.md @@ -19,6 +19,59 @@ for inference. The direct export path additionally uses llama.cpp's pure-Python `convert_hf_to_gguf.py` to build the model metadata/tokenizer; it is fetched automatically (a shallow `git clone`) or taken from `$LLAMA_CPP_DIR` if set. + +### macOS + +#### Symptom + +If you have installed gcc or clang on macOS using a tool like Homebrew, the OpenMP dynamic library with them can conflict with the OpenMP dynamic library used by OneComp's PyTorch backend. + +- OneComp's PyTorch backend is often configured to use an OpenMP library located within the .venv directory. +- Depending on your environment, Llama.cpp is configured to use an OpenMP library associated with gcc or clang. + +If the following problems is occurring , this conflict may be occurring. + +- Your Python interpreter shows the following warning message. + +```python +.../multiprocessing/resource_tracker.py:279: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown + warnings.warn('resource_tracker: There appear to be %d ' +``` + +- The following message is shown, when you import PyTorch and Llama.cpp in your script. + +```python +OMP: Error #15: Initializing libomp.dylib, but found libomp.dylib already initialized. +OMP: Hint This means that multiple copies of the OpenMP runtime have been linked into the program. +``` + +#### Solution + +##### 1. Search for OpenMP associated with PyTorch. + +Search for OpenMP library associated with PyTorch backend (using find command). + +```bash +$ find $PWD/.venv -type f \( -name 'libomp.dylib' -o -name 'libgomp*.dylib' \) -print | grep torch +/to/path/.venv/lib/python3./site-packages/torch/lib/libomp.dylib +``` + +##### 2. Create an .env + +Create a .env file and add the OpenMP path as an environment variable, as shown below. + +```bash +DYLD_LIBRARY_PATH="/to/path/.venv/lib/python3./site-packages/torch/lib" +``` + +##### 3. Run uv + +Pass the following `--env-file` options when running uv run. + +```bash +uv run --env-file /path/to/.env ... python your_script.py +``` + ## One entry point: `export_to_gguf` You do not need to know which path a checkpoint requires. `export_to_gguf` From 4554976d19674561b116c3b7baef2c29d0172d40 Mon Sep 17 00:00:00 2001 From: kimura-keiji Date: Mon, 24 Aug 2026 15:44:48 +0900 Subject: [PATCH 10/13] Modify CHANGELOG.md --- CHANGELOG.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77528141..904685f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,17 +7,13 @@ - Fix WikiText dataset loading in clean environments by using the canonical `Salesforce/wikitext` dataset ID for perplexity evaluation and LoRA SFT examples. - Fix warning regarding the data type arguments of Transformers. +- Fixed GemLite AssertionError during CPU inference execution for OneComp with Llama.cpp. +- Fixed `QuantizedModelLoader.load_quantized_model()` calling `unfuse_moe_experts()` twice on non-fused MoE checkpoints. An earlier unconditional unfuse (run right after building the empty model) was left in place when the checkpoint-aware unfuse (added for gpt-oss fused-MoE support) was introduced. The redundant unconditional call was removed, and the checkpoint-aware unfuse now runs before `_remap_state_dict_keys()` so key remapping still aligns against the unfused per-expert module paths. This also prevents wrongly unfusing gpt-oss fused-MoE checkpoints, whose fused 3D expert tensors must be loaded as-is (`quantized_model_loader.py`). ### Documentation - Add troubleshooting information for running OneComp with Llama.cpp on macOS. -### Bug Fix - -- Fixed GemLite AssertionError during CPU inference execution for OneComp with Llama.cpp. - -- Fixed `QuantizedModelLoader.load_quantized_model()` calling `unfuse_moe_experts()` twice on non-fused MoE checkpoints. An earlier unconditional unfuse (run right after building the empty model) was left in place when the checkpoint-aware unfuse (added for gpt-oss fused-MoE support) was introduced. The redundant unconditional call was removed, and the checkpoint-aware unfuse now runs before `_remap_state_dict_keys()` so key remapping still aligns against the unfused per-expert module paths. This also prevents wrongly unfusing gpt-oss fused-MoE checkpoints, whose fused 3D expert tensors must be loaded as-is (`quantized_model_loader.py`). - ## [v1.3.1] 2026-08-06 ### Bug Fix From b0f3f6d94dcefb59bf721d53ee6e49fd4c6ba18d Mon Sep 17 00:00:00 2001 From: kimura-keiji Date: Mon, 24 Aug 2026 15:57:07 +0900 Subject: [PATCH 11/13] Trivial-fix --- docs/user-guide/cpu-inference.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user-guide/cpu-inference.md b/docs/user-guide/cpu-inference.md index 81b87058..ce2134a4 100644 --- a/docs/user-guide/cpu-inference.md +++ b/docs/user-guide/cpu-inference.md @@ -38,7 +38,7 @@ If the following problems is occurring , this conflict may be occurring. warnings.warn('resource_tracker: There appear to be %d ' ``` -- The following message is shown, when you import PyTorch and Llama.cpp in your script. +- The following message is shown, when you import PyTorch and Llama.cpp in your script. ```python OMP: Error #15: Initializing libomp.dylib, but found libomp.dylib already initialized. From 2633dea9626823f7921d207f6bdaf3b34d429bb1 Mon Sep 17 00:00:00 2001 From: kimura-keiji Date: Mon, 24 Aug 2026 16:01:08 +0900 Subject: [PATCH 12/13] Update .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 602abe78..0c438e73 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,8 @@ models .cursor/rules/gitlab-integration.mdc .cursor/rules/slurm-submit.mdc .cursor/rules/run-tests-examples.mdc +.github/prompts +.github/copilot-instructions.md .hydra/ *.out *.err From 5ba420cc0ebfc77d4879234af33a2a59ff26a764 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kimura=2C=20Keiji/=E6=9C=A8=E6=9D=91=20=E5=9C=AD=E5=85=90?= Date: Mon, 24 Aug 2026 16:02:23 +0900 Subject: [PATCH 13/13] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 0c438e73..dec90f57 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ models .cursor/rules/run-tests-examples.mdc .github/prompts .github/copilot-instructions.md +.github/instructions .hydra/ *.out *.err