Skip to content

Refactor: flatten models/ to one directory per model build - #886

Open
zhangqi-chen wants to merge 1 commit into
hw-native-sys:mainfrom
zhangqi-chen:refactor/flatten-models
Open

Refactor: flatten models/ to one directory per model build#886
zhangqi-chen wants to merge 1 commit into
hw-native-sys:mainfrom
zhangqi-chen:refactor/flatten-models

Conversation

@zhangqi-chen

Copy link
Copy Markdown
Collaborator

The models/// nesting held no family-level shared code,
so the intermediate directories were pure namespacing. Flatten them to
[], which also settles the hyphen-vs-underscore
inconsistency between v4-flash and v3_2.

  • qwen3/14b, qwen3/32b, deepseek/v3_2 become qwen3_14b, qwen3_32b,
    deepseek_v3_2.
  • deepseek/v4-flash becomes deepseek_v4_flash_w8a8int and deepseek/v4-pro
    becomes deepseek_v4_pro_w4a8mx. The suffix names the deployment
    quantization with the CANN convert_model.py --quant_type vocabulary,
    separators dropped. Flash matches its Atlas A3 deployment; Pro names
    its A5 Hybrid MXFP8-MXFP4 target while its kernels still consume INT8
    re-quantized from the MXFP4 grid.
  • Drop the now-redundant model-name prefix from filenames under
    deepseek_v3_2, qwen3_32b, and the qwen3_14b drafts.
  • contract.py derived the models root as _KERNEL_DIR.parent.parent.parent,
    one level too many for the flatter tree; use .parent, which matches the
    variable name. config.py and constants.py exist only under models/, so
    the narrower prefix keeps the shadowed-module check equivalent.
  • Retarget the CI change selectors, the contract registry variant path,
    the contract test's Path-segment literals, and the docs.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Too many files!

This PR contains 184 files, which is 84 over the limit of 100.

To get a review, narrow the scope:
• coderabbit review --committed # exclude uncommitted changes
• coderabbit review --dir # limit to a subdirectory
• coderabbit review --base # compare against a closer base

Upgrade to a paid plan to raise the limit.

This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 875688ba-4bd6-4d75-b60a-1bdc8fb3d161

📥 Commits

Reviewing files that changed from the base of the PR and between fd91568 and 9b59d7f.

