onecomp 1.3.4__tar.gz → 1.4.1__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.
Files changed (329) hide show
  1. {onecomp-1.3.4/onecomp.egg-info → onecomp-1.4.1}/PKG-INFO +16 -6
  2. {onecomp-1.3.4 → onecomp-1.4.1}/README.md +15 -5
  3. onecomp-1.4.1/envs/openvino/example_export_openvino.py +66 -0
  4. onecomp-1.4.1/envs/openvino/openvino_export_utils.py +115 -0
  5. onecomp-1.4.1/example/post_process/example_global_ptq_mdbf.py +48 -0
  6. onecomp-1.4.1/example/post_process/example_router_fine_tuning.py +76 -0
  7. {onecomp-1.3.4 → onecomp-1.4.1}/llamacpp_plugins/gptq/llamacpp_plugin.py +42 -6
  8. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/__version__.py +1 -1
  9. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/cli.py +3 -1
  10. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/cpu/__init__.py +1 -1
  11. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/cpu/export/__init__.py +3 -3
  12. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/cpu/export/auto.py +28 -11
  13. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/cpu/export/checkpoint.py +8 -3
  14. onecomp-1.4.1/onecomp/cpu/export/dequantize.py +429 -0
  15. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/cpu/export/direct.py +32 -6
  16. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/cpu/export/fallback.py +8 -6
  17. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/cpu/export/skeleton.py +3 -2
  18. onecomp-1.4.1/onecomp/cpu/export/transforms/__init__.py +0 -0
  19. onecomp-1.4.1/onecomp/cpu/export/transforms/qwen35.py +258 -0
  20. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/cpu/llama_tooling.py +48 -5
  21. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/export/hub.py +1 -1
  22. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/export/model_card.py +38 -4
  23. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/post_process/__init__.py +2 -0
  24. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/post_process/_global_ptq/core.py +89 -16
  25. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/post_process/_global_ptq/dbf_adapter.py +30 -12
  26. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/post_process/_global_ptq/gptq_adapter.py +23 -12
  27. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/post_process/_global_ptq/helpers.py +23 -1
  28. onecomp-1.4.1/onecomp/post_process/_global_ptq/mdbf_adapter.py +236 -0
  29. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/post_process/_global_ptq/trainer.py +36 -12
  30. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/post_process/global_ptq.py +56 -1
  31. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/post_process/global_ptq_distributed.py +116 -41
  32. onecomp-1.4.1/onecomp/post_process/router_fine_tuning.py +398 -0
  33. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/mdbf/mdbf_layer.py +20 -11
  34. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/runner.py +18 -99
  35. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/utils/quantization_progress.py +7 -8
  36. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/utils/unfuse_moe.py +91 -18
  37. {onecomp-1.3.4 → onecomp-1.4.1/onecomp.egg-info}/PKG-INFO +16 -6
  38. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp.egg-info/SOURCES.txt +9 -1
  39. onecomp-1.4.1/scripts/check_readme_examples.py +68 -0
  40. onecomp-1.3.4/onecomp/cpu/export/dequantize.py +0 -166
  41. onecomp-1.3.4/onecomp/runner_methods/multi_gpu_quantization.py +0 -406
  42. {onecomp-1.3.4 → onecomp-1.4.1}/LICENSE +0 -0
  43. {onecomp-1.3.4 → onecomp-1.4.1}/benchmark/llama3-8b-gptq/quant_benchmark.py +0 -0
  44. {onecomp-1.3.4 → onecomp-1.4.1}/benchmark/llama3-8b-jointq/quant_benchmark.py +0 -0
  45. {onecomp-1.3.4 → onecomp-1.4.1}/benchmark/llama3-8b-lpcd-gptq/quant_benchmark.py +0 -0
  46. {onecomp-1.3.4 → onecomp-1.4.1}/benchmark/llama3-8b-qep-gptq/quant_benchmark.py +0 -0
  47. {onecomp-1.3.4 → onecomp-1.4.1}/benchmark/llama3-8b-various/quant_benchmark.py +0 -0
  48. {onecomp-1.3.4 → onecomp-1.4.1}/benchmark/qwen3-14b-gptq/quant_benchmark.py +0 -0
  49. {onecomp-1.3.4 → onecomp-1.4.1}/benchmark/qwen3-14b-jointq/quant_benchmark.py +0 -0
  50. {onecomp-1.3.4 → onecomp-1.4.1}/benchmark/qwen3-8b-gptq/quant_benchmark.py +0 -0
  51. {onecomp-1.3.4 → onecomp-1.4.1}/benchmark/qwen3-8b-jointq/quant_benchmark.py +0 -0
  52. {onecomp-1.3.4 → onecomp-1.4.1}/dashboard/backend/app/__init__.py +0 -0
  53. {onecomp-1.3.4 → onecomp-1.4.1}/dashboard/backend/app/api/__init__.py +0 -0
  54. {onecomp-1.3.4 → onecomp-1.4.1}/dashboard/backend/app/api/jobs.py +0 -0
  55. {onecomp-1.3.4 → onecomp-1.4.1}/dashboard/backend/app/constants.py +0 -0
  56. {onecomp-1.3.4 → onecomp-1.4.1}/dashboard/backend/app/core/__init__.py +0 -0
  57. {onecomp-1.3.4 → onecomp-1.4.1}/dashboard/backend/app/core/config.py +0 -0
  58. {onecomp-1.3.4 → onecomp-1.4.1}/dashboard/backend/app/core/database.py +0 -0
  59. {onecomp-1.3.4 → onecomp-1.4.1}/dashboard/backend/app/main.py +0 -0
  60. {onecomp-1.3.4 → onecomp-1.4.1}/dashboard/backend/app/models/__init__.py +0 -0
  61. {onecomp-1.3.4 → onecomp-1.4.1}/dashboard/backend/app/models/job.py +0 -0
  62. {onecomp-1.3.4 → onecomp-1.4.1}/dashboard/backend/app/schemas/__init__.py +0 -0
  63. {onecomp-1.3.4 → onecomp-1.4.1}/dashboard/backend/app/schemas/job.py +0 -0
  64. {onecomp-1.3.4 → onecomp-1.4.1}/dashboard/backend/app/services/__init__.py +0 -0
  65. {onecomp-1.3.4 → onecomp-1.4.1}/dashboard/backend/app/services/huggingface.py +0 -0
  66. {onecomp-1.3.4 → onecomp-1.4.1}/dashboard/backend/app/services/inference.py +0 -0
  67. {onecomp-1.3.4 → onecomp-1.4.1}/dashboard/backend/app/services/job_store.py +0 -0
  68. {onecomp-1.3.4 → onecomp-1.4.1}/dashboard/backend/app/worker/__init__.py +0 -0
  69. {onecomp-1.3.4 → onecomp-1.4.1}/dashboard/backend/app/worker/celery_app.py +0 -0
  70. {onecomp-1.3.4 → onecomp-1.4.1}/dashboard/backend/app/worker/tasks.py +0 -0
  71. {onecomp-1.3.4 → onecomp-1.4.1}/dashboard/backend/cpu_patch.py +0 -0
  72. {onecomp-1.3.4 → onecomp-1.4.1}/dashboard/backend/start_backend.py +0 -0
  73. {onecomp-1.3.4 → onecomp-1.4.1}/dashboard/backend/start_worker.py +0 -0
  74. {onecomp-1.3.4 → onecomp-1.4.1}/envs/vllm/v0_24_0_rocm/src/onecomp_vllm_v0_24_0_rocm/__init__.py +0 -0
  75. {onecomp-1.3.4 → onecomp-1.4.1}/envs/vllm/v0_24_0_rocm/src/onecomp_vllm_v0_24_0_rocm/patch.py +0 -0
  76. {onecomp-1.3.4 → onecomp-1.4.1}/example/cpu_inference/example_gptq_gguf_cpu.py +0 -0
  77. {onecomp-1.3.4 → onecomp-1.4.1}/example/cpu_inference/example_mixed_gptq_gguf_cpu.py +0 -0
  78. {onecomp-1.3.4 → onecomp-1.4.1}/example/cpu_inference/example_serve_cpu.py +0 -0
  79. {onecomp-1.3.4 → onecomp-1.4.1}/example/example_auto_run.py +0 -0
  80. {onecomp-1.3.4 → onecomp-1.4.1}/example/example_autobit.py +0 -0
  81. {onecomp-1.3.4 → onecomp-1.4.1}/example/example_custom_calibration.py +0 -0
  82. {onecomp-1.3.4 → onecomp-1.4.1}/example/example_gptq.py +0 -0
  83. {onecomp-1.3.4 → onecomp-1.4.1}/example/example_jointq.py +0 -0
  84. {onecomp-1.3.4 → onecomp-1.4.1}/example/example_lpcd_gptq.py +0 -0
  85. {onecomp-1.3.4 → onecomp-1.4.1}/example/example_mdbf.py +0 -0
  86. {onecomp-1.3.4 → onecomp-1.4.1}/example/example_qep_gptq.py +0 -0
  87. {onecomp-1.3.4 → onecomp-1.4.1}/example/example_save_load.py +0 -0
  88. {onecomp-1.3.4 → onecomp-1.4.1}/example/post_process/example_blockwise_global_ptq.py +0 -0
  89. {onecomp-1.3.4 → onecomp-1.4.1}/example/post_process/example_blockwise_global_ptq_staged.py +0 -0
  90. {onecomp-1.3.4 → onecomp-1.4.1}/example/post_process/example_blockwise_ptq.py +0 -0
  91. {onecomp-1.3.4 → onecomp-1.4.1}/example/post_process/example_global_ptq.py +0 -0
  92. {onecomp-1.3.4 → onecomp-1.4.1}/example/post_process/example_global_ptq_dbf.py +0 -0
  93. {onecomp-1.3.4 → onecomp-1.4.1}/example/post_process/example_global_ptq_distributed.py +0 -0
  94. {onecomp-1.3.4 → onecomp-1.4.1}/example/post_process/example_lora_gptq_vllm_inference.py +0 -0
  95. {onecomp-1.3.4 → onecomp-1.4.1}/example/post_process/example_lora_sft.py +0 -0
  96. {onecomp-1.3.4 → onecomp-1.4.1}/example/post_process/example_lora_sft_knowledge.py +0 -0
  97. {onecomp-1.3.4 → onecomp-1.4.1}/example/post_process/example_lora_sft_knowledge_jointq.py +0 -0
  98. {onecomp-1.3.4 → onecomp-1.4.1}/example/post_process/example_reload_post_process_resave.py +0 -0
  99. {onecomp-1.3.4 → onecomp-1.4.1}/example/pre_process/example_llama_preprocess_rtn.py +0 -0
  100. {onecomp-1.3.4 → onecomp-1.4.1}/example/pre_process/example_preprocess_save_load.py +0 -0
  101. {onecomp-1.3.4 → onecomp-1.4.1}/example/vllm_inference/example_autobit_vllm_inference.py +0 -0
  102. {onecomp-1.3.4 → onecomp-1.4.1}/example/vllm_inference/example_dbf_vllm_inference.py +0 -0
  103. {onecomp-1.3.4 → onecomp-1.4.1}/example/vllm_inference/example_gptq_vllm_gptoss_inference.py +0 -0
  104. {onecomp-1.3.4 → onecomp-1.4.1}/example/vllm_inference/example_gptq_vllm_inference.py +0 -0
  105. {onecomp-1.3.4 → onecomp-1.4.1}/example/vllm_inference/example_gptq_vllm_qwen36_inference.py +0 -0
  106. {onecomp-1.3.4 → onecomp-1.4.1}/example/vllm_inference/example_jointq_vllm_inference.py +0 -0
  107. {onecomp-1.3.4 → onecomp-1.4.1}/llamacpp_plugins/__init__.py +0 -0
  108. {onecomp-1.3.4 → onecomp-1.4.1}/llamacpp_plugins/gptq/__init__.py +0 -0
  109. {onecomp-1.3.4 → onecomp-1.4.1}/llamacpp_plugins/gptq/constants.py +0 -0
  110. {onecomp-1.3.4 → onecomp-1.4.1}/model_validation/autobit/validate_autobit.py +0 -0
  111. {onecomp-1.3.4 → onecomp-1.4.1}/model_validation/autobit_qep/validate_autobit.py +0 -0
  112. {onecomp-1.3.4 → onecomp-1.4.1}/model_validation/gptq/validate_gptq.py +0 -0
  113. {onecomp-1.3.4 → onecomp-1.4.1}/model_validation/gptq/validate_load.py +0 -0
  114. {onecomp-1.3.4 → onecomp-1.4.1}/model_validation/gptq/validate_vllm.py +0 -0
  115. {onecomp-1.3.4 → onecomp-1.4.1}/model_validation/jointq/validate_jointq.py +0 -0
  116. {onecomp-1.3.4 → onecomp-1.4.1}/model_validation/qep_gptq/validate_gptq.py +0 -0
  117. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/__init__.py +0 -0
  118. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/__main__.py +0 -0
  119. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/analyzer/__init__.py +0 -0
  120. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/analyzer/cumulative_error.py +0 -0
  121. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/analyzer/quantization_error.py +0 -0
  122. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/analyzer/weight_outlier.py +0 -0
  123. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/calibration/__init__.py +0 -0
  124. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/calibration/_cache.py +0 -0
  125. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/calibration/c4.py +0 -0
  126. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/calibration/calibration_config.py +0 -0
  127. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/calibration/calibration_data_loader.py +0 -0
  128. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/calibration/chunking.py +0 -0
  129. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/calibration/custom.py +0 -0
  130. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/calibration/wikitext.py +0 -0
  131. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/cpu/cli.py +0 -0
  132. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/cpu/eval/__init__.py +0 -0
  133. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/cpu/eval/benchmark.py +0 -0
  134. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/cpu/eval/inspect_gguf.py +0 -0
  135. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/cpu/eval/parity.py +0 -0
  136. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/cpu/eval/perplexity.py +0 -0
  137. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/cpu/export/blocks.py +0 -0
  138. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/cpu/export/rotation.py +0 -0
  139. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/cpu/inference.py +0 -0
  140. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/cpu/serve.py +0 -0
  141. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/eval/__init__.py +0 -0
  142. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/eval/__main__.py +0 -0
  143. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/eval/conf/__init__.py +0 -0
  144. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/eval/conf/eval_config.yaml +0 -0
  145. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/eval/evals/__init__.py +0 -0
  146. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/eval/evals/base.py +0 -0
  147. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/eval/evals/mt_bench/__init__.py +0 -0
  148. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/eval/evals/mt_bench/adapter.py +0 -0
  149. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/eval/evals/mt_bench/data.py +0 -0
  150. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/eval/evals/mt_bench/gen_answer.py +0 -0
  151. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/eval/evals/mt_bench/judge.py +0 -0
  152. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/eval/evals/mt_bench/radar_chart.py +0 -0
  153. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/eval/evals/mt_bench/run.py +0 -0
  154. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/eval/evals/mt_bench/show_result.py +0 -0
  155. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/eval/evals/throughput/__init__.py +0 -0
  156. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/eval/evals/throughput/adapter.py +0 -0
  157. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/eval/evals/throughput/bench.py +0 -0
  158. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/eval/evals/throughput/run.py +0 -0
  159. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/eval/orchestrator/__init__.py +0 -0
  160. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/eval/orchestrator/aggregator.py +0 -0
  161. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/eval/orchestrator/runner.py +0 -0
  162. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/eval/orchestrator/server.py +0 -0
  163. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/eval/orchestrator/subprocess_runner.py +0 -0
  164. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/eval/run_evaluate.py +0 -0
  165. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/eval/schema.py +0 -0
  166. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/eval/utils/__init__.py +0 -0
  167. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/eval/utils/model_utils.py +0 -0
  168. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/eval/utils/ports.py +0 -0
  169. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/eval/utils/resources.py +0 -0
  170. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/eval/utils/secrets.py +0 -0
  171. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/export/__init__.py +0 -0
  172. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/export/gguf_export.py +0 -0
  173. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/export/gguf_reader.py +0 -0
  174. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/export/gguf_writer.py +0 -0
  175. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/log.py +0 -0
  176. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/lpcd/__init__.py +0 -0
  177. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/lpcd/_gradient_solver.py +0 -0
  178. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/lpcd/_lpcd_config.py +0 -0
  179. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/lpcd/_lpcd_runner.py +0 -0
  180. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/lpcd/_metric.py +0 -0
  181. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/lpcd/_refiner.py +0 -0
  182. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/lpcd/arch/_llama.py +0 -0
  183. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/lpcd/arch/_llama_cf.py +0 -0
  184. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/lpcd/arch/_qwen3.py +0 -0
  185. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/model_config.py +0 -0
  186. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/post_process/_base.py +0 -0
  187. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/post_process/_blockwise/__init__.py +0 -0
  188. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/post_process/_blockwise/dbf_block_optimizer.py +0 -0
  189. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/post_process/_blockwise/dbf_cbq_optimizer.py +0 -0
  190. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/post_process/_blockwise/generic_block_optimizer.py +0 -0
  191. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/post_process/_blockwise/gptq_block_optimizer.py +0 -0
  192. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/post_process/_blockwise/gptq_cbq_optimizer.py +0 -0
  193. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/post_process/_blockwise/helpers.py +0 -0
  194. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/post_process/_blockwise/onebit_block_optimizer.py +0 -0
  195. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/post_process/_blockwise/onebit_cbq_optimizer.py +0 -0
  196. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/post_process/_global_ptq/__init__.py +0 -0
  197. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/post_process/_global_ptq/losses.py +0 -0
  198. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/post_process/_runtime.py +0 -0
  199. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/post_process/blockwise_ptq.py +0 -0
  200. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/post_process/post_process_lora_sft.py +0 -0
  201. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/pre_process/__init__.py +0 -0
  202. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/pre_process/hadamard_utils.py +0 -0
  203. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/pre_process/modeling_llama.py +0 -0
  204. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/pre_process/modeling_qwen3.py +0 -0
  205. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/pre_process/optimizer.py +0 -0
  206. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/pre_process/prepare_rotated_model.py +0 -0
  207. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/pre_process/preprocess_args.py +0 -0
  208. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/pre_process/quant_models.py +0 -0
  209. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/pre_process/rotation_utils.py +0 -0
  210. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/pre_process/train_rotation.py +0 -0
  211. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/qep/__init__.py +0 -0
  212. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/qep/_qep_config.py +0 -0
  213. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/qep/_quantize_with_qep.py +0 -0
  214. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/qep/_quantize_with_qep_arch.py +0 -0
  215. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantized_model_loader.py +0 -0
  216. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/__init__.py +0 -0
  217. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/_quantizer.py +0 -0
  218. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/arb/__init__.py +0 -0
  219. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/arb/_arb.py +0 -0
  220. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/arb/arb_impl.py +0 -0
  221. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/autobit/__init__.py +0 -0
  222. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/autobit/_autobit.py +0 -0
  223. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/autobit/activation_stats.py +0 -0
  224. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/autobit/dbf_fallback.py +0 -0
  225. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/autobit/ilp.py +0 -0
  226. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/autobit/manual.py +0 -0
  227. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/autobit/visualize.py +0 -0
  228. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/cq/__init__.py +0 -0
  229. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/cq/_cq.py +0 -0
  230. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/cq/cq_impl.py +0 -0
  231. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/dbf/__init__.py +0 -0
  232. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/dbf/_dbf.py +0 -0
  233. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/dbf/admm_extended.py +0 -0
  234. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/dbf/balance.py +0 -0
  235. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/dbf/config.py +0 -0
  236. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/dbf/dbf_impl.py +0 -0
  237. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/dbf/dbf_layer.py +0 -0
  238. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/dbf/dbf_original.py +0 -0
  239. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/dbf/fine_tune.py +0 -0
  240. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/dbf/middle.py +0 -0
  241. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/gemlite.py +0 -0
  242. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/gptq/__init__.py +0 -0
  243. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/gptq/_gptq.py +0 -0
  244. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/gptq/config.py +0 -0
  245. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/gptq/gptq_layer.py +0 -0
  246. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/jointq/__init__.py +0 -0
  247. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/jointq/_jointq.py +0 -0
  248. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/jointq/core/__init__.py +0 -0
  249. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/jointq/core/__version__.py +0 -0
  250. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/jointq/core/clip.py +0 -0
  251. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/jointq/core/error_propagation/__init__.py +0 -0
  252. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/jointq/core/error_propagation/local_search_advanced.py +0 -0
  253. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/jointq/core/error_propagation/quantize_advanced.py +0 -0
  254. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/jointq/core/error_propagation/quantizer_advanced.py +0 -0
  255. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/jointq/core/local_search.py +0 -0
  256. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/jointq/core/quantize.py +0 -0
  257. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/jointq/core/quantize_multi_gpu.py +0 -0
  258. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/jointq/core/quantizer.py +0 -0
  259. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/jointq/core/solution.py +0 -0
  260. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/mdbf/__init__.py +0 -0
  261. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/mdbf/_mdbf.py +0 -0
  262. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/mdbf/admm.py +0 -0
  263. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/mdbf/config.py +0 -0
  264. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/mdbf/gradient_refine.py +0 -0
  265. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/mdbf/initialize.py +0 -0
  266. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/mdbf/mdbf_impl.py +0 -0
  267. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/mdbf/utils.py +0 -0
  268. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/onebit/__init__.py +0 -0
  269. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/onebit/_onebit.py +0 -0
  270. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/onebit/onebit_impl.py +0 -0
  271. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/onebit/onebit_layer.py +0 -0
  272. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/qbb/__init__.py +0 -0
  273. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/qbb/_qbb.py +0 -0
  274. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/qbb/qbb_impl.py +0 -0
  275. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/quip/__init__.py +0 -0
  276. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/quip/_quip.py +0 -0
  277. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/quip/quant_quip.py +0 -0
  278. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/quip/quip_impl.py +0 -0
  279. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/quip/utils.py +0 -0
  280. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/quip/utils_had.py +0 -0
  281. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/quip/vector_balance.py +0 -0
  282. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/rtn/__init__.py +0 -0
  283. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/rtn/_rtn.py +0 -0
  284. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/rtn/quantizer.py +0 -0
  285. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/quantizer/rtn/rtn_impl.py +0 -0
  286. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/rotated_model_config.py +0 -0
  287. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/runner_methods/__init__.py +0 -0
  288. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/runner_methods/chunked_quantization.py +0 -0
  289. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/runner_methods/jointq_error_propagation.py +0 -0
  290. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/utils/__init__.py +0 -0
  291. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/utils/accuracy.py +0 -0
  292. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/utils/activation_capture.py +0 -0
  293. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/utils/activation_check.py +0 -0
  294. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/utils/blockwise.py +0 -0
  295. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/utils/device.py +0 -0
  296. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/utils/dtype.py +0 -0
  297. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/utils/lora.py +0 -0
  298. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/utils/model_inputs.py +0 -0
  299. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/utils/mxfp4_compat.py +0 -0
  300. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/utils/perplexity.py +0 -0
  301. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/utils/quant_config.py +0 -0
  302. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp/utils/vram_estimator.py +0 -0
  303. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp.egg-info/dependency_links.txt +0 -0
  304. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp.egg-info/entry_points.txt +0 -0
  305. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp.egg-info/requires.txt +0 -0
  306. {onecomp-1.3.4 → onecomp-1.4.1}/onecomp.egg-info/top_level.txt +0 -0
  307. {onecomp-1.3.4 → onecomp-1.4.1}/pyproject.toml +0 -0
  308. {onecomp-1.3.4 → onecomp-1.4.1}/scripts/check_copyright_header.py +0 -0
  309. {onecomp-1.3.4 → onecomp-1.4.1}/scripts/check_no_japanese.py +0 -0
  310. {onecomp-1.3.4 → onecomp-1.4.1}/scripts/prepare_calibration_cache.py +0 -0
  311. {onecomp-1.3.4 → onecomp-1.4.1}/setup.cfg +0 -0
  312. {onecomp-1.3.4 → onecomp-1.4.1}/vllm_plugins/__init__.py +0 -0
  313. {onecomp-1.3.4 → onecomp-1.4.1}/vllm_plugins/dbf/__init__.py +0 -0
  314. {onecomp-1.3.4 → onecomp-1.4.1}/vllm_plugins/dbf/modules/__init__.py +0 -0
  315. {onecomp-1.3.4 → onecomp-1.4.1}/vllm_plugins/dbf/modules/gemlite_linear.py +0 -0
  316. {onecomp-1.3.4 → onecomp-1.4.1}/vllm_plugins/dbf/modules/naive.py +0 -0
  317. {onecomp-1.3.4 → onecomp-1.4.1}/vllm_plugins/dbf/vllm_plugin.py +0 -0
  318. {onecomp-1.3.4 → onecomp-1.4.1}/vllm_plugins/gptq/__init__.py +0 -0
  319. {onecomp-1.3.4 → onecomp-1.4.1}/vllm_plugins/gptq/constants.py +0 -0
  320. {onecomp-1.3.4 → onecomp-1.4.1}/vllm_plugins/gptq/gptoss_wna16_moe.py +0 -0
  321. {onecomp-1.3.4 → onecomp-1.4.1}/vllm_plugins/gptq/vllm_plugin.py +0 -0
  322. {onecomp-1.3.4 → onecomp-1.4.1}/vllm_plugins/patches/__init__.py +0 -0
  323. {onecomp-1.3.4 → onecomp-1.4.1}/vllm_plugins/patches/_paths.py +0 -0
  324. {onecomp-1.3.4 → onecomp-1.4.1}/vllm_plugins/patches/apply_all.py +0 -0
  325. {onecomp-1.3.4 → onecomp-1.4.1}/vllm_plugins/patches/gpt_oss_gptq_moe.py +0 -0
  326. {onecomp-1.3.4 → onecomp-1.4.1}/vllm_plugins/patches/gpt_oss_wna16_bias.py +0 -0
  327. {onecomp-1.3.4 → onecomp-1.4.1}/vllm_plugins/utils/__init__.py +0 -0
  328. {onecomp-1.3.4 → onecomp-1.4.1}/vllm_plugins/utils/module.py +0 -0
  329. {onecomp-1.3.4 → onecomp-1.4.1}/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.4
