tico 0.2.0.dev260702__tar.gz → 0.2.0.dev260706__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.
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/PKG-INFO +7 -2
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/README.md +6 -1
- tico-0.2.0.dev260706/tico/_version.py +1 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/debug/wrapper_smoke/cases/gemma4.py +266 -0
- tico-0.2.0.dev260706/tico/quantization/wrapq/examples/gemma4/quantize_for_causal_lm.py +163 -0
- tico-0.2.0.dev260706/tico/quantization/wrapq/examples/gemma4/quantize_for_conditional_generation.py +215 -0
- tico-0.2.0.dev260706/tico/quantization/wrapq/wrappers/gemma4/quant_for_causal_lm.py +120 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/gemma4/quant_for_conditional_generation.py +49 -19
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/registry.py +2 -2
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico.egg-info/PKG-INFO +7 -2
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico.egg-info/SOURCES.txt +2 -0
- tico-0.2.0.dev260702/tico/_version.py +0 -1
- tico-0.2.0.dev260702/tico/quantization/wrapq/wrappers/gemma4/quant_for_causal_lm.py +0 -78
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/LICENSE +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/pyproject.toml +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/setup.cfg +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/config/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/config/base.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/config/factory.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/config/v1.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/experimental/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/interpreter/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/interpreter/infer.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/interpreter/interpreter.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/cast_aten_where_arg_type.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/cast_clamp_mixed_type_args.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/cast_mixed_type_args.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/const_prop_pass.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/convert_conv1d_to_conv2d.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/convert_conv3d_to_conv2d.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/convert_expand_to_slice_cat.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/convert_gather_to_gather_nd.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/convert_layout_op_to_reshape.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/convert_matmul_to_linear.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/convert_repeat_to_expand_copy.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/convert_sym_size_to_circle_shape.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/convert_to_relu6.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/decompose_addmm.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/decompose_batch_norm.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/decompose_fake_quantize.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/decompose_fake_quantize_tensor_qparams.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/decompose_group_norm.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/decompose_grouped_conv2d.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/decompose_slice_scatter.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/eliminate_rank_round_trip_region.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/extract_dtype_kwargs.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/fill_meta_val.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/fuse_leading_unsqueeze_reshape.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/fuse_redundant_reshape_to_mean.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/legalize_causal_mask_value.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/legalize_predefined_layout_operators.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/lower_copy.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/lower_pow2_to_mul.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/lower_to_resize_nearest_neighbor.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/lower_to_slice.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/merge_consecutive_cat.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/ops.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/remove_nop.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/remove_redundant_assert_nodes.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/remove_redundant_expand.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/remove_redundant_permute.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/remove_redundant_reshape.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/remove_redundant_slice.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/remove_redundant_to_copy.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/remove_unused_placeholder.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/restore_linear.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/passes/segment_index_select.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/pt2_to_circle.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/algorithm/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/algorithm/cle/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/algorithm/cle/cle.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/algorithm/cle/quantizer.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/algorithm/fpi_gptq/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/algorithm/fpi_gptq/fpi_gptq.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/algorithm/fpi_gptq/quantizer.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/algorithm/fpi_gptq/util.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/algorithm/gptq/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/algorithm/gptq/gptq.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/algorithm/gptq/quant.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/algorithm/gptq/quantizer.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/algorithm/gptq/utils.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/algorithm/qwen3_vl_gptq/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/algorithm/qwen3_vl_gptq/gptq.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/algorithm/qwen3_vl_gptq/quantizer.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/algorithm/qwen3_vl_gptq/utils.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/algorithm/smoothquant/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/algorithm/smoothquant/observer.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/algorithm/smoothquant/quantizer.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/algorithm/smoothquant/smooth_quant.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/algorithm/spinquant/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/algorithm/spinquant/fuse_norm_utils.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/algorithm/spinquant/hadamard_utils.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/algorithm/spinquant/quantizer.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/algorithm/spinquant/qwen3_vl_model_utils.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/algorithm/spinquant/qwen3_vl_quantizer.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/algorithm/spinquant/qwen3_vl_rotation_utils.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/algorithm/spinquant/rotation_utils.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/algorithm/spinquant/spin_llama.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/algorithm/spinquant/spin_qwen3_vl.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/config/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/config/base.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/config/builders.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/config/cle.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/config/fpi_gptq.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/config/gemma4_builders.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/config/gptq.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/config/llama_attention.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/config/ptq.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/config/qwen3_vl_gptq.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/config/qwen3_vl_spinquant.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/config/smoothquant.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/config/specs.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/config/spinquant.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/config/utils.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/evaluation/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/evaluation/backend.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/evaluation/evaluate.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/evaluation/executor/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/evaluation/executor/backend_executor.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/evaluation/executor/circle_executor.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/evaluation/executor/triv24_executor.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/evaluation/hellaswag_eval_utils.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/evaluation/llava_bench_judge_eval_utils.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/evaluation/lmms_eval_utils.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/evaluation/lmms_tasks/videomme_mini/utils.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/evaluation/metric.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/evaluation/mmlu_eval_utils.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/evaluation/mmmu_eval_utils.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/evaluation/optional_deps.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/evaluation/script/llm_tasks_eval.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/evaluation/script/mini_vqa_eval.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/evaluation/utils.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/evaluation/vlm_eval_utils.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/examples/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/examples/configs/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/examples/evaluate.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/examples/inspect.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/examples/quantize.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/passes/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/passes/fold_quant_ops.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/passes/insert_quantize_on_dtype_mismatch.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/passes/propagate_qparam_backward.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/passes/propagate_qparam_forward.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/passes/qparam_safe_const_prop.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/passes/quantize_bias.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/passes/remove_weight_dequant_op.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/public_interface.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/quantizer.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/quantizer_registry.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/adapters/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/adapters/base.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/adapters/gemma4.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/adapters/llama.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/adapters/qwen3_vl.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/config.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/context.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/data/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/data/llm.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/data/vlm.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/debug/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/debug/static_gemma4_runtime.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/debug/static_llama_runtime.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/debug/static_qwen3_vl_runtime.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/debug/tied_embedding.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/debug/trace.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/debug/wrapper_smoke/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/debug/wrapper_smoke/case.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/debug/wrapper_smoke/cases/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/debug/wrapper_smoke/cases/llama.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/debug/wrapper_smoke/cases/nn.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/debug/wrapper_smoke/cases/qwen3_vl.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/debug/wrapper_smoke/registry.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/debug/wrapper_smoke/result.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/debug/wrapper_smoke/runner.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/debug/wrapper_smoke/utils.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/evaluation/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/evaluation/hellaswag.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/evaluation/llava_bench_judge.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/evaluation/llm.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/evaluation/mmlu.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/evaluation/mmmu.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/evaluation/video_mme.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/evaluation/vlm.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/export/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/export/checkpoint.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/export/circle.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/export/llama.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/qparams.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/runner.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/stages/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/stages/base.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/stages/cle.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/stages/gptq.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/stages/ptq.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/stages/smoothquant.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/stages/spinquant.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/recipes/utils.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/dtypes.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/compare_ppl.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/debug_quant_outputs.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/evaluate_fk_llama_model.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/gemma4/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/gemma4/quantize_model.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/gemma4/quantize_multimodal_embedder.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/gemma4/quantize_text_scaled_word_embedding.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/gemma4/quantize_vision_model.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/gemma4/quantize_vision_patch_embedder.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/gemma4/quantize_vision_pooler.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/llama/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/llama/quantize_attention_decode.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/llama/quantize_attention_prefill.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/llama/quantize_decoder_layer_decode.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/llama/quantize_decoder_layer_prefill.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/llama/quantize_mlp.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/nn/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/nn/quantize_conv3d.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/nn/quantize_conv3d_special_case.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/nn/quantize_layernorm.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/nn/quantize_linear.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/nn/quantize_tied_embedding.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/quantize_full_qmodel_with_gptq.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/quantize_qwen3_vl_with_gptq.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/quantize_with_gptq.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/qwen/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/qwen/quantize_for_conditional_generation.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/qwen/quantize_model.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/qwen/quantize_text_attention.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/qwen/quantize_text_decoder_layer.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/qwen/quantize_text_mlp.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/qwen/quantize_text_model.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/qwen/quantize_vision_attention.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/qwen/quantize_vision_block.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/qwen/quantize_vision_mlp.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/qwen/quantize_vision_model.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/qwen/quantize_vision_patch_embed.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/qwen/quantize_vision_patch_merger.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/qwen/trace_qwen.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/examples/static_llama_layer_runtime.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/mode.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/observers/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/observers/affine_base.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/observers/base.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/observers/ema.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/observers/identity.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/observers/minmax.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/observers/mx.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/qscheme.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/quantizer.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/utils/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/utils/check_missing_qparam.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/utils/introspection.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/utils/metrics.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/utils/reduce_utils.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/utils/utils.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/utils/version.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrap_helper.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/fairseq/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/fairseq/decoder_export_single_step.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/fairseq/quant_decoder.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/fairseq/quant_decoder_layer.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/fairseq/quant_encoder.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/fairseq/quant_encoder_layer.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/fairseq/quant_mha.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/gemma4/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/gemma4/export_adapters.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/gemma4/quant_clippable_linear.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/gemma4/quant_model.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/gemma4/quant_multimodal_embedder.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/gemma4/quant_rmsnorm.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/gemma4/quant_text_attention.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/gemma4/quant_text_decoder_layer.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/gemma4/quant_text_mlp.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/gemma4/quant_text_model.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/gemma4/quant_text_scaled_word_embedding.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/gemma4/quant_vision_attention.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/gemma4/quant_vision_encoder.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/gemma4/quant_vision_encoder_layer.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/gemma4/quant_vision_mlp.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/gemma4/quant_vision_model.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/gemma4/quant_vision_patch_embedder.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/gemma4/quant_vision_pooler.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/gemma4/utils.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/llama/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/llama/export_adapters.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/llama/quant_attention.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/llama/quant_decoder_layer.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/llama/quant_mlp.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/llama/quant_model.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/llama/quant_model_for_causal_lm.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/nn/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/nn/quant_conv3d.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/nn/quant_conv3d_decomposed.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/nn/quant_embedding.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/nn/quant_layernorm.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/nn/quant_linear.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/nn/quant_silu.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/ops/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/ops/quant_rmsnorm.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/ptq_wrapper.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/quant_elementwise.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/quant_module_base.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/qwen_vl/export_adapters.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/qwen_vl/quant_for_conditional_generation.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/qwen_vl/quant_model.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/qwen_vl/quant_text_attention.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/qwen_vl/quant_text_decoder_layer.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/qwen_vl/quant_text_mlp.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/qwen_vl/quant_text_model.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/qwen_vl/quant_vision_attention.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/qwen_vl/quant_vision_block.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/qwen_vl/quant_vision_mlp.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/qwen_vl/quant_vision_model.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/qwen_vl/quant_vision_patch_embed.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/quantization/wrapq/wrappers/qwen_vl/quant_vision_patch_merger.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/circle_graph.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/circle_mapping.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/circle_serializer.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/adapters/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/adapters/llama_rmsnorm.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/adapters/onert/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/adapters/onert/llama_attention.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/hashable_opcode.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/node_visitor.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_abs.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_add.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_alias_copy.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_any.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_arange_start_step.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_argmax.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_attention.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_avg_pool2d.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_bmm.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_cat.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_circle_gather_nd.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_circle_shape.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_clamp.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_clone.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_constant_pad_nd.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_conv2d.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_cos.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_cumsum.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_depthwise_conv2d.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_dequantize_per_channel.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_dequantize_per_tensor.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_div.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_elu.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_embedding.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_eq.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_exp.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_expand.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_full.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_full_like.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_ge.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_gelu.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_gt.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_index.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_index_select.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_instance_norm.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_le.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_leaky_relu.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_linear.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_log.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_log1p.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_logical_and.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_logical_not.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_lt.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_max_dim.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_max_pool2d_with_indices.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_maximum.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_mean.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_minimum.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_mm.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_mul.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_ne.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_neg.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_permute.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_pow.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_prelu.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_quantize_per_tensor.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_reciprocal.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_relu.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_relu6.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_repeat.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_reshape.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_resize_nearest_neighbor.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_rmsnorm.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_round.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_rsqrt.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_scalar_tensor.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_select_copy.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_sigmoid.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_sin.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_slice.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_softmax.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_split_with_sizes.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_sqrt.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_squeeze.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_sub.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_sum.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_tanh.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_to_copy.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_transpose_conv.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_unsqueeze.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_view.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/op_where.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/operators/utils.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/pack.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/serialize/quant_param.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/utils/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/utils/compat/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/utils/compat/torch.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/utils/compat/transformers.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/utils/convert.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/utils/define.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/utils/diff_graph.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/utils/dtype.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/utils/errors.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/utils/graph.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/utils/installed_packages.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/utils/logging.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/utils/model.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/utils/mx/__init__.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/utils/mx/dtypes.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/utils/mx/elemwise_ops.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/utils/mx/formats.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/utils/mx/mx_ops.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/utils/padding.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/utils/passes.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/utils/pytree_utils.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/utils/record_input.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/utils/register_custom_op.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/utils/serialize.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/utils/signature.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/utils/trace_decorators.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/utils/utils.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/utils/validate_args_kwargs.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico/utils/version.py +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico.egg-info/dependency_links.txt +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico.egg-info/entry_points.txt +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico.egg-info/requires.txt +0 -0
- {tico-0.2.0.dev260702 → tico-0.2.0.dev260706}/tico.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tico
|
|
3
|
-
Version: 0.2.0.
|
|
3
|
+
Version: 0.2.0.dev260706
|
|
4
4
|
Summary: Convert Exported Torch Module To Circle
|
|
5
5
|
License: This file provides full text of licenses used in this project
|
|
6
6
|
|
|
@@ -255,7 +255,12 @@ Requires-Dist: pyyaml
|
|
|
255
255
|
Requires-Dist: tqdm
|
|
256
256
|
Dynamic: license-file
|
|
257
257
|
|
|
258
|
-
|
|
258
|
+
<p align="center">
|
|
259
|
+
<picture>
|
|
260
|
+
<source media="(prefers-color-scheme: dark)" srcset="./assets/logo/banner/tico-banner-dark.png">
|
|
261
|
+
<img src="./assets/logo/banner/tico-banner-light.png" alt="TICO — Torch IR to Circle" width="640">
|
|
262
|
+
</picture>
|
|
263
|
+
</p>
|
|
259
264
|
|
|
260
265
|
_TICO_ (**T**orch **I**R to **C**ircle [ONE](https://github.com/Samsung/ONE)) is a Python
|
|
261
266
|
library that converts PyTorch modules into Circle models — a lightweight and efficient
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="./assets/logo/banner/tico-banner-dark.png">
|
|
4
|
+
<img src="./assets/logo/banner/tico-banner-light.png" alt="TICO — Torch IR to Circle" width="640">
|
|
5
|
+
</picture>
|
|
6
|
+
</p>
|
|
2
7
|
|
|
3
8
|
_TICO_ (**T**orch **I**R to **C**ircle [ONE](https://github.com/Samsung/ONE)) is a Python
|
|
4
9
|
library that converts PyTorch modules into Circle models — a lightweight and efficient
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.0.dev260706"
|
|
@@ -1550,6 +1550,270 @@ class Gemma4ModelCase(Gemma4BaseCase):
|
|
|
1550
1550
|
)
|
|
1551
1551
|
|
|
1552
1552
|
|
|
1553
|
+
class Gemma4ForConditionalGenerationCase(Gemma4BaseCase):
|
|
1554
|
+
"""Smoke case for one tiny Gemma4ForConditionalGeneration."""
|
|
1555
|
+
|
|
1556
|
+
name = "gemma4_for_conditional_generation"
|
|
1557
|
+
description = (
|
|
1558
|
+
"Quantize one tiny Gemma4ForConditionalGeneration "
|
|
1559
|
+
"(vision + text decoder + lm_head + softcapping)."
|
|
1560
|
+
)
|
|
1561
|
+
tags = ("gemma4", "e2b", "model", "conditional_generation", "image-text")
|
|
1562
|
+
max_mean_abs_diff = 5.0
|
|
1563
|
+
seq_len = 16
|
|
1564
|
+
num_visual_tokens = 4
|
|
1565
|
+
|
|
1566
|
+
def ptq_config(self, cfg: Mapping[str, Any]) -> Any:
|
|
1567
|
+
"""Build the PTQ config used by Gemma4ForConditionalGeneration smoke checks."""
|
|
1568
|
+
from tico.quantization.config.gemma4_builders import build_gemma4_e2b_ptq_config
|
|
1569
|
+
|
|
1570
|
+
return build_gemma4_e2b_ptq_config(
|
|
1571
|
+
num_text_layers=int(self.text_cfg.num_hidden_layers),
|
|
1572
|
+
num_vision_layers=int(self.vision_cfg.num_hidden_layers),
|
|
1573
|
+
model_args={
|
|
1574
|
+
"vision": {
|
|
1575
|
+
"visual_start_idx": 0,
|
|
1576
|
+
"num_visual_tokens": self.num_visual_tokens,
|
|
1577
|
+
}
|
|
1578
|
+
},
|
|
1579
|
+
)
|
|
1580
|
+
|
|
1581
|
+
def build(self, cfg: Mapping[str, Any]) -> tuple[torch.nn.Module, torch.nn.Module]:
|
|
1582
|
+
"""Build a tiny Gemma4ForConditionalGeneration and reference copy."""
|
|
1583
|
+
from transformers.models.gemma4.configuration_gemma4 import Gemma4Config
|
|
1584
|
+
from transformers.models.gemma4.modeling_gemma4 import (
|
|
1585
|
+
Gemma4ForConditionalGeneration,
|
|
1586
|
+
)
|
|
1587
|
+
|
|
1588
|
+
torch.manual_seed(123)
|
|
1589
|
+
self.text_cfg = _make_text_config(layer_types=("full_attention",))
|
|
1590
|
+
# Enable logit softcapping to exercise that code path.
|
|
1591
|
+
self.text_cfg.final_logit_softcapping = 30.0
|
|
1592
|
+
self.vision_cfg = _make_vision_config()
|
|
1593
|
+
|
|
1594
|
+
config = Gemma4Config(
|
|
1595
|
+
text_config=self.text_cfg,
|
|
1596
|
+
vision_config=self.vision_cfg,
|
|
1597
|
+
audio_config=None,
|
|
1598
|
+
image_token_id=10,
|
|
1599
|
+
video_token_id=11,
|
|
1600
|
+
audio_token_id=12,
|
|
1601
|
+
)
|
|
1602
|
+
module = Gemma4ForConditionalGeneration(config).eval()
|
|
1603
|
+
return module, clone_module(module)
|
|
1604
|
+
|
|
1605
|
+
def _sample(self) -> ForwardInput:
|
|
1606
|
+
"""Create one synthetic Gemma4ForConditionalGeneration text-only input.
|
|
1607
|
+
|
|
1608
|
+
Token IDs are kept in [0, 9] to avoid colliding with the image
|
|
1609
|
+
placeholder token ID (10).
|
|
1610
|
+
"""
|
|
1611
|
+
input_ids = torch.randint(0, 10, (1, self.seq_len))
|
|
1612
|
+
return ForwardInput(
|
|
1613
|
+
(),
|
|
1614
|
+
{
|
|
1615
|
+
"input_ids": input_ids,
|
|
1616
|
+
},
|
|
1617
|
+
)
|
|
1618
|
+
|
|
1619
|
+
def calibration_inputs(
|
|
1620
|
+
self,
|
|
1621
|
+
prepared: torch.nn.Module,
|
|
1622
|
+
cfg: Mapping[str, Any],
|
|
1623
|
+
) -> list[ForwardInput]:
|
|
1624
|
+
"""Create Gemma4ForConditionalGeneration calibration samples."""
|
|
1625
|
+
return [self._sample() for _ in range(3)]
|
|
1626
|
+
|
|
1627
|
+
def eval_input(
|
|
1628
|
+
self,
|
|
1629
|
+
prepared: torch.nn.Module,
|
|
1630
|
+
cfg: Mapping[str, Any],
|
|
1631
|
+
) -> ForwardInput:
|
|
1632
|
+
"""Create the Gemma4ForConditionalGeneration evaluation sample."""
|
|
1633
|
+
return self._sample()
|
|
1634
|
+
|
|
1635
|
+
def forward(self, module: torch.nn.Module, sample: ForwardInput) -> Any:
|
|
1636
|
+
"""Run the Gemma4ForConditionalGeneration without sharing mutable sample state.
|
|
1637
|
+
|
|
1638
|
+
The wrapper returns logits directly (not a Gemma4CausalLMOutputWithPast).
|
|
1639
|
+
"""
|
|
1640
|
+
cloned = _clone_forward_input(sample)
|
|
1641
|
+
return module(*cloned.args, **dict(cloned.kwargs))
|
|
1642
|
+
|
|
1643
|
+
def reference_forward(
|
|
1644
|
+
self, reference: torch.nn.Module, sample: ForwardInput
|
|
1645
|
+
) -> Any:
|
|
1646
|
+
"""Run the original Gemma4ForConditionalGeneration without sharing mutable state."""
|
|
1647
|
+
cloned = _clone_forward_input(sample)
|
|
1648
|
+
output = reference(*cloned.args, **dict(cloned.kwargs))
|
|
1649
|
+
return output.logits if hasattr(output, "logits") else output
|
|
1650
|
+
|
|
1651
|
+
def export_module(
|
|
1652
|
+
self, quantized: torch.nn.Module, cfg: Mapping[str, Any]
|
|
1653
|
+
) -> torch.nn.Module:
|
|
1654
|
+
"""Export the wrapped Gemma4ForConditionalGeneration in prefill mode."""
|
|
1655
|
+
wrapped = getattr(quantized, "wrapped", quantized)
|
|
1656
|
+
if hasattr(wrapped, "as_export_module"):
|
|
1657
|
+
return wrapped.as_export_module(mode="prefill").eval()
|
|
1658
|
+
return quantized
|
|
1659
|
+
|
|
1660
|
+
def export_input(
|
|
1661
|
+
self, eval_sample: ForwardInput, cfg: Mapping[str, Any]
|
|
1662
|
+
) -> ForwardInput:
|
|
1663
|
+
"""Create static export inputs expected by the export adapter.
|
|
1664
|
+
|
|
1665
|
+
The export adapter's forward_export() takes precomputed inputs:
|
|
1666
|
+
- inputs_embeds: (1, S, H)
|
|
1667
|
+
- per_layer_inputs: (1, S, L, P) or None
|
|
1668
|
+
- attention_masks: dict[layer_type -> mask]
|
|
1669
|
+
- position_embeddings: dict[layer_type -> (cos, sin)]
|
|
1670
|
+
"""
|
|
1671
|
+
hidden_size = int(self.text_cfg.hidden_size)
|
|
1672
|
+
head_dim = int(self.text_cfg.head_dim)
|
|
1673
|
+
num_layers = int(self.text_cfg.num_hidden_layers)
|
|
1674
|
+
ple_dim = int(getattr(self.text_cfg, "hidden_size_per_layer_input", 0) or 0)
|
|
1675
|
+
layer_types = list(self.text_cfg.layer_types)
|
|
1676
|
+
|
|
1677
|
+
inputs_embeds = torch.randn(1, self.seq_len, hidden_size)
|
|
1678
|
+
|
|
1679
|
+
per_layer_inputs = None
|
|
1680
|
+
if ple_dim > 0:
|
|
1681
|
+
per_layer_inputs = torch.randn(1, self.seq_len, num_layers, ple_dim)
|
|
1682
|
+
|
|
1683
|
+
attention_masks: dict[str, torch.Tensor] = {}
|
|
1684
|
+
position_embeddings: dict[str, tuple[torch.Tensor, torch.Tensor]] = {}
|
|
1685
|
+
for layer_type in layer_types:
|
|
1686
|
+
attention_masks[layer_type] = torch.zeros(1, 1, self.seq_len, self.seq_len)
|
|
1687
|
+
cos = torch.ones(1, self.seq_len, head_dim)
|
|
1688
|
+
sin = torch.zeros(1, self.seq_len, head_dim)
|
|
1689
|
+
position_embeddings[layer_type] = (cos, sin)
|
|
1690
|
+
|
|
1691
|
+
return ForwardInput(
|
|
1692
|
+
(inputs_embeds, per_layer_inputs, attention_masks, position_embeddings),
|
|
1693
|
+
{},
|
|
1694
|
+
)
|
|
1695
|
+
|
|
1696
|
+
|
|
1697
|
+
class Gemma4ForCausalLMCase(Gemma4BaseCase):
|
|
1698
|
+
"""Smoke case for one tiny Gemma4ForCausalLM (text-only)."""
|
|
1699
|
+
|
|
1700
|
+
name = "gemma4_for_causal_lm"
|
|
1701
|
+
description = (
|
|
1702
|
+
"Quantize one tiny Gemma4ForCausalLM " "(text decoder + lm_head + softcapping)."
|
|
1703
|
+
)
|
|
1704
|
+
tags = ("gemma4", "e2b", "model", "causal_lm", "text")
|
|
1705
|
+
max_mean_abs_diff = 5.0
|
|
1706
|
+
seq_len = 16
|
|
1707
|
+
|
|
1708
|
+
def ptq_config(self, cfg: Mapping[str, Any]) -> Any:
|
|
1709
|
+
"""Build the PTQ config used by Gemma4ForCausalLM smoke checks."""
|
|
1710
|
+
from tico.quantization.config.gemma4_builders import build_gemma4_e2b_ptq_config
|
|
1711
|
+
|
|
1712
|
+
return build_gemma4_e2b_ptq_config(
|
|
1713
|
+
num_text_layers=int(self.text_cfg.num_hidden_layers),
|
|
1714
|
+
num_vision_layers=0,
|
|
1715
|
+
)
|
|
1716
|
+
|
|
1717
|
+
def build(self, cfg: Mapping[str, Any]) -> tuple[torch.nn.Module, torch.nn.Module]:
|
|
1718
|
+
"""Build a tiny Gemma4ForCausalLM and reference copy."""
|
|
1719
|
+
from transformers.models.gemma4.modeling_gemma4 import Gemma4ForCausalLM
|
|
1720
|
+
|
|
1721
|
+
torch.manual_seed(123)
|
|
1722
|
+
self.text_cfg = _make_text_config(layer_types=("full_attention",))
|
|
1723
|
+
# Enable logit softcapping to exercise that code path.
|
|
1724
|
+
self.text_cfg.final_logit_softcapping = 30.0
|
|
1725
|
+
|
|
1726
|
+
module = Gemma4ForCausalLM(self.text_cfg).eval()
|
|
1727
|
+
return module, clone_module(module)
|
|
1728
|
+
|
|
1729
|
+
def _sample(self) -> ForwardInput:
|
|
1730
|
+
"""Create one synthetic Gemma4ForCausalLM text-only input."""
|
|
1731
|
+
input_ids = torch.randint(0, self.text_cfg.vocab_size, (1, self.seq_len))
|
|
1732
|
+
return ForwardInput(
|
|
1733
|
+
(),
|
|
1734
|
+
{
|
|
1735
|
+
"input_ids": input_ids,
|
|
1736
|
+
},
|
|
1737
|
+
)
|
|
1738
|
+
|
|
1739
|
+
def calibration_inputs(
|
|
1740
|
+
self,
|
|
1741
|
+
prepared: torch.nn.Module,
|
|
1742
|
+
cfg: Mapping[str, Any],
|
|
1743
|
+
) -> list[ForwardInput]:
|
|
1744
|
+
"""Create Gemma4ForCausalLM calibration samples."""
|
|
1745
|
+
return [self._sample() for _ in range(3)]
|
|
1746
|
+
|
|
1747
|
+
def eval_input(
|
|
1748
|
+
self,
|
|
1749
|
+
prepared: torch.nn.Module,
|
|
1750
|
+
cfg: Mapping[str, Any],
|
|
1751
|
+
) -> ForwardInput:
|
|
1752
|
+
"""Create the Gemma4ForCausalLM evaluation sample."""
|
|
1753
|
+
return self._sample()
|
|
1754
|
+
|
|
1755
|
+
def forward(self, module: torch.nn.Module, sample: ForwardInput) -> Any:
|
|
1756
|
+
"""Run the Gemma4ForCausalLM without sharing mutable sample state.
|
|
1757
|
+
|
|
1758
|
+
The wrapper returns logits directly (not a Gemma4CausalLMOutputWithPast).
|
|
1759
|
+
"""
|
|
1760
|
+
cloned = _clone_forward_input(sample)
|
|
1761
|
+
return module(*cloned.args, **dict(cloned.kwargs))
|
|
1762
|
+
|
|
1763
|
+
def reference_forward(
|
|
1764
|
+
self, reference: torch.nn.Module, sample: ForwardInput
|
|
1765
|
+
) -> Any:
|
|
1766
|
+
"""Run the original Gemma4ForCausalLM without sharing mutable state."""
|
|
1767
|
+
cloned = _clone_forward_input(sample)
|
|
1768
|
+
output = reference(*cloned.args, **dict(cloned.kwargs))
|
|
1769
|
+
return output.logits if hasattr(output, "logits") else output
|
|
1770
|
+
|
|
1771
|
+
def export_module(
|
|
1772
|
+
self, quantized: torch.nn.Module, cfg: Mapping[str, Any]
|
|
1773
|
+
) -> torch.nn.Module:
|
|
1774
|
+
"""Export the wrapped Gemma4ForCausalLM in prefill mode."""
|
|
1775
|
+
wrapped = getattr(quantized, "wrapped", quantized)
|
|
1776
|
+
if hasattr(wrapped, "as_export_module"):
|
|
1777
|
+
return wrapped.as_export_module(mode="prefill").eval()
|
|
1778
|
+
return quantized
|
|
1779
|
+
|
|
1780
|
+
def export_input(
|
|
1781
|
+
self, eval_sample: ForwardInput, cfg: Mapping[str, Any]
|
|
1782
|
+
) -> ForwardInput:
|
|
1783
|
+
"""Create static export inputs expected by the export adapter.
|
|
1784
|
+
|
|
1785
|
+
The export adapter's forward_export() takes precomputed inputs:
|
|
1786
|
+
- inputs_embeds: (1, S, H)
|
|
1787
|
+
- per_layer_inputs: (1, S, L, P) or None
|
|
1788
|
+
- attention_masks: dict[layer_type -> mask]
|
|
1789
|
+
- position_embeddings: dict[layer_type -> (cos, sin)]
|
|
1790
|
+
"""
|
|
1791
|
+
hidden_size = int(self.text_cfg.hidden_size)
|
|
1792
|
+
head_dim = int(self.text_cfg.head_dim)
|
|
1793
|
+
num_layers = int(self.text_cfg.num_hidden_layers)
|
|
1794
|
+
ple_dim = int(getattr(self.text_cfg, "hidden_size_per_layer_input", 0) or 0)
|
|
1795
|
+
layer_types = list(self.text_cfg.layer_types)
|
|
1796
|
+
|
|
1797
|
+
inputs_embeds = torch.randn(1, self.seq_len, hidden_size)
|
|
1798
|
+
|
|
1799
|
+
per_layer_inputs = None
|
|
1800
|
+
if ple_dim > 0:
|
|
1801
|
+
per_layer_inputs = torch.randn(1, self.seq_len, num_layers, ple_dim)
|
|
1802
|
+
|
|
1803
|
+
attention_masks: dict[str, torch.Tensor] = {}
|
|
1804
|
+
position_embeddings: dict[str, tuple[torch.Tensor, torch.Tensor]] = {}
|
|
1805
|
+
for layer_type in layer_types:
|
|
1806
|
+
attention_masks[layer_type] = torch.zeros(1, 1, self.seq_len, self.seq_len)
|
|
1807
|
+
cos = torch.ones(1, self.seq_len, head_dim)
|
|
1808
|
+
sin = torch.zeros(1, self.seq_len, head_dim)
|
|
1809
|
+
position_embeddings[layer_type] = (cos, sin)
|
|
1810
|
+
|
|
1811
|
+
return ForwardInput(
|
|
1812
|
+
(inputs_embeds, per_layer_inputs, attention_masks, position_embeddings),
|
|
1813
|
+
{},
|
|
1814
|
+
)
|
|
1815
|
+
|
|
1816
|
+
|
|
1553
1817
|
GEMMA4_CASES = (
|
|
1554
1818
|
Gemma4TextMLPCase(),
|
|
1555
1819
|
Gemma4TextAttentionCase(),
|
|
@@ -1570,4 +1834,6 @@ GEMMA4_CASES = (
|
|
|
1570
1834
|
Gemma4MultimodalEmbedderCase(),
|
|
1571
1835
|
Gemma4VisionEncoderCase(),
|
|
1572
1836
|
Gemma4ModelCase(),
|
|
1837
|
+
Gemma4ForConditionalGenerationCase(),
|
|
1838
|
+
Gemma4ForCausalLMCase(),
|
|
1573
1839
|
)
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# Copyright (c) 2026 Samsung Electronics Co., Ltd. All Rights Reserved
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
|
|
16
|
+
"""Example: PTQ quantization of Gemma4ForCausalLM.
|
|
17
|
+
|
|
18
|
+
The ``Gemma4ForCausalLM`` is the text-only causal LM that wraps
|
|
19
|
+
``Gemma4TextModel`` (text decoder) and adds an ``lm_head`` linear layer
|
|
20
|
+
to produce vocabulary logits. It also applies logit softcapping when
|
|
21
|
+
``final_logit_softcapping`` is set in the text config.
|
|
22
|
+
|
|
23
|
+
This script demonstrates the full PTQ flow:
|
|
24
|
+
|
|
25
|
+
1. Create a tiny Gemma4ForCausalLM with random weights.
|
|
26
|
+
2. Prepare the model for quantization with a Gemma4-specific PTQ config.
|
|
27
|
+
3. Calibrate with synthetic text-only data.
|
|
28
|
+
4. Convert to a fake-quantized model.
|
|
29
|
+
5. Compare FP vs. quantized logits.
|
|
30
|
+
6. Export to Circle format via the export adapter.
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
import copy
|
|
34
|
+
import sys
|
|
35
|
+
|
|
36
|
+
import torch
|
|
37
|
+
|
|
38
|
+
import tico
|
|
39
|
+
import tico.quantization
|
|
40
|
+
import tico.quantization.config.ptq
|
|
41
|
+
from tico.quantization.config.gemma4_builders import build_gemma4_e2b_ptq_config
|
|
42
|
+
from tico.quantization.evaluation.metric import compute_peir
|
|
43
|
+
from tico.quantization.evaluation.utils import plot_two_outputs
|
|
44
|
+
from tico.quantization.wrapq.utils.version import has_transformers_for
|
|
45
|
+
|
|
46
|
+
torch.manual_seed(123)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
# Check if transformers is available
|
|
50
|
+
if not has_transformers_for("gemma4"):
|
|
51
|
+
print(
|
|
52
|
+
"Error: transformers package with Gemma4 support not installed. "
|
|
53
|
+
"Cannot test Gemma4ForCausalLM."
|
|
54
|
+
)
|
|
55
|
+
sys.exit(1)
|
|
56
|
+
|
|
57
|
+
from transformers.models.gemma4.configuration_gemma4 import Gemma4TextConfig
|
|
58
|
+
from transformers.models.gemma4.modeling_gemma4 import Gemma4ForCausalLM
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _make_text_config() -> Gemma4TextConfig:
|
|
62
|
+
"""Create a tiny Gemma4 text config for the example."""
|
|
63
|
+
cfg = Gemma4TextConfig(
|
|
64
|
+
vocab_size=256,
|
|
65
|
+
hidden_size=64,
|
|
66
|
+
intermediate_size=128,
|
|
67
|
+
num_hidden_layers=1,
|
|
68
|
+
num_attention_heads=2,
|
|
69
|
+
num_key_value_heads=2,
|
|
70
|
+
num_global_key_value_heads=2,
|
|
71
|
+
head_dim=32,
|
|
72
|
+
global_head_dim=32,
|
|
73
|
+
max_position_embeddings=128,
|
|
74
|
+
layer_types=["full_attention"],
|
|
75
|
+
rope_parameters={
|
|
76
|
+
"full_attention": {"rope_type": "default", "rope_theta": 10000.0}
|
|
77
|
+
},
|
|
78
|
+
attention_bias=False,
|
|
79
|
+
attention_dropout=0.0,
|
|
80
|
+
use_cache=False,
|
|
81
|
+
enable_moe_block=False,
|
|
82
|
+
# Enable logit softcapping to exercise that code path.
|
|
83
|
+
final_logit_softcapping=30.0,
|
|
84
|
+
)
|
|
85
|
+
if not hasattr(cfg, "_attn_implementation"):
|
|
86
|
+
setattr(cfg, "_attn_implementation", "eager")
|
|
87
|
+
else:
|
|
88
|
+
cfg._attn_implementation = "eager"
|
|
89
|
+
return cfg
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def generate_text_only_calibration_data(
|
|
93
|
+
batch_size: int,
|
|
94
|
+
seq_len: int,
|
|
95
|
+
vocab_size: int,
|
|
96
|
+
num_samples: int = 20,
|
|
97
|
+
) -> list[dict]:
|
|
98
|
+
"""Generate text-only calibration data for PTQ."""
|
|
99
|
+
calibration_data = []
|
|
100
|
+
for _ in range(num_samples):
|
|
101
|
+
input_ids = torch.randint(0, vocab_size, (batch_size, seq_len))
|
|
102
|
+
sample = {
|
|
103
|
+
"input_ids": input_ids,
|
|
104
|
+
}
|
|
105
|
+
calibration_data.append(sample)
|
|
106
|
+
return calibration_data
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def main():
|
|
110
|
+
# Create the model with a tiny config (no download needed).
|
|
111
|
+
text_config = _make_text_config()
|
|
112
|
+
|
|
113
|
+
model = Gemma4ForCausalLM(text_config)
|
|
114
|
+
orig_model = copy.deepcopy(model)
|
|
115
|
+
model.eval()
|
|
116
|
+
|
|
117
|
+
# Dimensions
|
|
118
|
+
batch_size = 1
|
|
119
|
+
seq_len = 16
|
|
120
|
+
|
|
121
|
+
# Build a Gemma4-specific PTQ config.
|
|
122
|
+
ptq_config = build_gemma4_e2b_ptq_config(
|
|
123
|
+
num_text_layers=int(text_config.num_hidden_layers),
|
|
124
|
+
num_vision_layers=0,
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
# Prepare the model for quantization
|
|
128
|
+
print("Preparing model for quantization...")
|
|
129
|
+
prepared_model = tico.quantization.prepare(model, ptq_config)
|
|
130
|
+
|
|
131
|
+
# Calibrate with text-only data
|
|
132
|
+
print("Calibrating (text-only)...")
|
|
133
|
+
calibration_data = generate_text_only_calibration_data(
|
|
134
|
+
batch_size=batch_size,
|
|
135
|
+
seq_len=seq_len,
|
|
136
|
+
vocab_size=text_config.vocab_size,
|
|
137
|
+
num_samples=20,
|
|
138
|
+
)
|
|
139
|
+
with torch.no_grad():
|
|
140
|
+
for sample in calibration_data:
|
|
141
|
+
prepared_model(**sample)
|
|
142
|
+
|
|
143
|
+
# Convert to quantized model
|
|
144
|
+
print("Converting to quantized model...")
|
|
145
|
+
quantized_model = tico.quantization.convert(prepared_model)
|
|
146
|
+
|
|
147
|
+
# Compute PEIR between quantized model and original model
|
|
148
|
+
eval_sample = calibration_data[0]
|
|
149
|
+
with torch.no_grad():
|
|
150
|
+
quant_out = quantized_model(**eval_sample)
|
|
151
|
+
fp_out = orig_model(**eval_sample).logits
|
|
152
|
+
|
|
153
|
+
print(f"\n┌───────────── Quantization Error Summary ─────────────")
|
|
154
|
+
print(f"│ FP output shape : {tuple(fp_out.shape)}")
|
|
155
|
+
print(f"│ Quant output shape : {tuple(quant_out.shape)}")
|
|
156
|
+
print(f"│ Mean |diff| : {(quant_out - fp_out).abs().mean().item():.6f}")
|
|
157
|
+
print(f"│ PEIR : {compute_peir(fp_out, quant_out) * 100:.6f} %")
|
|
158
|
+
print(f"└──────────────────────────────────────────────────────")
|
|
159
|
+
print(plot_two_outputs(fp_out, quant_out))
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
if __name__ == "__main__":
|
|
163
|
+
main()
|
tico-0.2.0.dev260706/tico/quantization/wrapq/examples/gemma4/quantize_for_conditional_generation.py
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# Copyright (c) 2026 Samsung Electronics Co., Ltd. All Rights Reserved
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
|
|
16
|
+
"""Example: PTQ quantization of Gemma4ForConditionalGeneration.
|
|
17
|
+
|
|
18
|
+
The ``Gemma4ForConditionalGeneration`` is the top-level model that wraps
|
|
19
|
+
``Gemma4Model`` (vision + text decoder) and adds an ``lm_head`` linear layer
|
|
20
|
+
to produce vocabulary logits. It also applies logit softcapping when
|
|
21
|
+
``final_logit_softcapping`` is set in the text config.
|
|
22
|
+
|
|
23
|
+
This script demonstrates the full PTQ flow:
|
|
24
|
+
|
|
25
|
+
1. Create a tiny Gemma4ForConditionalGeneration with random weights.
|
|
26
|
+
2. Prepare the model for quantization with a Gemma4-specific PTQ config.
|
|
27
|
+
3. Calibrate with synthetic text-only data.
|
|
28
|
+
4. Convert to a fake-quantized model.
|
|
29
|
+
5. Compare FP vs. quantized logits.
|
|
30
|
+
6. Export to Circle format via the export adapter.
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
import copy
|
|
34
|
+
import sys
|
|
35
|
+
|
|
36
|
+
import torch
|
|
37
|
+
|
|
38
|
+
import tico
|
|
39
|
+
import tico.quantization
|
|
40
|
+
from tico.quantization.config.gemma4_builders import build_gemma4_e2b_ptq_config
|
|
41
|
+
from tico.quantization.evaluation.metric import compute_peir
|
|
42
|
+
from tico.quantization.evaluation.utils import plot_two_outputs
|
|
43
|
+
from tico.quantization.wrapq.utils.version import has_transformers_for
|
|
44
|
+
|
|
45
|
+
torch.manual_seed(123)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
# Check if transformers is available
|
|
49
|
+
if not has_transformers_for("gemma4"):
|
|
50
|
+
print(
|
|
51
|
+
"Error: transformers package with Gemma4 support not installed. "
|
|
52
|
+
"Cannot test Gemma4ForConditionalGeneration."
|
|
53
|
+
)
|
|
54
|
+
sys.exit(1)
|
|
55
|
+
|
|
56
|
+
from transformers.models.gemma4.configuration_gemma4 import (
|
|
57
|
+
Gemma4Config,
|
|
58
|
+
Gemma4TextConfig,
|
|
59
|
+
Gemma4VisionConfig,
|
|
60
|
+
)
|
|
61
|
+
from transformers.models.gemma4.modeling_gemma4 import Gemma4ForConditionalGeneration
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _make_vision_config() -> Gemma4VisionConfig:
|
|
65
|
+
"""Create a tiny Gemma4 vision config for the example."""
|
|
66
|
+
cfg = Gemma4VisionConfig(
|
|
67
|
+
hidden_size=32,
|
|
68
|
+
intermediate_size=64,
|
|
69
|
+
num_hidden_layers=1,
|
|
70
|
+
num_attention_heads=4,
|
|
71
|
+
num_key_value_heads=2,
|
|
72
|
+
head_dim=8,
|
|
73
|
+
patch_size=4,
|
|
74
|
+
position_embedding_size=8,
|
|
75
|
+
pooling_kernel_size=2,
|
|
76
|
+
attention_dropout=0.0,
|
|
77
|
+
max_position_embeddings=128,
|
|
78
|
+
rms_norm_eps=1e-6,
|
|
79
|
+
use_clipped_linears=False,
|
|
80
|
+
rope_parameters={"rope_type": "default", "rope_theta": 100.0},
|
|
81
|
+
standardize=True,
|
|
82
|
+
)
|
|
83
|
+
if not hasattr(cfg, "_attn_implementation"):
|
|
84
|
+
setattr(cfg, "_attn_implementation", "eager")
|
|
85
|
+
else:
|
|
86
|
+
cfg._attn_implementation = "eager"
|
|
87
|
+
return cfg
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def _make_text_config() -> Gemma4TextConfig:
|
|
91
|
+
"""Create a tiny Gemma4 text config for the example."""
|
|
92
|
+
cfg = Gemma4TextConfig(
|
|
93
|
+
vocab_size=256,
|
|
94
|
+
hidden_size=64,
|
|
95
|
+
intermediate_size=128,
|
|
96
|
+
num_hidden_layers=1,
|
|
97
|
+
num_attention_heads=2,
|
|
98
|
+
num_key_value_heads=2,
|
|
99
|
+
num_global_key_value_heads=2,
|
|
100
|
+
head_dim=32,
|
|
101
|
+
global_head_dim=32,
|
|
102
|
+
max_position_embeddings=128,
|
|
103
|
+
layer_types=["full_attention"],
|
|
104
|
+
rope_parameters={
|
|
105
|
+
"full_attention": {"rope_type": "default", "rope_theta": 10000.0}
|
|
106
|
+
},
|
|
107
|
+
attention_bias=False,
|
|
108
|
+
attention_dropout=0.0,
|
|
109
|
+
use_cache=False,
|
|
110
|
+
enable_moe_block=False,
|
|
111
|
+
# Enable logit softcapping to exercise that code path.
|
|
112
|
+
final_logit_softcapping=30.0,
|
|
113
|
+
)
|
|
114
|
+
if not hasattr(cfg, "_attn_implementation"):
|
|
115
|
+
setattr(cfg, "_attn_implementation", "eager")
|
|
116
|
+
else:
|
|
117
|
+
cfg._attn_implementation = "eager"
|
|
118
|
+
return cfg
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def _make_gemma4_config() -> Gemma4Config:
|
|
122
|
+
"""Create a tiny Gemma4 top-level config for the example."""
|
|
123
|
+
return Gemma4Config(
|
|
124
|
+
text_config=_make_text_config(),
|
|
125
|
+
vision_config=_make_vision_config(),
|
|
126
|
+
audio_config=None,
|
|
127
|
+
image_token_id=10,
|
|
128
|
+
video_token_id=11,
|
|
129
|
+
audio_token_id=12,
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def generate_text_only_calibration_data(
|
|
134
|
+
batch_size: int,
|
|
135
|
+
seq_len: int,
|
|
136
|
+
vocab_size: int,
|
|
137
|
+
num_samples: int = 20,
|
|
138
|
+
) -> list[dict]:
|
|
139
|
+
"""Generate text-only calibration data for PTQ."""
|
|
140
|
+
calibration_data = []
|
|
141
|
+
for _ in range(num_samples):
|
|
142
|
+
input_ids = torch.randint(0, vocab_size, (batch_size, seq_len))
|
|
143
|
+
# Avoid image placeholder token IDs to keep this text-only.
|
|
144
|
+
input_ids = input_ids.clamp(0, 9)
|
|
145
|
+
sample = {
|
|
146
|
+
"input_ids": input_ids,
|
|
147
|
+
}
|
|
148
|
+
calibration_data.append(sample)
|
|
149
|
+
return calibration_data
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def main():
|
|
153
|
+
# Create the model with a tiny config (no download needed).
|
|
154
|
+
config = _make_gemma4_config()
|
|
155
|
+
text_config = config.get_text_config()
|
|
156
|
+
vision_config = config.vision_config
|
|
157
|
+
|
|
158
|
+
model = Gemma4ForConditionalGeneration(config)
|
|
159
|
+
orig_model = copy.deepcopy(model)
|
|
160
|
+
model.eval()
|
|
161
|
+
|
|
162
|
+
# Dimensions
|
|
163
|
+
batch_size = 1
|
|
164
|
+
seq_len = 16
|
|
165
|
+
num_visual_tokens = 4
|
|
166
|
+
|
|
167
|
+
# Build a Gemma4-specific PTQ config.
|
|
168
|
+
ptq_config = build_gemma4_e2b_ptq_config(
|
|
169
|
+
num_text_layers=int(text_config.num_hidden_layers),
|
|
170
|
+
num_vision_layers=int(vision_config.num_hidden_layers),
|
|
171
|
+
model_args={
|
|
172
|
+
"vision": {
|
|
173
|
+
"visual_start_idx": 0,
|
|
174
|
+
"num_visual_tokens": num_visual_tokens,
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
# Prepare the model for quantization
|
|
180
|
+
print("Preparing model for quantization...")
|
|
181
|
+
prepared_model = tico.quantization.prepare(model, ptq_config)
|
|
182
|
+
|
|
183
|
+
# Calibrate with text-only data
|
|
184
|
+
print("Calibrating (text-only)...")
|
|
185
|
+
calibration_data = generate_text_only_calibration_data(
|
|
186
|
+
batch_size=batch_size,
|
|
187
|
+
seq_len=seq_len,
|
|
188
|
+
vocab_size=text_config.vocab_size,
|
|
189
|
+
num_samples=20,
|
|
190
|
+
)
|
|
191
|
+
with torch.no_grad():
|
|
192
|
+
for sample in calibration_data:
|
|
193
|
+
prepared_model(**sample)
|
|
194
|
+
|
|
195
|
+
# Convert to quantized model
|
|
196
|
+
print("Converting to quantized model...")
|
|
197
|
+
quantized_model = tico.quantization.convert(prepared_model)
|
|
198
|
+
|
|
199
|
+
# Compute PEIR between quantized model and original model
|
|
200
|
+
eval_sample = calibration_data[0]
|
|
201
|
+
with torch.no_grad():
|
|
202
|
+
quant_out = quantized_model(**eval_sample)
|
|
203
|
+
fp_out = orig_model(**eval_sample).logits
|
|
204
|
+
|
|
205
|
+
print(f"\n┌───────────── Quantization Error Summary ─────────────")
|
|
206
|
+
print(f"│ FP output shape : {tuple(fp_out.shape)}")
|
|
207
|
+
print(f"│ Quant output shape : {tuple(quant_out.shape)}")
|
|
208
|
+
print(f"│ Mean |diff| : {(quant_out - fp_out).abs().mean().item():.6f}")
|
|
209
|
+
print(f"│ PEIR : {compute_peir(fp_out, quant_out) * 100:.6f} %")
|
|
210
|
+
print(f"└──────────────────────────────────────────────────────")
|
|
211
|
+
print(plot_two_outputs(fp_out, quant_out))
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
if __name__ == "__main__":
|
|
215
|
+
main()
|