⛔ Files ignored due to path filters (1)
  • models/qwen3_14b/kernels/paged_attention_cce/generated/kernel_tiling/kernel_tiling.h is excluded by !**/generated/**
📒 Files selected for processing (184)
  • .claude/CLAUDE.md
  • .claude/skills/create-issue/SKILL.md
  • .claude/skills/fix-pr/SKILL.md
  • .claude/skills/fmt-coding-style/SKILL.md
  • .claude/skills/incore-profiling/incore_profile.py
  • .github/scripts/detect_changes.py
  • .github/workflows/ci.yml
  • .github/workflows/daily_ci.yml
  • AGENTS.md
  • README.md
  • contract/registry.py
  • docs/debug-and-tune/debugging.md
  • docs/debug-and-tune/performance-tuning.md
  • docs/models/deepseek.md
  • docs/models/qwen3.md
  • docs/run-and-validate/compile-runtime-workflow.md
  • models/deepseek_v3_2/decode_back.py
  • models/deepseek_v3_2/decode_front.py
  • models/deepseek_v3_2/prefill_back.py
  • models/deepseek_v4_flash_w8a8int/config.py
  • models/deepseek_v4_flash_w8a8int/decode_attention_csa.py
  • models/deepseek_v4_flash_w8a8int/decode_attention_hca.py
  • models/deepseek_v4_flash_w8a8int/decode_attention_swa.py
  • models/deepseek_v4_flash_w8a8int/decode_compressor_ratio128.py
  • models/deepseek_v4_flash_w8a8int/decode_compressor_ratio4.py
  • models/deepseek_v4_flash_w8a8int/decode_fwd.py
  • models/deepseek_v4_flash_w8a8int/decode_fwd_mtp.py
  • models/deepseek_v4_flash_w8a8int/decode_indexer.py
  • models/deepseek_v4_flash_w8a8int/decode_indexer_compressor.py
  • models/deepseek_v4_flash_w8a8int/decode_input_pack.py
  • models/deepseek_v4_flash_w8a8int/decode_layer.py
  • models/deepseek_v4_flash_w8a8int/decode_metadata.py
  • models/deepseek_v4_flash_w8a8int/decode_metadata_device.py
  • models/deepseek_v4_flash_w8a8int/decode_mtp.py
  • models/deepseek_v4_flash_w8a8int/decode_mtp_verify.py
  • models/deepseek_v4_flash_w8a8int/decode_sparse_attn.py
  • models/deepseek_v4_flash_w8a8int/decode_sparse_attn_hca.py
  • models/deepseek_v4_flash_w8a8int/decode_sparse_attn_swa.py
  • models/deepseek_v4_flash_w8a8int/expert_routed.py
  • models/deepseek_v4_flash_w8a8int/expert_shared.py
  • models/deepseek_v4_flash_w8a8int/gate.py
  • models/deepseek_v4_flash_w8a8int/hc_head.py
  • models/deepseek_v4_flash_w8a8int/hc_post.py
  • models/deepseek_v4_flash_w8a8int/hc_pre.py
  • models/deepseek_v4_flash_w8a8int/lm_head.py
  • models/deepseek_v4_flash_w8a8int/lookup_embedding.py
  • models/deepseek_v4_flash_w8a8int/moe.py
  • models/deepseek_v4_flash_w8a8int/mtp_projection.py
  • models/deepseek_v4_flash_w8a8int/prefill_attention_csa.py
  • models/deepseek_v4_flash_w8a8int/prefill_attention_hca.py
  • models/deepseek_v4_flash_w8a8int/prefill_attention_swa.py
  • models/deepseek_v4_flash_w8a8int/prefill_compressor_ratio128.py
  • models/deepseek_v4_flash_w8a8int/prefill_compressor_ratio4.py
  • models/deepseek_v4_flash_w8a8int/prefill_fwd.py
  • models/deepseek_v4_flash_w8a8int/prefill_indexer.py
  • models/deepseek_v4_flash_w8a8int/prefill_indexer_compressor.py
  • models/deepseek_v4_flash_w8a8int/prefill_layer.py
  • models/deepseek_v4_flash_w8a8int/prefill_mtp.py
  • models/deepseek_v4_flash_w8a8int/prefill_sparse_attn.py
  • models/deepseek_v4_flash_w8a8int/qkv_proj_rope.py
  • models/deepseek_v4_flash_w8a8int/rmsnorm.py
  • models/deepseek_v4_flash_w8a8int/rope_interleave.py
  • models/deepseek_v4_flash_w8a8int/rope_tables.py
  • models/deepseek_v4_pro_w4a8mx/config.py
  • models/deepseek_v4_pro_w4a8mx/decode_attention_csa.py
  • models/deepseek_v4_pro_w4a8mx/decode_attention_hca.py
  • models/deepseek_v4_pro_w4a8mx/decode_attention_swa.py
  • models/deepseek_v4_pro_w4a8mx/decode_compressor_ratio128.py
  • models/deepseek_v4_pro_w4a8mx/decode_compressor_ratio4.py
  • models/deepseek_v4_pro_w4a8mx/decode_fwd.py
  • models/deepseek_v4_pro_w4a8mx/decode_indexer.py
  • models/deepseek_v4_pro_w4a8mx/decode_indexer_compressor.py
  • models/deepseek_v4_pro_w4a8mx/decode_layer.py
  • models/deepseek_v4_pro_w4a8mx/decode_metadata.py
  • models/deepseek_v4_pro_w4a8mx/decode_mtp.py
  • models/deepseek_v4_pro_w4a8mx/decode_sparse_attn.py
  • models/deepseek_v4_pro_w4a8mx/decode_sparse_attn_hca.py
  • models/deepseek_v4_pro_w4a8mx/decode_sparse_attn_swa.py
  • models/deepseek_v4_pro_w4a8mx/expert_routed.py
  • models/deepseek_v4_pro_w4a8mx/expert_shared.py
  • models/deepseek_v4_pro_w4a8mx/gate.py
  • models/deepseek_v4_pro_w4a8mx/hc_head.py
  • models/deepseek_v4_pro_w4a8mx/hc_post.py
  • models/deepseek_v4_pro_w4a8mx/hc_pre.py
  • models/deepseek_v4_pro_w4a8mx/lm_head.py
  • models/deepseek_v4_pro_w4a8mx/moe.py
  • models/deepseek_v4_pro_w4a8mx/mtp_projection.py
  • models/deepseek_v4_pro_w4a8mx/prefill_attention_csa.py
  • models/deepseek_v4_pro_w4a8mx/prefill_attention_hca.py
  • models/deepseek_v4_pro_w4a8mx/prefill_attention_swa.py
  • models/deepseek_v4_pro_w4a8mx/prefill_compressor_ratio128.py
  • models/deepseek_v4_pro_w4a8mx/prefill_compressor_ratio4.py
  • models/deepseek_v4_pro_w4a8mx/prefill_fwd.py
  • models/deepseek_v4_pro_w4a8mx/prefill_indexer.py
  • models/deepseek_v4_pro_w4a8mx/prefill_indexer_compressor.py
  • models/deepseek_v4_pro_w4a8mx/prefill_layer.py
  • models/deepseek_v4_pro_w4a8mx/prefill_mtp.py
  • models/deepseek_v4_pro_w4a8mx/prefill_sparse_attn.py
  • models/deepseek_v4_pro_w4a8mx/qkv_proj_rope.py
  • models/deepseek_v4_pro_w4a8mx/rmsnorm.py
  • models/deepseek_v4_pro_w4a8mx/rope_tables.py
  • models/qwen3_14b/config.py
  • models/qwen3_14b/constants.py
  • models/qwen3_14b/contract.py
  • models/qwen3_14b/decode_fwd.py
  • models/qwen3_14b/decode_layer_a8w8.py
  • models/qwen3_14b/decode_ssn_draft.py
  • models/qwen3_14b/decode_tq_draft.py
  • models/qwen3_14b/greedy_sample.py
  • models/qwen3_14b/kernels/paged_attention_cce/attention/entry.cpp
  • models/qwen3_14b/kernels/paged_attention_cce/attention_rope/entry.cpp
  • models/qwen3_14b/kernels/paged_attention_cce/kernel/fai_body.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/kernel/metadata_layout.h
  • models/qwen3_14b/kernels/paged_attention_cce/kernel/rope_qkv_generated.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/tiling/entry.cpp
  • models/qwen3_14b/kernels/paged_attention_cce/tiling/qwen_fai_runtime_tiler.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/arch/arch.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/arch/cross_core_sync.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/arch/local_tensor_buffer.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/arch/resource.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/base_defs.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/coord.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/detail/alignment.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/detail/dependent_false.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/detail/macros.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/epilogue/block/CombineScale.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/epilogue/block/block_epilogue.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/epilogue/block/block_epilogue_init_outputs.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/epilogue/block/block_epilogue_online_softmax.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/epilogue/block/block_epilogue_online_softmax_low_prec.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/epilogue/block/block_epilogue_rescale_o.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/epilogue/block/block_epilogue_rescale_o_low_prec.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/epilogue/dispatch_policy.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/epilogue/tile_common/copy_gm_to_ub.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/epilogue/tile_common/copy_ub_to_gm.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/epilogue/tile_common/tile_broadcast_inplace_by_column.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/epilogue/tile_common/tile_broadcast_inplace_by_row.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/epilogue/tile_common/tile_broadcast_mul.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/epilogue/tile_common/tile_broadcast_one_blk.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/epilogue/tile_common/tile_cast.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/epilogue/tile_common/tile_copy.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/epilogue/tile_common/tile_elemwise_add.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/epilogue/tile_common/tile_elemwise_mul.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/epilogue/tile_common/tile_elemwise_muls.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/epilogue/tile_common/tile_swizzle.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/gemm/block/block_mmad.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/gemm/block/block_mmad_pv.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/gemm/block/block_mmad_pv_decode.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/gemm/block/block_mmad_qk.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/gemm/block/block_mmad_qk_decode.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/gemm/dispatch_policy.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/gemm/gemm_type.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/gemm/helper.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/gemm/tile_common/copy_gm_to_l1.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/gemm/tile_common/copy_gm_to_ub.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/gemm/tile_common/copy_l0c_to_gm.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/gemm/tile_common/copy_l1_to_bt.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/gemm/tile_common/copy_l1_to_l0a.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/gemm/tile_common/copy_l1_to_l0b.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/gemm/tile_common/copy_ub_to_gm.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/gemm/tile_common/tile_copy.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/gemm/tile_common/tile_copy_tla.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/gemm/tile_common/tile_mmad.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/gemm_coord.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/layout/layout.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/layout/matrix.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/layout/vector.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/attn_infra/matrix_coord.hpp
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/flash_attention_regular.h
  • models/qwen3_14b/kernels/paged_attention_cce/vendor/fused_infer_attention_score/kernel_common.hpp
  • models/qwen3_14b/paged_attention_cce.py
  • models/qwen3_14b/prefill_fwd.py
  • models/qwen3_14b/prefill_fwd_a8w8.py
  • models/qwen3_14b/prefill_tq_draft.py
  • models/qwen3_14b/rms_lm_head.py
  • models/qwen3_14b/rope_qkv_regen.py
  • models/qwen3_14b/test_paged_attention_cce.py
  • models/qwen3_14b/topk_select.py
  • models/qwen3_14b/turboquant_kv.py
  • models/qwen3_14b/weights.py
  • models/qwen3_32b/decode.py
  • models/qwen3_32b/decode_4d.py
  • models/qwen3_32b/prefill_draft.py
  • tests/contract/test_qwen3_14b_contract.py

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

The models/<family>/<variant>/ nesting held no family-level shared code,
so the intermediate directories were pure namespacing. Flatten them to
<family>_<version>[_<quant>], which also settles the hyphen-vs-underscore
inconsistency between v4-flash and v3_2.

- qwen3/14b, qwen3/32b, deepseek/v3_2 become qwen3_14b, qwen3_32b,
  deepseek_v3_2.
- deepseek/v4-flash becomes deepseek_v4_flash_w8a8int and deepseek/v4-pro
  becomes deepseek_v4_pro_w4a8mx. The suffix names the deployment
  quantization with the CANN convert_model.py --quant_type vocabulary,
  separators dropped. Flash matches its Atlas A3 deployment; Pro names
  its A5 Hybrid MXFP8-MXFP4 target while its kernels still consume INT8
  re-quantized from the MXFP4 grid.
- Drop the now-redundant model-name prefix from filenames under
  deepseek_v3_2, qwen3_32b, and the qwen3_14b drafts.
- contract.py derived the models root as _KERNEL_DIR.parent.parent.parent,
  one level too many for the flatter tree; use .parent, which matches the
  variable name. config.py and constants.py exist only under models/, so
  the narrower prefix keeps the shadowed-module check equivalent.
- Retarget the CI change selectors, the contract registry variant path,
  the contract test's Path-segment literals, and the docs.
@zhangqi-chen
zhangqi-chen force-pushed the refactor/flatten-models branch from f77fec9 to 9b59d7f Compare August 3, 2026 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant