onecomp 1.3.3__tar.gz → 1.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {onecomp-1.3.3/onecomp.egg-info → onecomp-1.4.0}/PKG-INFO +19 -5
- {onecomp-1.3.3 → onecomp-1.4.0}/README.md +18 -4
- onecomp-1.4.0/envs/openvino/example_export_openvino.py +66 -0
- onecomp-1.4.0/envs/openvino/openvino_export_utils.py +115 -0
- onecomp-1.4.0/example/post_process/example_global_ptq_mdbf.py +48 -0
- onecomp-1.4.0/example/post_process/example_router_fine_tuning.py +76 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/__version__.py +1 -1
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/cpu/__init__.py +1 -1
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/cpu/export/__init__.py +3 -3
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/cpu/export/auto.py +28 -11
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/cpu/export/checkpoint.py +8 -3
- onecomp-1.4.0/onecomp/cpu/export/dequantize.py +393 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/cpu/export/fallback.py +3 -4
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/model_config.py +9 -2
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/post_process/__init__.py +2 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/post_process/_global_ptq/core.py +89 -16
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/post_process/_global_ptq/dbf_adapter.py +30 -12
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/post_process/_global_ptq/gptq_adapter.py +23 -12
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/post_process/_global_ptq/helpers.py +23 -1
- onecomp-1.4.0/onecomp/post_process/_global_ptq/mdbf_adapter.py +236 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/post_process/_global_ptq/trainer.py +36 -12
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/post_process/global_ptq.py +56 -1
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/post_process/global_ptq_distributed.py +116 -41
- onecomp-1.4.0/onecomp/post_process/router_fine_tuning.py +398 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/qep/_quantize_with_qep_arch.py +11 -4
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantized_model_loader.py +12 -17
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/mdbf/mdbf_layer.py +20 -11
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/runner.py +17 -97
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/utils/blockwise.py +78 -2
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/utils/quantization_progress.py +7 -8
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/utils/unfuse_moe.py +7 -2
- {onecomp-1.3.3 → onecomp-1.4.0/onecomp.egg-info}/PKG-INFO +19 -5
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp.egg-info/SOURCES.txt +8 -1
- onecomp-1.4.0/scripts/check_readme_examples.py +68 -0
- onecomp-1.4.0/scripts/prepare_calibration_cache.py +284 -0
- onecomp-1.3.3/onecomp/cpu/export/dequantize.py +0 -166
- onecomp-1.3.3/onecomp/runner_methods/multi_gpu_quantization.py +0 -406
- {onecomp-1.3.3 → onecomp-1.4.0}/LICENSE +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/benchmark/llama3-8b-gptq/quant_benchmark.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/benchmark/llama3-8b-jointq/quant_benchmark.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/benchmark/llama3-8b-lpcd-gptq/quant_benchmark.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/benchmark/llama3-8b-qep-gptq/quant_benchmark.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/benchmark/llama3-8b-various/quant_benchmark.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/benchmark/qwen3-14b-gptq/quant_benchmark.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/benchmark/qwen3-14b-jointq/quant_benchmark.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/benchmark/qwen3-8b-gptq/quant_benchmark.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/benchmark/qwen3-8b-jointq/quant_benchmark.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/dashboard/backend/app/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/dashboard/backend/app/api/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/dashboard/backend/app/api/jobs.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/dashboard/backend/app/constants.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/dashboard/backend/app/core/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/dashboard/backend/app/core/config.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/dashboard/backend/app/core/database.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/dashboard/backend/app/main.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/dashboard/backend/app/models/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/dashboard/backend/app/models/job.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/dashboard/backend/app/schemas/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/dashboard/backend/app/schemas/job.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/dashboard/backend/app/services/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/dashboard/backend/app/services/huggingface.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/dashboard/backend/app/services/inference.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/dashboard/backend/app/services/job_store.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/dashboard/backend/app/worker/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/dashboard/backend/app/worker/celery_app.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/dashboard/backend/app/worker/tasks.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/dashboard/backend/cpu_patch.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/dashboard/backend/start_backend.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/dashboard/backend/start_worker.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/envs/vllm/v0_24_0_rocm/src/onecomp_vllm_v0_24_0_rocm/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/envs/vllm/v0_24_0_rocm/src/onecomp_vllm_v0_24_0_rocm/patch.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/example/cpu_inference/example_gptq_gguf_cpu.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/example/cpu_inference/example_mixed_gptq_gguf_cpu.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/example/cpu_inference/example_serve_cpu.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/example/example_auto_run.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/example/example_autobit.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/example/example_custom_calibration.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/example/example_gptq.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/example/example_jointq.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/example/example_lpcd_gptq.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/example/example_mdbf.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/example/example_qep_gptq.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/example/example_save_load.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/example/post_process/example_blockwise_global_ptq.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/example/post_process/example_blockwise_global_ptq_staged.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/example/post_process/example_blockwise_ptq.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/example/post_process/example_global_ptq.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/example/post_process/example_global_ptq_dbf.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/example/post_process/example_global_ptq_distributed.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/example/post_process/example_lora_gptq_vllm_inference.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/example/post_process/example_lora_sft.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/example/post_process/example_lora_sft_knowledge.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/example/post_process/example_lora_sft_knowledge_jointq.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/example/post_process/example_reload_post_process_resave.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/example/pre_process/example_llama_preprocess_rtn.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/example/pre_process/example_preprocess_save_load.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/example/vllm_inference/example_autobit_vllm_inference.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/example/vllm_inference/example_dbf_vllm_inference.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/example/vllm_inference/example_gptq_vllm_gptoss_inference.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/example/vllm_inference/example_gptq_vllm_inference.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/example/vllm_inference/example_gptq_vllm_qwen36_inference.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/example/vllm_inference/example_jointq_vllm_inference.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/llamacpp_plugins/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/llamacpp_plugins/gptq/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/llamacpp_plugins/gptq/constants.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/llamacpp_plugins/gptq/llamacpp_plugin.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/model_validation/autobit/validate_autobit.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/model_validation/autobit_qep/validate_autobit.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/model_validation/gptq/validate_gptq.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/model_validation/gptq/validate_load.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/model_validation/gptq/validate_vllm.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/model_validation/jointq/validate_jointq.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/model_validation/qep_gptq/validate_gptq.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/__main__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/analyzer/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/analyzer/cumulative_error.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/analyzer/quantization_error.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/analyzer/weight_outlier.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/calibration/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/calibration/_cache.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/calibration/c4.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/calibration/calibration_config.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/calibration/calibration_data_loader.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/calibration/chunking.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/calibration/custom.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/calibration/wikitext.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/cli.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/cpu/cli.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/cpu/eval/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/cpu/eval/benchmark.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/cpu/eval/inspect_gguf.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/cpu/eval/parity.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/cpu/eval/perplexity.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/cpu/export/blocks.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/cpu/export/direct.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/cpu/export/rotation.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/cpu/export/skeleton.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/cpu/inference.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/cpu/llama_tooling.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/cpu/serve.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/eval/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/eval/__main__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/eval/conf/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/eval/conf/eval_config.yaml +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/eval/evals/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/eval/evals/base.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/eval/evals/mt_bench/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/eval/evals/mt_bench/adapter.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/eval/evals/mt_bench/data.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/eval/evals/mt_bench/gen_answer.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/eval/evals/mt_bench/judge.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/eval/evals/mt_bench/radar_chart.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/eval/evals/mt_bench/run.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/eval/evals/mt_bench/show_result.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/eval/evals/throughput/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/eval/evals/throughput/adapter.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/eval/evals/throughput/bench.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/eval/evals/throughput/run.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/eval/orchestrator/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/eval/orchestrator/aggregator.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/eval/orchestrator/runner.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/eval/orchestrator/server.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/eval/orchestrator/subprocess_runner.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/eval/run_evaluate.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/eval/schema.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/eval/utils/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/eval/utils/model_utils.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/eval/utils/ports.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/eval/utils/resources.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/eval/utils/secrets.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/export/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/export/gguf_export.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/export/gguf_reader.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/export/gguf_writer.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/export/hub.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/export/model_card.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/log.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/lpcd/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/lpcd/_gradient_solver.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/lpcd/_lpcd_config.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/lpcd/_lpcd_runner.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/lpcd/_metric.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/lpcd/_refiner.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/lpcd/arch/_llama.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/lpcd/arch/_llama_cf.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/lpcd/arch/_qwen3.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/post_process/_base.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/post_process/_blockwise/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/post_process/_blockwise/dbf_block_optimizer.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/post_process/_blockwise/dbf_cbq_optimizer.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/post_process/_blockwise/generic_block_optimizer.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/post_process/_blockwise/gptq_block_optimizer.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/post_process/_blockwise/gptq_cbq_optimizer.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/post_process/_blockwise/helpers.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/post_process/_blockwise/onebit_block_optimizer.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/post_process/_blockwise/onebit_cbq_optimizer.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/post_process/_global_ptq/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/post_process/_global_ptq/losses.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/post_process/_runtime.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/post_process/blockwise_ptq.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/post_process/post_process_lora_sft.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/pre_process/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/pre_process/hadamard_utils.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/pre_process/modeling_llama.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/pre_process/modeling_qwen3.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/pre_process/optimizer.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/pre_process/prepare_rotated_model.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/pre_process/preprocess_args.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/pre_process/quant_models.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/pre_process/rotation_utils.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/pre_process/train_rotation.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/qep/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/qep/_qep_config.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/qep/_quantize_with_qep.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/_quantizer.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/arb/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/arb/_arb.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/arb/arb_impl.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/autobit/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/autobit/_autobit.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/autobit/activation_stats.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/autobit/dbf_fallback.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/autobit/ilp.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/autobit/manual.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/autobit/visualize.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/cq/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/cq/_cq.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/cq/cq_impl.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/dbf/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/dbf/_dbf.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/dbf/admm_extended.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/dbf/balance.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/dbf/config.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/dbf/dbf_impl.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/dbf/dbf_layer.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/dbf/dbf_original.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/dbf/fine_tune.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/dbf/middle.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/gemlite.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/gptq/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/gptq/_gptq.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/gptq/config.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/gptq/gptq_layer.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/jointq/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/jointq/_jointq.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/jointq/core/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/jointq/core/__version__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/jointq/core/clip.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/jointq/core/error_propagation/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/jointq/core/error_propagation/local_search_advanced.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/jointq/core/error_propagation/quantize_advanced.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/jointq/core/error_propagation/quantizer_advanced.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/jointq/core/local_search.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/jointq/core/quantize.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/jointq/core/quantize_multi_gpu.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/jointq/core/quantizer.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/jointq/core/solution.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/mdbf/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/mdbf/_mdbf.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/mdbf/admm.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/mdbf/config.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/mdbf/gradient_refine.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/mdbf/initialize.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/mdbf/mdbf_impl.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/mdbf/utils.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/onebit/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/onebit/_onebit.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/onebit/onebit_impl.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/onebit/onebit_layer.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/qbb/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/qbb/_qbb.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/qbb/qbb_impl.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/quip/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/quip/_quip.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/quip/quant_quip.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/quip/quip_impl.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/quip/utils.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/quip/utils_had.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/quip/vector_balance.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/rtn/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/rtn/_rtn.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/rtn/quantizer.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/quantizer/rtn/rtn_impl.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/rotated_model_config.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/runner_methods/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/runner_methods/chunked_quantization.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/runner_methods/jointq_error_propagation.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/utils/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/utils/accuracy.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/utils/activation_capture.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/utils/activation_check.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/utils/device.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/utils/dtype.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/utils/lora.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/utils/model_inputs.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/utils/mxfp4_compat.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/utils/perplexity.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/utils/quant_config.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp/utils/vram_estimator.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp.egg-info/dependency_links.txt +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp.egg-info/entry_points.txt +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp.egg-info/requires.txt +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/onecomp.egg-info/top_level.txt +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/pyproject.toml +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/scripts/check_copyright_header.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/scripts/check_no_japanese.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/setup.cfg +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/vllm_plugins/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/vllm_plugins/dbf/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/vllm_plugins/dbf/modules/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/vllm_plugins/dbf/modules/gemlite_linear.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/vllm_plugins/dbf/modules/naive.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/vllm_plugins/dbf/vllm_plugin.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/vllm_plugins/gptq/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/vllm_plugins/gptq/constants.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/vllm_plugins/gptq/gptoss_wna16_moe.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/vllm_plugins/gptq/vllm_plugin.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/vllm_plugins/patches/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/vllm_plugins/patches/_paths.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/vllm_plugins/patches/apply_all.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/vllm_plugins/patches/gpt_oss_gptq_moe.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/vllm_plugins/patches/gpt_oss_wna16_bias.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/vllm_plugins/utils/__init__.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/vllm_plugins/utils/module.py +0 -0
- {onecomp-1.3.3 → onecomp-1.4.0}/vllm_plugins/utils/rotation.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: onecomp
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.0
|
|
4
4
|
Summary: Python package for LLM compression
|
|
5
5
|
Author: Keiji Kimura
|
|
6
6
|
License: MIT License
|
|
@@ -154,10 +154,13 @@ Full documentation is available at **[https://FujitsuResearch.github.io/OneCompr
|
|
|
154
154
|
- **JointQ**: Joint quantization method that optimizes weight assignments and scale parameters simultaneously for improved quantization accuracy. Supports group-wise quantization (e.g., 4-bit, groupsize=128).
|
|
155
155
|
- **MDBF (Multi-Envelope Double Binary Factorization)**: A binary factorization quantizer that approximates each weight matrix as a sum of multi-path sign matrices with multi-scale FP16 envelopes, generalizing DBF and LittleBit for aggressive low-bit (sub-1-bit) compression. Supports ADMM/gradient refinement, activation-aware initialization, and a GemLite-accelerated 1-bit inference path. See the [MDBF guide](https://FujitsuResearch.github.io/OneCompression/algorithms/mdbf/) for details.
|
|
156
156
|
- **Block-wise PTQ**: Post-quantization block-wise distillation that minimises intermediate-representation MSE against an FP16 teacher model at Transformer-block granularity. Includes Phase 1 (greedy per-block optimisation) and Phase 2 CBQ (cross-block sliding-window optimisation). Supports GPTQ, DBF, and OneBit quantizers.
|
|
157
|
+
- **Global PTQ**: Globally optimise GPTQ scales/zeros, DBF scaling factors, and MDBF amplitude parameters through KL distillation from a full-precision teacher. Supports optional MDBF binary-factor training with STE, single-device and distributed execution with DeepSpeed, and configurable teacher device placement. See the [Global PTQ guide](docs/user-guide/post-process.md#global-ptq-parameter-optimisation).
|
|
158
|
+
- **MoE Router Fine-Tuning**: Adapt routing decisions after expert quantization by training only router parameters with next-token prediction loss, while experts and other weights remain frozen. Results use the normal quantized-model save/load workflow. See the [router fine-tuning guide](docs/user-guide/post-process.md#router-fine-tuning-for-quantized-moe-models).
|
|
157
159
|
- **LoRA SFT Post-Process**: Fine-tune quantized models with LoRA adapters for accuracy recovery or domain-specific knowledge injection. Supports SFT loss, teacher distillation, and intermediate block alignment.
|
|
158
160
|
- **Rotation Preprocessing**: SpinQuant/OstQuant-based rotation preprocessing that reduces quantization error by learning optimal rotation matrices before quantization. Rotation/scaling matrices are absorbed into model weights, with online Hadamard hooks automatically registered at load time. Supports Llama and Qwen3 architectures.
|
|
159
161
|
- **Web Dashboard (HPC)**: A browser-based dashboard for launching quantization jobs, deploying models, and validating chat-based inference in HPC environments. See [dashboard/README.md](dashboard/README.md) for details.
|
|
160
162
|
- **GGUF Export & Hugging Face Hub Integration**: Convert models to the GGUF v3 format (F16) for llama.cpp/Ollama with a dependency-free built-in writer, generate model cards with quantization recipes and evaluation results, and push save directories to the Hugging Face Hub. Supports Llama (SentencePiece or Llama-3-style BPE) and Qwen2 (BPE) architectures, including multi-EOS stop-token mapping. See the [GGUF Export guide](https://FujitsuResearch.github.io/OneCompression/user-guide/gguf-export/).
|
|
163
|
+
- **OpenVINO Export**: Export supported OneComp GPTQ 4-bit text-generation checkpoints to OpenVINO IR using an isolated, dependency-locked OpenVINO 2026.3.1 environment and conversion example. Checkpoint metadata is normalized in a temporary copy without modifying the source. See the [OpenVINO export guide](envs/openvino/README.md).
|
|
161
164
|
- (TBD)
|
|
162
165
|
|
|
163
166
|
## 🤖 Supported Models
|
|
@@ -240,7 +243,7 @@ Then install OneComp from PyPI (see step 2 below). GPTQ quantization and Hugging
|
|
|
240
243
|
> - GPTQ (`run_gptq`): Hessian and weights are moved to CPU for the full column-wise loop (including inverse-Hessian Cholesky). If that loop stayed on MPS, `quantize()` would call `maxq.item()` once per column; each call triggers **per-column host sync** (wait for pending MPS ops, then read one scalar—not a full Hessian/weight copy every column)—often several times slower than CPU on Apple Silicon (e.g. ~4× in internal benchmarks with PyTorch 2.12). Keeping GPTQ on CPU avoids that overhead. With `mse=True`, `find_params` also calls `quantize()` in a grid loop and benefits from the same CPU placement.
|
|
241
244
|
> - QEP weight correction (`adjust_weight`, when QEP correction runs—typically `qep=True` with error propagation enabled): Per-layer work stays on MPS (e.g. `weight @ delta_hatX`, diagonal damping). Only the Cholesky solve uses CPU via `_safe_cholesky_and_solve` (one solve per layer, not per column); moving all of QEP to CPU does not materially improve speed. The subsequent GPTQ step still uses the CPU path above.
|
|
242
245
|
>
|
|
243
|
-
> DBF-based AutoBit fallback
|
|
246
|
+
> DBF-based AutoBit fallback is not supported on MPS.
|
|
244
247
|
|
|
245
248
|
#### 2. Install `onecomp`
|
|
246
249
|
|
|
@@ -250,7 +253,7 @@ Once PyTorch is installed, you can install `onecomp`:
|
|
|
250
253
|
pip install onecomp
|
|
251
254
|
```
|
|
252
255
|
|
|
253
|
-
To enable multi-GPU training
|
|
256
|
+
To enable multi-GPU training for Global PTQ (DeepSpeed), install with the `distributed` extra:
|
|
254
257
|
|
|
255
258
|
```bash
|
|
256
259
|
pip install "onecomp[distributed]"
|
|
@@ -296,7 +299,7 @@ See the **MPS device placement (GPTQ vs QEP)** note under [macOS (MPS)](#macos-m
|
|
|
296
299
|
|
|
297
300
|
Adding `--extra dev` installs development tools (black, pre-commit, pytest, pylint).
|
|
298
301
|
Adding `--extra visualize` installs matplotlib for visualization features.
|
|
299
|
-
Adding `--extra distributed` installs DeepSpeed for multi-GPU training.
|
|
302
|
+
Adding `--extra distributed` installs DeepSpeed for Global PTQ multi-GPU training.
|
|
300
303
|
Adding `--extra hydra` installs `hydra-core` for the example scripts and `model_validation/` runners that use Hydra-based configuration.
|
|
301
304
|
|
|
302
305
|
To use vLLM for serving quantized models on Linux, add `--extra vllm` together with `--extra cu130`:
|
|
@@ -409,6 +412,7 @@ See [`notebook/README.md`](./notebook/README.md) for local setup, or the
|
|
|
409
412
|
| | [example_qep_gptq.py](./example/example_qep_gptq.py) | GPTQ + QEP (error propagation) |
|
|
410
413
|
| | [example_lpcd_gptq.py](./example/example_lpcd_gptq.py) | GPTQ + QEP + LPCD quantization |
|
|
411
414
|
| | [example_jointq.py](./example/example_jointq.py) | JointQ quantization |
|
|
415
|
+
| | [example_mdbf.py](./example/example_mdbf.py) | MDBF quantization |
|
|
412
416
|
| | [example_autobit.py](./example/example_autobit.py) | AutoBit mixed-precision quantization |
|
|
413
417
|
| | [example_auto_run.py](./example/example_auto_run.py) | AutoBit with automatic VRAM estimation |
|
|
414
418
|
| Calibration | [example_custom_calibration.py](./example/example_custom_calibration.py) | Custom calibration dataset with CalibrationConfig |
|
|
@@ -421,7 +425,9 @@ See [`notebook/README.md`](./notebook/README.md) for local setup, or the
|
|
|
421
425
|
| | [example_blockwise_global_ptq_staged.py](./example/post_process/example_blockwise_global_ptq_staged.py) | Staged BlockWisePTQ → GlobalPTQ across save/load boundaries with accumulated post-process metadata |
|
|
422
426
|
| | [example_global_ptq.py](./example/post_process/example_global_ptq.py) | Global PTQ with packed buffers by default and HF-compatible safetensors output |
|
|
423
427
|
| | [example_global_ptq_dbf.py](./example/post_process/example_global_ptq_dbf.py) | Global PTQ with the DBF backend and HF-compatible safetensors output |
|
|
428
|
+
| | [example_global_ptq_mdbf.py](./example/post_process/example_global_ptq_mdbf.py) | Global PTQ with the MDBF backend and HF-compatible safetensors output |
|
|
424
429
|
| | [example_global_ptq_distributed.py](./example/post_process/example_global_ptq_distributed.py) | Multi-GPU Global PTQ with DeepSpeed / torchrun and safetensors output |
|
|
430
|
+
| | [example_router_fine_tuning.py](./example/post_process/example_router_fine_tuning.py) | Router-only next-token fine-tuning for a quantized MoE model |
|
|
425
431
|
| | [example_lora_sft.py](./example/post_process/example_lora_sft.py) | LoRA SFT post-quantization fine-tuning |
|
|
426
432
|
| | [example_lora_sft_knowledge.py](./example/post_process/example_lora_sft_knowledge.py) | LoRA SFT knowledge injection |
|
|
427
433
|
| | [example_lora_sft_knowledge_jointq.py](./example/post_process/example_lora_sft_knowledge_jointq.py) | LoRA SFT knowledge injection on a JointQ-quantized model |
|
|
@@ -432,6 +438,9 @@ See [`notebook/README.md`](./notebook/README.md) for local setup, or the
|
|
|
432
438
|
| | [example_jointq_vllm_inference.py](./example/vllm_inference/example_jointq_vllm_inference.py) | JointQ quantization and vLLM inference |
|
|
433
439
|
| | [example_autobit_vllm_inference.py](./example/vllm_inference/example_autobit_vllm_inference.py) | AutoBit quantization and vLLM inference |
|
|
434
440
|
| | [example_dbf_vllm_inference.py](./example/vllm_inference/example_dbf_vllm_inference.py) | DBF quantization and vLLM inference |
|
|
441
|
+
| CPU Inference | [example_gptq_gguf_cpu.py](./example/cpu_inference/example_gptq_gguf_cpu.py) | Export GPTQ quantized models to GGUF and run CPU inference |
|
|
442
|
+
| | [example_mixed_gptq_gguf_cpu.py](./example/cpu_inference/example_mixed_gptq_gguf_cpu.py) | Export Mixed-GPTQ quantized models to GGUF and run CPU inference |
|
|
443
|
+
| | [example_serve_cpu.py](./example/cpu_inference/example_serve_cpu.py) | Serve a GGUF model with llama.cpp on CPU |
|
|
435
444
|
|
|
436
445
|
## 🔌 vLLM Inference
|
|
437
446
|
|
|
@@ -473,7 +482,12 @@ See the [GPT-OSS guide](docs/user-guide/gptoss.md) for HF save/load, patch detai
|
|
|
473
482
|
|
|
474
483
|
## 📄 License
|
|
475
484
|
|
|
476
|
-
|
|
485
|
+
OneComp is licensed under the [MIT License](./LICENSE).
|
|
486
|
+
|
|
487
|
+
The dependencies installed with OneComp are separate open-source software (OSS)
|
|
488
|
+
projects and are distributed under their respective licenses. Their licenses
|
|
489
|
+
may change when the dependencies are updated, so please check the license
|
|
490
|
+
terms of the installed versions as well.
|
|
477
491
|
|
|
478
492
|
## Citation
|
|
479
493
|
|
|
@@ -40,10 +40,13 @@ Full documentation is available at **[https://FujitsuResearch.github.io/OneCompr
|
|
|
40
40
|
- **JointQ**: Joint quantization method that optimizes weight assignments and scale parameters simultaneously for improved quantization accuracy. Supports group-wise quantization (e.g., 4-bit, groupsize=128).
|
|
41
41
|
- **MDBF (Multi-Envelope Double Binary Factorization)**: A binary factorization quantizer that approximates each weight matrix as a sum of multi-path sign matrices with multi-scale FP16 envelopes, generalizing DBF and LittleBit for aggressive low-bit (sub-1-bit) compression. Supports ADMM/gradient refinement, activation-aware initialization, and a GemLite-accelerated 1-bit inference path. See the [MDBF guide](https://FujitsuResearch.github.io/OneCompression/algorithms/mdbf/) for details.
|
|
42
42
|
- **Block-wise PTQ**: Post-quantization block-wise distillation that minimises intermediate-representation MSE against an FP16 teacher model at Transformer-block granularity. Includes Phase 1 (greedy per-block optimisation) and Phase 2 CBQ (cross-block sliding-window optimisation). Supports GPTQ, DBF, and OneBit quantizers.
|
|
43
|
+
- **Global PTQ**: Globally optimise GPTQ scales/zeros, DBF scaling factors, and MDBF amplitude parameters through KL distillation from a full-precision teacher. Supports optional MDBF binary-factor training with STE, single-device and distributed execution with DeepSpeed, and configurable teacher device placement. See the [Global PTQ guide](docs/user-guide/post-process.md#global-ptq-parameter-optimisation).
|
|
44
|
+
- **MoE Router Fine-Tuning**: Adapt routing decisions after expert quantization by training only router parameters with next-token prediction loss, while experts and other weights remain frozen. Results use the normal quantized-model save/load workflow. See the [router fine-tuning guide](docs/user-guide/post-process.md#router-fine-tuning-for-quantized-moe-models).
|
|
43
45
|
- **LoRA SFT Post-Process**: Fine-tune quantized models with LoRA adapters for accuracy recovery or domain-specific knowledge injection. Supports SFT loss, teacher distillation, and intermediate block alignment.
|
|
44
46
|
- **Rotation Preprocessing**: SpinQuant/OstQuant-based rotation preprocessing that reduces quantization error by learning optimal rotation matrices before quantization. Rotation/scaling matrices are absorbed into model weights, with online Hadamard hooks automatically registered at load time. Supports Llama and Qwen3 architectures.
|
|
45
47
|
- **Web Dashboard (HPC)**: A browser-based dashboard for launching quantization jobs, deploying models, and validating chat-based inference in HPC environments. See [dashboard/README.md](dashboard/README.md) for details.
|
|
46
48
|
- **GGUF Export & Hugging Face Hub Integration**: Convert models to the GGUF v3 format (F16) for llama.cpp/Ollama with a dependency-free built-in writer, generate model cards with quantization recipes and evaluation results, and push save directories to the Hugging Face Hub. Supports Llama (SentencePiece or Llama-3-style BPE) and Qwen2 (BPE) architectures, including multi-EOS stop-token mapping. See the [GGUF Export guide](https://FujitsuResearch.github.io/OneCompression/user-guide/gguf-export/).
|
|
49
|
+
- **OpenVINO Export**: Export supported OneComp GPTQ 4-bit text-generation checkpoints to OpenVINO IR using an isolated, dependency-locked OpenVINO 2026.3.1 environment and conversion example. Checkpoint metadata is normalized in a temporary copy without modifying the source. See the [OpenVINO export guide](envs/openvino/README.md).
|
|
47
50
|
- (TBD)
|
|
48
51
|
|
|
49
52
|
## 🤖 Supported Models
|
|
@@ -126,7 +129,7 @@ Then install OneComp from PyPI (see step 2 below). GPTQ quantization and Hugging
|
|
|
126
129
|
> - GPTQ (`run_gptq`): Hessian and weights are moved to CPU for the full column-wise loop (including inverse-Hessian Cholesky). If that loop stayed on MPS, `quantize()` would call `maxq.item()` once per column; each call triggers **per-column host sync** (wait for pending MPS ops, then read one scalar—not a full Hessian/weight copy every column)—often several times slower than CPU on Apple Silicon (e.g. ~4× in internal benchmarks with PyTorch 2.12). Keeping GPTQ on CPU avoids that overhead. With `mse=True`, `find_params` also calls `quantize()` in a grid loop and benefits from the same CPU placement.
|
|
127
130
|
> - QEP weight correction (`adjust_weight`, when QEP correction runs—typically `qep=True` with error propagation enabled): Per-layer work stays on MPS (e.g. `weight @ delta_hatX`, diagonal damping). Only the Cholesky solve uses CPU via `_safe_cholesky_and_solve` (one solve per layer, not per column); moving all of QEP to CPU does not materially improve speed. The subsequent GPTQ step still uses the CPU path above.
|
|
128
131
|
>
|
|
129
|
-
> DBF-based AutoBit fallback
|
|
132
|
+
> DBF-based AutoBit fallback is not supported on MPS.
|
|
130
133
|
|
|
131
134
|
#### 2. Install `onecomp`
|
|
132
135
|
|
|
@@ -136,7 +139,7 @@ Once PyTorch is installed, you can install `onecomp`:
|
|
|
136
139
|
pip install onecomp
|
|
137
140
|
```
|
|
138
141
|
|
|
139
|
-
To enable multi-GPU training
|
|
142
|
+
To enable multi-GPU training for Global PTQ (DeepSpeed), install with the `distributed` extra:
|
|
140
143
|
|
|
141
144
|
```bash
|
|
142
145
|
pip install "onecomp[distributed]"
|
|
@@ -182,7 +185,7 @@ See the **MPS device placement (GPTQ vs QEP)** note under [macOS (MPS)](#macos-m
|
|
|
182
185
|
|
|
183
186
|
Adding `--extra dev` installs development tools (black, pre-commit, pytest, pylint).
|
|
184
187
|
Adding `--extra visualize` installs matplotlib for visualization features.
|
|
185
|
-
Adding `--extra distributed` installs DeepSpeed for multi-GPU training.
|
|
188
|
+
Adding `--extra distributed` installs DeepSpeed for Global PTQ multi-GPU training.
|
|
186
189
|
Adding `--extra hydra` installs `hydra-core` for the example scripts and `model_validation/` runners that use Hydra-based configuration.
|
|
187
190
|
|
|
188
191
|
To use vLLM for serving quantized models on Linux, add `--extra vllm` together with `--extra cu130`:
|
|
@@ -295,6 +298,7 @@ See [`notebook/README.md`](./notebook/README.md) for local setup, or the
|
|
|
295
298
|
| | [example_qep_gptq.py](./example/example_qep_gptq.py) | GPTQ + QEP (error propagation) |
|
|
296
299
|
| | [example_lpcd_gptq.py](./example/example_lpcd_gptq.py) | GPTQ + QEP + LPCD quantization |
|
|
297
300
|
| | [example_jointq.py](./example/example_jointq.py) | JointQ quantization |
|
|
301
|
+
| | [example_mdbf.py](./example/example_mdbf.py) | MDBF quantization |
|
|
298
302
|
| | [example_autobit.py](./example/example_autobit.py) | AutoBit mixed-precision quantization |
|
|
299
303
|
| | [example_auto_run.py](./example/example_auto_run.py) | AutoBit with automatic VRAM estimation |
|
|
300
304
|
| Calibration | [example_custom_calibration.py](./example/example_custom_calibration.py) | Custom calibration dataset with CalibrationConfig |
|
|
@@ -307,7 +311,9 @@ See [`notebook/README.md`](./notebook/README.md) for local setup, or the
|
|
|
307
311
|
| | [example_blockwise_global_ptq_staged.py](./example/post_process/example_blockwise_global_ptq_staged.py) | Staged BlockWisePTQ → GlobalPTQ across save/load boundaries with accumulated post-process metadata |
|
|
308
312
|
| | [example_global_ptq.py](./example/post_process/example_global_ptq.py) | Global PTQ with packed buffers by default and HF-compatible safetensors output |
|
|
309
313
|
| | [example_global_ptq_dbf.py](./example/post_process/example_global_ptq_dbf.py) | Global PTQ with the DBF backend and HF-compatible safetensors output |
|
|
314
|
+
| | [example_global_ptq_mdbf.py](./example/post_process/example_global_ptq_mdbf.py) | Global PTQ with the MDBF backend and HF-compatible safetensors output |
|
|
310
315
|
| | [example_global_ptq_distributed.py](./example/post_process/example_global_ptq_distributed.py) | Multi-GPU Global PTQ with DeepSpeed / torchrun and safetensors output |
|
|
316
|
+
| | [example_router_fine_tuning.py](./example/post_process/example_router_fine_tuning.py) | Router-only next-token fine-tuning for a quantized MoE model |
|
|
311
317
|
| | [example_lora_sft.py](./example/post_process/example_lora_sft.py) | LoRA SFT post-quantization fine-tuning |
|
|
312
318
|
| | [example_lora_sft_knowledge.py](./example/post_process/example_lora_sft_knowledge.py) | LoRA SFT knowledge injection |
|
|
313
319
|
| | [example_lora_sft_knowledge_jointq.py](./example/post_process/example_lora_sft_knowledge_jointq.py) | LoRA SFT knowledge injection on a JointQ-quantized model |
|
|
@@ -318,6 +324,9 @@ See [`notebook/README.md`](./notebook/README.md) for local setup, or the
|
|
|
318
324
|
| | [example_jointq_vllm_inference.py](./example/vllm_inference/example_jointq_vllm_inference.py) | JointQ quantization and vLLM inference |
|
|
319
325
|
| | [example_autobit_vllm_inference.py](./example/vllm_inference/example_autobit_vllm_inference.py) | AutoBit quantization and vLLM inference |
|
|
320
326
|
| | [example_dbf_vllm_inference.py](./example/vllm_inference/example_dbf_vllm_inference.py) | DBF quantization and vLLM inference |
|
|
327
|
+
| CPU Inference | [example_gptq_gguf_cpu.py](./example/cpu_inference/example_gptq_gguf_cpu.py) | Export GPTQ quantized models to GGUF and run CPU inference |
|
|
328
|
+
| | [example_mixed_gptq_gguf_cpu.py](./example/cpu_inference/example_mixed_gptq_gguf_cpu.py) | Export Mixed-GPTQ quantized models to GGUF and run CPU inference |
|
|
329
|
+
| | [example_serve_cpu.py](./example/cpu_inference/example_serve_cpu.py) | Serve a GGUF model with llama.cpp on CPU |
|
|
321
330
|
|
|
322
331
|
## 🔌 vLLM Inference
|
|
323
332
|
|
|
@@ -359,7 +368,12 @@ See the [GPT-OSS guide](docs/user-guide/gptoss.md) for HF save/load, patch detai
|
|
|
359
368
|
|
|
360
369
|
## 📄 License
|
|
361
370
|
|
|
362
|
-
|
|
371
|
+
OneComp is licensed under the [MIT License](./LICENSE).
|
|
372
|
+
|
|
373
|
+
The dependencies installed with OneComp are separate open-source software (OSS)
|
|
374
|
+
projects and are distributed under their respective licenses. Their licenses
|
|
375
|
+
may change when the dependencies are updated, so please check the license
|
|
376
|
+
terms of the installed versions as well.
|
|
363
377
|
|
|
364
378
|
## Citation
|
|
365
379
|
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"""Export a local OneComp GPTQ 4-bit checkpoint to OpenVINO IR.
|
|
2
|
+
|
|
3
|
+
Copyright 2025-2026 Fujitsu Ltd.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
from openvino_export_utils import (
|
|
11
|
+
modules_shape,
|
|
12
|
+
read_checkpoint_quantization,
|
|
13
|
+
save_openvino_tokenizer,
|
|
14
|
+
temporary_model_path_for_openvino_export,
|
|
15
|
+
validate_ir_files,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
# Replace this placeholder with the path to your local OneComp GPTQ 4-bit model.
|
|
19
|
+
MODEL_PATH = "CHANGE_TO_ONECOMP_GPTQ_MODEL_PATH"
|
|
20
|
+
|
|
21
|
+
# Directory that receives the OpenVINO IR and tokenizer files.
|
|
22
|
+
OUT_DIR = Path("ov_gptq_int4_model_from_onecomp")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def main() -> None:
|
|
26
|
+
from optimum.intel.openvino import OVModelForCausalLM
|
|
27
|
+
from transformers import AutoTokenizer
|
|
28
|
+
|
|
29
|
+
model_path = Path(MODEL_PATH)
|
|
30
|
+
quantization = read_checkpoint_quantization(model_path)
|
|
31
|
+
print(
|
|
32
|
+
"[INFO] checkpoint modules_in_block_to_quantize shape: "
|
|
33
|
+
f"{modules_shape(quantization.get('modules_in_block_to_quantize'))}"
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
OUT_DIR.mkdir(parents=True, exist_ok=True)
|
|
37
|
+
with temporary_model_path_for_openvino_export(model_path) as prepared_model_path:
|
|
38
|
+
# For an already-GPTQ-quantized model, do not pass OVWeightQuantizationConfig
|
|
39
|
+
# here. Keep the existing GPTQ 4-bit weights when exporting to OpenVINO IR.
|
|
40
|
+
model = OVModelForCausalLM.from_pretrained(
|
|
41
|
+
prepared_model_path,
|
|
42
|
+
export=True,
|
|
43
|
+
compile=False,
|
|
44
|
+
local_files_only=True,
|
|
45
|
+
trust_remote_code=True,
|
|
46
|
+
load_in_8bit=False,
|
|
47
|
+
)
|
|
48
|
+
model.save_pretrained(OUT_DIR)
|
|
49
|
+
|
|
50
|
+
# Save the Hugging Face tokenizer, plus the OpenVINO tokenizer and
|
|
51
|
+
# detokenizer required by OpenVINO GenAI.
|
|
52
|
+
tokenizer = AutoTokenizer.from_pretrained(
|
|
53
|
+
prepared_model_path,
|
|
54
|
+
local_files_only=True,
|
|
55
|
+
trust_remote_code=True,
|
|
56
|
+
)
|
|
57
|
+
tokenizer.save_pretrained(OUT_DIR)
|
|
58
|
+
save_openvino_tokenizer(tokenizer, OUT_DIR)
|
|
59
|
+
|
|
60
|
+
parsed_models = validate_ir_files(OUT_DIR)
|
|
61
|
+
print(f"[INFO] Parsed OpenVINO IR files: {', '.join(parsed_models)}")
|
|
62
|
+
print(f"[INFO] Export completed: {OUT_DIR.resolve()}")
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
if __name__ == "__main__":
|
|
66
|
+
main()
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"""Shared helpers for exporting OneComp GPTQ checkpoints to OpenVINO IR.
|
|
2
|
+
|
|
3
|
+
Copyright 2025-2026 Fujitsu Ltd.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import json
|
|
9
|
+
import shutil
|
|
10
|
+
import tempfile
|
|
11
|
+
from contextlib import contextmanager
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
from typing import Any, Iterator
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def read_checkpoint_quantization(model_path: Path) -> dict[str, Any]:
|
|
17
|
+
"""Return the checkpoint quantization metadata without modifying it."""
|
|
18
|
+
config_path = model_path / "config.json"
|
|
19
|
+
if not config_path.is_file():
|
|
20
|
+
raise FileNotFoundError(f"Checkpoint config was not found: {config_path}")
|
|
21
|
+
|
|
22
|
+
with config_path.open(encoding="utf-8") as config_file:
|
|
23
|
+
config = json.load(config_file)
|
|
24
|
+
|
|
25
|
+
quantization = config.get("quantization_config")
|
|
26
|
+
if not isinstance(quantization, dict):
|
|
27
|
+
raise ValueError(f"quantization_config is missing from {config_path}")
|
|
28
|
+
return quantization
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def modules_shape(modules: Any) -> str:
|
|
32
|
+
"""Describe modules_in_block_to_quantize as flat, nested, empty, or invalid."""
|
|
33
|
+
if not isinstance(modules, list):
|
|
34
|
+
return "invalid"
|
|
35
|
+
if not modules:
|
|
36
|
+
return "empty"
|
|
37
|
+
if all(isinstance(name, str) for name in modules):
|
|
38
|
+
return "flat"
|
|
39
|
+
if all(
|
|
40
|
+
isinstance(group, list) and group and all(isinstance(name, str) for name in group)
|
|
41
|
+
for group in modules
|
|
42
|
+
):
|
|
43
|
+
return "nested"
|
|
44
|
+
return "invalid"
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@contextmanager
|
|
48
|
+
def temporary_model_path_for_openvino_export(model_path: Path) -> Iterator[Path]:
|
|
49
|
+
"""Yield a model path with flat GPTQ module metadata normalized.
|
|
50
|
+
|
|
51
|
+
Some OneComp checkpoints store modules_in_block_to_quantize as List[str],
|
|
52
|
+
while current Transformers and Optimum expect List[List[str]]. For that
|
|
53
|
+
shape, a temporary checkpoint copy is patched and removed after use.
|
|
54
|
+
The source checkpoint is never changed.
|
|
55
|
+
"""
|
|
56
|
+
source = model_path.expanduser().resolve()
|
|
57
|
+
if not source.is_dir():
|
|
58
|
+
raise NotADirectoryError(f"Checkpoint directory was not found: {source}")
|
|
59
|
+
|
|
60
|
+
quantization = read_checkpoint_quantization(source)
|
|
61
|
+
modules_key = "modules_in_block_to_quantize"
|
|
62
|
+
if modules_key not in quantization:
|
|
63
|
+
raise ValueError(f"{modules_key} is missing from {source / 'config.json'}")
|
|
64
|
+
|
|
65
|
+
modules = quantization[modules_key]
|
|
66
|
+
shape = modules_shape(modules)
|
|
67
|
+
if shape == "invalid":
|
|
68
|
+
raise ValueError("modules_in_block_to_quantize has an unsupported shape")
|
|
69
|
+
if shape != "flat":
|
|
70
|
+
yield source
|
|
71
|
+
return
|
|
72
|
+
|
|
73
|
+
with tempfile.TemporaryDirectory(prefix="onecomp_ov_export_compat_") as temp_root:
|
|
74
|
+
temporary_model = Path(temp_root) / source.name
|
|
75
|
+
shutil.copytree(source, temporary_model, symlinks=True)
|
|
76
|
+
|
|
77
|
+
temporary_config_path = temporary_model / "config.json"
|
|
78
|
+
with temporary_config_path.open(encoding="utf-8") as config_file:
|
|
79
|
+
temporary_config = json.load(config_file)
|
|
80
|
+
temporary_config["quantization_config"]["modules_in_block_to_quantize"] = [modules]
|
|
81
|
+
with temporary_config_path.open("w", encoding="utf-8") as config_file:
|
|
82
|
+
json.dump(temporary_config, config_file, indent=2, ensure_ascii=False)
|
|
83
|
+
config_file.write("\n")
|
|
84
|
+
|
|
85
|
+
print(
|
|
86
|
+
"[INFO] Using a temporary checkpoint copy with "
|
|
87
|
+
"modules_in_block_to_quantize normalized from flat to nested."
|
|
88
|
+
)
|
|
89
|
+
print(f"[INFO] Temporary checkpoint: {temporary_model}")
|
|
90
|
+
yield temporary_model
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def save_openvino_tokenizer(tokenizer: Any, output_dir: Path) -> None:
|
|
94
|
+
"""Save OpenVINO tokenizer and detokenizer models for OpenVINO GenAI."""
|
|
95
|
+
import openvino as ov
|
|
96
|
+
from openvino_tokenizers import convert_tokenizer
|
|
97
|
+
|
|
98
|
+
ov_tokenizer, ov_detokenizer = convert_tokenizer(tokenizer, with_detokenizer=True)
|
|
99
|
+
ov.save_model(ov_tokenizer, output_dir / "openvino_tokenizer.xml")
|
|
100
|
+
ov.save_model(ov_detokenizer, output_dir / "openvino_detokenizer.xml")
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def validate_ir_files(output_dir: Path) -> list[str]:
|
|
104
|
+
"""Parse every exported non-tokenizer IR with OpenVINO Core."""
|
|
105
|
+
import openvino as ov
|
|
106
|
+
|
|
107
|
+
excluded = {"openvino_tokenizer.xml", "openvino_detokenizer.xml"}
|
|
108
|
+
model_files = sorted(path for path in output_dir.glob("*.xml") if path.name not in excluded)
|
|
109
|
+
if not model_files:
|
|
110
|
+
raise FileNotFoundError(f"No model IR XML was generated in {output_dir}")
|
|
111
|
+
|
|
112
|
+
core = ov.Core()
|
|
113
|
+
for model_file in model_files:
|
|
114
|
+
core.read_model(model_file)
|
|
115
|
+
return [path.name for path in model_files]
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""Example: MDBF quantization followed by Global PTQ.
|
|
2
|
+
|
|
3
|
+
Usage:
|
|
4
|
+
python example/post_process/example_global_ptq_mdbf.py
|
|
5
|
+
|
|
6
|
+
Copyright 2025-2026 Fujitsu Ltd.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import torch
|
|
10
|
+
|
|
11
|
+
from onecomp import MDBF, CalibrationConfig, GlobalPTQ, ModelConfig, Runner, setup_logger
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def main():
|
|
15
|
+
setup_logger()
|
|
16
|
+
model_id = "TinyLlama/TinyLlama-1.1B-intermediate-step-1431k-3T"
|
|
17
|
+
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
|
18
|
+
model_config = ModelConfig(model_id=model_id, device=device)
|
|
19
|
+
|
|
20
|
+
global_ptq = GlobalPTQ(
|
|
21
|
+
epochs=3,
|
|
22
|
+
dbf_lr=5e-4,
|
|
23
|
+
optimize_binary=True,
|
|
24
|
+
mdbf_ste_k=2.0,
|
|
25
|
+
calibration_config=CalibrationConfig(num_calibration_samples=32, max_length=512),
|
|
26
|
+
)
|
|
27
|
+
runner = Runner(
|
|
28
|
+
model_config=model_config,
|
|
29
|
+
quantizer=MDBF(target_bits=1.0),
|
|
30
|
+
calibration_config=CalibrationConfig(max_length=512, num_calibration_samples=128),
|
|
31
|
+
post_processes=[global_ptq],
|
|
32
|
+
)
|
|
33
|
+
runner.run()
|
|
34
|
+
|
|
35
|
+
original_ppl, _, quantized_ppl = runner.calculate_perplexity(
|
|
36
|
+
original_model=True,
|
|
37
|
+
quantized_model=True,
|
|
38
|
+
)
|
|
39
|
+
print(f"\nOriginal PPL: {original_ppl:.4f}")
|
|
40
|
+
print(f"MDBF + Global PTQ PPL: {quantized_ppl:.4f}")
|
|
41
|
+
|
|
42
|
+
save_dir = "./tinyllama-mdbf-globalptq"
|
|
43
|
+
runner.save_quantized_model(save_dir)
|
|
44
|
+
print(f"\nModel saved to {save_dir}")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
if __name__ == "__main__":
|
|
48
|
+
main()
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""Example: MoE quantization + router-only fine-tuning.
|
|
2
|
+
|
|
3
|
+
End-to-end demonstration of the RouterFineTuning post-process workflow:
|
|
4
|
+
1. Quantize a mixture-of-experts model with GPTQ
|
|
5
|
+
2. Fine-tune only its routers with next-token prediction loss
|
|
6
|
+
3. Evaluate PPL (original vs quantized + router fine-tuning)
|
|
7
|
+
4. Save the fine-tuned model to HF-compatible safetensors
|
|
8
|
+
|
|
9
|
+
Copyright 2025-2026 Fujitsu Ltd.
|
|
10
|
+
|
|
11
|
+
Usage:
|
|
12
|
+
python example/post_process/example_router_fine_tuning.py
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from onecomp import (
|
|
16
|
+
GPTQ,
|
|
17
|
+
CalibrationConfig,
|
|
18
|
+
ModelConfig,
|
|
19
|
+
RouterFineTuning,
|
|
20
|
+
Runner,
|
|
21
|
+
setup_logger,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def main():
|
|
26
|
+
setup_logger()
|
|
27
|
+
|
|
28
|
+
save_dir = "./gpt-oss-20b-mixed_gptq_router_ft"
|
|
29
|
+
|
|
30
|
+
model_config = ModelConfig(
|
|
31
|
+
model_id="openai/gpt-oss-20b",
|
|
32
|
+
)
|
|
33
|
+
quantizer = GPTQ(wbits=4, groupsize=128)
|
|
34
|
+
print(
|
|
35
|
+
f"Quantizer: {type(quantizer).__name__} (wbits={quantizer.wbits}, groupsize={quantizer.groupsize})"
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
router_fine_tuning = RouterFineTuning(
|
|
39
|
+
dataset_name="Salesforce/wikitext",
|
|
40
|
+
dataset_config_name="wikitext-2-raw-v1",
|
|
41
|
+
train_split="train",
|
|
42
|
+
text_column="text",
|
|
43
|
+
max_train_samples=512,
|
|
44
|
+
max_length=512,
|
|
45
|
+
epochs=1,
|
|
46
|
+
batch_size=1,
|
|
47
|
+
gradient_accumulation_steps=8,
|
|
48
|
+
lr=1e-5,
|
|
49
|
+
logging_steps=10,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
runner = Runner(
|
|
53
|
+
model_config=model_config,
|
|
54
|
+
quantizer=quantizer,
|
|
55
|
+
calibration_config=CalibrationConfig(
|
|
56
|
+
max_length=512,
|
|
57
|
+
num_calibration_samples=128,
|
|
58
|
+
),
|
|
59
|
+
moe_quant_experts=True,
|
|
60
|
+
post_processes=[router_fine_tuning],
|
|
61
|
+
)
|
|
62
|
+
runner.run()
|
|
63
|
+
|
|
64
|
+
original_ppl, _, fine_tuned_ppl = runner.calculate_perplexity(
|
|
65
|
+
original_model=True,
|
|
66
|
+
quantized_model=True,
|
|
67
|
+
)
|
|
68
|
+
print(f"\nOriginal MoE PPL: {original_ppl:.4f}")
|
|
69
|
+
print(f"Quantized MoE + router FT PPL: {fine_tuned_ppl:.4f}")
|
|
70
|
+
|
|
71
|
+
runner.save_quantized_model(save_dir)
|
|
72
|
+
print(f"\nModel saved (safetensors) to {save_dir}")
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
if __name__ == "__main__":
|
|
76
|
+
main()
|
|
@@ -11,7 +11,7 @@ Public API:
|
|
|
11
11
|
export_to_gguf -- single entry: routes any supported checkpoint to GGUF
|
|
12
12
|
convert_gptq_to_gguf -- direct, lossless GPTQ -> GGUF (preserves QEP codes)
|
|
13
13
|
export_via_dequantize -- fallback: dequantize -> convert -> llama-quantize
|
|
14
|
-
dequantize_to_hf -- reconstruct a dense
|
|
14
|
+
dequantize_to_hf -- reconstruct a dense HF model (GPTQ/DBF/MDBF/rotated)
|
|
15
15
|
LlamaCppModel -- CPU text generation on a GGUF model
|
|
16
16
|
inspect_gguf -- per-tensor quant types / size / effective bit-width
|
|
17
17
|
perplexity -- CPU perplexity of a GGUF model on text
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"""GGUF export for OneComp
|
|
1
|
+
"""GGUF export for OneComp quantized checkpoints.
|
|
2
2
|
|
|
3
3
|
Modules:
|
|
4
4
|
blocks -- lossless packing of GPTQ codes into GGUF legacy blocks
|
|
5
5
|
checkpoint -- read an OneComp GPTQ checkpoint into ``GPTQLayer`` objects
|
|
6
|
-
dequantize -- reconstruct a dense
|
|
6
|
+
dequantize -- reconstruct a dense HF model from GPTQ/DBF/MDBF weights
|
|
7
7
|
skeleton -- build a metadata/tokenizer skeleton GGUF and stitch tensors
|
|
8
8
|
direct -- direct, lossless GPTQ -> GGUF export (preferred)
|
|
9
|
-
fallback -- dequantize -> llama-quantize export (re-quantizes
|
|
9
|
+
fallback -- dequantize -> llama-quantize export (re-quantizes)
|
|
10
10
|
rotation -- fold a rotated model's online down_proj Hadamard into weights
|
|
11
11
|
auto -- single entry point that routes by quant_method / rotation
|
|
12
12
|
|
|
@@ -9,6 +9,7 @@ gptq AutoGPTQ qweight/qzeros/scales direct (lossless)
|
|
|
9
9
|
mixed_gptq same, per-layer bitwidths mixed (lossless + K-quant)
|
|
10
10
|
jointq / rtn same AutoGPTQ layout direct (lossless)
|
|
11
11
|
dbf DoubleBinaryLinear (binary factors) fallback (dequantize)
|
|
12
|
+
mdbf multi-path binary factors fallback (dequantize)
|
|
12
13
|
autobit mix of gptq/dbf children fallback (dequantize)
|
|
13
14
|
============ ==================================== =========================
|
|
14
15
|
|
|
@@ -21,7 +22,8 @@ the dequantize fallback, which folds the Hadamard back into the weight
|
|
|
21
22
|
(see :mod:`onecomp.cpu.export.rotation`) so the GGUF runs correctly with no
|
|
22
23
|
online operation.
|
|
23
24
|
|
|
24
|
-
OneBit
|
|
25
|
+
OneBit is rejected up-front, for every ``mode``; see
|
|
26
|
+
``UNSUPPORTED_METHODS`` in :mod:`onecomp.cpu.export.checkpoint` for why.
|
|
25
27
|
|
|
26
28
|
Copyright 2025-2026 Fujitsu Ltd.
|
|
27
29
|
|
|
@@ -35,6 +37,7 @@ from logging import getLogger
|
|
|
35
37
|
from typing import Dict, Optional
|
|
36
38
|
|
|
37
39
|
from onecomp.cpu.export.checkpoint import (
|
|
40
|
+
UNSUPPORTED_METHODS,
|
|
38
41
|
configured_bit_widths,
|
|
39
42
|
load_quant_config,
|
|
40
43
|
needs_mixed_export,
|
|
@@ -43,18 +46,15 @@ from onecomp.cpu.export.checkpoint import (
|
|
|
43
46
|
|
|
44
47
|
logger = getLogger(__name__)
|
|
45
48
|
|
|
46
|
-
# Methods we will not export (no faithful GGUF representation / out of scope).
|
|
47
|
-
_UNSUPPORTED = {"onebit"}
|
|
48
|
-
|
|
49
49
|
|
|
50
50
|
def plan_export(quantized_dir: str) -> Dict[str, object]:
|
|
51
51
|
"""Decide which export path to use for ``quantized_dir`` (no side effects).
|
|
52
52
|
|
|
53
|
-
Returns a dict with ``
|
|
54
|
-
|
|
53
|
+
Returns a dict with ``path`` (direct / mixed / fallback / unsupported), the
|
|
54
|
+
parsed :class:`QuantMeta` under ``meta``, and a human-readable ``reason``.
|
|
55
55
|
"""
|
|
56
56
|
meta = read_quant_meta(quantized_dir)
|
|
57
|
-
if meta.quant_method in
|
|
57
|
+
if meta.quant_method in UNSUPPORTED_METHODS:
|
|
58
58
|
return {
|
|
59
59
|
"path": "unsupported",
|
|
60
60
|
"meta": meta,
|
|
@@ -108,24 +108,41 @@ def export_to_gguf(
|
|
|
108
108
|
quantized_dir: OneComp quantized checkpoint directory.
|
|
109
109
|
out_gguf: Output ``.gguf`` path.
|
|
110
110
|
mode: ``auto`` (route by quant_method/rotation) or force a path with
|
|
111
|
-
``direct`` / ``mixed`` / ``fallback``.
|
|
111
|
+
``direct`` / ``mixed`` / ``fallback``. Forcing a path does not
|
|
112
|
+
override support or layout requirements.
|
|
112
113
|
qtype: target type for the fallback (dequantize) path, e.g. ``Q4_K_M``.
|
|
113
114
|
original_model: optional original FP model dir for skeleton metadata.
|
|
114
115
|
work_dir: scratch directory.
|
|
115
116
|
|
|
116
117
|
Returns:
|
|
117
118
|
Summary dict including the chosen ``path`` and per-path details.
|
|
119
|
+
|
|
120
|
+
Raises:
|
|
121
|
+
ValueError: If the method or forced mode is incompatible, or ``mode``
|
|
122
|
+
is not one of auto/direct/mixed/fallback.
|
|
118
123
|
"""
|
|
119
124
|
plan = plan_export(quantized_dir)
|
|
120
|
-
chosen = mode if mode != "auto" else plan["path"]
|
|
121
125
|
meta = plan["meta"]
|
|
122
126
|
|
|
123
|
-
|
|
127
|
+
# Test the *plan*, not the resolved mode: an explicit ``mode=`` names a path,
|
|
128
|
+
# not a capability, so forcing one must not route an unsupported method into
|
|
129
|
+
# an exporter that cannot represent it.
|
|
130
|
+
if plan["path"] == "unsupported":
|
|
124
131
|
raise ValueError(
|
|
125
132
|
f"quant_method={meta.quant_method!r} is not supported for CPU/GGUF export. "
|
|
126
|
-
"Supported: gptq, mixed_gptq, jointq, rtn, dbf, autobit
|
|
133
|
+
"Supported: gptq, mixed_gptq, jointq, rtn, dbf, mdbf, autobit "
|
|
134
|
+
"(and rotated variants)."
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
if mode in ("direct", "mixed") and not meta.supports_direct:
|
|
138
|
+
raise ValueError(
|
|
139
|
+
f"mode={mode!r} needs the AutoGPTQ block layout and no online Hadamard "
|
|
140
|
+
f"(quant_method={meta.quant_method!r}, rotated={meta.rotated}); "
|
|
141
|
+
"use mode='fallback'."
|
|
127
142
|
)
|
|
128
143
|
|
|
144
|
+
chosen = mode if mode != "auto" else plan["path"]
|
|
145
|
+
|
|
129
146
|
logger.info(
|
|
130
147
|
"export_to_gguf: %s -> %s | method=%s rotated=%s | path=%s (%s)",
|
|
131
148
|
quantized_dir,
|
|
@@ -86,6 +86,10 @@ class QuantMeta:
|
|
|
86
86
|
# (so iter_gptq_layers can read them): GPTQ, QEP (same codes), JointQ, RTN, mixed.
|
|
87
87
|
_GPTQ_FAMILY = {"gptq", "mixed_gptq", "jointq", "rtn"}
|
|
88
88
|
|
|
89
|
+
# quant_method values with no GGUF export at all. Lives here (not in ``auto``)
|
|
90
|
+
# so the low-level ``dequantize_to_hf`` entry point rejects OneBit too.
|
|
91
|
+
UNSUPPORTED_METHODS = {"onebit"}
|
|
92
|
+
|
|
89
93
|
|
|
90
94
|
def configured_bit_widths(quant_config: dict) -> set:
|
|
91
95
|
"""All weight bit-widths in a checkpoint (default + per-layer ``quantization_bits``)."""
|
|
@@ -180,10 +184,11 @@ def _per_layer_overrides(quant_config: dict) -> Dict[str, Dict[str, int]]:
|
|
|
180
184
|
|
|
181
185
|
|
|
182
186
|
def iter_gptq_layers(save_directory: str) -> Iterator[GPTQLayer]:
|
|
183
|
-
"""Yield every
|
|
187
|
+
"""Yield every AutoGPTQ-layout linear in a saved OneComp model, fully unpacked.
|
|
184
188
|
|
|
185
|
-
|
|
186
|
-
|
|
189
|
+
GPTQ-family checkpoints use ``qweight`` / ``qzeros`` / ``scales`` tensors.
|
|
190
|
+
Checkpoints without this layout yield no layers here. DBF and MDBF instead
|
|
191
|
+
use dedicated dense reconstruction helpers; OneBit is unsupported.
|
|
187
192
|
"""
|
|
188
193
|
quant_config = load_quant_config(save_directory)
|
|
189
194
|
state = _load_state_dict(save_directory)
|