3
+ Version: 1.4.1
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
@@ -168,10 +171,11 @@ Other Hugging Face-compatible models may work but are currently untested.
168
171
  | # | Architecture | Verified Models | Status |
169
172
  |---|-------------|-----------------|--------|
170
173
  | 1 | Llama | TinyLlama, Llama-2, Llama-3 | ✅ Verified |
171
- | 2 | Qwen3 | Qwen3-0.6B ~ 32B | ✅ Verified |
172
- | 3 | Gemma | Gemma 2, Gemma 3, Gemma 4 | ✅ Verified |
174
+ | 2 | Qwen3 | Qwen3-0.6B ~ 32B, Qwen3-30B-A3B | ✅ Verified |
175
+ | 3 | Gemma | Gemma 2, Gemma 3, Gemma 4, Gemma 4-26B-A4B | ✅ Verified |
173
176
  | 4 | [GPT-OSS](docs/user-guide/gptoss.md) | openai/gpt-oss-20b, gpt-oss-120b | ✅ Verified |
174
177
  | 5 | Qwen3.6 | Qwen3.6-27B, Qwen3.6-35B-A3B | ✅ Verified |
178
+ | 6 | Qwen3.8 | Qwen3.8-27B | ✅ Verified |
175
179
 
176
180
 
177
181
  > **Note:** Support for additional architectures is planned. Contributions and test reports are welcome.
@@ -240,7 +244,7 @@ Then install OneComp from PyPI (see step 2 below). GPTQ quantization and Hugging
240
244
  > - 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
245
  > - 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
246
  >
243
- > DBF-based AutoBit fallback and multi-GPU quantization are not supported on MPS.
247
+ > DBF-based AutoBit fallback is not supported on MPS.
244
248
 
245
249
  #### 2. Install `onecomp`
246
250
 
@@ -250,7 +254,7 @@ Once PyTorch is installed, you can install `onecomp`:
250
254
  pip install onecomp
251
255
  ```
252
256
 
253
- To enable multi-GPU training features (DeepSpeed), install with the `distributed` extra:
257
+ To enable multi-GPU training for Global PTQ (DeepSpeed), install with the `distributed` extra:
254
258
 
255
259
  ```bash
256
260
  pip install "onecomp[distributed]"
@@ -296,7 +300,7 @@ See the **MPS device placement (GPTQ vs QEP)** note under [macOS (MPS)](#macos-m
296
300
 
297
301
  Adding `--extra dev` installs development tools (black, pre-commit, pytest, pylint).
298
302
  Adding `--extra visualize` installs matplotlib for visualization features.
299
- Adding `--extra distributed` installs DeepSpeed for multi-GPU training.
303
+ Adding `--extra distributed` installs DeepSpeed for Global PTQ multi-GPU training.
300
304
  Adding `--extra hydra` installs `hydra-core` for the example scripts and `model_validation/` runners that use Hydra-based configuration.
301
305
 
302
306
  To use vLLM for serving quantized models on Linux, add `--extra vllm` together with `--extra cu130`:
@@ -409,6 +413,7 @@ See [`notebook/README.md`](./notebook/README.md) for local setup, or the
409
413
  | | [example_qep_gptq.py](./example/example_qep_gptq.py) | GPTQ + QEP (error propagation) |
410
414
  | | [example_lpcd_gptq.py](./example/example_lpcd_gptq.py) | GPTQ + QEP + LPCD quantization |
411
415
  | | [example_jointq.py](./example/example_jointq.py) | JointQ quantization |
416
+ | | [example_mdbf.py](./example/example_mdbf.py) | MDBF quantization |
412
417
  | | [example_autobit.py](./example/example_autobit.py) | AutoBit mixed-precision quantization |
413
418
  | | [example_auto_run.py](./example/example_auto_run.py) | AutoBit with automatic VRAM estimation |
414
419
  | Calibration | [example_custom_calibration.py](./example/example_custom_calibration.py) | Custom calibration dataset with CalibrationConfig |
@@ -421,7 +426,9 @@ See [`notebook/README.md`](./notebook/README.md) for local setup, or the
421
426
  | | [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
427
  | | [example_global_ptq.py](./example/post_process/example_global_ptq.py) | Global PTQ with packed buffers by default and HF-compatible safetensors output |
423
428
  | | [example_global_ptq_dbf.py](./example/post_process/example_global_ptq_dbf.py) | Global PTQ with the DBF backend and HF-compatible safetensors output |
429
+ | | [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
430
  | | [example_global_ptq_distributed.py](./example/post_process/example_global_ptq_distributed.py) | Multi-GPU Global PTQ with DeepSpeed / torchrun and safetensors output |
431
+ | | [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
432
  | | [example_lora_sft.py](./example/post_process/example_lora_sft.py) | LoRA SFT post-quantization fine-tuning |
426
433
  | | [example_lora_sft_knowledge.py](./example/post_process/example_lora_sft_knowledge.py) | LoRA SFT knowledge injection |
427
434
  | | [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 +439,9 @@ See [`notebook/README.md`](./notebook/README.md) for local setup, or the
432
439
  | | [example_jointq_vllm_inference.py](./example/vllm_inference/example_jointq_vllm_inference.py) | JointQ quantization and vLLM inference |
433
440
  | | [example_autobit_vllm_inference.py](./example/vllm_inference/example_autobit_vllm_inference.py) | AutoBit quantization and vLLM inference |
434
441
  | | [example_dbf_vllm_inference.py](./example/vllm_inference/example_dbf_vllm_inference.py) | DBF quantization and vLLM inference |
442
+ | 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 |
443
+ | | [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 |
444
+ | | [example_serve_cpu.py](./example/cpu_inference/example_serve_cpu.py) | Serve a GGUF model with llama.cpp on CPU |
435
445
 
436
446
  ## 🔌 vLLM Inference
437
447
 
@@ -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
@@ -54,10 +57,11 @@ Other Hugging Face-compatible models may work but are currently untested.
54
57
  | # | Architecture | Verified Models | Status |
55
58
  |---|-------------|-----------------|--------|
56
59
  | 1 | Llama | TinyLlama, Llama-2, Llama-3 | ✅ Verified |
57
- | 2 | Qwen3 | Qwen3-0.6B ~ 32B | ✅ Verified |
58
- | 3 | Gemma | Gemma 2, Gemma 3, Gemma 4 | ✅ Verified |
60
+ | 2 | Qwen3 | Qwen3-0.6B ~ 32B, Qwen3-30B-A3B | ✅ Verified |
61
+ | 3 | Gemma | Gemma 2, Gemma 3, Gemma 4, Gemma 4-26B-A4B | ✅ Verified |
59
62
  | 4 | [GPT-OSS](docs/user-guide/gptoss.md) | openai/gpt-oss-20b, gpt-oss-120b | ✅ Verified |
60
63
  | 5 | Qwen3.6 | Qwen3.6-27B, Qwen3.6-35B-A3B | ✅ Verified |
64
+ | 6 | Qwen3.8 | Qwen3.8-27B | ✅ Verified |
61
65
 
62
66
 
63
67
  > **Note:** Support for additional architectures is planned. Contributions and test reports are welcome.
@@ -126,7 +130,7 @@ Then install OneComp from PyPI (see step 2 below). GPTQ quantization and Hugging
126
130
  > - 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
131
  > - 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
132
  >
129
- > DBF-based AutoBit fallback and multi-GPU quantization are not supported on MPS.
133
+ > DBF-based AutoBit fallback is not supported on MPS.
130
134
 
131
135
  #### 2. Install `onecomp`
132
136
 
@@ -136,7 +140,7 @@ Once PyTorch is installed, you can install `onecomp`:
136
140
  pip install onecomp
137
141
  ```
138
142
 
139
- To enable multi-GPU training features (DeepSpeed), install with the `distributed` extra:
143
+ To enable multi-GPU training for Global PTQ (DeepSpeed), install with the `distributed` extra:
140
144
 
141
145
  ```bash
142
146
  pip install "onecomp[distributed]"
@@ -182,7 +186,7 @@ See the **MPS device placement (GPTQ vs QEP)** note under [macOS (MPS)](#macos-m
182
186
 
183
187
  Adding `--extra dev` installs development tools (black, pre-commit, pytest, pylint).
184
188
  Adding `--extra visualize` installs matplotlib for visualization features.
185
- Adding `--extra distributed` installs DeepSpeed for multi-GPU training.
189
+ Adding `--extra distributed` installs DeepSpeed for Global PTQ multi-GPU training.
186
190
  Adding `--extra hydra` installs `hydra-core` for the example scripts and `model_validation/` runners that use Hydra-based configuration.
187
191
 
188
192
  To use vLLM for serving quantized models on Linux, add `--extra vllm` together with `--extra cu130`:
@@ -295,6 +299,7 @@ See [`notebook/README.md`](./notebook/README.md) for local setup, or the
295
299
  | | [example_qep_gptq.py](./example/example_qep_gptq.py) | GPTQ + QEP (error propagation) |
296
300
  | | [example_lpcd_gptq.py](./example/example_lpcd_gptq.py) | GPTQ + QEP + LPCD quantization |
297
301
  | | [example_jointq.py](./example/example_jointq.py) | JointQ quantization |
302
+ | | [example_mdbf.py](./example/example_mdbf.py) | MDBF quantization |
298
303
  | | [example_autobit.py](./example/example_autobit.py) | AutoBit mixed-precision quantization |
299
304
  | | [example_auto_run.py](./example/example_auto_run.py) | AutoBit with automatic VRAM estimation |
300
305
  | Calibration | [example_custom_calibration.py](./example/example_custom_calibration.py) | Custom calibration dataset with CalibrationConfig |
@@ -307,7 +312,9 @@ See [`notebook/README.md`](./notebook/README.md) for local setup, or the
307
312
  | | [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
313
  | | [example_global_ptq.py](./example/post_process/example_global_ptq.py) | Global PTQ with packed buffers by default and HF-compatible safetensors output |
309
314
  | | [example_global_ptq_dbf.py](./example/post_process/example_global_ptq_dbf.py) | Global PTQ with the DBF backend and HF-compatible safetensors output |
315
+ | | [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
316
  | | [example_global_ptq_distributed.py](./example/post_process/example_global_ptq_distributed.py) | Multi-GPU Global PTQ with DeepSpeed / torchrun and safetensors output |
317
+ | | [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
318
  | | [example_lora_sft.py](./example/post_process/example_lora_sft.py) | LoRA SFT post-quantization fine-tuning |
312
319
  | | [example_lora_sft_knowledge.py](./example/post_process/example_lora_sft_knowledge.py) | LoRA SFT knowledge injection |
313
320
  | | [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 +325,9 @@ See [`notebook/README.md`](./notebook/README.md) for local setup, or the
318
325
  | | [example_jointq_vllm_inference.py](./example/vllm_inference/example_jointq_vllm_inference.py) | JointQ quantization and vLLM inference |
319
326
  | | [example_autobit_vllm_inference.py](./example/vllm_inference/example_autobit_vllm_inference.py) | AutoBit quantization and vLLM inference |
320
327
  | | [example_dbf_vllm_inference.py](./example/vllm_inference/example_dbf_vllm_inference.py) | DBF quantization and vLLM inference |
328
+ | 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 |
329
+ | | [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 |
330
+ | | [example_serve_cpu.py](./example/cpu_inference/example_serve_cpu.py) | Serve a GGUF model with llama.cpp on CPU |
321
331
 
322
332
  ## 🔌 vLLM Inference
323
333
 
@@ -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()
@@ -51,6 +51,12 @@ from onecomp.cpu.export.skeleton import (
51
51
  skeleton_logical_shapes,
52
52
  stitch_gguf,
53
53
  )
54
+ from onecomp.cpu.export.transforms.qwen35 import (
55
+ Qwen35LinearAttentionLayout,
56
+ is_qwen35_model,
57
+ load_qwen35_layout,
58
+ transform_qwen35_gptq,
59
+ )
54
60
  from onecomp.cpu.llama_tooling import run_llama_quantize_per_tensor
55
61
 
56
62
  logger = getLogger(__name__)
@@ -99,7 +105,9 @@ def _direct_pack_feasible(layer: GPTQLayer) -> bool:
99
105
  return False
100
106
 
101
107
 
102
- def _route_layer(layer: GPTQLayer) -> Tuple[str, str, str]:
108
+ def _route_layer(
109
+ layer: GPTQLayer, model_layout: Optional[Qwen35LinearAttentionLayout] = None
110
+ ) -> Tuple[str, str, str]:
103
111
  """Decide (route, ggml_type_name, reason) for one unpacked GPTQ layer."""
104
112
  route, gtype = select_gguf_route(layer.wbits, layer.sym)
105
113
 
@@ -118,10 +126,26 @@ def _route_layer(layer: GPTQLayer) -> Tuple[str, str, str]:
118
126
  kq = _ACTORDER_KQUANT.get(layer.wbits, "Q4_K")
119
127
  return ROUTE_KQUANT, kq, "direct pack infeasible (zero-point/shape): K-quant fallback"
120
128
 
129
+ if route == ROUTE_DIRECT and model_layout is not None:
130
+ try:
131
+ transform_qwen35_gptq(
132
+ layer_name=layer.name,
133
+ q_int=layer.q_int,
134
+ scales=layer.scales,
135
+ zeros=layer.zeros,
136
+ groupsize=layer.groupsize,
137
+ layout=model_layout,
138
+ )
139
+ except UnsupportedGPTQLayout as exc:
140
+ kq = _ACTORDER_KQUANT.get(layer.wbits, "Q4_K")
141
+ return ROUTE_KQUANT, kq, str(exc)
142
+
121
143
  return route, gtype.name, ""
122
144
 
123
145
 
124
- def plan_mixed_export(quantized_dir: str) -> List[ModulePlan]:
146
+ def plan_mixed_export(
147
+ quantized_dir: str, model_layout: Optional[Qwen35LinearAttentionLayout] = None
148
+ ) -> List[ModulePlan]:
125
149
  """Return the per-module GGUF routing plan for a (mixed_)gptq checkpoint.
126
150
 
127
151
  Does not build a skeleton or pack anything; useful for previewing how a
@@ -129,7 +153,7 @@ def plan_mixed_export(quantized_dir: str) -> List[ModulePlan]:
129
153
  """
130
154
  plans: List[ModulePlan] = []
131
155
  for layer in iter_gptq_layers(quantized_dir):
132
- route, gtype_name, reason = _route_layer(layer)
156
+ route, gtype_name, reason = _route_layer(layer, model_layout=model_layout)
133
157
  plans.append(
134
158
  ModulePlan(
135
159
  name=layer.name,
@@ -178,8 +202,10 @@ def export_mixed_gptq_gguf(
178
202
  Returns:
179
203
  Summary dict with the routing breakdown and replacement counts.
180
204
  """
181
- plans = plan_mixed_export(quantized_dir)
205
+ model_layout = load_qwen35_layout(quantized_dir)
206
+ plans = plan_mixed_export(quantized_dir, model_layout=model_layout)
182
207
  has_kquant = any(p.route == ROUTE_KQUANT for p in plans)
208
+ model_layout = load_qwen35_layout(quantized_dir)
183
209
 
184
210
  owns_workdir = work_dir is None
185
211
  work_dir = work_dir or tempfile.mkdtemp(prefix="onecomp_mixed_gguf_")
@@ -189,7 +215,8 @@ def export_mixed_gptq_gguf(
189
215
  # *dequantized* values (not the original FP weights) so llama-quantize
190
216
  # re-quantizes the GPTQ-optimized weights. Force the dequantize path.
191
217
  skeleton_src = None if has_kquant else original_model
192
- skeleton = build_skeleton_gguf(quantized_dir, skeleton_src, work_dir)
218
+ no_mtp = is_qwen35_model(quantized_dir)
219
+ skeleton = build_skeleton_gguf(quantized_dir, skeleton_src, work_dir, no_mtp=no_mtp)
193
220
 
194
221
  import gguf
195
222
 
@@ -209,7 +236,7 @@ def export_mixed_gptq_gguf(
209
236
  if gguf_name is None:
210
237
  unmapped[layer.name] = "no GGUF tensor-name mapping"
211
238
  continue
212
- route, gtype_name, _reason = _route_layer(layer)
239
+ route, gtype_name, _reason = _route_layer(layer, model_layout=model_layout)
213
240
 
214
241
  if route == ROUTE_DIRECT:
215
242
  q_int, scales, zeros = layer.q_int, layer.scales, layer.zeros
@@ -217,6 +244,15 @@ def export_mixed_gptq_gguf(
217
244
  if n_perm is not None:
218
245
  q_int, scales, zeros = permute_gptq_rows(q_int, scales, zeros, n_perm)
219
246
  try:
247
+ if model_layout is not None:
248
+ q_int, scales, zeros = transform_qwen35_gptq(
249
+ layer_name=layer.name,
250
+ q_int=q_int,
251
+ scales=scales,
252
+ zeros=zeros,
253
+ groupsize=layer.groupsize,
254
+ layout=model_layout,
255
+ )
220
256
  packed, qtype = pack_gptq_linear(
221
257
  q_int=q_int.cpu().numpy(),
222
258
  scales=scales.cpu().numpy(),
@@ -6,4 +6,4 @@ Author: Keiji Kimura
6
6
 
7
7
  """
8
8
 
9
- __version__ = "1.3.4"
9
+ __version__ = "1.4.1"
@@ -144,5 +144,7 @@ def main():
144
144
  "wbits": args.wbits if args.wbits is not None else "auto",
145
145
  "groupsize": args.groupsize,
146
146
  }
147
- card = generate_model_card(args.model_id, recipe=recipe, results={})
147
+ card = generate_model_card(
148
+ args.model_id, recipe=recipe, results={}, repo_id=args.push_to_hub
149
+ )
148
150
  push_to_hub(save_dir, args.push_to_hub, model_card=card)
@@ -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 fp16 HF model (GPTQ/DBF/rotated)
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 GPTQ checkpoints.
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 fp16 HF model from a GPTQ checkpoint
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; universal)
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