Public report of EricLBuehler/mistral.rs, published 14 November 2026. It has the same score, grades and number of findings as the full report. The details of security findings (where they are in the code, which known vulnerabilities and which passwords or keys were found) are left out, so nobody can use them against the project.
Public
Executive report Measured under the Code Assurance Index, an open standard for code quality, using its published scoring rules (rubric version 2026.11.4). Assert signed this survey and filed it in the standard's public register, where anyone can look it up by its survey ID. Check this survey → Signed and filed in the standard's public register, 14 November 2026, 17:24 UTC · Survey ID cd_fd7956428b71461bb2e3e823ae558622

EricLBuehler/mistral.rs

Measured 14 November 2026, 17:24 UTC, at code version fb4cdc3

CAI score 54out of 100 Adequate
CriticalWeakAdequateStrongExemplary
Up 1 since the last survey

The score is built from these lenses. Each lens grades one area of the code, such as how easy it is to change or how well it is protected. The weakest lens counts most, so one weak area pulls the score down instead of being averaged away.

A very large codebase: 555,220 lines of product code in 18 projects, tests not counted · Estimated rebuild effort: about 3.9 person-years · Weakest lens: Security and Compliance, 44

Findings by how serious they are

124 critical 4840 serious 154 minor

17 dimensions are left out of the score. For each one, we either couldn't measure it in this code, or found no evidence of the safeguard we look for, such as a tested backup restore. They count neither for nor against the score, and Limitations lists each one with its reason.

This survey was produced by

Assert small markCanine Code Analyzer
Producer
Canine Development
Analyzer
Canine Code Analyzer engine 1.0.0
Measured
14 November 2026, 17:24 UTC

A measurement, not a certificate. The Code Assurance Index records a number together with the evidence it was worked out from, so anyone can recalculate it, but it doesn't certify or guarantee the code. The standard was written by Canine Development, which also builds the Canine Code Analyzer. It is open to any tool that implements it, and today the Canine Code Analyzer is the only one that does.

The score is deterministic, which means the same code always gets the same score. We work it out with tools that follow published rules, and an AI model never decides it, so anyone who applies the same rules to the same code gets the same number. How it is done is explained under Methodology ▸

76of 76 dimensions measured by tools.
5070of 5118 findings point to an exact file and line, so you can open each one in the code. The other 48 concern the repository as a whole, such as missing documentation.
76dimensions across 9 lenses, read from 555,220 lines of product code in 18 projects.
Chapters

Executive summary

EricLBuehler/mistral.rs falls short of our standard for a preview release, in part because it has pipeline tools referenced by a changeable name. It scores 54 out of 100 and is rated Adequate, and 114 of its 124 critical findings are security problems.

Security and Compliance, at 44, is the weakest lens and counts most in the score. The best first step is naming the access rules, worth about 7 points. Serving traffic only over an encrypted connection comes next, worth about 4 points. Raising Security and Compliance to 68 would lift the score to about 60.

Ninety pipeline tools are referenced by a changeable name, so the build pipeline can be tampered with. Seven settings leave the servers or containers unsafe, and six secrets can leak from the build pipeline. Pinning each tool to an exact version, correcting the unsafe settings and limiting each secret to its own step would close these risks. The four places where the code runs text as code or as a command need a direct call instead. The three passwords or keys in the code's history need replacing, with the old ones switched off. The nine form fields without a label need a label.

The product code is 555,220 lines, about €570,000 to rebuild.

A lens is capped at Adequate while one of its dimensions scores below 4 out of 10, however well the rest of the lens does. That way a serious problem in one place always shows in the lens's rating.

How the score is built: what each lens counts for The lenses don't count equally. The weakest lens counts most, the next weakest a little less, and so on, so a weak area pulls the score down instead of being averaged away. In the bar below, each part's width shows how much that lens counts and its colour shows its rating. Improving the widest part moves the score most, and as that lens improves, it counts for less, because another lens becomes the weakest.
Security and Compliance 44 · counts for 45%Production Readiness 53 · counts for 25%Code Health 55 · counts for 14%Maturity 66 · counts for 8%Accessibility 83 · counts for 4%Architecture 95 · counts for 2%Domain Modelling 100 · counts for 1%Event Sourcing 100 · counts for 1%Performance 100 · counts for 0%

If Security and Compliance rose from 44 to 68, the lowest score rated Strong, the score would rise from 54 to about 60.

Code composition: what the lines of code are
Product code 95%Tests 5%
New since the last survey: 1527 findings

These 1527 critical or serious findings weren't in the previous survey, on 27 October 2026. The first 100 are listed here, and the findings file in the download package lists them all.

  • Cyclomatic Complexity · GridImageProcessor::process_inputs (cyclomatic 58) mistralrs-core/src/vision_models/grid_processor.rs
  • Cyclomatic Complexity · mistralrs_quant::gguf::cuda::indexed_moe_fused_decode (cyclomatic 52) mistralrs-quant/src/gguf/cuda.rs
  • Cyclomatic Complexity · mistralrs_core::pipeline::loaders::auto_device_map::get_device_layers_attempt (cyclomatic 38) mistralrs-core/src/pipeline/loaders/auto_device_map.rs
  • Cyclomatic Complexity · GridImageProcessor::prepare_for_paged_prompt_planning (cyclomatic 30) mistralrs-core/src/vision_models/grid_processor.rs
  • Cyclomatic Complexity · mistralrs_core::vision_models::lfm3_d1::prompt::render_question (cyclomatic 26) mistralrs-core/src/vision_models/lfm3_d1/prompt.rs
  • Cyclomatic Complexity · mistralrs_pyo3::normalize_chat_messages (cyclomatic 25) mistralrs-pyo3/src/lib.rs
  • Cyclomatic Complexity · mistralrs_quant::gguf::quantize::quantize_cpu (cyclomatic 25) mistralrs-quant/src/gguf/quantize.rs
  • Cyclomatic Complexity · mistralrs_core::vision_models::lfm3_d1::parsing::parse_digits (cyclomatic 24) mistralrs-core/src/vision_models/lfm3_d1/parsing.rs
  • Cyclomatic Complexity · mistralrs_quant::gguf::fast_mmvq::fused_qkv_optional (cyclomatic 24) mistralrs-quant/src/gguf/fast_mmvq.rs
  • Cyclomatic Complexity · mistralrs_core::vision_models::lfm3_d1::parsing::parse_date_inner (cyclomatic 21) mistralrs-core/src/vision_models/lfm3_d1/parsing.rs
  • Cyclomatic Complexity · RoutedExperts::forward_grouped (cyclomatic 21) mistralrs-quant/src/routed_moe/cuda.rs
  • Cyclomatic Complexity · mistralrs_quant::afq::group::gate_up (cyclomatic 21) mistralrs-quant/src/afq/group.rs
  • Cyclomatic Complexity · mistralrs_quant::cutile::nvfp4::validate_input (cyclomatic 21) mistralrs-quant/src/cutile/nvfp4.rs
  • Cyclomatic Complexity · mistralrs_quant::routed_gemv::cuda::launch (cyclomatic 21) mistralrs-quant/src/routed_gemv/cuda.rs
  • Cyclomatic Complexity · mistralrs_server_core::speech_generation::match_response_with_options (cyclomatic 21) mistralrs-server-core/src/speech_generation.rs
  • Cyclomatic Complexity · Model::forward_hidden (cyclomatic 20) mistralrs-core/src/models/lfm3.rs
  • Cyclomatic Complexity · mistralrs_quant::cutile::qsa_decode::decode_shape (cyclomatic 20) mistralrs-quant/src/cutile/qsa_decode.rs
  • Cyclomatic Complexity · mistralrs_core::vision_models::lfm3_d1::parsing::parse_number (cyclomatic 19) mistralrs-core/src/vision_models/lfm3_d1/parsing.rs
  • Cyclomatic Complexity · mistralrs_core::cuda::gdn::try_fused_vmajor_prefill_recurrence_cuda (cyclomatic 18) mistralrs-core/src/cuda/gdn.rs
  • Cyclomatic Complexity · mistralrs_core::gguf::normal_config::build_lfm3 (cyclomatic 18) mistralrs-core/src/gguf/normal_config.rs
  • Cyclomatic Complexity · mistralrs_quant::cutile::nvfp4_matmul::prepare_gather_with (cyclomatic 18) mistralrs-quant/src/cutile/nvfp4_matmul.rs
  • Cyclomatic Complexity · mistralrs_quant::embedding::cuda::gather (cyclomatic 18) mistralrs-quant/src/embedding/cuda.rs
  • Cyclomatic Complexity · BlockwiseFP8Linear::prepare_provider (cyclomatic 17) mistralrs-quant/src/blockwise_fp8/mod.rs
  • Cyclomatic Complexity · ManagedEmbedding::prepare_mapped (cyclomatic 17) mistralrs-quant/src/embedding/storage.rs
  • Cyclomatic Complexity · mistralrs_quant::afq::group::qkv (cyclomatic 17) mistralrs-quant/src/afq/group.rs
  • Cyclomatic Complexity · mistralrs_quant::gguf::fast_mmvq::plain (cyclomatic 17) mistralrs-quant/src/gguf/fast_mmvq.rs
  • Cyclomatic Complexity · mistralrs_quant::gguf::gated_mix::try_fused_quantized_gated_mix (cyclomatic 17) mistralrs-quant/src/gguf/gated_mix.rs
  • Cyclomatic Complexity · mistralrs_server_core::audio_history::decorate_responses (cyclomatic 17) mistralrs-server-core/src/audio_history.rs
  • Cyclomatic Complexity · mistralrs_core::paged_attention::calculate_cache_config (cyclomatic 16) mistralrs-core/src/paged_attention/mod.rs
  • Cyclomatic Complexity · BlockwiseFP8Linear::forward_packed_glu (cyclomatic 16) mistralrs-quant/src/blockwise_fp8/mod.rs
  • Cyclomatic Complexity · mistralrs_quant::cutile::nvfp4_matmul::launch_dense (cyclomatic 16) mistralrs-quant/src/cutile/nvfp4_matmul.rs
  • Cyclomatic Complexity · mistralrs_quant::gguf::fast_mmvq::shared_lhs (cyclomatic 16) mistralrs-quant/src/gguf/fast_mmvq.rs
  • Cyclomatic Complexity · mistralrs_quant::gguf::group::cuda::dense (cyclomatic 16) mistralrs-quant/src/gguf/group.rs
  • Cyclomatic Complexity · mistralrs_quant::routed_gemv::cuda::operand (cyclomatic 16) mistralrs-quant/src/routed_gemv/cuda.rs
  • Cyclomatic Complexity · mistralrs_server_core::chat_completion::chatcompletions (cyclomatic 16) mistralrs-server-core/src/chat_completion.rs
  • Cognitive Complexity · GridImageProcessor::process_inputs (cognitive 129) mistralrs-core/src/vision_models/grid_processor.rs
  • Cognitive Complexity · mistralrs_core::pipeline::loaders::auto_device_map::get_device_layers_attempt (cognitive 77) mistralrs-core/src/pipeline/loaders/auto_device_map.rs
  • Cognitive Complexity · mistralrs_pyo3::normalize_chat_messages (cognitive 65) mistralrs-pyo3/src/lib.rs
  • Cognitive Complexity · GridImageProcessor::prepare_for_paged_prompt_planning (cognitive 61) mistralrs-core/src/vision_models/grid_processor.rs
  • Cognitive Complexity · mistralrs_server_core::audio_history::decorate_responses (cognitive 46) mistralrs-server-core/src/audio_history.rs
  • Cognitive Complexity · mistralrs_core::vision_models::lfm3_d1::prompt::render_question (cognitive 45) mistralrs-core/src/vision_models/lfm3_d1/prompt.rs
  • Cognitive Complexity · Model::forward_hidden (cognitive 42) mistralrs-core/src/models/lfm3.rs
  • Cognitive Complexity · mistralrs_core::vision_models::lfm3_d1::parsing::parse_date_inner (cognitive 38) mistralrs-core/src/vision_models/lfm3_d1/parsing.rs
  • Cognitive Complexity · ManagedEmbedding::prepare_mapped (cognitive 37) mistralrs-quant/src/embedding/storage.rs
  • Cognitive Complexity · RoutedExperts::forward_grouped (cognitive 35) mistralrs-quant/src/routed_moe/cuda.rs
  • Cognitive Complexity · mistralrs_core::vision_models::lfm3_d1::parsing::parse_digits (cognitive 31) mistralrs-core/src/vision_models/lfm3_d1/parsing.rs
  • Cognitive Complexity · VisionModel::position_embeddings (cognitive 28) mistralrs-core/src/vision_models/lfm3_vl/vision.rs
  • Cognitive Complexity · mistralrs_core::vision_models::lfm3_d1::parsing::parse_number (cognitive 28) mistralrs-core/src/vision_models/lfm3_d1/parsing.rs
  • Cognitive Complexity · mistralrs_core::gguf::lfm3_audio_bindings::bind_stack (cognitive 27) mistralrs-core/src/gguf/lfm3_audio_bindings.rs
  • Cognitive Complexity · mistralrs_core::gguf::normal_config::build_lfm3 (cognitive 27) mistralrs-core/src/gguf/normal_config.rs
  • Cognitive Complexity · mistralrs_quant::cutile::nvfp4_matmul::prepare_gather_with (cognitive 27) mistralrs-quant/src/cutile/nvfp4_matmul.rs
  • Cognitive Complexity · mistralrs_quant::cutile::nvfp4::validate_input (cognitive 25) mistralrs-quant/src/cutile/nvfp4.rs
  • Cognitive Complexity · mistralrs_server_core::speech_generation::speech_stream (cognitive 25) mistralrs-server-core/src/speech_generation.rs
  • Cognitive Complexity · mistralrs_core::cuda::gdn::try_fused_vmajor_prefill_recurrence_cuda (cognitive 24) mistralrs-core/src/cuda/gdn.rs
  • Cognitive Complexity · mistralrs_quant::cutile::nvfp4_matmul::launch_dense (cognitive 24) mistralrs-quant/src/cutile/nvfp4_matmul.rs
  • Cognitive Complexity · mistralrs_quant::gguf::group::cuda::dense (cognitive 24) mistralrs-quant/src/gguf/group.rs
  • Cognitive Complexity · DecisionPrompt::plan (cognitive 23) mistralrs-core/src/vision_models/lfm3_d1/prompt.rs
  • Cognitive Complexity · RegisteredShape::warm (cognitive 23) mistralrs-quant/src/cutile/nvfp4.rs
  • Cognitive Complexity · RowCodec::decode_row (cognitive 23) mistralrs-quant/src/embedding/mod.rs
  • Cognitive Complexity · mistralrs_quant::gguf::fast_mmvq::fused_qkv_optional (cognitive 23) mistralrs-quant/src/gguf/fast_mmvq.rs
  • Cognitive Complexity · mistralrs_quant::cutile::qsa_decode::decode_shape (cognitive 22) mistralrs-quant/src/cutile/qsa_decode.rs
  • Cognitive Complexity · CpuInputs::run (cognitive 21) mistralrs-quant/src/lfm3_conv.rs
  • Cognitive Complexity · RoutedExperts::forward (cognitive 21) mistralrs-quant/src/routed_moe/mod.rs
  • Cognitive Complexity · mistralrs_quant::cutile::nvfp4_matmul::launch_gather_prepared (cognitive 21) mistralrs-quant/src/cutile/nvfp4_matmul.rs
  • Cognitive Complexity · mistralrs_quant::routed_gemv::cuda::operand (cognitive 21) mistralrs-quant/src/routed_gemv/cuda.rs
  • Cognitive Complexity · mistralrs_core::vision_models::grid_processor::grid_packed_layout (cognitive 20) mistralrs-core/src/vision_models/grid_processor.rs
  • Cognitive Complexity · BlockwiseFP8Linear::forward_packed_glu (cognitive 20) mistralrs-quant/src/blockwise_fp8/mod.rs
  • Cognitive Complexity · mistralrs_quant::cutile::mxfp8_gemm::config (cognitive 20) mistralrs-quant/src/cutile/mxfp8_gemm.rs
  • Cognitive Complexity · mistralrs_quant::gguf::fast_mmvq::plain (cognitive 20) mistralrs-quant/src/gguf/fast_mmvq.rs
  • Cognitive Complexity · DecisionPlan::read_span (cognitive 19) mistralrs-core/src/vision_models/lfm3_d1/readout.rs
  • Cognitive Complexity · QsaAttention::forward_paged (cognitive 19) mistralrs-core/src/vision_models/qwen4_exp/qsa.rs
  • Cognitive Complexity · mistralrs_core::vision_models::lfm3_audio::config::normalize_config (cognitive 19) mistralrs-core/src/vision_models/lfm3_audio/config.rs
  • Cognitive Complexity · mistralrs_core::vision_models::lfm3_d1::readout::answer_codes (cognitive 19) mistralrs-core/src/vision_models/lfm3_d1/readout.rs
  • Cognitive Complexity · Matmul::cpu_fwd (cognitive 19) mistralrs-quant/src/mxfp8/mod.rs
  • Cognitive Complexity · AutoDeviceMapQuantization::pack_factor_for_candidates (cognitive 18) mistralrs-core/src/pipeline/loaders/mod.rs
  • Cognitive Complexity · GridImageProcessor::preprocess_inner (cognitive 18) mistralrs-core/src/vision_models/grid_processor.rs
  • Cognitive Complexity · mistralrs_core::vision_models::lfm3_d1::readout::json_paths (cognitive 18) mistralrs-core/src/vision_models/lfm3_d1/readout.rs
  • Cognitive Complexity · mistralrs_quant::distributed::packing::detect_format (cognitive 18) mistralrs-quant/src/distributed/packing.rs
  • Cognitive Complexity · mistralrs_quant::routed_gemv::cuda::launch (cognitive 18) mistralrs-quant/src/routed_gemv/cuda.rs
  • Cognitive Complexity · mistralrs_quant::uqff::report::validate_layer (cognitive 18) mistralrs-quant/src/uqff/report.rs
  • Cognitive Complexity · StreamingAudioCapture::stage (cognitive 18) mistralrs-server-core/src/audio_history.rs
  • Cognitive Complexity · mistralrs_server_core::chat_completion::chatcompletions (cognitive 18) mistralrs-server-core/src/chat_completion.rs
  • Cognitive Complexity · HybridCache::reserve_gdn_deferred_state (cognitive 17) mistralrs-core/src/kv_cache/hybrid_cache.rs
  • Cognitive Complexity · mistralrs_core::engine::speech::adapt_request (cognitive 17) mistralrs-core/src/engine/speech.rs
  • Cognitive Complexity · mistralrs_core::vision_models::lfm3_d1::parsing::decimal_mark (cognitive 17) mistralrs-core/src/vision_models/lfm3_d1/parsing.rs
  • Cognitive Complexity · mistralrs_quant::afq::group::gate_up (cognitive 17) mistralrs-quant/src/afq/group.rs
  • Cognitive Complexity · mistralrs_quant::cutile::mxfp8_gemm::kernels::mxfp8_gemm (cognitive 17) mistralrs-quant/src/cutile/mxfp8_gemm.rs
  • Cognitive Complexity · mistralrs_quant::cutile::nvfp4_matmul::kernels::routed_matmul (cognitive 17) mistralrs-quant/src/cutile/nvfp4_matmul.rs
  • Cognitive Complexity · mistralrs_quant::gguf::quantize::quantize_cpu (cognitive 17) mistralrs-quant/src/gguf/quantize.rs
  • Cognitive Complexity · plot_results.plot_concurrency (cognitive 17) releases/v0.9.5/scripts/plot_results.py
  • Cognitive Complexity · Model::new_inner (cognitive 16) mistralrs-core/src/models/lfm3.rs
  • Cognitive Complexity · Grid::new (cognitive 16) mistralrs-core/src/vision_models/lfm3_d1/prompt.rs
  • Cognitive Complexity · GenerationCache::audio_inputs (cognitive 16) mistralrs-core/src/vision_models/lfm3_omni/mod.rs
  • Cognitive Complexity · mistralrs_core::vision_models::grid_processor::expand_video_placeholders (cognitive 16) mistralrs-core/src/vision_models/grid_processor.rs
  • Cognitive Complexity · mistralrs_quant::afq::group::qkv (cognitive 16) mistralrs-quant/src/afq/group.rs
  • Cognitive Complexity · mistralrs_quant::gguf::fast_mmvq::shared_lhs (cognitive 16) mistralrs-quant/src/gguf/fast_mmvq.rs
  • God Classes · MethodTooLong: GridImageProcessor.process_inputs mistralrs-core/src/vision_models/grid_processor.rs
  • God Classes · FileTooLong: gguf/ffi.rs mistralrs-quant/src/gguf/ffi.rs
  • God Classes · FileTooLong: vision_models/grid_processor.rs mistralrs-core/src/vision_models/grid_processor.rs
  • God Classes · FunctionTooLong: mistralrs_quant::cutile::qsa_decode::kernels::qsa_attention_split mistralrs-quant/src/cutile/qsa_decode.rs

We compare every finding with the previous survey's. A finding that has only moved to another line in the same file counts as the same finding, so only new findings appear here. Advisory notes from the AI model are left out, because the model words them afresh in every survey.

Fixed since the last survey: 932 findings

These 932 critical or serious findings were in the previous survey, on 27 October 2026, and are gone from this one. The first 100 are listed here.

  • Cyclomatic Complexity · production_soak.validate_args (cyclomatic 181) scripts/production_soak.py
  • Cyclomatic Complexity · Qwen3VLImageProcessor::process_inputs (cyclomatic 54) mistralrs-core/src/vision_models/qwen3_vl/inputs_processor.rs
  • Cyclomatic Complexity · SoakClient.stream_request (cyclomatic 44) scripts/production_soak.py
  • Cyclomatic Complexity · production_soak.adversarial_mode (cyclomatic 43) scripts/production_soak.py
  • Cyclomatic Complexity · production_soak.compare_mode (cyclomatic 38) scripts/production_soak.py
  • Cyclomatic Complexity · production_soak.canary_mode (cyclomatic 37) scripts/production_soak.py
  • Cyclomatic Complexity · mistralrs_quant::distributed::layers::load_packed_weights (cyclomatic 36) mistralrs-quant/src/distributed/layers.rs
  • Cyclomatic Complexity · production_soak.run_long_context_correctness (cyclomatic 36) scripts/production_soak.py
  • Cyclomatic Complexity · production_soak.load_quality_replay_cases (cyclomatic 34) scripts/production_soak.py
  • Cyclomatic Complexity · Runner::send_chat_completion_request (cyclomatic 30) mistralrs-pyo3/src/lib.rs
  • Cyclomatic Complexity · Runner::send_chat_completion_request_to_model (cyclomatic 30) mistralrs-pyo3/src/lib.rs
  • Cyclomatic Complexity · Qwen3VLImageProcessor::prepare_for_paged_prompt_planning (cyclomatic 29) mistralrs-core/src/vision_models/qwen3_vl/inputs_processor.rs
  • Cyclomatic Complexity · mistralrs_quant::try_fused_quantized_ffn (cyclomatic 27) mistralrs-quant/src/lib.rs
  • Cyclomatic Complexity · production_soak.cuda_graph_evidence (cyclomatic 27) scripts/production_soak.py
  • Cyclomatic Complexity · mistralrs_core::pipeline::loaders::auto_device_map::get_device_layers (cyclomatic 26) mistralrs-core/src/pipeline/loaders/auto_device_map.rs
  • Cyclomatic Complexity · mistralrs_quant::cutile::nvfp4::launch (cyclomatic 26) mistralrs-quant/src/cutile/nvfp4.rs
  • Cyclomatic Complexity · TokenizerAdapter.exact_text (cyclomatic 26) scripts/production_soak.py
  • Cyclomatic Complexity · mistralrs_quant::try_fused_quantized_qkv (cyclomatic 25) mistralrs-quant/src/lib.rs
  • Cyclomatic Complexity · FastExpertsWeights::forward_grouped (cyclomatic 24) mistralrs-core/src/moe/experts/backends.rs
  • Cyclomatic Complexity · VectorFP8Linear::apply_isq (cyclomatic 24) mistralrs-quant/src/vector_fp8/mod.rs
  • Cyclomatic Complexity · mistralrs_quant::try_fused_gate_up_metal (cyclomatic 24) mistralrs-quant/src/lib.rs
  • Cyclomatic Complexity · mistralrs_quant::try_fused_quantized_gate_up (cyclomatic 23) mistralrs-quant/src/lib.rs
  • Cyclomatic Complexity · bench_nvfp4_serving.stream_request (cyclomatic 23) scripts/bench_nvfp4_serving.py
  • Cyclomatic Complexity · mistralrs_core::speculative::verifier::finish_verified_step (cyclomatic 21) mistralrs-core/src/speculative/verifier.rs
  • Cyclomatic Complexity · mistralrs_quant::try_fused_qkv_metal (cyclomatic 21) mistralrs-quant/src/lib.rs
  • Cyclomatic Complexity · mistralrs_quant::cutile::nvfp4_matmul::launch_gather (cyclomatic 21) mistralrs-quant/src/cutile/nvfp4_matmul.rs
  • Cyclomatic Complexity · mistralrs_quant::gguf::fast_mmvq::fused_qkv (cyclomatic 21) mistralrs-quant/src/gguf/fast_mmvq.rs
  • Cyclomatic Complexity · production_soak.quality_replay_pressure_plan_evidence (cyclomatic 21) scripts/production_soak.py
  • Cyclomatic Complexity · production_soak.compare_time_windows (cyclomatic 21) scripts/production_soak.py
  • Cyclomatic Complexity · ChatCompletionStreamer::__next__ (cyclomatic 20) mistralrs-pyo3/src/stream.rs
  • Cyclomatic Complexity · production_soak.multimodal_mode (cyclomatic 20) scripts/production_soak.py
  • Cyclomatic Complexity · production_soak.async_main (cyclomatic 20) scripts/production_soak.py
  • Cyclomatic Complexity · production_soak.text_prerequisite_evidence (cyclomatic 19) scripts/production_soak.py
  • Cyclomatic Complexity · ChatStore.editMessage (cyclomatic 19) mistralrs-cli/webui/src/lib/stores/chat.svelte.ts
  • Cyclomatic Complexity · production_soak.exact_output_diagnostics (cyclomatic 18) scripts/production_soak.py
  • Cyclomatic Complexity · production_soak.load_canary_artifact (cyclomatic 18) scripts/production_soak.py
  • Cyclomatic Complexity · production_soak.process_telemetry (cyclomatic 18) scripts/production_soak.py
  • Cyclomatic Complexity · production_soak.production_mode (cyclomatic 18) scripts/production_soak.py
  • Cyclomatic Complexity · verify_release_assets.main (cyclomatic 18) scripts/verify_release_assets.py
  • Cyclomatic Complexity · mistralrs_quant::cutile::nvfp4_matmul::launch_inner (cyclomatic 17) mistralrs-quant/src/cutile/nvfp4_matmul.rs
  • Cyclomatic Complexity · mistralrs_core::speculative::verifier::finish_verified_step_stochastic (cyclomatic 16) mistralrs-core/src/speculative/verifier.rs
  • Cyclomatic Complexity · BlockwiseFP8Linear::try_forward_fused_split_glu (cyclomatic 16) mistralrs-quant/src/blockwise_fp8/mod.rs
  • Cyclomatic Complexity · TokenizerAdapter.retrieval_text (cyclomatic 16) scripts/production_soak.py
  • Cyclomatic Complexity · production_soak.server_provenance_evidence (cyclomatic 16) scripts/production_soak.py
  • Cognitive Complexity · production_soak.validate_args (cognitive 332) scripts/production_soak.py
  • Cognitive Complexity · Qwen3VLImageProcessor::process_inputs (cognitive 120) mistralrs-core/src/vision_models/qwen3_vl/inputs_processor.rs
  • Cognitive Complexity · Runner::send_chat_completion_request (cognitive 82) mistralrs-pyo3/src/lib.rs
  • Cognitive Complexity · Runner::send_chat_completion_request_to_model (cognitive 82) mistralrs-pyo3/src/lib.rs
  • Cognitive Complexity · SoakClient.stream_request (cognitive 77) scripts/production_soak.py
  • Cognitive Complexity · mistralrs_quant::distributed::layers::load_packed_weights (cognitive 68) mistralrs-quant/src/distributed/layers.rs
  • Cognitive Complexity · production_soak.canary_mode (cognitive 65) scripts/production_soak.py
  • Cognitive Complexity · production_soak.run_long_context_correctness (cognitive 59) scripts/production_soak.py
  • Cognitive Complexity · Qwen3VLImageProcessor::prepare_for_paged_prompt_planning (cognitive 57) mistralrs-core/src/vision_models/qwen3_vl/inputs_processor.rs
  • Cognitive Complexity · mistralrs_core::pipeline::loaders::auto_device_map::get_device_layers (cognitive 56) mistralrs-core/src/pipeline/loaders/auto_device_map.rs
  • Cognitive Complexity · production_soak.adversarial_mode (cognitive 53) scripts/production_soak.py
  • Cognitive Complexity · TokenizerAdapter.exact_text (cognitive 42) scripts/production_soak.py
  • Cognitive Complexity · production_soak.load_quality_replay_cases (cognitive 39) scripts/production_soak.py
  • Cognitive Complexity · bench_nvfp4_serving.stream_request (cognitive 38) scripts/bench_nvfp4_serving.py
  • Cognitive Complexity · production_soak.compare_mode (cognitive 38) scripts/production_soak.py
  • Cognitive Complexity · FastExpertsWeights::forward_grouped (cognitive 35) mistralrs-core/src/moe/experts/backends.rs
  • Cognitive Complexity · production_soak.cuda_graph_evidence (cognitive 35) scripts/production_soak.py
  • Cognitive Complexity · mistralrs_quant::cutile::nvfp4_matmul::launch_gather (cognitive 34) mistralrs-quant/src/cutile/nvfp4_matmul.rs
  • Cognitive Complexity · production_soak.process_telemetry (cognitive 33) scripts/production_soak.py
  • Cognitive Complexity · mistralrs_quant::cutile::nvfp4::launch (cognitive 32) mistralrs-quant/src/cutile/nvfp4.rs
  • Cognitive Complexity · ChatStore.editMessage (cognitive 31) mistralrs-cli/webui/src/lib/stores/chat.svelte.ts
  • Cognitive Complexity · VectorFP8Linear::apply_isq (cognitive 30) mistralrs-quant/src/vector_fp8/mod.rs
  • Cognitive Complexity · mistralrs_core::speculative::verifier::finish_verified_step_stochastic (cognitive 29) mistralrs-core/src/speculative/verifier.rs
  • Cognitive Complexity · TokenizerAdapter.retrieval_text (cognitive 29) scripts/production_soak.py
  • Cognitive Complexity · mistralrs_core::speculative::verifier::finish_verified_step (cognitive 28) mistralrs-core/src/speculative/verifier.rs
  • Cognitive Complexity · mistralrs_quant::try_fused_quantized_qkv (cognitive 28) mistralrs-quant/src/lib.rs
  • Cognitive Complexity · production_soak.compare_time_windows (cognitive 27) scripts/production_soak.py
  • Cognitive Complexity · mistralrs_quant::try_fused_quantized_ffn (cognitive 26) mistralrs-quant/src/lib.rs
  • Cognitive Complexity · mistralrs_quant::try_fused_quantized_gate_up (cognitive 26) mistralrs-quant/src/lib.rs
  • Cognitive Complexity · mistralrs_quant::cutile::nvfp4_matmul::launch_inner (cognitive 25) mistralrs-quant/src/cutile/nvfp4_matmul.rs
  • Cognitive Complexity · production_soak.calibrate_prompt_profiles (cognitive 25) scripts/production_soak.py
  • Cognitive Complexity · verify_release_assets.main (cognitive 25) scripts/verify_release_assets.py
  • Cognitive Complexity · bench_nvfp4_serving.prepare (cognitive 24) scripts/bench_nvfp4_serving.py
  • Cognitive Complexity · production_soak.gpu_driver_provenance (cognitive 24) scripts/production_soak.py
  • Cognitive Complexity · production_soak.multimodal_mode (cognitive 23) scripts/production_soak.py
  • Cognitive Complexity · PleTable::quantize_shards (cognitive 21) mistralrs-core/src/vision_models/qwen4_exp/ple.rs
  • Cognitive Complexity · production_soak.exact_output_diagnostics (cognitive 21) scripts/production_soak.py
  • Cognitive Complexity · mistralrs_core::engine::memory::enforce_memory_goal (cognitive 20) mistralrs-core/src/engine/memory.rs
  • Cognitive Complexity · BlockwiseFP8Linear::try_forward_fused_split_glu (cognitive 20) mistralrs-quant/src/blockwise_fp8/mod.rs
  • Cognitive Complexity · mistralrs_quant::try_fused_gate_up_metal (cognitive 20) mistralrs-quant/src/lib.rs
  • Cognitive Complexity · mistralrs_quant::try_fused_qkv_metal (cognitive 20) mistralrs-quant/src/lib.rs
  • Cognitive Complexity · production_soak.load_canary_artifact (cognitive 20) scripts/production_soak.py
  • Cognitive Complexity · production_soak.quality_replay_pressure_plan_evidence (cognitive 20) scripts/production_soak.py
  • Cognitive Complexity · FastExpertsWeights::forward_impl (cognitive 19) mistralrs-core/src/moe/experts/backends.rs
  • Cognitive Complexity · production_soak.text_prerequisite_evidence (cognitive 19) scripts/production_soak.py
  • Cognitive Complexity · mistralrs_quant::gguf::fast_mmvq::fused_qkv (cognitive 18) mistralrs-quant/src/gguf/fast_mmvq.rs
  • Cognitive Complexity · mistralrs_quant::vector_fp8::ops::fp8_vector_quantize (cognitive 18) mistralrs-quant/src/vector_fp8/ops.rs
  • Cognitive Complexity · production_soak.resident_decode_mode (cognitive 18) scripts/production_soak.py
  • Cognitive Complexity · production_soak.production_mode (cognitive 18) scripts/production_soak.py
  • Cognitive Complexity · mistralrs_core::vision_models::qwen3_vl::inputs_processor::qwen3_packed_layout (cognitive 17) mistralrs-core/src/vision_models/qwen3_vl/inputs_processor.rs
  • Cognitive Complexity · upload_wheels.main (cognitive 17) scripts/upload_wheels.py
  • Cognitive Complexity · mistralrs_core::vision_models::qwen3_vl::inputs_processor::expand_video_placeholders (cognitive 16) mistralrs-core/src/vision_models/qwen3_vl/inputs_processor.rs
  • Cognitive Complexity · mistralrs_quant::afq::ops::cuda_backend::afq_mm_op (cognitive 16) mistralrs-quant/src/afq/ops.rs
  • Cognitive Complexity · mistralrs_quant::cutile::nvfp4_glu::launch (cognitive 16) mistralrs-quant/src/cutile/nvfp4_glu.rs
  • Cognitive Complexity · mistralrs_quant::fp8_config::checkpoint_linear_b (cognitive 16) mistralrs-quant/src/fp8_config.rs
  • Cognitive Complexity · build_wheels._detect_nccl (cognitive 16) scripts/build_wheels.py
Rebuild cost: about €570,000 · Estimate
Cost to rebuild€190,000 to €950,000, for 3,162 to 10,030 hours of work, about 3.9 person-years for 2 to 8 engineers
Difficulty of the problemStandard, judged from the kind of software and how it is built. Code that solves a harder problem, such as payments or medical bookings, costs more per line to write.
Quality factor×0.7 at a score of 54. Better code takes more work to write, so the factor is ×1.0 at a score of 70, lower below it and higher above it.
SizeVery large: 555,220 lines of product code
What it is notNot a quotation: nobody has offered to build it for that. Not a valuation: it says nothing about what the business is worth. Not a certified figure: no professional has signed it as one.

How the estimate is made: We price the hours a team would need to write this code again, at €60 to €95 an hour. Declarations and boilerplate are priced at a fast rate and logic at a slower one, and the logic is then multiplied by the difficulty of the problem and by the quality factor. The estimate can be about 30% off either way, and it moves most with the hourly rate and the difficulty. For this code, every line is priced as straight logic, which keeps the estimate on the low side.

Top priorities

The three actions that raise the score most for the work they take. The full ranked list is in the Roadmap.

1
Name the access rules — roles and permissions declared once (an enum Role/Permission, actix-web-grants #[protect(…)], axum-login's permission_required!, a casbin or oso policy) and consulted where access is checked, so the rule set is reviewable and testable on its own.
Raises the score by about 7 points · Medium effort · Access Controls
2
Secure the server's transport: serve TLS itself (`HttpServer::bind_rustls_0_23(addr, config)` in actix-web, `axum_server::bind_rustls(addr, RustlsConfig::from_pem_file(…))`, tonic's `Server::builder().tls_config(ServerTlsConfig::new().identity(…))`, Rocket's `[default.tls]`), or run it behind a TLS-terminating proxy and check `X-Forwarded-Proto`; send `Strict-Transport-Security` once it is HTTPS-only.
Raises the score by about 4 points · Medium effort · Web-Security Posture
3
Resolve the 1 No ADRs found finding(s) in ADR Quality — start with Cargo.toml.
Raises the score by about 2 points · Low effort · ADR Quality

Diagnosis: what the measurements show together

Each conclusion below combines several dimensions into one point that no single dimension shows, and lists the measurements it rests on.

Where the investment is most exposed · Value at risk
This code would cost about €570,000 to build again, about 3.9 person-years of work. Its weakest lens is Security and Compliance, at 44 (Weak). Security and Compliance is about how well the product is protected, and how it handles personal data. Because the weakest lens counts most in the score, work on Security and Compliance also moves the score most.
Based on: the rebuild estimate · the Security and Compliance grade · how much each lens counts
What to do: Start with the Security and Compliance actions in Top priorities.
If you do one thing first · First action
Name the access rules — roles and permissions declared once (an enum Role/Permission, actix-web-grants #[protect(…)], axum-login's permission_required!, a casbin or oso policy) and consulted where access is checked, so the rule set is reviewable and testable on its own. Of all the actions in this report, it raises the score most for the work it takes: about 7 points for medium effort. The next survey will show the change in the score.
Based on: the ranked actions in Top priorities, by score gain and effort
What hard-to-read code costs each year · Cost
Four dimensions measure how easy the code is to work in: two measure how tangled its logic is, one how much of it is copied, and one how well each part sticks to a single job. In this codebase they average 5.5 out of 10. Code at that level is slower to change than clean code, and we estimate the extra work at 6% to 14% on every change. The history of the code shows how much it changes: about 396,741 lines over the last 90 days, which is about 1,609,005 lines a year. At that pace, the extra work comes to an estimated 256.4 to 1538.5 engineer-days a year, and it grows as more code changes.
How this is estimated: The number of changed lines is measured from the history of the code. The rest rests on two assumptions of our own: code scoring 8 out of 10 or more adds no extra work, and each point below 8 adds 2.5% to 5.6% to every change, never less than 2% to 5% and never more than 40% to 60% in all; and an engineer changes 150 to 400 lines in a day. The result is a range for planning, not a measurement.
Based on: Cyclomatic Complexity · Cognitive Complexity · Code Duplication · Cohesion (LCOM4) · the code's change history
What to do: Start with the files listed under Churn × Complexity Hotspots, which change often and are hard to read, because that is where the extra work is paid most often.

Architecture — module dependency graph

Project dependencies, layered top-to-bottom; arrows show direction. Any dashed red edge points upward or sideways, which only happens where the projects form a dependency cycle. A graph without cycles has none.

arch mistralrs mistralrs mistralrs-core mistralrs-core mistralrs->mistralrs-core mistralrs-macros mistralrs-macros mistralrs->mistralrs-macros mistralrs-audio mistralrs-audio mistralrs-cli mistralrs-cli mistralrs-cli->mistralrs mistralrs-cli->mistralrs-core mistralrs-quant mistralrs-quant mistralrs-cli->mistralrs-quant mistralrs-sandbox mistralrs-sandbox mistralrs-cli->mistralrs-sandbox mistralrs-server-core mistralrs-server-core mistralrs-cli->mistralrs-server-core mistralrs-code-exec mistralrs-code-exec mistralrs-mcp mistralrs-mcp mistralrs-code-exec->mistralrs-mcp mistralrs-code-exec->mistralrs-sandbox mistralrs-core->mistralrs-audio mistralrs-core->mistralrs-code-exec mistralrs-flash-attn mistralrs-flash-attn mistralrs-core->mistralrs-flash-attn mistralrs-core->mistralrs-mcp mistralrs-metal-compile mistralrs-metal-compile mistralrs-core->mistralrs-metal-compile mistralrs-paged-attn mistralrs-paged-attn mistralrs-core->mistralrs-paged-attn mistralrs-core->mistralrs-quant mistralrs-core->mistralrs-sandbox mistralrs-vision mistralrs-vision mistralrs-core->mistralrs-vision mistralrs-paged-attn->mistralrs-metal-compile mistralrs-pyo3 mistralrs-pyo3 mistralrs-pyo3->mistralrs-core mistralrs-pyo3->mistralrs-mcp mistralrs-quant->mistralrs-metal-compile mistralrs-server-core->mistralrs-core mistralrs-webui mistralrs-webui

Architecture: which parts of the code depend on which

The code is divided into modules, groups of code that each handle one part of the product, and a module depends on another when it uses code from it. The table lists the modules both down the side and across the top, in an order where each module should only use modules listed above it. A number in a cell means the module on that row uses the module in that column, and it counts the pairs of building blocks (types) that connect them. The one thing to look for is a mark above the diagonal line. It means two or more modules use each other in a loop (a dependency cycle), so none of them can be changed, tested or released on its own.

816 modules, with 3931 dependencies between them. 17 loops run through 105 of the modules, marked above the diagonal.

The table shows the 40 modules with the most connections; 776 more are left out to keep it readable.

Which modules use which. The module on each row uses the module in each column, and the number counts the pairs of types that connect them. A cell above the diagonal is part of a loop.
uses →1 mistralrs_core.block_diffusion2 mistralrs_core.paged_attention.config3 mistralrs_core.speculative.target4 mistralrs_core.vision_models.preprocessor_config5 mistralrs_mcp.tools6 mistralrs_quant.distributed7 mistralrs_core.request8 mistralrs_quant.safetensors9 mistralrs_core.response10 mistralrs_quant11 mistralrs_quant.uqff12 mistralrs_core.diffusion_models.flux.autoencoder13 mistralrs_core.utils.model_config14 mistralrs_core.paged_attention15 mistralrs_core.pipeline.inputs_processor.text_models_inputs_processor16 mistralrs_core.pipeline.isq17 mistralrs_core.pipeline.processing18 mistralrs_core.attention19 mistralrs_core.pipeline.loaders20 mistralrs_core.diffusion_models.clip.text21 mistralrs_core.kv_cache22 mistralrs_core.paged_attention.layers.paged_attention23 mistralrs_core.amoe24 mistralrs_core.kv_cache.full_cache25 mistralrs_core.sequence26 mistralrs_core.pipeline27 mistralrs_core.xlora_models28 mistralrs_core29 mistralrs_core.pipeline.loaders.normal_loaders30 mistralrs_core.models.deepseek231 mistralrs_core.models.flint32 mistralrs_core.pipeline.loaders.multimodal_loaders33 mistralrs_core.pipeline.multimodal34 mistralrs_core.vision_models.idefics235 mistralrs_core.layers36 mistralrs_core.pipeline.normal37 mistralrs_core.embedding_models.embedding_gemma38 mistralrs_core.models.granite39 mistralrs_core.models.lfm240 mistralrs_core.vision_models.qwen3_5.text
1 mistralrs_core.block_diffusion
2 mistralrs_core.paged_attention.config
3 mistralrs_core.speculative.target
4 mistralrs_core.vision_models.preprocessor_config
5 mistralrs_mcp.tools
6 mistralrs_quant.distributed
7 mistralrs_core.request5
8 mistralrs_quant.safetensors2
9 mistralrs_core.response1
10 mistralrs_quant24
11 mistralrs_quant.uqff21
12 mistralrs_core.diffusion_models.flux.autoencoder7
13 mistralrs_core.utils.model_config3
14 mistralrs_core.paged_attention4
15 mistralrs_core.pipeline.inputs_processor.text_models_inputs_processor51
16 mistralrs_core.pipeline.isq31
17 mistralrs_core.pipeline.processing1221
18 mistralrs_core.attention11
19 mistralrs_core.pipeline.loaders422
20 mistralrs_core.diffusion_models.clip.text623
21 mistralrs_core.kv_cache1
22 mistralrs_core.paged_attention.layers.paged_attention379
23 mistralrs_core.amoe212
24 mistralrs_core.kv_cache.full_cache1
25 mistralrs_core.sequence31811
26 mistralrs_core.pipeline216352222
27 mistralrs_core.xlora_models11
28 mistralrs_core2112124
29 mistralrs_core.pipeline.loaders.normal_loaders2128228129551111
30 mistralrs_core.models.deepseek211315311132222131262
31 mistralrs_core.models.flint5131543211322111312152
32 mistralrs_core.pipeline.loaders.multimodal_loaders1212626626271521111232611
33 mistralrs_core.pipeline.multimodal112121425211143
34 mistralrs_core.vision_models.idefics21111126211463111161
35 mistralrs_core.layers1564151221
36 mistralrs_core.pipeline.normal1121323262113112
37 mistralrs_core.embedding_models.embedding_gemma213113112118
38 mistralrs_core.models.granite1142109611131225151251
39 mistralrs_core.models.lfm2113166111132211512351
40 mistralrs_core.vision_models.qwen3_5.text1124321314221121213711
Uses a module listed above itPart of a loopThe module itself
1 mistralrs_core.block_diffusion2 mistralrs_core.paged_attention.config3 mistralrs_core.speculative.target4 mistralrs_core.vision_models.preprocessor_config5 mistralrs_mcp.tools6 mistralrs_quant.distributed7 mistralrs_core.request8 mistralrs_quant.safetensors9 mistralrs_core.response10 mistralrs_quant11 mistralrs_quant.uqff12 mistralrs_core.diffusion_models.flux.autoencoder13 mistralrs_core.utils.model_config14 mistralrs_core.paged_attention15 mistralrs_core.pipeline.inputs_processor.text_models_inputs_processor16 mistralrs_core.pipeline.isq17 mistralrs_core.pipeline.processing18 mistralrs_core.attention19 mistralrs_core.pipeline.loaders20 mistralrs_core.diffusion_models.clip.text21 mistralrs_core.kv_cache22 mistralrs_core.paged_attention.layers.paged_attention23 mistralrs_core.amoe24 mistralrs_core.kv_cache.full_cache25 mistralrs_core.sequence26 mistralrs_core.pipeline27 mistralrs_core.xlora_models28 mistralrs_core29 mistralrs_core.pipeline.loaders.normal_loaders30 mistralrs_core.models.deepseek231 mistralrs_core.models.flint32 mistralrs_core.pipeline.loaders.multimodal_loaders33 mistralrs_core.pipeline.multimodal34 mistralrs_core.vision_models.idefics235 mistralrs_core.layers36 mistralrs_core.pipeline.normal37 mistralrs_core.embedding_models.embedding_gemma38 mistralrs_core.models.granite39 mistralrs_core.models.lfm240 mistralrs_core.vision_models.qwen3_5.textmistralrs_core.block_diffusion1mistralrs_core.paged_attention.config2mistralrs_core.speculative.target3mistralrs_core.vision_models.preprocessor_config4mistralrs_mcp.tools5mistralrs_quant.distributed6mistralrs_core.request7mistralrs_quant.safetensors8mistralrs_core.response9mistralrs_quant10mistralrs_quant.uqff11mistralrs_core.diffusion_models.flux.autoencoder12mistralrs_core.utils.model_config13mistralrs_core.paged_attention14mistralrs_core.pipeline.inputs_processor.text_models_inputs_processor15mistralrs_core.pipeline.isq16mistralrs_core.pipeline.processing17mistralrs_core.attention18mistralrs_core.pipeline.loaders19mistralrs_core.diffusion_models.clip.text20mistralrs_core.kv_cache21mistralrs_core.paged_attention.layers.paged_attention22mistralrs_core.amoe23mistralrs_core.kv_cache.full_cache24mistralrs_core.sequence25mistralrs_core.pipeline26mistralrs_core.xlora_models27mistralrs_core28mistralrs_core.pipeline.loaders.normal_loaders29mistralrs_core.models.deepseek230mistralrs_core.models.flint31mistralrs_core.pipeline.loaders.multimodal_loaders32mistralrs_core.pipeline.multimodal33mistralrs_core.vision_models.idefics234mistralrs_core.layers35mistralrs_core.pipeline.normal36mistralrs_core.embedding_models.embedding_gemma37mistralrs_core.models.granite38mistralrs_core.models.lfm239mistralrs_core.vision_models.qwen3_5.text405212421734513112211142262313792121318112163522221121121242128228129551111113153111322221312625131543211322111312152121262662627152111123261111212142521114311111262114631111611564151221112132326211311221311311211811421096111312251512511131661111322115123511124321314221121213711+776 more modules (most-connected shown)

At a glance — Code Health · 55% · Adequate · gated by D2, D4, X4 ·

At a glance — Architecture · 95% · Exemplary ·

At a glance — Maturity · 66% · Adequate · gated by M2 ·

At a glance — Readiness · 53% · Adequate · gated by R4, P7 ·

At a glance — Security · 44% · Weak · gated by D29, C2 ·

At a glance — Domain Modelling · 100% · Exemplary ·

At a glance — Event Sourcing · 100% · Exemplary ·

At a glance — Accessibility · 83% · Strong ·

At a glance — Performance · 100% · Exemplary ·

Security & Compliance — OWASP Top-10 mapping

Findings mapped to OWASP categories; the specific CVEs/secrets are in the Security dimension cards below and findings.md (redacted only on the public version of this report).

OWASP categoryFindingsSeverity
A05:2025 — Injection130High / Critical
A03:2025 — Software Supply Chain Failures22High / Critical
A02:2025 — Security Misconfiguration21High / Critical
A07:2025 — Authentication Failures4High / Critical

Roadmap

Top priorities: Name the access rules — roles and permissions declared once (an enum Role/Permission, actix-web-grants #[protect(…)], axum-login's permission_required!, a casbin or oso policy) and consulted where access is checked, so the rule set is reviewable and testable on its own; Secure the server's transport: serve TLS itself (`HttpServer::bind_rustls_0_23(addr, config)` in actix-web, `axum_server::bind_rustls(addr, RustlsConfig::from_pem_file(…))`, tonic's `Server::builder().tls_config(ServerTlsConfig::new().identity(…))`, Rocket's `[default.tls]`), or run it behind a TLS-terminating proxy and check `X-Forwarded-Proto`; send `Strict-Transport-Security` once it is HTTPS-only; Resolve the 1 No ADRs found finding(s) in ADR Quality — start with Cargo.toml.

Ranked by impact ÷ effort. "Helps" is the estimated gain on the 0–100 health score.

Do thisHelpsEffortDimension
Name the access rules — roles and permissions declared once (an enum Role/Permission, actix-web-grants #[protect(…)], axum-login's permission_required!, a casbin or oso policy) and consulted where access is checked, so the rule set is reviewable and testable on its own.+6.6 ptsMediumAccess Controls
Secure the server's transport: serve TLS itself (`HttpServer::bind_rustls_0_23(addr, config)` in actix-web, `axum_server::bind_rustls(addr, RustlsConfig::from_pem_file(…))`, tonic's `Server::builder().tls_config(ServerTlsConfig::new().identity(…))`, Rocket's `[default.tls]`), or run it behind a TLS-terminating proxy and check `X-Forwarded-Proto`; send `Strict-Transport-Security` once it is HTTPS-only.+3.8 ptsMediumWeb-Security Posture
Resolve the 1 No ADRs found finding(s) in ADR Quality — start with Cargo.toml.+1.9 ptsLowADR Quality
Resolve the 3 REDACTED finding(s) in Secrets (history) — start with REDACTED, REDACTED, REDACTED.+1.3 ptsLowSecrets (history)
Resolve the 2 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED, REDACTED.+1.1 ptsLowStatic Analysis (SAST)
Resolve the 6 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (5), REDACTED.+1.1 ptsLowStatic Analysis (SAST)
Resolve the 1 High vulnerability finding(s) in Dependency Vulnerabilities — start with REDACTED.+1.1 ptsLowDependency Vulnerabilities
Resolve the 7 High IaC finding(s) in IaC & Container Security — start with REDACTED (4), REDACTED, REDACTED.+1.1 ptsLowIaC & Container Security

File quality

Per-file score 0–10 — a quality signature. Of 554 files carrying findings, judged against the Preview bar: 1% slop · 8% mixed · 91% near-clean.

FileScoreBandWorst signal
REDACTED0.2SlopStatic Analysis (SAST): High: REDACTED
REDACTED0.6SlopIaC & Container Security: High IaC: REDACTED
REDACTED2.3SlopStatic Analysis (SAST): High: REDACTED
REDACTED3.0MixedDependency Vulnerabilities: High vulnerability: REDACTED
REDACTED3.3MixedIaC & Container Security: High IaC: REDACTED
REDACTED3.7MixedStatic Analysis (SAST): High: REDACTED
REDACTED4.3MixedStatic Analysis (SAST): High: REDACTED
REDACTED4.4MixedStatic Analysis (SAST): High: REDACTED
REDACTED4.4MixedIaC & Container Security: High IaC: REDACTED
REDACTED4.4MixedIaC & Container Security: High IaC: REDACTED
REDACTED4.6MixedStatic Analysis (SAST): High: REDACTED
REDACTED4.9MixedStatic Analysis (SAST): Medium: REDACTED
REDACTED5.0MixedStatic Analysis (SAST): Medium: REDACTED
mistralrs-core/src/toml_selector.rs5.1MixedChange Coupling: Boundary-crossing change coupling: toml_selector.rs ↔ lib.rs
REDACTED5.1MixedStatic Analysis (SAST): High: REDACTED
mistralrs-core/src/lib.rs5.5MixedCyclomatic Complexity: MistralRs::init_external_tool_callbacks (cyclomatic 27)
mistralrs-core/src/pipeline/chat_template.rs5.5MixedCyclomatic Complexity: mistralrs_core::pipeline::chat_template::apply_chat_template_to (cyclomatic 25)
mistralrs-quant/src/distributed/layers.rs5.5MixedCyclomatic Complexity: ReplicatedLayer::new_layers_matformer_indices (cyclomatic 21)
mistralrs/src/messages.rs5.5MixedCognitive Complexity: mistralrs::messages::resolve_pending (cognitive 20)
mistralrs/src/auto_model.rs5.9MixedGod Classes: TooManyFields: ModelBuilder

How the grades work

Every finding carries one of four grades. Three say how serious it is. The fourth says this survey could not settle it — and it is a grade, not a gap.

Critical — 124

A definite problem that already costs you something and drags the score down: a missing authorisation check, a dependency with a known exploit, a build that does not reproduce. Failure here tends to cause failures elsewhere.

Serious — 4840

Likely wrong, but not failing yet. It degrades the codebase over a longer horizon and can cause failures elsewhere — not urgent this week, not something to carry for two years either.

Minor — 154

Recorded, with no effect on how the codebase functions. Present so the survey is complete, not because it needs doing.

Could not be resolved — 17

Something this survey could not settle from the outside, and which could be critical or serious. Either a control was required and no positive evidence of it exists in the repository — a backup job that nothing shows was ever restored from proves nothing about restores — or our own analysis could not run over that part of the tree. This is not a clean result. These are excluded from the score rather than awarded a pass, so the number on the cover neither rewards nor penalises them: if you act on this survey without resolving them, you carry that risk yourself. Each one is named under Limitations.

Methodology & how to trust this report

This survey is a deep, periodic assessment — run each sprint, monthly, or quarterly, taking the time to go wider and deeper than a quick check and surfacing in one coherent report what you'd otherwise piece together from a dozen separate tools. It scores deterministically: the same commit yields the same score, every run. All 76 evaluated dimensions are computed by tools and static analysis; no language model sets or judges any of them. Overall confidence is 0.9, the weighted average across measured dimensions.

Every figure here is one of two kinds, and we label which: ✓ Measured — a deterministic fact (LoC, complexity, coverage); ~ Modeled — an estimate from a stated model (cost, effort, value-at-risk), always a range with its assumptions, never a precise fact. We never present a modelled estimate as if it were measured. Perfect or absent scores carry their provenance too (ADR-0011): ✓ Tool-verified means the property itself was measured across the surface; ○ Nothing flagged means the probes came back clean — a claim bounded by what a repository can show; ⊘ Not evidenced means a working control (a tested restore, an automated rollback) showed no positive evidence — absence of evidence is not evidence of a control, so it's excluded from the score rather than awarded a spurious 10.

What we checked — 76 dimensions across the health lenses
D1D2D3D4D5D6D10D12D13D14D15D17D19D20D21D23D26D28D29D30D31D34D35D36D37D43D44AC1AC2AC3AC5AX10AX3AX4AX9C2DM1DM2DM4DM5ES1ES2M1M2M3M4P1P10P2P3P4P6P7PF3R1R10R2R3R4R5R6R7R8R9S1X1X14X15X2X21X27X28X29X30X4X5

Each chip is a dimension scored from real signals across architecture, testing, dependencies, security & compliance, documentation, git-history and code quality — in one coherent pass. A surface report typically covers a handful.

How to trust any code-health report — three questions
  1. Can you open the finding? Real findings cite a repo-relative file and line you can open at the cited line — never an absolute scratch path. Here, 5070 of 5118 do; the remainder are repo-wide signals — a dimension-level measurement, not a single line. (Every path in this report is repo-relative by construction: paths are normalized at the producer and the report is rejected if any rooted path leaks through.)
  2. Is there a tool behind the number? Every score below names the method that produced it: Roslyn, git or a scanner, not a narrative.
  3. Does re-running give the same result? Run it again on the same commit and the score — and this report, byte for byte — is identical. A report whose numbers move between runs is describing the run, not the code.

This report answers yes to all three. That's the bar to hold any assessment to.

Tools & methods

The actual versions used this run (captured at analysis time) — re-run on the same commit for the identical score.

MethodBacksVersionEvaluator
Roslyn static analysisComplexity, cohesion, coupling, dead code, API surface, layering5.3.0✓ deterministic
Native secret scannerHardcoded secrets / credentials1.0.0✓ deterministic
Canine Code Analyzer duplication detector (in-process)Code duplication1.0.0✓ deterministic
Coverage (coverlet / dotnet-coverage)Line & branch coverage10.0.400✓ deterministic
NuGet / dotnetOutdated, vulnerable & deprecated dependencies10.0.400✓ deterministic
git / LibGit2SharpChurn hotspots, knowledge concentration, history2.43.0 · 0.31.0✓ deterministic
gitleaks · semgrep · trivy · checkovSecrets in history, SAST, CVEs, IaC & container, PII / GDPR1.86.0 · 0.69.3 · 3.2.533✓ deterministic

Every finding is locatable in findings.md. Run 01a1db16-7c80-75ed-a488-fd029e153c89.

The exact command behind every deep-scan dimension — tool, version, invocation and retained raw output — is in Appendix B — Reproduction & audit trail.

Run transparency — what happened this run

What ran differently this time — a tool absent, degraded, or that fell back to an estimate. Named openly, not folded silently into the scores. A degraded run also records its exact cause in diagnostics.md.

  • D8 Code Coverage — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Coverage NOT MEASURED: this repository's production source spans .ts, .rs, and our analyzer cannot run the .rs test suite(s) — so no coverage was collected for the repository as a whole. The JavaScript/TypeScript half did build and run, and its own line coverage came back at 99.1% — but that is a figure for one half of the product, and we do not publish a partial one as if it were complete. This is OUR limitation, not a defect in the repo — coverage is excluded from the score rather than counted as a near-zero.
  • D10 Test Quality — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. The 27 test(s) behind this row are the ones the JavaScript/TypeScript census could read, and this repository also carries at least 113 test source file(s) (.rs) that it cannot: it reads JavaScript/TypeScript test declarations off disk, so a JUnit/pytest-style suite is invisible to it. Skipped tests, zero-assertion tests and the other quality signals on this row are UNMEASURED in that suite — their absence from the counts above is a gap in this analyzer's language coverage, not a finding that those tests are sound.
  • D11 Test Reliability — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Test reliability NOT SCORED: this repository's production source includes .rs, and the rust executor ran against the .rs half and did not finish re-running within its tier budget — so reliability was not measured for the repository as a whole. The JavaScript/TypeScript (node:test via `npm ci --ignore-scripts` in mistralrs-cli/webui/ (21 tests); node:test via `npm ci --ignore-scripts` in website/ (6 tests)): measured (0 flaky) suite(s) did re-run, and came back with 0 flaky across 1 measured tier(s) — but that is a figure for one half of the product, and we do not publish a partial one as if it were complete. This is OUR limitation, not a defect in the repo — test reliability is excluded from the score rather than counted. The half was driven by a runner we ship, so this is not a missing-runner gap.
  • D14 License Compliance — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. This repository declares a Python pyproject.toml/requirements.txt (pip/uv/Poetry), but the licence verdict published here was taken over its crate dependencies. Nothing was read about its Python dependencies' licensing in either direction, and a clean score on this card must not be read as covering them.
  • D14 License Compliance — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. This repository declares package.json, but the licence verdict published here was taken over its crate dependencies. Nothing was read about its npm dependencies' licensing in either direction, and a clean score on this card must not be read as covering them.
  • D16 Bus Factor — not measured this run — This is a true statement about the repository that carries nothing for its owner to act on, so it is reported here rather than as a defect in their code. Single-maintainer repository — bus factor is not applicable (100 contributor(s) across 3515 commit(s) sampled, automation and bot accounts excluded). One of them holds 89% of the history; the other 99 hold 0.1% each on average, below the 5% at which there is somebody to hand the work to. That is a single maintainer with drive-by contributors, not a team whose knowledge has concentrated — so the bus factor is not applicable and there is nothing here for the owner to act on.
  • D19 Documentation Quality — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. Each ecosystem's manifests (what makes a folder runnable or a published package) need their own proof before D19 judges its units. Until then those folders' READMEs are judged only as documents (boilerplate, structure), never counted as complete.
  • D19 Documentation Quality — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. This kind did not reach the 95 % precision gate in three adjudicated runs (docs/plans/deterministic-engine/adjudication/D19-sample3-v3.md), so by the pre-registered fallback it publishes no row until a re-measurement shows it does. The candidates are counted here, not reported as findings, and the score does not include them.
  • D21 Naming Consistency — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. PREREGISTRATION version 20's fallback (adjudication D21-sample3-v3): this rule kind was adjudicated below the 95 % precision gate, so its candidates are counted here and not published, and the score covers only the acronym-spelling and awaitable-suffix rules. The kind returns as rows only after it shows a measured precision; this says nothing about whether these names are consistent.
  • D21 Naming Consistency — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. PREREGISTRATION version 20's fallback (adjudication D21-sample3-v3): this rule kind was adjudicated below the 95 % precision gate, so its candidates are counted here and not published, and the score covers only the acronym-spelling and awaitable-suffix rules. The kind returns as rows only after it shows a measured precision; this says nothing about whether these names are consistent.
  • D21 Naming Consistency — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. PREREGISTRATION version 20's fallback (adjudication D21-sample3-v3): this rule kind was adjudicated below the 95 % precision gate, so its candidates are counted here and not published, and the score covers only the acronym-spelling and awaitable-suffix rules. The kind returns as rows only after it shows a measured precision; this says nothing about whether these names are consistent.
  • D22 Internal API Consistency — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. D22's deterministic call-shape rules are gated on C# first (docs/plans/deterministic-engine.md, P5): each other language is switched on only after its own concept suite and A/B gate pass. This says nothing about whether that surface is consistent.
  • D24 Comment Value — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Each source language's comment syntax, and the code a comment annotates in it, needs its own proof before D24 judges it. Until then those comments are left unread, not counted as clean.
  • D27 Navigability — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Navigability is taken over call sites whose callee resolved. For C# that population includes calls into referenced assemblies; for this language only calls declared inside the repository count, so the abstention threshold reads the repository's use of its standard library as a resolution failure. That is a limit of this analyzer, not a build problem in this repository.
  • AC6 Visual & motion safety — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Visual & motion safety could not be assessed in this run — the check did not complete, so it is not scored. This is a gap in the analyzer, not a finding about this repository. Engine failure: ArgumentOutOfRangeException: startIndex cannot be larger than length of string. (Parameter 'startIndex').
  • AX6 Interface segregation — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check's reader does not cover most of the languages this repository's product is written in. What it read is kept, but it is too small a share to grade the product by. That is a gap in this analyzer's language reach — not a finding about this repository.
  • AXR1 Runtime accessibility — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Render strategy: boot via REDACTED (REDACTED). docker build failed (exit 1) — 24 | >>> COPY --chmod=755 dist/${TARGETARCH}/mistralrs /usr/local/bin/mistralrs 25 | # Chat templates for models that ship without one 26 | COPY chat_templates /chat_templates -------------------- ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref 0b61a2cf-39ec-49e5-90e1-4edf14df2394::6zynhec3i7hl0gmxnkzbs2nby: "/dist/amd64/mistralrs": not found; runtime evidence skipped.
  • GD1 Unfinished & placeholder code — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, F#, JavaScript/TypeScript, Dart, Ruby and Scala source only, and this repository's Python, Rust, Svelte components, c is most of its product and is not read yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • IC1 Incompleteness & stubs — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, JavaScript/TypeScript, Java, Dart, Ruby and Scala source only, and this repository's Python, Rust, Svelte components, c is most of its product and is not read yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • M4 Documentation accuracy — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. M4 checks only the claim kinds adjudicated at or above 95 % precision: links and versions (PREREGISTRATION version 9), and artefact counts an order of magnitude off. Paths, command arguments, installs, environment variables, settings, projects, packages, routes, cd targets, infrastructure products and removed modules are read but not checked, and none of them is reported or counted.
  • P5 DR & Backup — not measured this run — This is a true statement about the repository that carries nothing for its owner to act on, so it is reported here rather than as a defect in their code. No backup/snapshot/replication config, RTO/RPO or restore-procedure documentation was found — and no production persistence was detected either (no data-access packages, no data-store services, no database resources), so there is nothing in this repository whose loss a DR control would recover. If this system's data lives in a platform or ops repo we can't see, that's where the DR evidence belongs.
  • X10 Duplicated predicate — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. 50 further occurrence(s) are not listed individually; the score already reflects all 90.
  • X12 Unreachable branch — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check's reader does not cover most of the languages this repository's product is written in. What it read is kept, but it is too small a share to grade the product by. That is a gap in this analyzer's language reach — not a finding about this repository.
  • X13 Undrained process stream — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check's reader does not cover most of the languages this repository's product is written in. What it read is kept, but it is too small a share to grade the product by. That is a gap in this analyzer's language reach — not a finding about this repository.
  • X16 Unfloored truncation loop — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check's reader does not cover most of the languages this repository's product is written in. What it read is kept, but it is too small a share to grade the product by. That is a gap in this analyzer's language reach — not a finding about this repository.
  • X19 Unrestored process-global state — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check's reader does not cover most of the languages this repository's product is written in. What it read is kept, but it is too small a share to grade the product by. That is a gap in this analyzer's language reach — not a finding about this repository.
  • X24 Document value interpolated into markup unescaped — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check's reader does not cover most of the languages this repository's product is written in. What it read is kept, but it is too small a share to grade the product by. That is a gap in this analyzer's language reach — not a finding about this repository.
  • X3 Exception handling — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check's reader does not cover most of the languages this repository's product is written in. What it read is kept, but it is too small a share to grade the product by. That is a gap in this analyzer's language reach — not a finding about this repository.
  • X4 Structured logging — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. 482 further occurrence(s) are not listed individually; the score already reflects all 522.

Repo exclusion declarations (.gitattributes linguist-generated/vendored, .editorconfig generated_code): none declared — every source file was scored.

Limitations & what we did not check

We assess the repository exactly as committed, and only the repository. By design we do not reach outside the source tree: the live cloud account, the running CI/CD pipeline, the host's branch-protection and approval rules, the production configuration, or a restore actually exercised against a backup are all out of scope. That boundary is a feature, not a gap — a repo-relative, deterministic scan re-runs identically on any commit and every finding opens at a real file and line, where a live audit can neither be reproduced nor traced. The visible consequence is that controls which leave no in-repo evidence are reported as "not evidenced" and excluded from the score rather than awarded a number a static scan cannot justify.

Per-dimension blind spots

For each dimension that was measured, what a static, repo-only scan structurally cannot see — the honest edge of the measurement, not a failure of it.

  • D1 Cyclomatic Complexity: Cyclomatic complexity counts branches statically — it cannot tell an essential decision tree from accidental tangle, nor see complexity that lives in data or configuration (large switch-case token tables, DSL lexers/parsers, data-as-code rule tables) rather than control flow: a tokenizer's many single-character cases read as high complexity though each branch is trivial.
  • D2 Cognitive Complexity: Cognitive-complexity heuristics approximate how hard code is to follow; genuine domain difficulty and well-named intent that eases reading are not captured.
  • D3 God Classes: "God class" is sized by members and responsibilities visible in the type — a deliberately broad facade over a coherent subsystem can read the same as an accidental grab-bag. For front-end JS the file-length check is cohesion-aware (a single-responsibility module — one class/IIFE — earns a 3× threshold), but cohesion is approximated from top-level declarations, not true dependency structure.
  • D4 Code Duplication: Duplication is token-similarity — an in-process token-stream comparison over sliding windows, with type-aware normalization — so it finds copy-paste, not semantic duplication expressed differently. Committed machine-written code (scaffolded migrations, designer/codegen output, protobuf/OpenAPI stubs, model snapshots) is EXCLUDED — its repetition is the tool's, not the team's — so the score reflects hand-written duplication only.
  • D5 Coupling: Coupling is measured between projects/assemblies — runtime coupling through DI, reflection, messaging or shared databases is invisible to a static reference graph.
  • D6 Cohesion (LCOM4): LCOM4 cohesion is syntactic — it infers connectivity from which methods touch which fields/methods by name, not from real runtime behaviour or intent.
  • D10 Test Quality: Assertion density is structural — it cannot tell a meaningful behavioural assertion from a trivial one, only that an assertion is present.
  • D12 Dependency Hygiene: Dependency health reads manifests and lockfiles — a vulnerability in a vendored/copied dependency, or risk from how a dependency is actually used, is outside this view.
  • D13 REDACTED Scanning: REDACTED detection is signature- and entropy-based on the current tree — a secret that does not match a known pattern, or one already rotated, will not be flagged (a clean scan is "nothing matched", not "no secrets exist").
  • D14 License Compliance: License compatibility is checked against declared package metadata and a policy — mislabelled or missing license metadata, and obligations that depend on how you distribute, are not resolved here.
  • D15 Churn × Complexity Hotspots: Churn hotspots come from git history — a freshly imported or squashed repository has no churn signal, and recent rewrites can mask a historically risky file.
  • D17 Explicit Debt: Acknowledged-debt signals (TODO/FIXME, suppressions, dead code) are textual — undocumented debt that nobody marked, and debt that lives in design rather than annotations, is invisible. Committed machine-written code (scaffolded migrations, designer/codegen output, generated stubs) is excluded — it is never the team's dead code to delete.
  • D19 Documentation Quality: Documentation quality publishes two things only: a runnable or packaged unit with no example, and a multi-project root README that maps none of its parts. It does not judge clarity, and its other checks (overview, licence, boilerplate, structure, empty sections, XML-doc coverage) are withheld after adjudication: their candidates are counted in the card's gaps, not shown as rows. A false statement in a document is M4's; units are .NET projects only.
  • D20 ADR Quality: ADR quality checks the structure of the decision records present: it cannot know about decisions made and never recorded, and it does not judge how well a record argues its case. Records in a language the section lexicon does not cover are not evaluated.
  • D21 Naming Consistency: Naming consistency compares each name with the convention its structural peers follow in this repository: it cannot tell whether a consistently used name is a good one, and languages other than C# and TypeScript are not measured.
  • D23 Boundary Type-Coupling: Boundary leakage is detected from type references across detected contexts — leaks that flow through primitives, serialization or shared infrastructure may not surface as a typed reference.
  • D26 Project Cohesion: Project focus is sized from members/namespaces per project — a project that is broad by deliberate design reads the same as one that has sprawled.
  • D28 Secrets (history): Secret-history scanning sweeps the git log for known patterns — a secret that predates the available history, or never matched a signature, is not found (clean means "nothing matched in the history we can see").
  • D29 Static Analysis (SAST): SAST findings are pattern-based (semgrep) — it finds classes of bug it has rules for; logic flaws, auth/authorization gaps and issues needing runtime context are out of reach (and clean means "no rule matched").
  • D30 Dependency Vulnerabilities: CVE matching depends on accurate package/version metadata and on the advisory databases — a vulnerability with no published advisory, or in code not declared as a dependency, is not seen. Coverage needs a RESOLVED graph: an unpinned requirements.txt, or a pom without a resolved build, yields partial coverage rather than a clean verdict. An ecosystem the analyzer cannot scan is reported as unmeasured, never as clean.
  • D31 IaC & Container Security: IaC scanning checks Dockerfiles/Terraform/Kubernetes against best-practice rules — it cannot see the live cloud account, runtime configuration, or drift between the committed config and what is actually deployed.
  • D34 Knowledge Freshness: Freshness is decayed commit RECENCY, not comprehension — code read often but rarely committed reads as orphaned, and stable code that genuinely needs no changes is penalised the same as forgotten code; bot/squash commits distort it like the bus factor.
  • D35 Change Coupling: Change coupling is co-change in COMMITS — files split across separate commits, or coupled only through a shared config/build step, read as uncoupled, and a sweeping commit (rename/format) is excluded so it doesn't couple everything. It shows that files change together, not WHY: a high coupling can be a healthy cohesive pair as readily as a hidden leak.
  • D43 Malicious Dependencies: Only packages some vulnerability database has already NAMED as malicious are seen — a compromise published in the last hours, or never reported at all, is invisible here, and this dimension reading 10 is not evidence that a dependency is trustworthy. There is no typosquat or dependency-confusion analysis: a package nobody has reported is simply absent from the feeds. Coverage is the dependency scan's: an ecosystem that could not be scanned is disclosed as unmeasured, never as clean.
  • D44 Platform End-of-Life: The support table is FROZEN, so it goes out of date by losing RECALL: a release that ended support after the table was written is missed until the table is refreshed, and this dimension reading 10 is not evidence that a platform is current. Only platforms the repository DECLARES in a place this pass reads are seen — a runtime named only in a REDACTED (D31's subject), in a CI workflow (D29's), or in a file this pass does not parse (go.mod, a Gemfile ruby directive) is invisible here, which is why a repository declaring none of them abstains rather than scoring. Only frameworks with a PUBLISHED support policy are tracked: React, Flask and Express publish none, so their age cannot be judged and their absence from a report is not a statement that they are supported.
  • AC1 Text alternatives: Alt-text is detected structurally — the scan sees that an alternative EXISTS, not whether it meaningfully describes the image, and decorative-vs-missing is judged by attribute shape; runtime-injected images and a non-role=img decorative svg are out of scope. This is accessibility readiness, never a WCAG conformance claim.
  • AC2 Forms & labels: Label association is read from static markup — a label wired up at runtime (JS-set aria-labelledby, framework-injected ids) reads as missing, a present label says nothing about whether its text is correct. A known UI-library field component (e.g. a JSX <TextField>) is now checked conservatively — flagged only when it carries NO label/aria-label/aria-labelledby/id/name — but wrapper/context-labelled libraries (Chakra/Radix FormControl+FormLabel) aren't statically visible (possible false positive) and non-JSX lowercased components are still skipped. A click handler on a plain element is now asked for a name too (it is a control the author declared), but the subtree test that answers it is deliberately generous: any DYNAMIC text expression in the subtree counts as a name, so an icon chosen by a ternary ({cond ? <IconA/> : <IconB/>}) reads as named, and a glyph component from a library the icon-import list does not know still names its parent. A clean result is "no unlabelled control found", not a labelling proof.
  • AC3 Page structure: Page structure is read from the static markup tree — landmarks, headings and lang injected at runtime aren't seen, heading ORDER is checked structurally (not against the rendered visual hierarchy), and lang/title/main fire only on full documents, never partials, and the data-table check sees header-cell presence (a <th> exists), not whether each header correctly associates with its cells. Static readiness, not conformance.
  • AC5 ARIA correctness: ARIA correctness is checked against the static role/attribute shape — roles/attributes set dynamically aren't seen, a valid role says nothing about whether it matches the element's real behaviour, and required-state checks are suppressed when a JSX spread could supply them. The two-branch toggle check (a control whose state is conveyed only by which of two mutually exclusive branches renders) reads CONDITIONALS THAT ARE ATTRIBUTES — Vue v-if/v-else/v-show and Alpine x-if/x-show — so the same toggle written as a Svelte {#if} block or a JSX ternary is control flow the markup model never projects as a branch and is not seen at all.
  • AX10 Code composition: Role is inferred from namespace/folder convention, not semantics — a domain concept living in a folder named "Services" reads as application, and the split is lines-of-code, not business value. The business-logic-share score is a SOFT, FLOORED signal: it contributes to the Architecture lens but is floored at the Critical gate, so an infrastructure-heavy design (a gateway, an ETL, a driver) is legitimately low without being nuked to zero.
  • AX9 CQS / query purity: Handlers are found by interface/name convention — a query handler using neither is not seen. Mutation is a resolved write/publish invocation (SaveChanges/repository/bus), so a write hidden behind a hand-rolled wrapper, reflection, or a string-keyed service locator resolves to a non-persistence type and isn't flagged; it detects that a query writes state, not whether the write is a legitimate read-side cache update. Clean means "no resolved write/publish in a query body", not a proof of CQS purity.
  • DM4 Rich vs anemic domain model: Behaviour is detected as state mutation inside a method body — a method that enforces an invariant by validating-and-throwing without mutating reads as a query, and mutation delegated through an interface the scan can't resolve isn't credited; entities with zero public properties still drop out of the population. It detects that state changes, not whether the rule is correct.
  • M4 Documentation accuracy: Documentation accuracy checks links, versions and artefact counts against the tree: other claims (paths, commands, settings, routes) are read but not checked, and it cannot run the onboarding or measure how long a real new joiner takes.
  • P4 Deployment & Rollback: Approval/branch-protection rules live in repository settings the scan cannot see — only their in-repo evidence (config files, workflows) is checked, so a control enforced purely in the host's settings reads as "not evidenced".
  • P6 Release Hygiene: Rollback/observability controls are inferred from repo artefacts (pipelines, dashboards-as-code) — controls configured in external tooling, with no in-repo trace, cannot be credited.

Dimensions

D1 · Cyclomatic Complexity5.6 / 10Adequate✓ Tool-verified

What it measures: How tangled the control flow is — methods with many branches are hard to test and change.

Method: Cyclomatic complexity per method (1 + decision points), computed exhaustively across production source; test projects separated by convention. Deterministic.

Maturity: Documented → Verified → Prevented · effective 5.6 / 10 · rule-coverage 100% · ceiling Prevented

312 method(s) exceeded the cyclomatic complexity threshold of 15; the worst was Engine::run at 147. A further 48 method(s) were over the threshold but excluded as flat dispatchers (a long switch/match over independent cases: many branches, almost no nesting), the largest being mistralrs_quant::afq::ops::cuda_backend::afq_dequantize_op at 52 — they are counted neither in the figure above nor in this dimension's score. 15 files carry no cyclomatic complexity row at all for this reason — every one of their over-threshold functions was excluded, so the exclusion is disclosed nowhere in the file itself: mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs (AutoMultimodalLoader::get_loader at 31), mistralrs-code-exec/src/files.rs (mistralrs_code_exec::files::mime_for_format at 29), mistralrs-core/src/gguf/normal_registry.rs (CanonicalGgufArchitecture::from_str at 29), mistralrs-core/src/pipeline/loaders/normal_loaders.rs (NormalLoaderType::from_causal_lm_name at 29), mistralrs-core/src/model_metadata.rs (MultimodalLoaderType::arch_metadata at 28), and 10 more not listed here. They are named here because the per-file figures other dimensions report are taken BEFORE this exclusion, so such a file can show a high maximum complexity elsewhere in this report and nothing here, with nothing to reconcile the two.

mistralrs_core::pipeline::sampling::finish_or_add_toks_to_seq (cyclomatic 77) · ×84mistralrs-core/src/pipeline/sampling.rs:189
mistralrs_quant::afq::ops::cuda_backend::afq_mm_op (cyclomatic 55) · ×46mistralrs-quant/src/afq/ops.rs:2588
mistralrs_paged_attn::cuda::backend::flashinfer::flashinfer_decode (cyclomatic 54) · ×14mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:241
mistralrs_cli::commands::run::interactive::print_agentic_progress (cyclomatic 38) · ×14mistralrs-cli/src/commands/run/interactive.rs:1111
mistralrs_server_core::chat_completion::parse_request (cyclomatic 60) · ×9mistralrs-server-core/src/chat_completion.rs:605

+ 108 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Bring the 2 bodies over 120 down to 120 or less in Cyclomatic Complexity — start with Engine::run (cyclomatic 147), Engine::add_request (cyclomatic 125). — This score is capped by its worst body, so a finding fixed alone moves it by almost nothing — the next one down takes its place. Refactoring these 2 together lifts Cyclomatic Complexity from 5.6 to about 5.8/10, projected with the scoring formula itself and assuming each lands exactly at 120; a cleaner split scores higher.

Detailed fixes: d1_recommendation.md · top locations in Appendix A, every location in findings.md.

D2 · Cognitive Complexity2.7 / 10Weak✓ Tool-verified

What it measures: How hard the code is for a person to follow, beyond raw branching.

Method: Cognitive complexity per method (Sonar-style nesting-penalized score), computed exhaustively over production code, excluding test projects. Deterministic.

Maturity: Documented → Verified → Prevented · effective 2.7 / 10 · rule-coverage 100% · ceiling Prevented

549 method(s) exceeded the cognitive complexity threshold of 15; the worst was Engine::run at 511.

mistralrs_core::pipeline::sampling::finish_or_add_toks_to_seq (cognitive 263) · ×133mistralrs-core/src/pipeline/sampling.rs:189
mistralrs_quant::metal_kernels::afq_qmm_dispatch (cognitive 68) · ×66mistralrs-quant/src/metal_kernels/mod.rs:1024
mistralrs_cli::commands::run::interactive::print_agentic_progress (cognitive 93) · ×22mistralrs-cli/src/commands/run/interactive.rs:1111
mistralrs_server_core::chat_completion::parse_request (cognitive 143) · ×18mistralrs-server-core/src/chat_completion.rs:605
Model::prepare_inputs_labels_for_multimodal (cognitive 55) · ×17mistralrs-core/src/vision_models/llava/llava_next.rs:224

+ 183 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Bring the 5 bodies over 240 down to 240 or less in Cognitive Complexity — start with Engine::run (cognitive 511), mistralrs_core::pipeline::sampling::finish_or_add_toks_to_seq (cognitive 263), Pipeline::submit_step (cognitive 255). — This score is capped by its worst body, so a finding fixed alone moves it by almost nothing — the next one down takes its place. Refactoring these 5 together lifts Cognitive Complexity from 2.7 to about 3.8/10, projected with the scoring formula itself and assuming each lands exactly at 240; a cleaner split scores higher.

Detailed fixes: d2_recommendation.md · top locations in Appendix A, every location in findings.md.

D3 · God Classes7.1 / 10Strong✓ Tool-verified

What it measures: Over-large classes that try to do too much ("god classes").

Method: God-class detection by line and method-count thresholds per logical type (partial classes unified), filtered for generated code and registration/contract false positives. Deterministic.

Maturity: Documented → Verified → Prevented · effective 7.1 / 10 · rule-coverage 100% · ceiling Prevented

756 god class(es) detected.

FileTooLong: loaders/multimodal_loaders.rs · ×235mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs
MethodTooLong: Engine.run · ×223mistralrs-core/src/engine/mod.rs:1157
FunctionTooLong: mistralrs_core::model_loader::loader_from_model_selected · ×184mistralrs-core/src/model_loader.rs:292
ClassTooLong: MistralRs · ×78mistralrs-core/src/lib.rs:462
TooManyFields: PreProcessorConfig · ×19mistralrs-core/src/vision_models/preprocessor_config.rs:10

+ 2 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Resolve the 235 FileTooLong finding(s) in God Classes — start with REDACTED (29), inputs_processor.rs (14), text.rs (11). — One of this dimension's main actionable groups (235 warning-level).
  2. Resolve the 223 MethodTooLong finding(s) in God Classes — start with REDACTED (36), text.rs (27), inputs_processor.rs (25). — One of this dimension's main actionable groups (223 warning-level).
  3. Resolve the 184 FunctionTooLong finding(s) in God Classes — start with gdn.rs (16), REDACTED (16), ops.rs (10). — One of this dimension's main actionable groups (184 warning-level).

Detailed fixes: d3_recommendation.md · top locations in Appendix A, every location in findings.md.

D4 · Code Duplication3.7 / 10Weak✓ Tool-verified

What it measures: How much of the production code is copy-pasted: the share of production lines inside a reported copy (every copy of a duplicated block or of an edited member, each line once), 10 at none and 0 at a quarter of the lines.

Method: Code duplication via token-stream sliding windows with type-aware normalization (locals masked, type names preserved), scored on the share of production lines inside a reported copy (each line once; 10 at none, 0 at a quarter). Deterministic.

Maturity: Documented → Verified → Prevented · effective 3.7 / 10 · rule-coverage 100% · ceiling Verified

2211 duplicated block group(s) detected. 15.6 % of the production lines (86,755 of 555,220) are in a reported copy. A further 771 rows report members as variants of one another; the share counts each copied line once, however many rows cite it. 31 of the 2982 are in trees this repository does not ship — vendored, example/demo, project-template, fixture and benchmark code — and are ranked below the shipped groups rather than excluded from them: the duplication there is real and is still counted in this dimension's score. The dimensions that publish a production-file census leave those trees out of theirs, so this count is deliberately drawn over the wider population.

Duplicated block (9 lines × 2) · ×97mistralrs-cli/src/commands/quantize.rs:201
Duplicated block (8 lines × 2) · ×95mistralrs-cli/src/commands/run/mod.rs:136
Duplicated block (6 lines × 2) · ×95mistralrs-cli/src/commands/bench.rs:69
Duplicated block (7 lines × 2) · ×94mistralrs-core/src/attention/backends/cpu/avx.rs:68
Duplicated block (5 lines × 2) · ×84mistralrs-cli/src/commands/bench.rs:319

+ 715 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Resolve the 97 Duplicated block (9 lines × 2) finding(s) in Code Duplication — start with ops.rs (17), REDACTED (10), gdn.rs (6). — One of this dimension's main actionable groups (97 warning-level).
  2. Resolve the 95 Duplicated block (8 lines × 2) finding(s) in Code Duplication — start with ops.rs (17), REDACTED (13), gdn.rs (4). — One of this dimension's main actionable groups (95 warning-level).
  3. Resolve the 95 Duplicated block (6 lines × 2) finding(s) in Code Duplication — start with REDACTED (13), ops.rs (12), fp8_w8a16.rs (6). — One of this dimension's main actionable groups (95 warning-level).

Detailed fixes: d4_recommendation.md · top locations in Appendix A, every location in findings.md.

D5 · Coupling7.5 / 10Strong✓ Tool-verified

What it measures: Whether volatile projects sit underneath others that depend on them (so their churn ripples upward), and whether project dependencies form cycles. A widely-depended-on but stable shared/kernel project is healthy, not penalised.

Method: Dependency cycles via elementary-DFS over real .csproj references, plus Martin instability (afferent/efferent) per project. Exhaustive over the reference graph, deterministic.

Coverage: Exhaustive · type-level: afferent/efferent coupling + cycles computed over every production type — the population is all types, not a name convention.

Maturity: Documented → Verified → Prevented · effective 7.5 / 10 · rule-coverage 100% · ceiling Prevented

16 production modules (Cargo+npm), 0 dependency cycle(s), 0 unstable depended-on module(s). Read from the build's own module declarations; 5 module(s) off the main sequence, with abstractness counted on 15 of the 16 (the rest declare no modelled class or interface, export only macros, declare types in source no model reads, or have no source directory of their own).

Off the main sequence: mistralrs-audio · ×5

What to do

  1. Resolve the 5 Off the main sequence finding(s) in Coupling. — One of this dimension's main actionable groups (5 warning-level).

Detailed fixes: d5_recommendation.md · top locations in Appendix A, every location in findings.md.

D6 · Cohesion (LCOM4)9.8 / 10Stronggated by 13 serious findings✓ Tool-verified

What it measures: Whether a class's methods are focused on a single responsibility.

Method: LCOM4 cohesion per production class with at least two methods: connected components of methods sharing state or calls, computed syntactically. Deterministic, not a proxy.

Coverage: Exhaustive · type-level: LCOM4 cohesion computed over every production class — the population is all types, not a name convention.

Maturity: Documented → Verified → Prevented · effective 9.8 / 10 · rule-coverage 100% · ceiling Verified

13 of 745 classes have LCOM4 above 3.

Low cohesion: GgufModelBuilder (LCOM4 38) · ×13mistralrs/src/gguf.rs:12

What to do

  1. Resolve the 13 Low cohesion finding(s) in Cohesion (LCOM4) — start with lib.rs (2), gguf.rs, embedding_model.rs. — One of this dimension's main actionable groups (13 warning-level).

Detailed fixes: d6_recommendation.md · top locations in Appendix A, every location in findings.md.

D10 · Test Quality10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether the tests truly assert behaviour rather than just running the code.

Method: Per-test assertions, skips, and mock references analyzed via Roslyn; structured skip-reason tags (BUG:/ENV:) separate documented deferrals from debt. Deterministic.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Prevented

0 skipped, 0 zero-assertion, no mocking-framework packages referenced (hand-written doubles or no mocking) across 27 tests. Measured on the JavaScript/TypeScript suite only — at least 113 test source file(s) (.rs) went unread, so its test quality is unmeasured and is not in these counts.

✓ On the Gold path — maintain.

Detailed fixes: d10_recommendation.md.

D12 · Dependency Hygiene8.5 / 10Strong✓ Tool-verified

What it measures: Whether dependencies are current, not deprecated, and not bloated. Known vulnerabilities are D30's.

Method: Manifest scan via dotnet list package across all projects; worst-signal-per-package deduction (capped-linear for deprecation, prerelease and outdated) per KLoC. Known-vulnerable packages are D30's and are not charged here (rubric-2026.11.2). Exhaustive.

Maturity: Documented → Verified → Prevented · effective 8.5 / 10 · rule-coverage 100% · ceiling Verified

30 outdated, 0 yanked direct Cargo dependencies. Only DIRECT edges are graded: a transitive crate cannot be moved past what its parent's requirement admits, so reporting one would be advice its owner cannot take. A newer release is reported only where this repository's OWN requirement already admits it, so the remedy is `cargo update` and never a manifest edit — which means a release outside the declared range is deliberately NOT charged, because a written-down constraint is a decision rather than a defect. Note that a bare requirement is a CARET, and for a 0.x crate its ceiling is the minor. Whether any crate is UNMAINTAINED is not graded — crates.io publishes no maintenance status, and release age does not stand in for one. Known CVEs in this dependency graph are D30's question, read from REDACTED there.

Outdated: anyhow · ×30

Detailed fixes: d12_recommendation.md · top locations in Appendix A, every location in findings.md.

D13 · REDACTED Scanning10.0 / 10Exemplary○ Nothing flagged

What it measures: Whether any secrets (keys, tokens, passwords) have leaked into the code.

Method: In-process native secret scanner (entropy plus signature patterns) across all tracked files; no external tool. A clean result is a measured 10, not no-data zero. Deterministic.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Prevented

REDACTED scan ran and found no leaked secrets.

✓ On the Gold path — maintain.

Detailed fixes: d13_recommendation.md.

D14 · License Compliance10.0 / 10Exemplary○ Nothing flagged

What it measures: Whether the licenses of third-party packages are compatible with your policy.

Method: Third-party package licenses resolved from declared package metadata and checked against the configured policy (allow/deny/copyleft). Deterministic; clean = no incompatible license found at metadata depth.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Verified

0 of 839 shipped crate(s) use a banned license. Licences were resolved from crates.io over the crates a consumer compiles — this repository's REDACTED closed over its manifests' `[dependencies]` and `[build-dependencies]`. Crates it asks for ONLY under `[dev-dependencies]` are excluded: they are not compiled by anything that depends on this repository. A further 1 crate(s) in the closure resolve from git, a path or a private registry and publish no licence this pass can read; they are outside this verdict. This repository publishes itself under MIT, which is its own choice and is not judged here. ★ COVERAGE OF THIS VERDICT: it grades this repository's crate dependencies and nothing else. The repository also declares a Python pyproject.toml/requirements.txt (pip/uv/Poetry) and package.json, and the licences of those dependency graphs were NOT read by this pass — a gap in this engine's coverage, not a statement about them. So this result says the graded closure carries no banned licence; it does NOT say this repository's licensing is clear.

✓ On the Gold path — maintain.

Detailed fixes: d14_recommendation.md.

D15 · Churn × Complexity Hotspots9.2 / 10Stronggated by 76 serious findings✓ Tool-verified

What it measures: Files that change often and are also complex — the riskiest hotspots.

Method: Per production file churn times cyclomatic complexity over a rolling window, computed from git and Roslyn/JS/Razor analysis. Exhaustive, deterministic per commit date.

Maturity: Documented → Verified → Prevented · effective 9.2 / 10 · rule-coverage 100% · ceiling Documented

Top hotspots: mistralrs-core/src/engine/mod.rs (21×147=3087); mistralrs-core/src/pipeline/multimodal.rs (29×100=2900); mistralrs-core/src/pipeline/mod.rs (25×110=2750) Repeated repair below the complexity floor: mistralrs-core/src/tools/parsers/qwen.rs (3 of 4 changes were fixes)

Hotspot: mistralrs-core/src/engine/mod.rs · ×75mistralrs-core/src/engine/mod.rs:1157
Repeated repair: mistralrs-core/src/tools/parsers/qwen.rsmistralrs-core/src/tools/parsers/qwen.rs:119

What to do

  1. Resolve the 75 Hotspot finding(s) in Churn × Complexity Hotspots — start with REDACTED (9), text.rs (4), ops.rs (4). — One of this dimension's main actionable groups (75 warning-level).
  2. Resolve the 1 Repeated repair finding(s) in Churn × Complexity Hotspots — start with qwen.rs. — One of this dimension's main actionable groups (1 warning-level).

Detailed fixes: d15_recommendation.md · top locations in Appendix A, every location in findings.md.

D17 · Explicit Debt10.0 / 10Stronggated by 46 serious findings✓ Tool-verified

What it measures: Acknowledged debt left in the code — TODOs, dead code, suppressed warnings.

Method: Roslyn syntactic debt markers (suppressions/TODO/FIXME/HACK/empty-catch/commented-code/Obsolete) plus SymbolFinder dead-code analysis; weighted-debt-per-KLoC density deducted 2.0x per unit. Deterministic, exhaustive.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Prevented

46 deducted task-comment markers across 555220 LoC (0.0/KLoC) → score 10.0. Task comments only: this repository's language is read without a compiler, so D17's suppression, dead-code and commented-out-code arms did not run and this score counts fewer marker kinds than a .NET repository's would.

TodoComment · ×40mistralrs-vision/src/ops.rs:18
FixmeComment · ×4mistralrs-core/src/sampler.rs:248
XxxComment · ×2mistralrs-quant/src/safetensors.rs:161

What to do

  1. Resolve the 40 TodoComment finding(s) in Explicit Debt — start with REDACTED (13), varbuilder_utils.rs (3), lib.rs (2). — One of this dimension's main actionable groups (40 warning-level).
  2. Resolve the 4 FixmeComment finding(s) in Explicit Debt — start with sampler.rs, diffusion.rs, embedding.rs. — One of this dimension's main actionable groups (4 warning-level).
  3. Resolve the 2 XxxComment finding(s) in Explicit Debt — start with safetensors.rs (2). — One of this dimension's main actionable groups (2 warning-level).

Detailed fixes: d17_recommendation.md · top locations in Appendix A, every location in findings.md.

D19 · Documentation Quality10.0 / 10Exemplary○ Nothing flagged

What it measures: Whether the project's documentation is clear, complete, and useful.

Method: Every README, docs/ document and root guide parsed by its markup and measured in Unicode letters. Published: a runnable or packaged .NET project whose README (or a document it links, or a root guide) shows no example, and a root README naming none of three or more projects. Overview, licence, boilerplate, wall-of-text, empty-section and XML-doc rows are measured and withheld (counted in gaps) after adjudication. Deterministic, exhaustive, advisory.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

1 of 1 documentation facets pass in full. 106 document(s) read across 3 unit(s).

✓ On the Gold path — maintain.

Detailed fixes: d19_recommendation.md.

D20 · ADR Quality0.0 / 10Critical✓ Tool-verified

What it measures: Whether architecture decisions are recorded well (context, decision, consequences).

Method: Every ADR read by its section structure: nine located rules (a missing Decision, Context or Consequences section, a stale status, two records deciding the same question, a dangling supersede link, a number-only title, a single option, no named cost, no status where the log uses one, no enforcement field where the log adopted one), each a fixed deduction from 10; the score is the mean over evaluated records. Deterministic, no model. Advisory.

Maturity: Documented → Verified → Prevented · effective 0.0 / 10 · rule-coverage 100% · ceiling Documented

No architecture decision records were found.

No ADRs foundmistralrs-cli/Cargo.toml:16

What to do

  1. Resolve the 1 No ADRs found finding(s) in ADR Quality — start with Cargo.toml. — One of this dimension's main actionable groups (1 recommendation-level).

Detailed fixes: d20_recommendation.md · top locations in Appendix A, every location in findings.md.

D21 · Naming Consistency5.8 / 10Adequate✓ Tool-verified

What it measures: Whether names — types, methods, variables — are clear and consistent.

Method: Seven vocabulary-free rules (N1-N7) mine each naming convention from the repository and flag a name that breaks a convention its structural peers in the same unit follow; production C# and TypeScript, each its own population. Deterministic, no model, no sample. Advisory.

Maturity: Documented → Verified → Prevented · effective 5.8 / 10 · rule-coverage 100% · ceiling Verified

1 naming inconsistencies among 24 declarations measured against a convention their peers follow.

`OpenAIInputContent` spells `AI` where 23 names in the project spell it `Ai`mistralrs-server-core/src/responses_types/content.rs:93

What to do

  1. Resolve the 1 `OpenAIInputContent` spells `AI` where 23 names in the project spell it… finding(s) in Naming Consistency — start with content.rs. — One of this dimension's main actionable groups (1 recommendation-level).

Detailed fixes: d21_recommendation.md · top locations in Appendix A, every location in findings.md.

D23 · Boundary Type-Coupling10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether domain types (IDs, enums, value objects) leak across bounded-context boundaries.

Method: Cross-context domain-type leakage via Roslyn structural classification (strongly-typed IDs / value objects) over every public surface. Exhaustive, deterministic, type-level aggregate-boundary check.

Coverage: Bounded contexts derived from NAMESPACE prefix (or graph-inferred where available); cross-boundary domain-type leakage then checked exhaustively over every public member of every type.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Verified

No domain types leak across context boundaries (2 contexts). Contexts: mistralrs-core, mistralrs-server-core.

✓ On the Gold path — maintain.

Detailed fixes: d23_recommendation.md.

D26 · Project Cohesion6.7 / 10Adequate✓ Tool-verified

What it measures: Whether each project is a focused, coherent unit rather than an oversized grab-bag.

Method: Project size overshoot penalties (LoC / public-type count / namespace count, 2-of-3 flag) weighted by log magnitude. Exhaustive across projects, deterministic.

Maturity: Documented → Verified → Prevented · effective 6.7 / 10 · rule-coverage 100% · ceiling Documented

3 of 18 build units (Cargo, npm) flagged as possibly oversized/incoherent.

Projects may be oversized for their cohesion

What to do

  1. Resolve the 1 Projects may be oversized for their cohesion finding(s) in Project Cohesion. — One of this dimension's main actionable groups (1 recommendation-level).

Detailed fixes: d26_recommendation.md · top locations in Appendix A, every location in findings.md.

D28 · Secrets (history)7.0 / 10Adequategated by 3 critical findings✓ Tool-verified

What it measures: Whether any secrets were ever committed — scanned across the full git history, not just now.

Method: REDACTED scan via TWO gitleaks detect passes in an isolated checkout — the full git history, then a second --no-git pass over the working tree as it stands — merged and de-duplicated by (rule, file, line); each match flagged High. Both invocations are recorded in the audit trail. Exhaustive; when the tool is absent, or when its output cannot be parsed into the expected shape, the dimension is WITHHELD as an explicit measurement gap on our side — unscored and excluded from the lens, never a hedged middling score.

Maturity: Documented → Verified → Prevented · effective 7.0 / 10 · rule-coverage 100% · ceiling Documented

3 finding(s): 0 critical, 3 high, 0 medium, 0 low. Remediation for historically-committed secrets is credential rotation — they remain in history regardless of later deletion.

REDACTED
REDACTED

What to do

  1. Resolve the 3 REDACTED finding(s) in Secrets (history) — start with REDACTED, REDACTED, REDACTED. — One of this dimension's main actionable groups (3 issue-level).
  2. Resolve the 1 Rotate the exposed credentials finding(s) in Secrets (history). — One of this dimension's main actionable groups (1 recommendation-level).

Detailed fixes: d28_recommendation.md · top locations in Appendix A, every location in findings.md.

D29 · Static Analysis (SAST)0.3 / 10Critical✓ Tool-verified

What it measures: Real static-analysis (SAST) findings — likely security bugs in the code, any language.

Method: Polyglot static analysis via semgrep across the repo using the pinned, image-baked p/security-audit + p/owasp-top-ten rulesets (no scan-time registry fetch); severity rules (ERROR/WARNING/INFO) map to a full-band severity-weighted score. Exhaustive, deterministic; degrades on parse failure.

Coverage: semgrep pattern rules over all files — exhaustive for the rule set, blind to classes of bug without a rule (clean = no rule matched).

Maturity: Documented → Verified → Prevented · effective 0.3 / 10 · rule-coverage 100% · ceiling Documented

130 finding(s): 0 critical, 102 high, 17 medium, 11 low. 88 unpinned-GitHub-Actions row(s) are reported here but scored by D36 (supply-chain provenance), which measures that posture as `pinned_actions` — one pinning decision is charged once, not once per lens. semgrep hit a parse error in 4 file(s) — `REDACTED`, `examples/server/phi3_duckduckgo_mistral.rs.ipynb`, `install.sh` (lines 1470–1570), `mistralrs-paged-attn/third_party/flash-attention/hopper/heuristics.h` (line 14) — so no absence of findings in the named regions is evidence of anything; rows reported elsewhere in those files are real. Fix the syntax error (or exclude the file deliberately) and re-scan to cover them. Separately, one or more rules could not re-parse an embedded snippet in 3 file(s) (e.g. a workflow `run:` block read as shell). Those files WERE scanned and their other rows are unaffected; only those rules' view of those snippets is missing.

REDACTED
REDACTED
REDACTED
REDACTED
REDACTED

+ 6 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Resolve the 6 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (5), REDACTED. — One of this dimension's main actionable groups (6 issue-level).
  2. Resolve the 2 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED, REDACTED. — One of this dimension's main actionable groups (2 issue-level).
  3. No action in Static Analysis (SAST) — all 88 REDACTED finding(s) are reported here at file:line but scored by D36 (supply-chain provenance), so none is charged to this dimension. — One of this dimension's main actionable groups (88 issue-level, 0 of them charged here).

Detailed fixes: d29_recommendation.md · top locations in Appendix A, every location in findings.md.

D30 · Dependency Vulnerabilities6.6 / 10Adequate✓ Tool-verified

What it measures: Whether any dependency has a known published vulnerability (CVE), direct or transitive, in ANY ecosystem the repository declares — Dart pub, Elixir and Erlang via Hex, Go modules, Java and Kotlin via Maven/Gradle, JavaScript/npm, .NET/NuGet, PHP/Composer, Python/PyPI, RubyGems, Rust/Cargo and Swift.

Method: Dependency-CVE scan across every ecosystem the repository declares, scored ONCE. Three sources are unioned and deduplicated by advisory identity (rule id + alias closure, CVE<->GHSA) scoped to package+version, keeping the worst severity: `osv-scanner --recursive` over osv.dev for Dart pub, Elixir/Hex (and Erlang, whose `rebar.lock` syft first converts to a CycloneDX SBOM the scanner reads, with rows attributed back to the lock), Go, Java and Kotlin via Maven/Gradle (and Scala, whose sbt build's pinned direct declarations are written into a CycloneDX SBOM the scanner reads, with rows attributed back to the build file), npm, PHP/Composer, Python/PyPI, RubyGems, Rust/Cargo and Swift; `trivy fs --scanners vuln` for npm lockfiles; and `dotnet list package --vulnerable --include-transitive` for NuGet (with per-advisory collapse of the project x target-framework fan-out), plus a DECLARED-dependency arm that resolves a published gem's gemspec against rubygems.org where no Gemfile.lock is committed. `SeverityScore(c,h,m,l, normalizer 8.0)`. NotApplicable only when NO ecosystem is readable; if any applicable ecosystem could not be scanned the findings are REPORTED and the score is withheld. Supersedes the npm and OSV arms, retired 2026-09-05. Advisory since rubric-2026.11.2 (CAI decision 0006): every row is a match against a vulnerability database that changes daily, so the reading is shown and never moves a scored dimension, lens or the headline.

Maturity: Documented → Verified → Prevented · effective 6.6 / 10 · rule-coverage 100% · ceiling Documented

16 finding(s): 0 critical, 1 high, 15 medium, 0 low.

REDACTED
REDACTED
REDACTED
REDACTED
REDACTED

What to do

  1. Resolve the 1 High vulnerability finding(s) in Dependency Vulnerabilities — start with REDACTED. — One of this dimension's main actionable groups (1 issue-level).
  2. Resolve the 5 Medium advisory (unmaintained) finding(s) in Dependency Vulnerabilities — start with REDACTED (5). — One of this dimension's main actionable groups (5 warning-level).
  3. Resolve the 5 Medium vulnerability finding(s) in Dependency Vulnerabilities — start with REDACTED (5). — One of this dimension's main actionable groups (5 warning-level).

Detailed fixes: d30_recommendation.md · top locations in Appendix A, every location in findings.md.

D31 · IaC & Container Security6.4 / 10Adequate✓ Tool-verified

What it measures: Whether Dockerfiles / Terraform / Kubernetes config follow security best practices.

Method: IaC/container misconfiguration scan via trivy config (REDACTED/Terraform/K8s/Helm/CloudFormation); severity rules to 0-10 moderate normalizer. NotApplicable without manifests. Exhaustive, deterministic.

Maturity: Documented → Verified → Prevented · effective 6.4 / 10 · rule-coverage 100% · ceiling Documented

21 finding(s): 0 critical, 7 high, 12 medium, 2 low.

REDACTED
REDACTED
REDACTED

What to do

  1. Resolve the 12 Medium IaC finding(s) in IaC & Container Security — start with REDACTED (6), REDACTED (4), REDACTED. — One of this dimension's main actionable groups (12 warning-level).
  2. Resolve the 7 High IaC finding(s) in IaC & Container Security — start with REDACTED (4), REDACTED, REDACTED. — One of this dimension's main actionable groups (7 issue-level).
  3. Resolve the 2 Low IaC finding(s) in IaC & Container Security — start with REDACTED, REDACTED. — One of this dimension's main actionable groups (2 recommendation-level).

Detailed fixes: d31_recommendation.md · top locations in Appendix A, every location in findings.md.

D34 · Knowledge Freshness10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether anyone still has living knowledge of each file, or it has been orphaned — last understood long ago by someone now gone quiet. The sibling of the bus factor: D16 asks who owns it, D34 asks whether anyone still knows it.

Method: File orphaning as total living-knowledge decay below one focused-commit's worth within a year, computed per-file from the D16 decay model. Exhaustive, deterministic over fixed history.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

3 of 742 significant source file(s) are orphaned — their living knowledge has decayed to nothing, so no one currently understands them. The largest is mistralrs-core/src/vision_models/llava/utils.rs. Counted over 742 of the 860 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.

Orphaned file · ×3mistralrs-core/src/vision_models/llava/utils.rs:1
Orphaned files with no living knowledge

✓ On the Gold path — maintain.

Detailed fixes: d34_recommendation.md · top locations in Appendix A, every location in findings.md.

D35 · Change Coupling9.8 / 10Adequategated by 1 critical finding✓ Tool-verified

What it measures: Whether files that change together actually belong together — pairs that repeatedly co-change in git history despite having no explicit code dependency, surfacing the hidden/logical coupling (and boundaries in the wrong place) a static scan can't see.

Method: Pairwise co-occurrence over the per-commit file sets in git history (production source only — tests and generated dropped): Degree-of-Coupling = shared ÷ min individual revisions, reported above noise floors (each file ≥10 revisions, ≥5 shared commits, ≥50% strength); sweeping commits excluded. Deterministic over fixed history.

Coverage: Population: PRODUCTION source files only — test and generated files are dropped before pairing, so a class co-changing with its own test (trivially ~100%) can't drown the real production↔production coupling. Pairs ranked by Degree-of-Coupling. A non-source file is never a coupling PARTICIPANT either: documentation, schemas, config and data files are dropped with the rest, so a code↔docs pair — a command and the reference page that restates it — is not reported however strongly the two co-change; nor is coupling that runs THROUGH a build step or config file.

Maturity: Documented → Verified → Prevented · effective 9.8 / 10 · rule-coverage 100% · ceiling Documented

Strongest change-coupling: embedding.rs↔multimodal.rs 88%; diffusion.rs↔multimodal.rs 83%; embedding.rs↔normal.rs 81%

Boundary-crossing change coupling: toml_selector.rs ↔ lib.rsmistralrs-core/src/toml_selector.rs:1
Change coupling: embedding.rs ↔ multimodal.rs · ×6mistralrs-core/src/pipeline/embedding.rs:1
Change-coupling hub: diffusion.rs → gguf.rs, multimodal.rs, normal.rsmistralrs-core/src/pipeline/diffusion.rs

What to do

  1. Resolve the 1 Boundary-crossing change coupling finding(s) in Change Coupling — start with toml_selector.rs. — One of this dimension's main actionable groups (1 issue-level).
  2. Resolve the 6 Change coupling finding(s) in Change Coupling — start with embedding.rs (2), REDACTED (2), model_selected.rs. — One of this dimension's main actionable groups (6 warning-level).
  3. Resolve the 1 Change-coupling hub finding(s) in Change Coupling — start with diffusion.rs. — One of this dimension's main actionable groups (1 warning-level).

Detailed fixes: d35_recommendation.md · top locations in Appendix A, every location in findings.md.

D36 · Supply-chain Provenance & Signing5.0 / 10Adequate✓ Tool-verified

What it measures: Whether the build pipeline provides supply-chain integrity — generated provenance/attestation, signed artifacts (cosign/sigstore), an SBOM, and pinned build actions. Presence of the configuration, not a runtime guarantee.

Method: Supply-chain provenance/signing read deterministically from CI/build config (.github/workflows, .gitlab-ci.yml, azure-pipelines, Jenkinsfile, .circleci) + the release surface: four signals — generated provenance/attestation (SLSA/in-toto/actions-attest), artifact signing (cosign/sigstore/gitsign), an SBOM (syft/sbom-action/*.spdx.json/*.cdx.json), and SHA-pinned build actions — scored 10·present/denom. NotApplicable without a build pipeline. Detects configuration presence, not runtime enforcement.

Maturity: Documented → Verified → Prevented · effective 5.0 / 10 · rule-coverage 100% · ceiling Documented

2/4 supply-chain integrity signals present (provenance, signing, SBOM, pinned actions).

REDACTED
REDACTED
REDACTED
REDACTED
REDACTED

+ 1 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Resolve the 1 REDACTED finding(s) in Supply-chain Provenance & Signing — start with REDACTED. — One of this dimension's main actionable groups (1 issue-level).
  2. Resolve the 1 REDACTED finding(s) in Supply-chain Provenance & Signing. — One of this dimension's main actionable groups (1 warning-level).
  3. Resolve the 1 REDACTED finding(s) in Supply-chain Provenance & Signing — start with REDACTED. — One of this dimension's main actionable groups (1 warning-level).

Detailed fixes: d36_recommendation.md · top locations in Appendix A, every location in findings.md.

D37 · Vulnerability-disclosure Policy10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether the repository publishes a coordinated-vulnerability-disclosure policy (SECURITY.md or security.txt) with a reporting contact, so finders know how to report a vulnerability. Presence of a policy file with a contact, not whether the policy is adequate or honoured.

Method: Vulnerability-disclosure policy read deterministically from the repo: a SECURITY.md (root/.github/docs) or .well-known/security.txt / security.txt, regex-checked for a reporting contact (email / URL / mailto). Present + contact → 10; present without a contact → 4; NotApplicable when no policy file exists (it may live off-repo). Detects the policy file's presence + contact, not its adequacy.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

A vulnerability-disclosure policy (SECURITY.md) is published with a reporting contact.

✓ On the Gold path — maintain.

Detailed fixes: d37_recommendation.md.

D43 · Malicious Dependencies10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether any dependency the repository declares is published as MALICIOUS rather than merely vulnerable — a package that is an attacker's work, in any ecosystem osv-scanner reads. Reported apart from D30 because the answer is binary: there is no safe version to upgrade to, and the fix is to remove the package and rotate every credential it could have read.

Method: The same dependency scan D30 reads, partitioned on the scanner's own classification rather than rescanned: a row is MALICIOUS when its id is in the `MAL-` space (the ossf/malicious-packages feed) OR its `database_specific.cwe_ids` carries `CWE-506` ("Embedded Malicious Code"). Both channels are structural; the summary text is deliberately NOT read, because a malicious-package record whose summary says only "Critical severity vulnerability" is a real shape ([GHSA redacted]) and a text matcher misses it. Scored BINARY: any surviving row is 0, whatever its severity and however many CVEs sit beside it — a hostile dependency is not a quantity. Applicability and degradation are D30's: NotApplicable only when no ecosystem is readable, and an unscannable ecosystem degrades rather than reading clean. Advisory since rubric-2026.11.2 (CAI decision 0006): the malicious-package feed is a database that changes daily, so the reading is shown and never moves a scored dimension, lens or the headline.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

No dependency in any ecosystem this repository declares is published as malicious.

✓ On the Gold path — maintain.

Detailed fixes: d43_recommendation.md.

D44 · Platform End-of-Life10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether anyone still ships security patches for the platform this repository RUNS ON — the runtime it pins and the framework majors its own constraints hold it to. Separate from D12 because the question differs: a current Django on an end-of-life Python is perfectly up to date and completely unsupported, and the fix is a migration rather than a version bump. What the repository says it merely SUPPORTS is never charged.

Method: End-of-life PLATFORM read from the repository's own declarations and graded against a FROZEN, dated table of vendor support dates — no network, no feed, no API, so this dimension answers identically inside a closed scan fence. Two subjects: a RUNTIME the project pins (a single or all-end-of-life TargetFramework, a .nvmrc or .python-version, a requires-python CAP) and a FRAMEWORK major a dependency constraint cannot move off (a caret, tilde or exact version; `vue@^2.7.16` pins Vue 2). A FLOOR is deliberately never charged — `requires-python = ">=3.8"` states what a package SUPPORTS, not what it runs on — and a multi-target project is charged only when EVERY target is out of support. Runtime 4.0/product capped 8.0, framework 1.5 capped 4.5. The table is safe to freeze because a statement about support that ended in the past cannot become false: it loses recall as it ages, never precision, and a test asserts every entry predates the freeze date. Disjoint from D31 (a container image's OS layer) and D29 (the toolchain a CI workflow installs). Abstains when the repository declares no platform this pass reads — never scores it clean.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

0 end-of-life runtime(s) and 0 end-of-life framework(s), read from 1 platform declaration(s) and 0 dependency declaration(s). This dimension reads what the repository says about ITSELF — a pinned target framework, a version file, a capped requires-python, a Rust toolchain pin, a framework major a constraint cannot move off. A FLOOR is deliberately never charged: `requires-python = ">=3.8"` states what the package SUPPORTS, not what it runs on, and a well-maintained library declares exactly that while running its own CI on a current release. The end-of-life facts are FROZEN and dated, so this dimension needs no network and answers identically inside a closed scan fence; as the table ages it loses recall and never precision, because a statement about support that ended in the past cannot become false. The OS layer of a container image is D31's question and the toolchain a CI workflow installs is D29's; this row is neither.

✓ On the Gold path — maintain.

Detailed fixes: d44_recommendation.md.

Frontend & cross-cutting dimensions

R = React/JS · M = Maturity · P = Readiness.

AC1 · Text alternatives10.0 / 10Exemplary○ Nothing flagged

Other · Accessibility — Whether non-text content carries a text alternative — img/area/input[type=image] have alt, a meaningful svg has a title or aria-label, video has a captions track, and object/embed/canvas have a name or fallback content. Static markup readiness, not a WCAG conformance claim.

Method: Static markup-model scan: every img/area/input[type=image] checked for alt, svg[role=img] for a title/aria-label, video for a captions <track>. Components skipped, spreads suppressed. Deterministic, hard fact per element.

Coverage: Population: image/media elements — img, area, input[type=image], svg, video, object, embed, canvas — across the PARSED MARKUP files only (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx); components, hidden subtrees and dynamic-attribute elements are skipped. Markup built in script — tagged-template (html`…`) UIs and hyperscript DOM factories — is NOT read by any producer, so it contributes no element to this population; where such a frontend is present the card discloses it as an analyzer gap rather than scoring around it.

AC2 · Forms & labels5.4 / 10Adequate✓ Tool-verified

Other · Accessibility — Whether form controls have a programmatic label (an associated label, aria-label or aria-labelledby), buttons have text, links have an accessible name, a click handler on a plain element names the control it declares, fieldsets have a non-empty legend, known UI-library field components carry a label prop, and a placeholder isn't used as the only label. Static markup readiness, not a WCAG conformance claim.

Method: Static markup-model scan: inputs/selects/textareas checked for an associated label[for]/wrapping label/aria-label/aria-labelledby (per document), buttons for accessible text, fieldsets for a legend; placeholder-only labelling flagged. Deterministic, hard fact per control.

Coverage: Population: form controls, buttons, links, fieldsets and known UI-library field components in the PARSED MARKUP files only (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx); components, hidden subtrees and spread/dynamic-attribute elements are skipped, so a control whose label arrives through a spread or a runtime expression is deliberately not judged. Markup built in script — tagged-template (html`…`) UIs and hyperscript DOM factories — is not read at all.

  • This control has only a placeholder — a placeholder is not a label (it vanishes on input and many AT ignore it). Add a <label for>, a wrapping <label>, or aria-label. (×3) — mistralrs-cli/webui/src/lib/components/AgentApproval.svelte:93, mistralrs-cli/webui/src/lib/components/ParamPopover.svelte:101, mistralrs-cli/webui/src/lib/components/SettingsPanel.svelte:149
  • This control has no associated label. Add a <label for> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it. (×6) — mistralrs-cli/webui/src/lib/components/ParamPopover.svelte:86, mistralrs-cli/webui/src/lib/components/SettingsPanel.svelte:172, mistralrs-cli/webui/src/lib/components/SettingsPanel.svelte:188, …

What to do

  • Give every control a programmatic label (a <label for> / wrapping <label> / aria-label) and every button text — a placeholder is not a label.
AC3 · Page structure10.0 / 10Exemplary○ Nothing flagged

Other · Accessibility — Whether pages declare a language (well-formed BCP-47) and a non-empty title, expose exactly one main landmark and a sane heading order with non-empty headings, keep zoom enabled, title their iframes, give data tables header cells, and avoid meta-refresh. Static markup readiness, not a WCAG conformance claim.

Method: Static markup-model scan: html lang, document <title>, a main landmark and heading order on full documents only, plus zoom-disabling viewports, untitled iframes and meta-refresh anywhere. Deterministic, per structural checkpoint.

Coverage: Population: the PARSED MARKUP documents (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx). The page-level checks — lang, title, single main landmark — fire ONCE PER FULL DOCUMENT (an <html> root) and never on a partial or component fragment, so a repo of fragments is assessed only on the per-element checks (heading order, table headers, iframe titles, meta-refresh, zoom). Markup built in script — tagged-template (html`…`) UIs and hyperscript DOM factories — is not read at all.

AC5 · ARIA correctness10.0 / 10Exemplary○ Nothing flagged

Other · Accessibility — Whether ARIA is used correctly — valid non-abstract roles, the ARIA state a role requires, valid (non-misspelled) aria-* attribute names, in-enum values for token-typed aria-* attributes, and no aria-hidden on (or wrapping) a focusable element. Static markup readiness, not a WCAG conformance claim.

Method: Static markup-model scan: role values checked against the WAI-ARIA role set (abstract/invalid flagged), required ARIA state for a role, and aria-hidden on a focusable element. Deterministic, role/attribute level.

Coverage: Population: elements in the PARSED MARKUP files (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx) that carry a role or an aria-* attribute; roles and token values are checked against the ARIA enums exhaustively within that set. An expression-valued (dynamic) role or aria-* value is skipped rather than guessed, and markup built in script — tagged-template (html`…`) UIs and hyperscript DOM factories — is not read at all.

AX10 · Code composition9.8 / 10Exemplary✓ Tool-verified

Other · Architecture — How the codebase splits by code ROLE — domain, application, infrastructure, test, generated. The significance map behind the knowledge/coupling weighting, and a DDD signal in its own right: a thin domain core under fat infrastructure is the anemic-domain smell, quantified. How each file's role is decided, because the split is only as good as that: a generated name or a build-output tree makes it Generated, a test project makes it Test, and otherwise the file's NAMESPACE and PATH words are matched against fixed vocabularies in a fixed ORDER — domain, then infrastructure, then application — so a file whose words hit two layers is counted under the earlier one. A production file matching none of them counts as application, so that share reads 'application or unclassified' rather than a measured application layer. Roles come from naming convention, never from what the code does. On this repository the split was taken from the source tree on disk rather than from a loaded .NET workspace, so a file's role is decided by its PATH segments alone — no declared namespace was available to add to the evidence — and generated output is excluded from the census entirely rather than counted as a generated share.

Method: Roslyn line-count by code ROLE: every source file classified Domain/Application/Infrastructure/Test/Generated by namespace + path convention (the shared CodeRoleClassifier), then significant lines summed per role. Deterministic; the advisory score is the business-logic (domain+application) share of production code.

Coverage: Population: ALL source files, each bucketed into ONE of five roles (Domain/Application/Infrastructure/Test/Generated) by namespace + path convention — a file whose layer isn't named in the convention falls to Application (the neutral default), and the split is line-count, not semantic depth or business value.

AX3 · Project dependency cycles10.0 / 10Exemplary✓ Tool-verified

Other · Architecture — Whether the project-reference graph is acyclic (cycles block independent build/deploy and signal eroding boundaries).

Method: Project reference cycles via elementary-DFS over real .csproj references, using the engine shared with D5/D7; cyclic versus acyclic. Exhaustive, deterministic.

AX4 · Dependency direction10.0 / 10Exemplary✓ Tool-verified

Other · Architecture — Whether dependencies point inward (Domain ← Application ← Infrastructure/Web) — the clean-architecture dependency rule, checked across the project graph.

Method: Layer violations by name-segment inference (Domain/Core to Application to Infrastructure/Web) over the project-reference graph. Exhaustive over all projects, deterministic.

AX9 · CQS / query purity10.0 / 10Exemplary✓ Tool-verified

Other · Architecture — Whether read (query) handlers stay side-effect-free — a query that writes persistent state or raises events breaks CQS and makes reads unsafe to retry, cache, or route to a read replica.

Method: Roslyn scan: CQRS handlers classified query-vs-command by interface (IQueryHandler/ICommandHandler/IRequestHandler<TQuery,TResult>) and name convention (*Query/Get*/Find* vs *Command); each query handler's body checked for persistent-state writes (SaveChanges/repository Add-Update) or event publishes by resolved invocation. Deterministic, type-level, exhaustive over the detected handlers.

Coverage: Population: CQRS handlers identified by IQueryHandler/ICommandHandler/IRequestHandler interface + *Query/Get*/Find*/*Command NAME convention; query purity then checked exhaustively within that set — a query handler using neither convention is invisible, and mutation is a resolved persistence/publish CALL, not full dataflow.

C2 · Access Controls1.7 / 10Critical✓ Tool-verified

Other · Security — Whether access is authorized by default — a framework authorization attribute/decorator or policy, or imperative guard methods (throw-on-violation) called from handlers.

Method: Roslyn scan: [Authorize] usage and authorization policies, plus imperative throw-on-violation guard methods detected via syntax. Deterministic.

  • Authorization IS enforced here (by route guards, auth middleware or checks that refuse a caller) — this is NOT a claim that endpoints are unprotected. What's missing is a NAMED rule set: who may do what is encoded inline where it is checked, so the rules can't be listed, reviewed or tested apart from the code that applies them. Recommendation, not a defect.
  • Only 1 place(s) refuse an unauthorized caller — too few to demonstrate default-deny across handlers.

What to do

  • Name the access rules — roles and permissions declared once (an enum Role/Permission, actix-web-grants #[protect(…)], axum-login's permission_required!, a casbin or oso policy) and consulted where access is checked, so the rule set is reviewable and testable on its own.
  • Enforce authorization at every handler — a guard on each route, or a global authentication guard/middleware with explicit public opt-outs, so protected-by-default is demonstrable.
DM1 · Aggregate boundaries10.0 / 10Exemplary✓ Tool-verified

Other · Domain Modelling — Whether an aggregate references another aggregate by identity rather than embedding it by object reference.

Method: Roslyn (DDD-gated): aggregate roots identified by convention; each aggregate field checked for direct references to other aggregates versus id-only. Deterministic, DDD-native.

Coverage: Population: aggregate roots identified by AggregateRoot/IAggregateRoot base/interface NAME convention; reference-by-identity then checked exhaustively within that set — a root not using those names is invisible.

DM2 · Strongly-typed ids10.0 / 10Exemplary✓ Tool-verified

Other · Domain Modelling — Whether domain identifiers are strongly typed (a newtype wrapper) rather than raw primitives — consistency once an idiom exists.

Method: Roslyn (DDD-gated): strongly-typed id adoption on domain entities/events; raw Guid/int/string ids counted versus wrapped types. An id wrapper is recognised by VALUE SEMANTICS, not by being a struct — a record struct, a record class (`record ApartmentId(Guid Value)`) or a class declared by a typed-id base (`class MemberId : TypedIdValueBase`) all count, while a plain mutable class (reference equality) and a verb-phrase query record (`GetCustomerById`) do not. Deterministic, adoption percentage.

Coverage: Population: id-like members by *Id/*Key NAME suffix; strongly-typed-ID shape then checked semantically — non-suffixed identifiers are not seen.

DM4 · Rich vs anemic domain model10.0 / 10Exemplary✓ Tool-verified

Other · Domain Modelling — Whether domain entities own their behaviour (invariant-enforcing commands) rather than being data-only structs driven by a foreign service.

Method: Roslyn (DDD-gated): entity method BODIES classified mutator-vs-query — only methods that mutate the entity's own declared state count as invariant-protecting behaviour, so a getter/passthrough doesn't rescue an anemic class. Deterministic, exhaustive over domain-layer entities.

Coverage: Population: entities by name/base convention; rich-vs-anemic judged by classifying each method body mutator-vs-query — logic-bearing domain types outside the convention are invisible.

DM5 · Encapsulated state10.0 / 10Exemplary✓ Tool-verified

Other · Domain Modelling — Whether a domain type's identity-bearing field stays immutable — a `pub` mutable field under a hand-rolled Hash/PartialEq breaks the value-identity invariant.

Method: Roslyn (DDD-gated): entities scanned for publicly writable state — public setters, and (C#/VB) own mutable collections handed out through an auto-property, a public field or a bare-field expression getter, where a computed/copying getter is never charged. One finding per entity; score softened when Marten/EF rehydration frameworks present. Deterministic, framework-aware.

Coverage: Population: entities by convention; encapsulation (setter shape) checked exhaustively within the set.

ES1 · Fold determinism10.0 / 10Exemplary✓ Tool-verified

Other · Event Sourcing — Whether the recovery-replay fold is deterministic — state derived purely from each event's own fields, no clock/random/IO on the replay path.

Method: Roslyn syntax scan (event-sourcing gated): Apply/When folds checked for forbidden tokens (DateTime.Now, Guid.NewGuid, Random, IO), stripped of comments/strings. Deterministic, hard fact per fold.

ES2 · Immutable events10.0 / 10Exemplary✓ Tool-verified

Other · Event Sourcing — Whether domain events stay immutable (private fields, set once) rather than carrying mutable state.

Method: Roslyn scan (event-sourcing gated): persisted events checked for public setters; immutability verified per property/field. Deterministic, hard fact.

M1 · Documentation (README)8.8 / 10Exemplary✓ Tool-verified

Maturity · Maturity — Whether the repository and its projects have a README, and whether it is substantive.

Method: Filesystem scan: README presence, word count, and headings for depth; git history for staleness. Exhaustive across root and project dirs, deterministic.

M2 · Architecture documentation2.0 / 10Weak✓ Tool-verified

Maturity · Maturity — Whether key decisions (ADRs) and the high-level shape (C4/diagrams) are written down.

Method: Filesystem scan: ADR folder/naming conventions or content, plus Mermaid/PlantUML/C4/architecture.md discovery. Exhaustive, deterministic.

  • No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.

What to do

  • Record your significant design decisions. Write one short document per decision, giving its date, the situation, the decision and its consequences, and keep them together with your other design documents. A docs/adr folder with each file named by number and title is the easiest place to find them.
M3 · Folder & project structure10.0 / 10Exemplary✓ Tool-verified

Maturity · Maturity — Whether the repository is organised deliberately: production code and tests are set apart in a way its ecosystem or the repository itself declares.

Method: Filesystem scan: src/test folder separation and namespace-prefix consistency (majority RootNamespace agreement). Exhaustive across projects, deterministic.

M4 · Documentation accuracy8.0 / 10Strong✓ Tool-verified

Maturity · Maturity — Whether the project's current-state documentation describes the code that exists.

Method: Every current-state document's checkable claims looked up in the tree (links, versions, and artefact counts an order of magnitude off), plus two README checks: an advertised infrastructure product with no footprint, and a module the CHANGELOG records as removed. Deterministic, no model. Advisory.

  • mistralrs-mcp/README.md links to `../docs/MCP/README.md`, but `docs/MCP/README.md` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong. — mistralrs-mcp/README.md:54

What to do

  • Reconcile the README with reality: mistralrs-mcp/README.md links to `../docs/MCP/README.md`, but `docs/MCP/README.md` does not exist.
P1 · CI/CD gates10.0 / 10Exemplary○ Nothing flagged

Readiness · Readiness — Whether an automated pipeline builds and tests every change.

Method: Filesystem scan: CI workflow files (.github/workflows, .gitlab-ci.yml, etc.) for build and test stages. Exhaustive, deterministic.

P10 · Library API & versioning10.0 / 10Exemplary○ Nothing flagged

Readiness · Readiness — For a library: a deliberate (small) public API surface and explicit semantic versioning so consumers can depend on it safely.

Method: Roslyn scan: public API surface area and semantic-versioning markers (SemVer attributes, changelog entries) for libraries; off .NET, a library is the ecosystem's publication act (an npm package that is not private and names an entry point, a PyPI distribution with a build system, a Rust library crate, a Maven/Gradle module that publishes, a Go module with no package main, a gemspec, a Composer library, a SwiftPM library product, a pub.dev or Hex package), its surface is the share of types the language's code model records as public (Rust, Swift, Java, Kotlin, Go, Dart; not measured where the model records no type visibility or, as in TypeScript, only module-level export), and its version is read from the manifest, a semver CHANGELOG, release tooling or semver git tags. Exhaustive, deterministic.

P2 · Observability8.0 / 10Strong✓ Tool-verified

Readiness · Readiness — Whether the code is diagnosable in production — structured logging, tracing/metrics, health checks.

Method: Filesystem/Roslyn scan: structured-logging frameworks (Serilog, NLog), OpenTelemetry, and health-check endpoint patterns. Exhaustive, deterministic.

P3 · Security & performance tooling4.0 / 10Weak✓ Tool-verified

Readiness · Readiness — Whether SAST, secret/dependency scanning and performance benchmarking are wired in (presence, not runtime).

Method: Filesystem scan: SAST configuration, dependency-update automation, secret scanning, and a benchmark harness or benchmark step — in this repository's own ecosystem. Exhaustive, deterministic.

  • `docs/package.json` declares packages, and nothing in the repository keeps them current: no Dependabot or Renovate configuration that schedules updates, and no dependency-review gate on pull requests. A pinned dependency stays at the version it was added at until someone notices — including after an advisory is published against it. Add a `.github/dependabot.yml` with one `package-ecosystem` entry per ecosystem the tree uses (or an enabled `renovate.json`), and gate pull requests with `actions/dependency-review-action`. — docs/package.json:19

What to do

  • Enable Dependabot/Renovate or a dependency-review gate.
  • Add gitleaks/trufflehog in CI to block PRs that introduce committed secrets.
P4 · Deployment & Rollback7.0 / 10Strong✓ Tool-verified

Readiness · Readiness — Whether releases are automated and safely reversible (probes, rolling updates, approval gates) — from manifests/pipeline files, not the live environment.

Method: Filesystem scan: deployment manifests/IaC (K8s YAML, Helm, Terraform) for rolling updates, probes, approval gates, migration hooks. Exhaustive, deterministic.

P6 · Release Hygiene10.0 / 10Exemplary✓ Tool-verified

Readiness · Readiness — Whether releases are traceable — a maintained changelog and explicit version stamping.

Method: Filesystem scan: changelog file presence and version tags in csproj or git tags. Exhaustive, deterministic.

P7 · Outbound HTTP resilience3.0 / 10Weak✓ Tool-verified

Readiness · Readiness — Whether outbound HTTP calls are wrapped in resilience (retry/timeout/circuit-breaker) so a failing dependency doesn't cascade.

Method: Source scan: outbound HTTP clients and what bounds them — resilience handlers (Polly, AddStandardResilienceHandler) on .NET; on Go, the JVM, Python, JavaScript/TypeScript, Ruby, PHP, Rust, Elixir, Swift, Dart and Erlang, a timeout, deadline, retry or breaker beside each call, or a process-wide client default (a framework-wide deadline such as Drupal core's, Laravel's or actix's awc counts). Exhaustive, deterministic.

  • `reqwest::blocking::Client::new(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout. — mistralrs-core/src/engine/tool_dispatch.rs:461
  • `reqwest::blocking::get(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout. (×4) — mistralrs-core/src/pipeline/amoe.rs:647, mistralrs-pyo3/src/util.rs:219, mistralrs-pyo3/src/util.rs:272, …

What to do

  • Give every client a whole-request bound: `reqwest::Client::builder().timeout(Duration::from_secs(10))` (never `reqwest::get` or `Client::new()`, which have none), ureq's `timeout_global`, or wrap the call in `tokio::time::timeout`; add retry with back-off (`reqwest-retry`'s `RetryTransientMiddleware`, `backoff`) around dependencies that fail.
PF3 · Async & latency hygiene10.0 / 10Exemplary✓ Tool-verified

Readiness · Performance — Whether asynchronous code stays responsive — it avoids sync-over-async blocking (a .NET .Wait()/.GetAwaiter().GetResult(), a time.sleep or blocking HTTP call inside a Python coroutine, a *Sync call inside an async JavaScript function, block_on inside a Rust async fn, runBlocking inside a Kotlin suspend function, block() inside a Reactor publisher) that stalls a thread or event loop and risks deadlock, and, where the code is a reusable library on .NET, awaits with ConfigureAwait(false) so it never captures and stalls its caller's context.

Method: Production-source scan: sync-over-async blocking counted everywhere — .Wait()/.GetAwaiter().GetResult() in .NET; off .NET, read from each language's code model, a blocking call inside an async function (Python, TS/JS, Rust, Kotlin, Swift, Dart) or inside a Java method returning a Reactor Mono/Flux or a Scala method returning a Future or effect — and, for a .NET library with ≥5 awaits, the share of awaits using ConfigureAwait(false). Deterministic, syntax/text detection.

R1 · Type Safety8.8 / 10Exemplary✓ Tool-verified

React / JS · Code Health — How much of the frontend is typed TypeScript vs untyped JavaScript.

Method: Frontend file inventory: the share of typed TypeScript vs untyped JavaScript across the source tree. Deterministic, exhaustive over frontend files.

R10 · Code Duplication9.3 / 10Exemplary✓ Tool-verified

React / JS · Code Health — The share of the scored frontend lines inside a near-exact copy-pasted block of substantial extent (the D4 clone algorithm over JS/TS tokens, D-386; each line once, 10 at none and 0 at a quarter of the lines, as D4): a block is reported only where its copies still agree on most of their own identifiers and literals, or were renamed as they were pasted but kept most of their constants, and where the copies carry enough code to stand on their own or the copied extent reaches 30 lines — so a re-implementation sharing neither names nor values, and a small pasted declaration, are both found and deliberately not reported, and a clean R10 is not a claim that nothing was copied.

Method: Near-exact copy-pasted blocks of substantial extent across the frontend (the D4 clone algorithm run over JS/TS tokens). Masking finds the candidates; a block is reported when its copies still agree on most of their own identifiers and literals, or when a renamed copy still agrees on most of its constants, AND the copies carry enough code to stand on their own — or when the copied extent reaches 30 lines. So a re-implementation sharing neither names nor values, and a small pasted declaration, are deliberately not counted. Scored on the share of the scored frontend lines inside a reported copy, on the same curve as D4. Deterministic.

  • mistralrs-cli/webui/src/lib/components/AssistantMessage.svelte:29 · mistralrs-cli/webui/src/lib/components/UserMessage.svelte:64 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — mistralrs-cli/webui/src/lib/components/AssistantMessage.svelte:29
  • mistralrs-cli/webui/src/lib/components/FileCard.svelte:27 · mistralrs-cli/webui/src/lib/services/streaming.ts:11 — the 2 copies are spread across 2 directories, so the shared home is a decision rather than an obvious spot: check first whether one of them already owns this behaviour, and otherwise put the extracted module somewhere all of the sites already reach rather than making one of them depend on another. — mistralrs-cli/webui/src/lib/components/FileCard.svelte:27
  • mistralrs-cli/webui/src/lib/services/api.ts:30 · mistralrs-cli/webui/src/lib/services/api.ts:40 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported. — mistralrs-cli/webui/src/lib/services/api.ts:30

What to do

  • Act on each finding's own remediation rather than one rule: the move depends on what recurs. Where the copies are executable blocks, give the shared part one home and call it from each site; where they are declarations, a listing, a specialisation already delegating to its base, or one shape repeated per entity, there is no call site and the move is a shared type, a generated set or a factory — sometimes there is nothing to extract.
R2 · Cyclomatic Complexity8.9 / 10Exemplary✓ Tool-verified

React / JS · Code Health — Per-function cyclomatic/cognitive complexity from the token-level function scanner (D-386) — real branching, not a regex heuristic.

Method: Per-function cyclomatic/cognitive complexity from a token-level function scanner (real branching, not a regex heuristic), computed over every frontend function. Deterministic.

  • streamChatCompletion has cyclomatic complexity 43 and cognitive complexity 91; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — mistralrs-cli/webui/src/lib/services/streaming.ts:21
  • fetch has cyclomatic complexity 16 and cognitive complexity 19; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — mistralrs-cli/webui/tests/chat-store.test.mjs:45
  • onToolCallProgress has cyclomatic complexity 15 and cognitive complexity 16; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — mistralrs-cli/webui/src/lib/stores/chat.svelte.ts:445
  • buildApiMessages has cyclomatic complexity 14 and cognitive complexity 18; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — mistralrs-cli/webui/src/lib/stores/chat.svelte.ts:344
  • finalizeStreaming has cyclomatic complexity 13 and cognitive complexity 13; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — mistralrs-cli/webui/src/lib/stores/chat.svelte.ts:573
  • addFile has cyclomatic complexity 12 and cognitive complexity 11; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — mistralrs-cli/webui/src/lib/components/ChatInput.svelte:136
  • generateAssistant has cyclomatic complexity 11 and cognitive complexity 10; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — mistralrs-cli/webui/src/lib/stores/chat.svelte.ts:378
  • loadChat has cyclomatic complexity 11 and cognitive complexity 9; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes. — mistralrs-cli/webui/src/lib/stores/chat.svelte.ts:718
R3 · Large Files8.7 / 10Strong✓ Tool-verified

React / JS · Code Health — How many source files exceed the large-file threshold.

Method: Components/modules exceeding the large-file threshold, counted exhaustively across the frontend source tree. Deterministic.

  • mistralrs-cli/webui/src/lib/stores/chat.svelte.ts has 718 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module. — mistralrs-cli/webui/src/lib/stores/chat.svelte.ts:1

What to do

  • Split each oversized file along the responsibilities already in it, into smaller focused modules in the same package.
R4 · Test Coverage2.3 / 10Weak✓ Tool-verified

React / JS · Readiness — Static test reachability (D-386): the share of production files reachable from any test via the import graph — measured without running anything.

Method: Static test reachability: the share of production files reachable from any test via the import graph — measured without running anything. Deterministic.

  • No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one. (×23) — mistralrs-cli/webui/src/lib/types.ts:1, mistralrs-cli/webui/src/lib/components/ChatInput.svelte:1, mistralrs-cli/webui/src/lib/components/FileCard.svelte:1, …

What to do

  • Add tests that import the unreached modules (directly or through their public entry).
R5 · Dependency Freshness9.6 / 10Exemplary✓ Tool-verified

React / JS · Readiness — How outdated the npm dependencies are (a maturity signal). JS/npm CVEs are scored separately in D30 (JS/npm Dependency Vulnerabilities).

Method: npm dependency staleness from manifest/registry metadata (a maturity signal; JS/npm CVEs are scored separately in D30, which answers dependency vulnerabilities for every ecosystem). Deterministic.

R6 · Tooling10.0 / 10Exemplary✓ Tool-verified

React / JS · Readiness — Whether the project wires up test, lint and typecheck — detected from each package.json script's COMMAND (eslint / tsc / vitest / jest / playwright), not just its name, and corroborated against CI-workflow invocations so a tool run only in CI still counts.

Method: package.json scanned for test/lint/typecheck script wiring. Deterministic presence check.

R7 · Dead Code9.8 / 10Exemplary✓ Tool-verified

React / JS · Code Health — Files unreachable from every application/tooling/test entry point, and exports nothing imports (module-graph reachability, D-386).

Method: Dead code: files unreachable from every application/tooling/test entry point plus exports nothing imports, via module-graph reachability. Deterministic, exhaustive over the import graph.

  • Nothing imports this binding — it is safe to review for removal. (×5) — mistralrs-cli/webui/src/lib/services/api.ts:145, mistralrs-cli/webui/src/lib/services/api.ts:149, mistralrs-cli/webui/src/lib/services/api.ts:153, …

What to do

  • Delete the dead files and unused exports — every line is maintenance cost and rebuild-estimate inflation with zero runtime value.
R8 · Dependency Hygiene10.0 / 10Exemplary✓ Tool-verified

React / JS · Readiness — npm dependency truthfulness (D-386): unused dependencies, imports not declared anywhere, and type-/test-only packages shipped as production deps.

Method: npm dependency truthfulness: unused dependencies, imports declared nowhere, and type-/test-only packages shipped as production deps — from the manifest + import graph. Deterministic.

R9 · Circular Imports10.0 / 10Exemplary✓ Tool-verified

React / JS · Architecture — Import cycles in the module graph (D-386) — files that can only be understood and changed together.

Method: Import cycles in the module graph, detected exhaustively over JS/TS imports (the same cycle detection as the .NET coupling dimension). Deterministic.

S1 · Web-Security Posture6.5 / 10Adequate✓ Tool-verified

Other · Security — Read from this repository's Rust source: cryptographic hygiene (weak hash or cipher, key material fixed in the source) and outbound TLS (certificate validation, protocol version) — facts about code that hold whether or not it serves anything itself. This repository commits the configuration that serves its own HTTP surface, so that configuration was read in full for the security response headers it sets. This repository serves HTTP itself (`axum::serve(` (mistralrs-cli/src/commands/config.rs:198)), so its Rust source was also read for the server controls: TLS served or HSTS set, security response headers, cookie flags and inbound validation — each credited where its Rust spelling appears in production source, not proven on every route. A Rocket 0.5 application is credited the headers Rocket's default `Shield` sends unless it attaches its own, and its cookie jar's SameSite=Strict default; a session middleware its default cookie flags.

Method: Roslyn plus filesystem scan: HSTS/security headers, secure cookies, input validation, middleware order, weak crypto (MD5/SHA1/DES); HTTPS-metadata context-aware. On a repository with no .NET source it reads JavaScript/TypeScript, Dart, Ruby, Scala, Rust or Elixir source itself (test, vendored, generated and minified paths not) for the arms that hold whether or not the code serves HTTP: a weak hash or cipher, key material fixed in the source, a TLS client that accepts any certificate, and (JavaScript/TypeScript, Ruby, Scala, Rust and Elixir) an obsolete TLS version; the server controls are not assessed there, and a Dart, Ruby, Scala, Rust or Elixir repository that serves no HTTP of its own is N/A on them. Deterministic.

  • This repository starts an HTTP server and nothing in its Rust source or committed `Rocket.toml` secures the transport: no TLS served (actix-web `bind_rustls`/`bind_openssl`, axum-server `bind_rustls` with a `RustlsConfig`, tonic `ServerTlsConfig`, a `TlsAcceptor`, Rocket's `[default.tls]`), no `Strict-Transport-Security` header, no `X-Forwarded-Proto` read from a TLS-terminating proxy — so its traffic may cross the network in clear text. (−2.0 on this card.) The server: `axum::serve(` (mistralrs-cli/src/commands/config.rs:198).

What to do

  • Secure the server's transport: serve TLS itself (`HttpServer::bind_rustls_0_23(addr, config)` in actix-web, `axum_server::bind_rustls(addr, RustlsConfig::from_pem_file(…))`, tonic's `Server::builder().tls_config(ServerTlsConfig::new().identity(…))`, Rocket's `[default.tls]`), or run it behind a TLS-terminating proxy and check `X-Forwarded-Proto`; send `Strict-Transport-Security` once it is HTTPS-only.
X1 · Async correctness10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether the code avoids sync-over-async (deadlock-prone blocking on tasks) and async void.

Method: Roslyn syntax scan: async methods scanned for .Wait()/.GetAwaiter().GetResult() and async-void outside event handlers. Deterministic, hard fact per invocation.

X14 · Bypassable address classification10.0 / 10Exemplary○ Nothing flagged

Other · Security — Whether a hand-rolled public/private IP check can be walked past — a method that unwraps IPv4-mapped IPv6 but returns the opposite verdict for the same host written as IPv4-compatible, 6to4 or NAT64.

Method: Roslyn syntax + semantics: methods that unwrap IPv4-mapped IPv6 and hand-roll IPv4 range carve-outs, checked for whether the IPv6 branch also accounts for the IPv4-compatible, 6to4 and NAT64 embeddings. Deterministic, provable per finding. Advisory.

X15 · Unvalidated length from an untrusted reader2.7 / 10Weak✓ Tool-verified

Other · Security — Whether a length read out of the stream being parsed is bounded before it is allocated or read — an unchecked count taken from the input lets the input choose the allocation.

Method: Roslyn syntax + semantics: integer lengths read from a BinaryReader and spent on a bulk read or an array allocation, checked for any comparison or bounding call on the value anywhere in the method. Deterministic, provable per finding. Advisory.

  • `key_len` is read from the bytes being parsed at line 211 (`read_u64`), then used to size a `vec![…; n]` at line 212 — and nowhere in its scope is `key_len` compared to anything, clamped, or bounded against the input that remains. Whoever wrote those bytes therefore chooses the allocation directly: it reserves the whole length before a single byte of the payload is known to exist, so a 32-bit length asks for up to 4 GiB, and an allocation the allocator refuses aborts the process with `memory allocation of … bytes failed` — an abort, not a panic, so no `catch_unwind` intercepts it and the whole process dies; a 64-bit length past `isize::MAX` panics with `capacity overflow` instead, out of a parser whose failure path was written for malformed input, not for hostile input. Bound `key_len` against the bytes actually remaining and a maximum the format allows before allocating. — mistralrs-quant/src/imatrix.rs:212
  • `len_data` is read from the bytes being parsed at line 216 (`read_u64`), then used to size a `Vec::with_capacity` at line 217 — and nowhere in its scope is `len_data` compared to anything, clamped, or bounded against the input that remains. Whoever wrote those bytes therefore chooses the allocation directly: it reserves the whole length before a single byte of the payload is known to exist, so a 32-bit length asks for up to 4 GiB, and an allocation the allocator refuses aborts the process with `memory allocation of … bytes failed` — an abort, not a panic, so no `catch_unwind` intercepts it and the whole process dies; a 64-bit length past `isize::MAX` panics with `capacity overflow` instead, out of a parser whose failure path was written for malformed input, not for hostile input. Bound `len_data` against the bytes actually remaining and a maximum the format allows before allocating. — mistralrs-quant/src/imatrix.rs:217

What to do

  • Each finding names the read that takes the length from the input and the site that spends it, and states that the value is never compared in between. Confirm from the two, then bound the length against the remaining stream before using it.
X2 · Cancellation propagation5.0 / 10Adequate✓ Tool-verified

Other · Code Health — Whether async functions that make a cancellable request accept or pass on an AbortSignal (adoption curve).

Method: Roslyn scan: every async method (excluding framework-fixed overrides/Blazor handlers) checked for CancellationToken parameter presence. Deterministic, adoption percentage. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same question: every named async function that itself makes a request an AbortSignal can cancel (global `fetch`, axios and its file-local instances, ky, ofetch) counts, and it is compliant when its parameters or body name a signal or it hands one of its own parameters to the request as options; signatures a framework fixes (JSX event handlers, route and lifecycle exports, request-first handlers, `override`, `'use server'` modules, TanStack `mutationFn`) are exempt unless they take a signal. Deterministic, adoption percentage.

  • Only 1/6 async functions that make a cancellable request (fetch, axios, ky, ofetch, got, undici, node:http) accept an AbortSignal or pass one on, so a request keeps running after whatever wanted it has given up — a page navigated away from, an unmounted component, a timed-out job. Take a `signal` (or an options object that carries one) and hand it to the request; where nothing could ever cancel the call, omitting it is a deliberate choice — judge against how the function is used.
  • `get` awaits `fetch(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `fetch(url, { signal })`. — mistralrs-cli/webui/src/lib/services/api.ts:24
  • `post` awaits `fetch(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `fetch(url, { signal })`. — mistralrs-cli/webui/src/lib/services/api.ts:30
  • `postVoid` awaits `fetch(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `fetch(url, { signal })`. — mistralrs-cli/webui/src/lib/services/api.ts:40
  • `uploadFile` awaits `fetch(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `fetch(url, { signal })`. — mistralrs-cli/webui/src/lib/services/api.ts:131
  • `resolveAgentApproval` awaits `fetch(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `fetch(url, { signal })`. — mistralrs-cli/webui/src/lib/services/streaming.ts:185

What to do

  • Thread an AbortSignal through async functions that make requests, so the work stops when its caller gives up.
X21 · Side-effecting pattern guard10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a `when` guard is free of side effects — a guard that increments a counter or assigns while deciding whether its arm matches applies that change during PATTERN MATCHING, on an arm that may not be selected, and skips it entirely when a short-circuit to its left answers first.

Method: Roslyn syntax: `when` guards on case labels and switch-expression arms, read for a mutation (`++`/`--`/assignment) sitting in a position the guard's own `&&`/`||`/`??`/`?:`/`?.` can skip. Deterministic, provable per finding. Advisory.

X27 · Collection changed while being enumerated10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a `for` loop leaves the `RefCell` it is walking alone — safe Rust rejects a body that changes the collection its loop borrows at compile time, except through interior mutability: a `RefCell` borrowed in the loop's header stays borrowed until the loop ends, so a `borrow_mut()` of it inside the body panics with `already borrowed: BorrowMutError` and the remaining elements are never seen. Whether a `for` loop leaves the `dict`, `set` or `deque` it is walking alone — CPython's iterators over those check that the collection has not changed size since the loop began, so a body that removes from (or empties) the very collection the loop is walking makes the next step raise `RuntimeError: dictionary changed size during iteration` and the remaining items are never seen.

Method: Roslyn syntax + semantics: `foreach` statements whose body calls a structural mutator (`Add`/`Remove`/`Clear`/`Insert`/…) on the very expression the loop is enumerating. Two arms. ARM A — the source is a concrete fragile BCL collection, or a live `Keys`/`Values` view over one, and the mutator resolves to that same collection's own member; concurrent and immutable collections and arrays are outside the population by construction, since their enumerators survive a structural change. ARM B — the source is an argument-less accessor CALL on a receiver whose body is in source: the accessor must return a stored field VERBATIM and a sibling member must structurally change that same field, both read off the implementations rather than from the members' names. A mutation the loop provably exits immediately after (`break`/`return`/`throw`/`goto`), or one written inside a nested loop or a lambda, is counted and never reported. Deterministic, provable per finding. Advisory.

X28 · Index access outside its own emptiness guard10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a condition that tests a value for emptiness indexes that same value only where the test holds — an `||` written one parenthesis too far to the left leaves an index access outside the guard beside it, so the empty case the guard exists to anticipate reaches the index and throws.

Method: Roslyn syntax only, no semantic model: the OUTERMOST `&&`/`||` of every boolean condition, read for a symbol the condition tests for emptiness (`string.IsNullOrEmpty`/`IsNullOrWhiteSpace`, a `Length`/`Count` comparison against a literal, `Any()`, a `Length`/`Count` pattern, or a comparison against `""`) and ALSO indexes. Each `symbol[...]` access is placed by a boolean-reachability walk from the access up to the outermost connective: an access is COVERED when some enclosing step has it in the right operand and the left operand, under the truth value that step forces, proves the symbol non-empty — a recursion over `&&`/`||` whose true- and false-directions are asymmetric. A finding needs BOTH an uncovered access and a covered one on the same symbol in the same condition, which is the agreeing twin that separates a misplaced parenthesis from an unrelated length test. Bare index accesses with no emptiness test in the condition are neither counted nor reported; a non-identifier receiver and a lambda nested inside the condition are outside the population. Deterministic, provable per finding. Advisory.

X29 · Per-element action decided by a fixed element10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a decision taken once per element is taken ABOUT that element — a test inside a counted loop that reads a fixed subscript of the very collection its guarded statement indexes by the loop variable applies element zero's answer to all of them, so the elements that differ from it are all handled wrongly, and in the same direction.

Method: Roslyn syntax only, no semantic model: every `for` statement declaring exactly ONE loop variable, and every `if` inside its body that is not under a nested loop or a lambda. A site enters the population when the `if`’s condition never mentions the loop variable while the statement it guards indexes some collection by that variable ALONE (`c[i]`; `c[i + 1]` and `c[i, j]` are outside it). A finding additionally needs the AGREEING TWIN at the same-collection grain: the condition must read THAT SAME collection at a subscript that does not move — written into the condition, or reached through a local declared BEFORE the loop, so an alias bound inside the body is not followed. Both collection expressions must be simple identifiers. On a repository with no .NET source the same rule reads JavaScript/TypeScript off the engine’s own token stream (tests included, bundles and vendored paths not): a `for (let|var|const x = …; …; …)` with one declarator and a braced body, an alias followed only when it is declared before the loop in a block that encloses it and never assigned inside the loop. Deterministic, provable per finding. Advisory.

X30 · Support guard that admits what it rejects10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a guard written as a NEGATED `||` says what its author meant — `!(a || b || x != k)` is `!a && !b && x == k` by De Morgan, so a bail-out that mixes capabilities the code needs with a fault it refuses turns inside out: it fires only where the capabilities are ABSENT, and lets every value the fault term names walk straight into the body that cannot handle it.

Method: Roslyn syntax only, no semantic model: every logical-not whose operand is a parenthesised `||` chain of two or more disjuncts, flattened (a left-nested `a || b || c` read once would see `(a || b)` as one disjunct). A site enters the population on that shape alone. A finding additionally needs the disjuncts to DISAGREE in polarity: at least one bare boolean read — an identifier or member access, never an invocation, which is a predicate rather than a capability flag — and at least one `x != <constant>`, the only form that negates into an exact-value pin (`== null` negates into a looser requirement and is outside the fault set). Consistently-polarised disjunctions, all-fault or all-capability, are counted and never reported; a negated `&&` is outside the population entirely. No same-receiver gate: it was measured to cost a real defect and remove no false positive. Deterministic, provable per finding. Advisory.

X4 · Structured logging2.5 / 10Weak✓ Tool-verified

Other · Code Health — Whether log calls use message templates (queryable) rather than interpolated strings.

Method: Roslyn syntax scan: every log call-site counted; interpolated-string first-argument violations flagged. Population is all log calls, not estimated. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `trace`/`debug`/`info`/`warn`/`error`/`fatal`/`verbose`/`silly`/`http`/`log` call on a receiver named for a logger, in a package whose own or an enclosing `package.json` declares a logger that carries values as fields (pino, pino-http, nestjs-pino, Fastify, winston, bunyan, tslog, LogTape, roarr), whose first deciding argument is a template literal with substitutions; an object-literal fields argument is stepped over, a plain string message clears the call. Python is read the same way: a `debug`/`info`/`warning`/`error`/`exception`/`critical`/`log` call on a logger in a file that imports the standard library’s `logging` or structlog (loguru, which formats at the call, is not judged), whose message is a whole f-string with a non-constant field; a `%`-formatted, `.format()`-ed or concatenated message is not convicted, as in C#. PHP is read the same way: a PSR-3 level call (`emergency`…`debug`, `log`) on a logger (`$logger`, `$this->logger`, Laravel’s `Log::`, `logger()`, `\Drupal::logger()`) in a package whose `composer.json` requires a PSR-3 logger or a framework that hands one out (psr/log, Monolog, Laravel, Symfony, Drupal, CakePHP), or a file that imports one, whose message is a double-quoted string interpolating a variable; a single-quoted message clears the call, and `sprintf` or `.` concatenation is not convicted, as in C#. Dart is read the same way: a `trace`/`debug`/`info`/`warn`/`error`/`fatal` call on Sentry’s structured logger (`Sentry.logger`) whose message is a whole string literal interpolating a value (`$name`, `${…}`); the `Sentry.logger.fmt` template API clears the call. Dart that logs only through loggers with one message and no fields (package:logging, package:logger, talker, dart:developer) is not applicable rather than a reach gap. Ruby is read the same way: a `trace`/`debug`/`info`/`warn`/`error`/`fatal` call on the console gem’s `Console` (declared by a Gemfile, gemspec or Gemfile.lock, or required) or, where SemanticLogger, Ougai or dry-logger is declared or required, on a receiver named for a logger (`logger`, `@logger`, `Rails.logger`, `log`), whose first deciding argument is, as the whole argument, a double-quoted string interpolating a non-constant value (`#{…}`, `#@ivar`); a plain literal clears the call, keyword arguments are the fields, and a block, `%`-format or `+` concatenation is not convicted. Ruby that logs only through the standard Logger (Rails.logger) is not applicable rather than a reach gap. Deterministic.

  • `warn!` at line 121 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-server-core/src/chat_completion.rs:121
  • `warn!` at line 657 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-server-core/src/chat_completion.rs:657
  • `debug!` at line 441 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-server-core/src/metrics.rs:441
  • `debug!` at line 483 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-server-core/src/metrics.rs:483
  • `info!` at line 875 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-server-core/src/metrics.rs:875
  • `info!` at line 879 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-server-core/src/metrics.rs:879
  • `info!` at line 884 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-server-core/src/metrics.rs:884
  • `info!` at line 942 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-server-core/src/metrics.rs:942
  • `info!` at line 966 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-server-core/src/metrics.rs:966
  • `info!` at line 1057 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-server-core/src/mistralrs_for_server_builder.rs:1057
  • `info!` at line 1062 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-server-core/src/mistralrs_for_server_builder.rs:1062
  • `info!` at line 1139 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-server-core/src/mistralrs_for_server_builder.rs:1139
  • `info!` at line 1293 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-server-core/src/mistralrs_for_server_builder.rs:1293
  • `info!` at line 1298 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-server-core/src/mistralrs_for_server_builder.rs:1298
  • `info!` at line 1314 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-server-core/src/mistralrs_for_server_builder.rs:1314
  • `info!` at line 1318 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-server-core/src/mistralrs_for_server_builder.rs:1318
  • `info!` at line 1320 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-server-core/src/mistralrs_for_server_builder.rs:1320
  • `debug!` at line 1404 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-server-core/src/mistralrs_for_server_builder.rs:1404
  • `debug!` at line 1413 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-server-core/src/mistralrs_for_server_builder.rs:1413
  • `warn!` at line 1110 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-server-core/src/openai.rs:1110
  • `warn!` at line 188 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-server-core/src/streaming.rs:188
  • `debug!` at line 28 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-sandbox/src/linux/cgroups.rs:28
  • `debug!` at line 34 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-sandbox/src/linux/cgroups.rs:34
  • `debug!` at line 37 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-sandbox/src/linux/cgroups.rs:37
  • `debug!` at line 81 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-sandbox/src/linux/mod.rs:81
  • `warn!` at line 44 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-sandbox/src/linux/namespaces.rs:44
  • `debug!` at line 20 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-quant/src/utils/log.rs:20
  • `info!` at line 33 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-quant/src/utils/log.rs:33
  • `warn!` at line 46 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-quant/src/utils/log.rs:46
  • `debug!` at line 409 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-quant/src/gguf/mod.rs:409
  • `warn!` at line 501 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-quant/src/embedding/storage.rs:501
  • `warn!` at line 522 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-quant/src/embedding/storage.rs:522
  • `info!` at line 277 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-quant/src/distributed/mod.rs:277
  • `debug!` at line 578 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-quant/src/distributed/mod.rs:578
  • `debug!` at line 609 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-quant/src/distributed/mod.rs:609
  • `debug!` at line 640 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-quant/src/distributed/mod.rs:640
  • `debug!` at line 727 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-quant/src/distributed/mod.rs:727
  • `debug!` at line 758 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-quant/src/distributed/mod.rs:758
  • `debug!` at line 789 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-quant/src/distributed/mod.rs:789
  • `info!` at line 528 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — mistralrs-quant/src/cutile/fp8_gemm.rs:528

What to do

  • Interpolated log message defeats structured logging
X5 · Nullable reference types5.6 / 10Adequate✓ Tool-verified

Other · Code Health — Whether strict null checking is enabled and not undermined by heavy `!` assertion — TypeScript's `strictNullChecks` (which `strict` turns on) is what makes `string` exclude `null` and `undefined`, and the postfix `!` is the operator that silences it.

Method: Roslyn compiler-options scan: NullableContextOptions per project; null-forgiving (!) suppression density per 1k syntax nodes. Deterministic, adoption plus suppression penalty.

  • 1/2 of this repository's type-checking configuration(s) turn on strict null checking (`"strict": true`, or `"strictNullChecks": true`). A configuration that states neither is counted as OFF, because off is tsc's own default; a solution-style one whose `"files"` is empty and whose `"references"` point at other projects is in neither number, because it checks no source itself. Where it is off, `string` admits `null` and `undefined`: passing a value that is null compiles silently and throws on the first property access.
  • ~1.6 `!` null assertions per 1k TypeScript source lines — 3 assertion(s) across the 1902 source line(s) of the 10 TypeScript file(s) read, which is the only code the operator asserts anything in (a `!` in a `.js` file is not this operator and was not counted, and one in a file whose null checking is off silences nothing). Densest: mistralrs-cli/webui/src/lib/stores/chat.svelte.ts (1), mistralrs-cli/webui/src/lib/utils/markdown.ts (1), mistralrs-cli/webui/src/main.ts (1). Each one tells the compiler to trust the author about null, suppressing the very diagnostic `strictNullChecks` exists to produce. Many are correct: each is a claim the checker could not verify, and it is wrong only where the value can in fact be missing, so review the densest places first.

What to do

  • The findings name the configuration each number was taken from and, for the assertions, the files that hold them. Turn null checking on where it is off — `"strict": true` in the base tsconfig that the others extend switches `strictNullChecks` on with the rest of the family — and then resolve the assertions rather than adding to them. A `!` on a value the checker could show to be null is a promise the author cannot check from where they are standing, and each one is a `TypeError: Cannot read properties of null` waiting for the path that makes it true; where the value genuinely cannot be null, say something the checker can see instead (narrow it with a test, make the property required, drop the `?`).

WCAG coverage — what static analysis assessed

Statically assessed 11 of 55 WCAG 2.2 Level A/AA success criteria (20%; ≈22% of the 50 WCAG 2.1 AA criteria for EN 301 549). The other 44 require runtime or manual evaluation. Partial signal only (a clean result is necessary, not sufficient; static analysis fully verifies none). This is accessibility readiness, not a conformance claim — a WCAG conformance claim requires manual evaluation (WCAG-EM 1.0).

DimensionWCAG 2.2 A/AA criteriaCoverage
AC1 · Text alternatives1.1.1, 1.2.2, 1.2.5Partial signal
AC2 · Forms & labels1.3.1, 3.3.2, 4.1.2Partial signal
AC3 · Page structure1.4.4, 2.2.1, 2.4.1, 2.4.2, 3.1.1, 4.1.2Partial signal
AC5 · ARIA correctness4.1.2Partial signal

Not statically assessed — these 44 Level A/AA criteria need runtime or manual evaluation (WCAG-EM): 1.2.1, 1.2.3, 1.2.4, 1.3.2, 1.3.3, 1.3.4, 1.3.5, 1.4.1, 1.4.2, 1.4.3, 1.4.5, 1.4.10, 1.4.11, 1.4.12, 1.4.13, 2.1.1, 2.1.2, 2.1.4, 2.2.2, 2.3.1, 2.4.3, 2.4.4, 2.4.5, 2.4.6, 2.4.7, 2.4.11, 2.5.1, 2.5.2, 2.5.3, 2.5.4, 2.5.7, 2.5.8, 3.1.2, 3.2.1, 3.2.2, 3.2.3, 3.2.4, 3.2.6, 3.3.1, 3.3.3, 3.3.4, 3.3.7, 3.3.8, 4.1.3.

Reference — by lens

The score is the rank-weighted fold of these lenses (worst-heaviest), each including its meta-dimensions; a lens with a Critical contributor is capped at Fair (its band reads "gated by …") and is never the strongest area however high its average.

LensScoreRatingImpact
Code Health55%Adequate — gated by D2, D4, X4Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Architecture95%ExemplarySolid.
Maturity66%Adequate — gated by M2Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Readiness53%Adequate — gated by R4, P7Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Security44%Weak — gated by D29, C2Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Domain Modelling100%ExemplaryStrongest area.
Event Sourcing100%ExemplarySolid.
Accessibility83%StrongSolid.
Performance100%ExemplarySolid.
Unscored — 3 check(s) recorded observations but carry no score

These checks ran and found something, but they do not carry a score — either by design (an advisory check reports evidence rather than grading it) or because they could not be scored here. They are excluded from the score for that reason, not because there was nothing to see.

  • X10 Duplicated predicate — 40 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
  • X6 Hand-rolled structured-format parsing — 4 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
  • X7 Silent fallback defaults — 3 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
Not evidenced — 1 control(s) we could not find positive evidence for

These checks grade a working control, and the repository shows no evidence of one. That is deliberately not scored as a zero: a repository cannot show an ops runbook, a database TTL or an infrastructure-side audit log, so absence of evidence here is not evidence the control is missing. It is also not a statement that the check is irrelevant to this codebase — the thing it grades applies; we just could not see it. Excluded from the score either way.

  • P5 DR & Backup — not evidenced — repo shows no backup/RTO/RPO controls; absence of evidence is not evidence of a working control
Not included — 56 check(s) not relevant to this codebase

These checks had nothing to measure here (no tests, no git history, the codebase is small, or the architecture style doesn't apply), so they're omitted above rather than scored low.

  • AC4 Keyboard semantics — No interactive element found in the parsed markup — AC4 not applicable here.
  • AC6 Visual & motion safety — Visual & motion safety could not be assessed in this run — the check did not complete, so it is not scored. This is a gap in the analyzer, not a finding about this repository.
  • AX1 Captive dependencies — Not applicable: this repository's Python imports no dependency-injection container and defines no container of its own — nothing that both registers and resolves bindings, and nothing that names two lifetimes — so nothing holds one lifetime's instance while handing out another's; Rust with no dependency-injection crate has no container to hand one lifetime's instance to another — every value is owned by the code that builds it, and the borrow checker rejects a longer-lived value keeping a borrow of a shorter-lived one; this repository's TypeScript imports no dependency-injection container and defines no container of its own — nothing that both registers and resolves bindings, and nothing that names two lifetimes — so nothing holds one lifetime's instance while handing out another's.
  • AX2 Stateful singletons — No container singleton was found, so there is no shared instance for concurrent requests to race on. No function in this Python code is served by a threaded web framework (a Flask, Bottle or FastAPI route, a Django or Pyramid view), so no module is shared between request threads. Rust's compiler refuses unsynchronised shared mutation — a value shared across threads must be Sync — so the race this check looks for cannot be written. TypeScript/JavaScript runs each process's requests on one event loop, so no two requests write a shared object at the same instant (interleaving across an await is a different defect).
  • AX5 Architecture & structure — not assessed — architecture style/structure is computed from a project graph (projects, types, module namespaces) that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • AX6 Interface segregation — AX6 reached only 1% of this repository's production lines — rust (526,315 lines), python (27,226 lines), c (4,106 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
  • AX7 Slice cohesion — not applicable — not a vertical-slice architecture
  • AX8 Test isolation — no test/production split to check
  • AXB2 Runtime readiness — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
  • AXR1 Runtime accessibility — docker build failed (exit 1) — 24 | >>> COPY --chmod=755 dist/${TARGETARCH}/mistralrs /usr/local/bin/mistralrs 25 | # Chat templates for models that ship without one 26 | COPY chat_templates /chat_templates -------------------- ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref 0b61a2cf-39ec-49e5-90e1-4edf14df2394::6zynhec3i7hl0gmxnkzbs2nby: "/dist/amd64/mistralrs": not found; runtime evidence skipped This is a statement about this run, not a statement about your application: nothing here says the surface is inaccessible, only that it was never rendered.
  • C1 Data Protection — No personal data detected in a persisted data model — no PII-named field (email, first_name, date_of_birth, phone, …) or stored credential in a Diesel schema, a SeaORM entity, a Diesel or sqlx row struct, or a SQL CREATE TABLE or ALTER TABLE — and no database or data-store crate (sqlx, Diesel, SeaORM, rusqlite, tokio-postgres, MongoDB, …) in the source either, so this repository keeps no data at rest for these controls to protect.
  • C3 Audit Trail — No personal data detected in a persisted data model — no PII-named field (email, first_name, date_of_birth, phone, …) or stored credential in a Diesel schema, a SeaORM entity, a Diesel or sqlx row struct, or a SQL CREATE TABLE or ALTER TABLE — and no database or data-store crate (sqlx, Diesel, SeaORM, rusqlite, tokio-postgres, MongoDB, …) in the source either, so this repository keeps no sensitive data whose changes an audit trail would record. If it does (through a store configured outside this repository, for instance), the trail belongs to wherever that data is stored.
  • C4 Data Retention — No personal data detected in a persisted data model — no PII-named field (email, first_name, date_of_birth, phone, …) or stored credential in a Diesel schema, a SeaORM entity, a Diesel or sqlx row struct, or a SQL CREATE TABLE or ALTER TABLE — and no database or data-store crate (sqlx, Diesel, SeaORM, rusqlite, tokio-postgres, MongoDB, …) in the source either, so this repository keeps no personal data whose lifetime a retention limit would bound.
  • C5 Data-Subject Rights — No personal data detected in a persisted data model — no PII-named field (email, first_name, date_of_birth, phone, …) or stored credential in a Diesel schema, a SeaORM entity, a Diesel or sqlx row struct, or a SQL CREATE TABLE or ALTER TABLE — and no database or data-store crate (sqlx, Diesel, SeaORM, rusqlite, tokio-postgres, MongoDB, …) in the source either, so this repository keeps no personal data for a data subject to erase, export or consent over.
  • D11 Test Reliability — Test reliability not scored — polyglot repository, one half's runner produced no measurement
  • D16 Bus Factor — single-maintainer repository — bus factor is not applicable
  • D18 Solution Shape — D18 scores the shape of a .NET solution; this repository has no .NET solution or project files, so the dimension does not apply.
  • D22 Internal API Consistency — API consistency is measured on C# only; the exposed Rust surface was not measured.
  • D24 Comment Value — D24 reads C#, Visual Basic, TypeScript and JavaScript comments only; comments in this repository's .py, .rs source were not judged.
  • D25 ADR Conformance — no ADRs to check
  • D27 Navigability — D27 counts a call into the standard library or a dependency as unresolved for this repository's language (.rs), so too few call sites counted as resolved to assess navigability. Not scored: this is a gap in the analyzer, not a verdict about this repository.
  • D32 Data Compliance (PII/GDPR) — No personal data was found crossing a boundary the PII/GDPR ruleset checks — nothing written to a log or console sink, placed in a URL or query string, or persisted to browser storage. That is a clean result for the LEAK surface only: this ruleset detects personal data escaping, it does not inventory the personal data a repository holds, so it is not evidence that this repository has no personal-data surface. The personal-data map (Appendix C) and the C1-C5 compliance cards are what speak to that.
  • D40 Network Egress Confinement — No Kubernetes/orchestration workloads found in the repository manifests; network egress policy is a cluster-native control that may live at the platform/firewall layer, so there is nothing to assess here.
  • D41 Kernel & Syscall Confinement — No Kubernetes/orchestration workloads found in the repository manifests; seccomp/AppArmor/SELinux confinement is a workload-level control, so there is nothing to assess here.
  • D42 Runtime Threat Enforcement — No Kubernetes/orchestration workloads found in the repository manifests; runtime threat-detection and admission-control policy are cluster-level controls, so there is nothing to assess here.
  • D7 Architectural Integrity — no checkable ADRs, and no project-reference graph for the cycle pass to read — so this dimension makes no claim about dependency cycles in either direction (where this repository's language has an import-cycle lens, cycles are reported there). Architectural integrity not assessed
  • D8 Code Coverage — Coverage not measured — polyglot repository, one half has no runner
  • DM3 Integration-event coupling — not applicable: no DDD domain layer was detected (no aggregate, entity or value-object structure), so there is no domain model for this card to grade
  • DM6 Domain ↔ infrastructure boundary — this Rust crate maps no type to a persistence framework (diesel/sea-orm/sqlx), so DM6's domain↔infrastructure fusion read has no population to be taken over
  • DM7 Repository granularity — not applicable: no DDD domain layer was detected (no aggregate, entity or value-object structure), so there is no domain model for this card to grade
  • ED2 Event/command shape — not scored — deciding whether a command has more than one competing handler requires resolving the call graph, and a call made through an inferred or generic receiver has no resolvable owner in the source. Reported as guidance rather than measured
  • ED5 Idempotency — no mutating command handlers or message consumers detected — idempotency check not applicable
  • GD1 Unfinished & placeholder code — no source files were read — this check reads C#, F#, JavaScript/TypeScript, Dart, Ruby and Scala, and none was read for this repository's product. That is a limit of the analyzer, not a finding about your code.
  • IC1 Incompleteness & stubs — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • P12 CI test-gate honesty — Reported, not scored — and nothing was matched here. The coverage check applies to any stack, and the automatic-re-run check to any GitHub-Actions workflow, but the checks for excluded tests, skipped tests and sleep-based synchronisation currently recognise only some ecosystems' test-runner idioms, so on a repository built with another stack the zeros below mean 'not checked', not 'clean'.
  • P8 Schema migrations — no ORM, schema-migration tool or schema auto-create was found in this repository's dependency manifests or source, so there is no database schema for this check to judge
  • P9 Domain vs controller coverage — coverage data present for 6 file(s), but no domain-layer files were identified: no covered file's path contains any of the markers this check keys on (/domain/, /aggregates/, /valueobjects/, /domainmodel/, .domain/, /entities/), which are matched case-insensitively anywhere in the path. With no domain partition there is nothing to compare the web/controller layer against — if this repository keeps its business rules under a folder named none of those, that naming is what the check cannot see, not the domain logic.
  • PF1 Benchmark discipline — Not applicable: no benchmark suite was found. This check searched for `#[bench]`, criterion's `bench_function`/`bench_with_input`, `#[divan::bench]` or `#[library_benchmark]` in any `.rs` file, or criterion, divan, iai or a `[[bench]]` target in a Cargo.toml, and for a `*benchmark*` script that this repository's CI runs. Benchmarks are credited as a bonus, so their absence is neither scored nor deducted.
  • PF2 Allocation hygiene — Not scored: this check counted allocation-aware idioms (Span, pools, stackalloc) per line, which describes what kind of code a repository is rather than whether it has an allocation problem, so it was withdrawn. Nothing here is a finding about your code.
  • R11 Import Boundaries — No recognizable feature-sliced/layered src layout — boundary rules not applicable.
  • SC1 Supply-chain hygiene — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
  • X12 Unreachable branch — X12 reached only 6% of this repository's production lines — rust (526,315 lines), c (4,106 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
  • X13 Undrained process stream — X13 reached only 6% of this repository's production lines — rust (526,315 lines), c (4,106 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
  • X16 Unfloored truncation loop — X16 reached only 1% of this repository's production lines — rust (526,315 lines), python (27,226 lines), c (4,106 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
  • X17 Uncapped recursion over a caller-supplied document — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
  • X18 Disposal-pattern correctness — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
  • X19 Unrestored process-global state — X19 reached only 6% of this repository's production lines — rust (526,315 lines), c (4,106 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
  • X20 Mistyped argument guard — This check asks whether an argument guard reports an EMPTY value as a NULL one, which needs a language that throws a null-specific argument exception — .NET's ArgumentNullException, the JVM's NullPointerException, Dart's ArgumentError.notNull. This repository contains none of those languages: the ones it is written in have a single exception for a bad argument, so there is no pair of exceptions to confuse and nothing here for it to assess. Not a gap in the analyzer and not a finding about your code.
  • X22 Contradicted release guard — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
  • X23 Unguarded diagnostic materialisation — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
  • X24 Document value interpolated into markup unescaped — X24 reached only 6% of this repository's production lines — rust (526,315 lines), c (4,106 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
  • X25 Inert configuration knob — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
  • X26 Unsynchronised callback handoff — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
  • X3 Exception handling — X3 reached only 6% of this repository's production lines — rust (526,315 lines), c (4,106 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
  • X32 Type resolved by simple name across every loaded assembly — This check is about how a .NET program searches the assemblies loaded into its process for a type, and this repository contains no .NET source, so there is nothing here for it to assess. Not a gap in the analyzer and not a finding about your code.
  • X9 Subsumed condition operand — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.

Appendix A — Findings (grouped)

The findings behind the scores, grouped by severity, then by dimension and kind. The high-severity issues are enumerated in full below; items per group are capped at 25 with any overflow stated explicitly per group, never silently truncated. The complete machine-readable list of every finding (all severities) is the companion findings.md in this report's bundle.

Critical — 124 finding(s)
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • + 63 more in this group — see findings.md.
AC2 · Forms & labels · <input> without a programmatic label · ×8
  • <input> without a programmatic label mistralrs-cli/webui/src/lib/components/AgentApproval.svelte:93 — This control has only a placeholder — a placeholder is not a label (it vanishes on input and many AT ignore it). Add a <label for>, a wrapping <label>, or aria-label.
  • <input> without a programmatic label mistralrs-cli/webui/src/lib/components/ParamPopover.svelte:86 — This control has no associated label. Add a <label for> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
  • <input> without a programmatic label mistralrs-cli/webui/src/lib/components/ParamPopover.svelte:101 — This control has only a placeholder — a placeholder is not a label (it vanishes on input and many AT ignore it). Add a <label for>, a wrapping <label>, or aria-label.
  • <input> without a programmatic label mistralrs-cli/webui/src/lib/components/SettingsPanel.svelte:172 — This control has no associated label. Add a <label for> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
  • <input> without a programmatic label mistralrs-cli/webui/src/lib/components/SettingsPanel.svelte:188 — This control has no associated label. Add a <label for> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
  • <input> without a programmatic label mistralrs-cli/webui/src/lib/components/SettingsPanel.svelte:204 — This control has no associated label. Add a <label for> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
  • <input> without a programmatic label mistralrs-cli/webui/src/lib/components/SettingsPanel.svelte:218 — This control has no associated label. Add a <label for> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
  • <input> without a programmatic label mistralrs-cli/webui/src/lib/components/SettingsPanel.svelte:234 — This control has no associated label. Add a <label for> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
D31 · IaC & Container Security · High IaC · ×7
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D28 · Secrets (history) · REDACTED · ×3
  • REDACTED
  • REDACTED
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
AC2 · Forms & labels · <textarea> without a programmatic label · ×1
  • <textarea> without a programmatic label mistralrs-cli/webui/src/lib/components/SettingsPanel.svelte:149 — This control has only a placeholder — a placeholder is not a label (it vanishes on input and many AT ignore it). Add a <label for>, a wrapping <label>, or aria-label.
D29 · Static Analysis (SAST) · REDACTED · ×1
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED · ×1
  • REDACTED
D30 · Dependency Vulnerabilities · High vulnerability · ×1
  • REDACTED
D35 · Change Coupling · Boundary-crossing change coupling · ×1
  • Boundary-crossing change coupling: toml_selector.rs ↔ lib.rs mistralrs-core/src/toml_selector.rs:1 — `mistralrs-core/src/toml_selector.rs` (context mistralrs-core) and `mistralrs-pyo3/src/lib.rs` (context mistralrs-pyo3) sit in DIFFERENT parts of the tree yet change together 62% of the time (10 of the 16 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) — the bounded-context boundary may be in the wrong place, or one context is leaking into the other. This is the behavioural boundary violation a static scan can't see. You can check this without leaving the row: of the 10 shared commits counted here, the most recent 3 are `e124932c` fix(quant): misc fixes, warmup metal kernels (#2353); `3fb22c84` feat(quant): support isq/uqff/imatrix machinery for broader model cla…; `6927a4f2` Parallel + I/O pipelined ISQ (#1870) — run `git show` on any of them.
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
Serious — 4840 finding(s)
D3 · God Classes · FileTooLong · ×235
  • FileTooLong: loaders/multimodal_loaders.rs mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs — FileTooLong — 8156 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 7656 over it, 16.31× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: loaders/normal_loaders.rs mistralrs-core/src/pipeline/loaders/normal_loaders.rs — FileTooLong — 5477 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 4977 over it, 10.95× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: src/ops.rs mistralrs-core/src/ops.rs — FileTooLong — 5322 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 78 free functions. The bar is 500 significant lines; this is 4822 over it, 10.64× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: cuda/gdn.rs mistralrs-core/src/cuda/gdn.rs — FileTooLong — 4971 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 57 free functions. The bar is 500 significant lines; this is 4471 over it, 9.94× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: metal_kernels/mod.rs mistralrs-quant/src/metal_kernels/mod.rs — FileTooLong — 3992 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 72 free functions. The bar is 500 significant lines; this is 3492 over it, 7.98× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: pipeline/cuda_graph.rs mistralrs-core/src/pipeline/cuda_graph.rs — FileTooLong — 3106 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 77 free functions. The bar is 500 significant lines; this is 2606 over it, 6.21× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: src/layers.rs mistralrs-core/src/layers.rs — FileTooLong — 3101 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 37 free functions. The bar is 500 significant lines; this is 2601 over it, 6.20× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: speculative/dflash.rs mistralrs-core/src/speculative/dflash.rs — FileTooLong — 3051 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 2551 over it, 6.10× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: pipeline/multimodal.rs mistralrs-core/src/pipeline/multimodal.rs — FileTooLong — 2736 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 2236 over it, 5.47× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: pipeline/mod.rs mistralrs-core/src/pipeline/mod.rs — FileTooLong — 2497 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 1997 over it, 4.99× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: utils/ops.rs mistralrs-quant/src/utils/ops.rs — FileTooLong — 2448 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 1948 over it, 4.90× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: layers/paged_attention.rs mistralrs-core/src/paged_attention/layers/paged_attention.rs — FileTooLong — 2392 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 35 free functions. The bar is 500 significant lines; this is 1892 over it, 4.78× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: pipeline/normal.rs mistralrs-core/src/pipeline/normal.rs — FileTooLong — 2382 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 1882 over it, 4.76× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: src/lib.rs mistralrs-pyo3/src/lib.rs — FileTooLong — 2317 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 1817 over it, 4.63× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: pipeline/inputs_processor.rs mistralrs-core/src/pipeline/inputs_processor.rs — FileTooLong — 2293 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 1793 over it, 4.59× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: src/lib.rs mistralrs-core/src/lib.rs — FileTooLong — 2164 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 77% of them inside a single declaration: MistralRs (3 blocks, 462-3045). The bar is 500 significant lines; this is 1664 over it, 4.33× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: afq/ops.rs mistralrs-quant/src/afq/ops.rs — FileTooLong — 2095 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 1595 over it, 4.19× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: gguf/normal_config.rs mistralrs-core/src/gguf/normal_config.rs — FileTooLong — 2064 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 72 free functions. The bar is 500 significant lines; this is 1564 over it, 4.13× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: gemma4/text.rs mistralrs-core/src/vision_models/gemma4/text.rs — FileTooLong — 2056 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 1556 over it, 4.11× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: engine/mod.rs mistralrs-core/src/engine/mod.rs — FileTooLong — 2009 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 81% of them inside a single declaration: Engine (3 blocks, 205-2619). The bar is 500 significant lines; this is 1509 over it, 4.02× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: kv_cache/hybrid_cache.rs mistralrs-core/src/kv_cache/hybrid_cache.rs — FileTooLong — 1980 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 60% of them inside a single declaration: HybridCache (5 blocks, 1082-4229). The bar is 500 significant lines; this is 1480 over it, 3.96× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: models/granite.rs mistralrs-core/src/models/granite.rs — FileTooLong — 1950 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 1450 over it, 3.90× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: src/lib.rs mistralrs-quant/src/lib.rs — FileTooLong — 1912 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 39 free functions. The bar is 500 significant lines; this is 1412 over it, 3.82× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: src/sequence.rs mistralrs-core/src/sequence.rs — FileTooLong — 1831 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 1331 over it, 3.66× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: gguf/ffi.rs mistralrs-quant/src/gguf/ffi.rs — FileTooLong — 1755 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 1255 over it, 3.51× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • + 210 more in this group — see findings.md.
D3 · God Classes · MethodTooLong · ×223
  • MethodTooLong: Engine.run mistralrs-core/src/engine/mod.rs:1157 — MethodTooLong — run runs 1105 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 1005 over it, 11.05× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: MultimodalLoader.load_model_from_path mistralrs-core/src/pipeline/multimodal.rs:526 — MethodTooLong — load_model_from_path runs 964 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 864 over it, 9.64× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: Pipeline.submit_step mistralrs-core/src/pipeline/mod.rs:2255 — MethodTooLong — submit_step runs 804 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 704 over it, 8.04× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: NormalLoader.load_model_from_path mistralrs-core/src/pipeline/normal.rs:659 — MethodTooLong — load_model_from_path runs 771 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 671 over it, 7.71× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: Engine.add_request mistralrs-core/src/engine/add_request.rs:156 — MethodTooLong — add_request runs 738 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 638 over it, 7.38× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: GridImageProcessor.process_inputs mistralrs-core/src/vision_models/grid_processor.rs:1139 — MethodTooLong — process_inputs runs 570 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 470 over it, 5.70× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: Qwen2_5VLImageProcessor.process_inputs mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:352 — MethodTooLong — process_inputs runs 516 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 416 over it, 5.16× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: Qwen2VLImageProcessor.process_inputs mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:918 — MethodTooLong — process_inputs runs 516 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 416 over it, 5.16× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: Gemma4ImageProcessor.process_inputs mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1025 — MethodTooLong — process_inputs runs 512 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 412 over it, 5.12× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: EmbeddingLoader.load_model_from_path mistralrs-core/src/pipeline/embedding.rs:209 — MethodTooLong — load_model_from_path runs 445 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 345 over it, 4.45× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: Gemma4Model.forward_inner mistralrs-core/src/vision_models/gemma4/mod.rs:341 — MethodTooLong — forward_inner runs 436 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 336 over it, 4.36× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: ImageEmbedding.forward mistralrs-core/src/vision_models/phi3/mod.rs:697 — MethodTooLong — forward runs 346 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 246 over it, 3.46× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: OpenResponsesStreamer.poll_next mistralrs-server-core/src/responses.rs:1158 — MethodTooLong — poll_next runs 329 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 229 over it, 3.29× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: MistralRsForServerBuilder.build_multi_model mistralrs-server-core/src/mistralrs_for_server_builder.rs:911 — MethodTooLong — build_multi_model runs 325 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 225 over it, 3.25× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: HqqBits.bitpack_type mistralrs-quant/src/hqq/mod.rs:156 — MethodTooLong — bitpack_type runs 306 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 206 over it, 3.06× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: PagedAttentionScheduler.schedule mistralrs-core/src/paged_attention/scheduler.rs:930 — MethodTooLong — schedule runs 299 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 199 over it, 2.99× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: Qwen3VLModel.forward mistralrs-core/src/vision_models/qwen3_vl/mod.rs:653 — MethodTooLong — forward runs 292 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 192 over it, 2.92× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: Qwen3VLMoEModel.forward mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:99 — MethodTooLong — forward runs 292 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 192 over it, 2.92× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: LLaVAInputProcessor.process_inputs mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:273 — MethodTooLong — process_inputs runs 291 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 191 over it, 2.91× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: LLaVANextInputProcessor.process_inputs mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:309 — MethodTooLong — process_inputs runs 284 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 184 over it, 2.84× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: Qwen3_5TextModel.forward_embeds mistralrs-core/src/vision_models/qwen3_5/text.rs:1358 — MethodTooLong — forward_embeds runs 280 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 180 over it, 2.80× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: PagedAttention.metal_fwd mistralrs-paged-attn/src/metal/backend/paged_attention.rs:321 — MethodTooLong — metal_fwd runs 280 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 180 over it, 2.80× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: MLlamaImageProcessor.process_inputs mistralrs-core/src/vision_models/mllama/inputs_processor.rs:320 — MethodTooLong — process_inputs runs 277 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 177 over it, 2.77× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: ImageEmbedding.forward mistralrs-core/src/vision_models/phi4/image_embedding.rs:465 — MethodTooLong — forward runs 273 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 173 over it, 2.73× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: Gemma3nLoader.non_mapped_size_in_bytes mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6002 — MethodTooLong — non_mapped_size_in_bytes runs 266 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 166 over it, 2.66× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • + 198 more in this group — see findings.md.
D3 · God Classes · FunctionTooLong · ×184
  • FunctionTooLong: mistralrs_core::model_loader::loader_from_model_selected mistralrs-core/src/model_loader.rs:292 — FunctionTooLong — mistralrs_core::model_loader::loader_from_model_selected runs 572 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 472 over it, 5.72× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: mistralrs_core::pipeline::inputs_processor::text_models_inputs_processor::make_prompt_chunk mistralrs-core/src/pipeline/inputs_processor.rs:872 — FunctionTooLong — mistralrs_core::pipeline::inputs_processor::text_models_inputs_processor::make_prompt_chunk runs 564 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 464 over it, 5.64× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: mistralrs_quant::afq::ops::cuda_backend::afq_mm_op mistralrs-quant/src/afq/ops.rs:2588 — FunctionTooLong — mistralrs_quant::afq::ops::cuda_backend::afq_mm_op runs 513 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 413 over it, 5.13× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: mistralrs_pyo3::parse_which mistralrs-pyo3/src/lib.rs:715 — FunctionTooLong — mistralrs_pyo3::parse_which runs 431 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 331 over it, 4.31× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: mistralrs_server_core::chat_completion::parse_request mistralrs-server-core/src/chat_completion.rs:605 — FunctionTooLong — mistralrs_server_core::chat_completion::parse_request runs 430 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 330 over it, 4.30× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: mistralrs_core::cuda::gdn::speculative_recurrence_checkpoints_cuda mistralrs-core/src/cuda/gdn.rs:3813 — FunctionTooLong — mistralrs_core::cuda::gdn::speculative_recurrence_checkpoints_cuda runs 410 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 310 over it, 4.10× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: mistralrs_quant::afq::ops::cuda_backend::afq_dequantize_op mistralrs-quant/src/afq/ops.rs:2102 — FunctionTooLong — mistralrs_quant::afq::ops::cuda_backend::afq_dequantize_op runs 400 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 300 over it, 4.00× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: mistralrs_core::toml_selector::loader_from_selected mistralrs-core/src/toml_selector.rs:808 — FunctionTooLong — mistralrs_core::toml_selector::loader_from_selected runs 398 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 298 over it, 3.98× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: mistralrs_core::pipeline::sampling::finish_or_add_toks_to_seq mistralrs-core/src/pipeline/sampling.rs:189 — FunctionTooLong — mistralrs_core::pipeline::sampling::finish_or_add_toks_to_seq runs 397 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 297 over it, 3.97× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: mistralrs_quant::cutile::routed_lora::routed_lora_kernel::routed_lora_one_shot mistralrs-quant/src/cutile/routed_lora.rs:69 — FunctionTooLong — mistralrs_quant::cutile::routed_lora::routed_lora_kernel::routed_lora_one_shot runs 379 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 279 over it, 3.79× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: mistralrs_quant::cutile::fused_moe_fp8::fused_moe_fp8::fused_moe_fp8_kernel mistralrs-quant/src/cutile/fused_moe_fp8.rs:48 — FunctionTooLong — mistralrs_quant::cutile::fused_moe_fp8::fused_moe_fp8::fused_moe_fp8_kernel runs 358 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 258 over it, 3.58× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: mistralrs_paged_attn::cuda::backend::mla::flashinfer_mla_decode mistralrs-paged-attn/src/cuda/backend/mla.rs:227 — FunctionTooLong — mistralrs_paged_attn::cuda::backend::mla::flashinfer_mla_decode runs 350 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 250 over it, 3.50× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: mistralrs_quant::cutile::qsa_decode::kernels::qsa_attention_split mistralrs-quant/src/cutile/qsa_decode.rs:31 — FunctionTooLong — mistralrs_quant::cutile::qsa_decode::kernels::qsa_attention_split runs 337 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 237 over it, 3.37× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: mistralrs_quant::cutile::fused_moe::fused_moe::fused_moe_kernel mistralrs-quant/src/cutile/fused_moe.rs:36 — FunctionTooLong — mistralrs_quant::cutile::fused_moe::fused_moe::fused_moe_kernel runs 329 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 229 over it, 3.29× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: mistralrs_core::cuda::gdn::deferred_recurrence_rmsnorm_gate_cuda mistralrs-core/src/cuda/gdn.rs:4368 — FunctionTooLong — mistralrs_core::cuda::gdn::deferred_recurrence_rmsnorm_gate_cuda runs 326 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 226 over it, 3.26× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: mistralrs_quant::afq::ops::cuda_backend::afq_quantize_op mistralrs-quant/src/afq/ops.rs:1706 — FunctionTooLong — mistralrs_quant::afq::ops::cuda_backend::afq_quantize_op runs 309 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 209 over it, 3.09× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: mistralrs_core::speculative::driver::verify_staged_batch mistralrs-core/src/speculative/driver.rs:348 — FunctionTooLong — mistralrs_core::speculative::driver::verify_staged_batch runs 279 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 179 over it, 2.79× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: mistralrs_paged_attn::metal::backend::paged_prefill::metal_paged_prefill mistralrs-paged-attn/src/metal/backend/paged_prefill.rs:434 — FunctionTooLong — mistralrs_paged_attn::metal::backend::paged_prefill::metal_paged_prefill runs 270 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 170 over it, 2.70× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: mistralrs_quant::cutile::qsa::kernels::qsa_attention mistralrs-quant/src/cutile/qsa.rs:264 — FunctionTooLong — mistralrs_quant::cutile::qsa::kernels::qsa_attention runs 260 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 160 over it, 2.60× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: mistralrs_core::paged_attention::plan::gather_prefill_workspace_bytes mistralrs-core/src/paged_attention/plan.rs:506 — FunctionTooLong — mistralrs_core::paged_attention::plan::gather_prefill_workspace_bytes runs 259 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 159 over it, 2.59× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: mistralrs_paged_attn::cuda::backend::fa3::fa3_fp8_decode mistralrs-paged-attn/src/cuda/backend/fa3.rs:318 — FunctionTooLong — mistralrs_paged_attn::cuda::backend::fa3::fa3_fp8_decode runs 259 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 159 over it, 2.59× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: mistralrs_core::pipeline::loaders::auto_device_map::get_device_layers_attempt mistralrs-core/src/pipeline/loaders/auto_device_map.rs:262 — FunctionTooLong — mistralrs_core::pipeline::loaders::auto_device_map::get_device_layers_attempt runs 258 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 158 over it, 2.58× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: mistralrs_core::diagnostics::run_doctor mistralrs-core/src/diagnostics.rs:415 — FunctionTooLong — mistralrs_core::diagnostics::run_doctor runs 252 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 152 over it, 2.52× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: mistralrs_cli::commands::serve::convert_text_model mistralrs-cli/src/commands/serve.rs:537 — FunctionTooLong — mistralrs_cli::commands::serve::convert_text_model runs 251 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 151 over it, 2.51× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: mistralrs_paged_attn::cuda::backend::flashinfer::flashinfer_decode mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:241 — FunctionTooLong — mistralrs_paged_attn::cuda::backend::flashinfer::flashinfer_decode runs 250 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 150 over it, 2.50× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • + 159 more in this group — see findings.md.
D2 · Cognitive Complexity · mistralrs_core · ×133
  • mistralrs_core::pipeline::sampling::finish_or_add_toks_to_seq (cognitive 263) mistralrs-core/src/pipeline/sampling.rs:189 — mistralrs_core::pipeline::sampling::finish_or_add_toks_to_seq has cognitive complexity 263 (threshold 15). Drivers by points: if/else 79 (215 pts), loops 5 (29 pts), boolean chains 12, match/switch 3 (7 pts) (nesting depth added 164). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • mistralrs_core::vision_models::qwen3_vl::get_rope_index (cognitive 177) mistralrs-core/src/vision_models/qwen3_vl/mod.rs:55 — mistralrs_core::vision_models::qwen3_vl::get_rope_index has cognitive complexity 177 (threshold 15). Drivers by points: if/else 28 (92 pts), loops 18 (62 pts), match/switch 6 (17 pts), boolean chains 6 (nesting depth added 119). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_core::pipeline::inputs_processor::text_models_inputs_processor::make_prompt_chunk (cognitive 137) mistralrs-core/src/pipeline/inputs_processor.rs:872 — mistralrs_core::pipeline::inputs_processor::text_models_inputs_processor::make_prompt_chunk has cognitive complexity 137 (threshold 15). Drivers by points: if/else 65 (114 pts), loops 7 (18 pts), boolean chains 5 (nesting depth added 60). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_core::pipeline::paths::get_adapter_paths (cognitive 119) mistralrs-core/src/pipeline/paths.rs:75 — mistralrs_core::pipeline::paths::get_adapter_paths has cognitive complexity 119 (threshold 15). Drivers by points: if/else 32 (83 pts), loops 9 (30 pts), match/switch 2 (4 pts), boolean chains 2 (nesting depth added 74). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_core::pipeline::paths::get_chat_template (cognitive 83) mistralrs-core/src/pipeline/paths.rs:568 — mistralrs_core::pipeline::paths::get_chat_template has cognitive complexity 83 (threshold 15). Drivers by points: if/else 31 (71 pts), loops 1 (7 pts), match/switch 3 (5 pts) (nesting depth added 48). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • mistralrs_core::attention::backends::cpu::full::compute_tiled_qblock (cognitive 82) mistralrs-core/src/attention/backends/cpu/full.rs:195 — mistralrs_core::attention::backends::cpu::full::compute_tiled_qblock has cognitive complexity 82 (threshold 15). Drivers by points: if/else 16 (43 pts), loops 13 (35 pts), match/switch 1 (3 pts), boolean chains 1 (nesting depth added 51). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_core::mla::forward::mla_cache_forward (cognitive 82) mistralrs-core/src/mla/forward.rs:356 — mistralrs_core::mla::forward::mla_cache_forward has cognitive complexity 82 (threshold 15). Drivers by points: if/else 33 (66 pts), loops 5 (13 pts), match/switch 1 (2 pts), boolean chains 1 (nesting depth added 42). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_core::engine::agentic_loop::agentic_loop (cognitive 81) mistralrs-core/src/engine/agentic_loop.rs:1256 — mistralrs_core::engine::agentic_loop::agentic_loop has cognitive complexity 81 (threshold 15). Drivers by points: if/else 27 (57 pts), match/switch 4 (12 pts), loops 5 (9 pts), boolean chains 3 (nesting depth added 42). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_core::pipeline::loaders::auto_device_map::get_device_layers_attempt (cognitive 77) mistralrs-core/src/pipeline/loaders/auto_device_map.rs:262 — mistralrs_core::pipeline::loaders::auto_device_map::get_device_layers_attempt has cognitive complexity 77 (threshold 15). Drivers by points: if/else 38 (62 pts), boolean chains 7, loops 3 (5 pts), match/switch 3 (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_core::diagnostics::run_doctor (cognitive 72) mistralrs-core/src/diagnostics.rs:415 — mistralrs_core::diagnostics::run_doctor has cognitive complexity 72 (threshold 15). Drivers by points: if/else 41 (61 pts), boolean chains 6, loops 3, match/switch 1 (2 pts) (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_core::cuda::gdn::speculative_recurrence_checkpoints_cuda::cuda_fwd (cognitive 71) mistralrs-core/src/cuda/gdn.rs:3821 — mistralrs_core::cuda::gdn::speculative_recurrence_checkpoints_cuda::cuda_fwd has cognitive complexity 71 (threshold 15). Drivers by points: if/else 35 (38 pts), boolean chains 25, match/switch 5 (6 pts), loops 2 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • mistralrs_core::pipeline::isq::gguf_imatrix_names (cognitive 68) mistralrs-core/src/pipeline/isq.rs:1405 — mistralrs_core::pipeline::isq::gguf_imatrix_names has cognitive complexity 68 (threshold 15). Drivers by points: if/else 57 (61 pts), boolean chains 7 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • mistralrs_core::pipeline::sampling::sample_sequence (cognitive 61) mistralrs-core/src/pipeline/sampling.rs:1450 — mistralrs_core::pipeline::sampling::sample_sequence has cognitive complexity 61 (threshold 15). Drivers by points: if/else 20 (43 pts), boolean chains 10, loops 1 (5 pts), match/switch 3 (nesting depth added 27). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • mistralrs_core::ops::try_cuda_qk_rms_norm_rope_positions (cognitive 56) mistralrs-core/src/ops.rs:6014 — mistralrs_core::ops::try_cuda_qk_rms_norm_rope_positions has cognitive complexity 56 (threshold 15). Drivers by points: if/else 34 (40 pts), match/switch 8 (10 pts), boolean chains 5, loops 1 (nesting depth added 8). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • mistralrs_core::ops::try_cuda_qk_rms_norm_rope (cognitive 55) mistralrs-core/src/ops.rs:5585 — mistralrs_core::ops::try_cuda_qk_rms_norm_rope has cognitive complexity 55 (threshold 15). Drivers by points: if/else 32 (38 pts), match/switch 9 (11 pts), boolean chains 5, loops 1 (nesting depth added 8). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • mistralrs_core::pipeline::isq_flow::plan::resolve_and_install_isq_plan (cognitive 54) mistralrs-core/src/pipeline/isq_flow/plan.rs:141 — mistralrs_core::pipeline::isq_flow::plan::resolve_and_install_isq_plan has cognitive complexity 54 (threshold 15). Drivers by points: if/else 29 (38 pts), boolean chains 14, loops 1 (2 pts) (nesting depth added 10). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • mistralrs_core::attention::backends::cpu::mask::mask_offset (cognitive 51) mistralrs-core/src/attention/backends/cpu/mask.rs:65 — mistralrs_core::attention::backends::cpu::mask::mask_offset has cognitive complexity 51 (threshold 15). Drivers by points: if/else 27 (42 pts), boolean chains 6, loops 1 (2 pts), match/switch 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_core::pipeline::inputs_processor::text_models_inputs_processor::make_completion_chunk (cognitive 48) mistralrs-core/src/pipeline/inputs_processor.rs:1582 — mistralrs_core::pipeline::inputs_processor::text_models_inputs_processor::make_completion_chunk has cognitive complexity 48 (threshold 15). Drivers by points: if/else 21 (31 pts), loops 3 (7 pts), match/switch 3 (6 pts), boolean chains 4 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_core::distributed::prepare_distributed_mapper (cognitive 46) mistralrs-core/src/distributed.rs:569 — mistralrs_core::distributed::prepare_distributed_mapper has cognitive complexity 46 (threshold 15). Drivers by points: if/else 26 (35 pts), loops 3 (6 pts), boolean chains 4, match/switch 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_core::vision_models::lfm3_d1::prompt::render_question (cognitive 45) mistralrs-core/src/vision_models/lfm3_d1/prompt.rs:628 — mistralrs_core::vision_models::lfm3_d1::prompt::render_question has cognitive complexity 45 (threshold 15). Drivers by points: if/else 16 (29 pts), loops 4 (9 pts), match/switch 4 (6 pts), boolean chains 1 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_core::speculative::driver::verify_staged_batch (cognitive 44) mistralrs-core/src/speculative/driver.rs:348 — mistralrs_core::speculative::driver::verify_staged_batch has cognitive complexity 44 (threshold 15). Drivers by points: if/else 17 (31 pts), loops 10 (11 pts), boolean chains 2 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_core::speculative::hybrid_state::replay_gdn_prefixes (cognitive 43) mistralrs-core/src/speculative/hybrid_state.rs:345 — mistralrs_core::speculative::hybrid_state::replay_gdn_prefixes has cognitive complexity 43 (threshold 15). Drivers by points: if/else 17 (31 pts), loops 4 (7 pts), boolean chains 4, match/switch 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_core::gguf::normal_bindings::bind_block_tensor (cognitive 41) mistralrs-core/src/gguf/normal_bindings.rs:118 — mistralrs_core::gguf::normal_bindings::bind_block_tensor has cognitive complexity 41 (threshold 15). Drivers by points: if/else 11 (21 pts), match/switch 6 (11 pts), boolean chains 9 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_core::paged_attention::plan::prompt_prefill_workspace (cognitive 41) mistralrs-core/src/paged_attention/plan.rs:1091 — mistralrs_core::paged_attention::plan::prompt_prefill_workspace has cognitive complexity 41 (threshold 15). Drivers by points: if/else 17 (28 pts), boolean chains 11, loops 1, match/switch 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_core::pipeline::chat_template::calculate_eos_tokens (cognitive 41) mistralrs-core/src/pipeline/chat_template.rs:175 — mistralrs_core::pipeline::chat_template::calculate_eos_tokens has cognitive complexity 41 (threshold 15). Drivers by points: if/else 9 (23 pts), loops 5 (10 pts), match/switch 2 (6 pts), boolean chains 2 (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • + 108 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (9 lines × 2) · ×97
  • Duplicated block (9 lines × 2) mistralrs-cli/src/commands/quantize.rs:201 — mistralrs-cli/src/commands/quantize.rs:201-209 | mistralrs-cli/src/commands/serve.rs:1117-1125 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-cli/src/commands/quantize.rs:201` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) mistralrs-core/src/attention/backends/cpu/avx.rs:34 — mistralrs-core/src/attention/backends/cpu/avx.rs:34-42 | mistralrs-core/src/attention/backends/cpu/avx.rs:277-285 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/attention/backends/cpu/avx.rs:34` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) mistralrs-core/src/attention/backends/cpu/neon.rs:3 — mistralrs-core/src/attention/backends/cpu/neon.rs:3-11 | mistralrs-core/src/attention/backends/cpu/neon.rs:137-145 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/attention/backends/cpu/neon.rs:3` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) mistralrs-core/src/attention/backends/flash.rs:68 — mistralrs-core/src/attention/backends/flash.rs:68-76 | mistralrs-core/src/attention/backends/flash.rs:159-167 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/attention/backends/flash.rs:68` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/attention/backends/flash.rs:77` calls `Some` and `mistralrs-core/src/attention/backends/flash.rs:168` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 2) mistralrs-core/src/cuda/gated_add.rs:92 — mistralrs-core/src/cuda/gated_add.rs:92-100 | mistralrs-core/src/cuda/rounded_rope.rs:113-121 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/gated_add.rs:92` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) mistralrs-core/src/cuda/gdn.rs:1133 — mistralrs-core/src/cuda/gdn.rs:1133-1141 | mistralrs-core/src/cuda/gdn.rs:1246-1255 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/gdn.rs:1133` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (9 lines × 2) mistralrs-core/src/embedding_models/inputs_processor.rs:24 — mistralrs-core/src/embedding_models/inputs_processor.rs:24-32 | mistralrs-core/src/pipeline/inputs_processor.rs:162-170 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (9 lines × 2) mistralrs-core/src/embedding_models/qwen3_embedding.rs:376 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:376-384 | mistralrs-core/src/models/flint.rs:826-834 — before extracting anything, compare `mistralrs-core/src/embedding_models/qwen3_embedding.rs` and `mistralrs-core/src/models/flint.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 68 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/qwen3_embedding.rs:376` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) mistralrs-core/src/lib.rs:872 — mistralrs-core/src/lib.rs:872-880 | mistralrs-core/src/lib.rs:920-928 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/lib.rs:872` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) mistralrs-core/src/lib.rs:2528 — mistralrs-core/src/lib.rs:2528-2536 | mistralrs-core/src/lib.rs:2591-2599 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/lib.rs:2528` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) mistralrs-core/src/metal/gdn.rs:163 — mistralrs-core/src/metal/gdn.rs:163-171 | mistralrs-core/src/metal/gdn.rs:274-282 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/metal/gdn.rs:163` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) mistralrs-core/src/metal/gdn.rs:179 — mistralrs-core/src/metal/gdn.rs:179-187 | mistralrs-core/src/metal/gdn.rs:294-302 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/metal/gdn.rs:179` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) mistralrs-core/src/metal/gdn.rs:754 — mistralrs-core/src/metal/gdn.rs:754-762 | mistralrs-core/src/metal/gdn.rs:939-947 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/metal/gdn.rs:754` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) mistralrs-core/src/models/glm4.rs:228 — mistralrs-core/src/models/glm4.rs:228-236 | mistralrs-core/src/models/glm4_moe.rs:290-298 — before extracting anything, compare `mistralrs-core/src/models/glm4.rs` and `mistralrs-core/src/models/glm4_moe.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 359 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/glm4.rs:228` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) mistralrs-core/src/models/llama.rs:251 — mistralrs-core/src/models/llama.rs:251-259 | mistralrs-core/src/models/smollm3.rs:267-275 — before extracting anything, compare `mistralrs-core/src/models/llama.rs` and `mistralrs-core/src/models/smollm3.rs` as WHOLE FILES: this scan already matched 47 separate duplicated blocks between them, totalling at least 727 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (9 lines × 2) mistralrs-core/src/models/mixtral.rs:512 — mistralrs-core/src/models/mixtral.rs:512-520 | mistralrs-core/src/models/starcoder2.rs:513-521 — before extracting anything, compare `mistralrs-core/src/models/mixtral.rs` and `mistralrs-core/src/models/starcoder2.rs` as WHOLE FILES: this scan already matched 41 separate duplicated blocks between them, totalling at least 495 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/mixtral.rs:512` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) mistralrs-core/src/models/phi3_5_moe.rs:597 — mistralrs-core/src/models/phi3_5_moe.rs:597-605 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:507-515 — before extracting anything, compare `mistralrs-core/src/models/phi3_5_moe.rs` and `mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 174 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/phi3_5_moe.rs:597` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) mistralrs-core/src/models/qwen3_next.rs:1190 — mistralrs-core/src/models/qwen3_next.rs:1190-1198 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:527-535 — before extracting anything, compare `mistralrs-core/src/models/qwen3_next.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/text.rs` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 461 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/qwen3_next.rs:1190` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) mistralrs-core/src/moe/experts/mod.rs:181 — mistralrs-core/src/moe/experts/mod.rs:181-189 | mistralrs-core/src/moe/experts/mod.rs:252-260 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/moe/experts/mod.rs:181` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) mistralrs-core/src/ops.rs:1130 — mistralrs-core/src/ops.rs:1130-1138 | mistralrs-core/src/ops.rs:2189-2197 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:1130` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/ops.rs:2187` calls `F32` and `mistralrs-core/src/ops.rs:1129` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 2) mistralrs-core/src/ops.rs:2101 — mistralrs-core/src/ops.rs:2101-2109 | mistralrs-core/src/ops.rs:2258-2266 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:2101` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (9 lines × 2) mistralrs-core/src/ops.rs:2771 — mistralrs-core/src/ops.rs:2771-2779 | mistralrs-core/src/ops.rs:2814-2822 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:2771` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: `mistralrs-core/src/ops.rs:2771` is reached only past a guard at line 2760 that tests `pending.producer_stream` and leaves the function early, and `mistralrs-core/src/ops.rs:2814` reads `pending.producer_stream` with no such check. What separates these copies is not which lines they run but which PRECONDITION they enforce, so one of them is operating on state the other one refuses. Decide which is intended BEFORE unifying them — extract the shared part and whichever copy is missing the check keeps running unchecked, and if the guard is the correct behaviour then that hole is already live.
  • Duplicated block (9 lines × 2) mistralrs-core/src/ops.rs:4491 — mistralrs-core/src/ops.rs:4491-4499 | mistralrs-core/src/ops.rs:5458-5466 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:4491` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) mistralrs-core/src/ops.rs:4845 — mistralrs-core/src/ops.rs:4845-4853 | mistralrs-quant/src/metal_fp8.rs:76-84 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:4845` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) mistralrs-core/src/paged_attention/scheduler.rs:1076 — mistralrs-core/src/paged_attention/scheduler.rs:1076-1084 | mistralrs-core/src/paged_attention/scheduler.rs:1112-1120 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • + 72 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (8 lines × 2) · ×95
  • Duplicated block (8 lines × 2) mistralrs-cli/src/commands/run/mod.rs:136 — mistralrs-cli/src/commands/run/mod.rs:136-143 | mistralrs-cli/src/commands/run/mod.rs:165-172 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (8 lines × 2) mistralrs-cli/src/commands/serve.rs:707 — mistralrs-cli/src/commands/serve.rs:707-714 | mistralrs-cli/src/commands/serve.rs:764-771 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-cli/src/commands/serve.rs:707` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) mistralrs-cli/src/commands/serve.rs:879 — mistralrs-cli/src/commands/serve.rs:879-886 | mistralrs-cli/src/commands/serve.rs:891-898 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (8 lines × 2) mistralrs-core/src/attention/backends/cpu/neon.rs:268 — mistralrs-core/src/attention/backends/cpu/neon.rs:268-275 | mistralrs-core/src/attention/backends/cpu/neon.rs:511-518 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/attention/backends/cpu/neon.rs:268` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/attention/backends/cpu/neon.rs:519` calls `out` and `mistralrs-core/src/attention/backends/cpu/neon.rs:276` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (8 lines × 2) mistralrs-core/src/attention/backends/cpu/neon.rs:288 — mistralrs-core/src/attention/backends/cpu/neon.rs:288-295 | mistralrs-core/src/attention/backends/cpu/neon.rs:532-539 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/attention/backends/cpu/neon.rs:288` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `b` to `&[half::f16]` in one and `&[half::bf16]` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (8 lines × 2) mistralrs-core/src/cuda/gdn.rs:3172 — mistralrs-core/src/cuda/gdn.rs:3172-3179 | mistralrs-core/src/cuda/gdn.rs:3182-3189 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/gdn.rs:3172` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) mistralrs-core/src/decision.rs:87 — mistralrs-core/src/decision.rs:87-94 | mistralrs-core/src/decision.rs:100-107 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/decision.rs:87` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) mistralrs-core/src/diffusion_models/t5/mod.rs:525 — mistralrs-core/src/diffusion_models/t5/mod.rs:525-532 | mistralrs-core/src/diffusion_models/t5/mod.rs:599-606 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/diffusion_models/t5/mod.rs:525` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) mistralrs-core/src/gdn/layer.rs:213 — mistralrs-core/src/gdn/layer.rs:213-220 | mistralrs-core/src/gdn/layer.rs:336-343 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/gdn/layer.rs:213` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (8 lines × 2) mistralrs-core/src/gguf/normal_config.rs:1640 — mistralrs-core/src/gguf/normal_config.rs:1640-1647 | mistralrs-core/src/gguf/normal_config.rs:2376-2383 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/gguf/normal_config.rs:1640` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) mistralrs-core/src/kv_cache/hybrid_cache.rs:1204 — mistralrs-core/src/kv_cache/hybrid_cache.rs:1204-1211 | mistralrs-core/src/kv_cache/hybrid_cache.rs:2064-2071 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (8 lines × 2) mistralrs-core/src/kv_cache/hybrid_cache.rs:1271 — mistralrs-core/src/kv_cache/hybrid_cache.rs:1271-1278 | mistralrs-core/src/kv_cache/hybrid_cache.rs:2128-2135 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/kv_cache/hybrid_cache.rs:1271` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) mistralrs-core/src/kv_cache/hybrid_cache.rs:1800 — mistralrs-core/src/kv_cache/hybrid_cache.rs:1800-1807 | mistralrs-core/src/speculative/gdn_transitions.rs:165-172 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/kv_cache/hybrid_cache.rs:1800` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) mistralrs-core/src/layers.rs:1633 — mistralrs-core/src/layers.rs:1633-1640 | mistralrs-core/src/layers.rs:1944-1951 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/layers.rs:1633` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) mistralrs-core/src/metal/gdn.rs:319 — mistralrs-core/src/metal/gdn.rs:319-326 | mistralrs-core/src/metal/gdn.rs:980-987 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (8 lines × 2) mistralrs-core/src/ops.rs:596 — mistralrs-core/src/ops.rs:596-603 | mistralrs-core/src/ops.rs:758-765 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:596` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) mistralrs-core/src/ops.rs:2049 — mistralrs-core/src/ops.rs:2049-2056 | mistralrs-core/src/ops.rs:2182-2189 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (8 lines × 2) mistralrs-core/src/ops.rs:7036 — mistralrs-core/src/ops.rs:7036-7043 | mistralrs-core/src/ops.rs:7092-7099 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:7036` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) mistralrs-core/src/paged_attention/cache_engine.rs:457 — mistralrs-core/src/paged_attention/cache_engine.rs:457-464 | mistralrs-core/src/paged_attention/cache_engine.rs:495-502 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/paged_attention/cache_engine.rs:457` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) mistralrs-core/src/pipeline/chat_template.rs:511 — mistralrs-core/src/pipeline/chat_template.rs:511-518 | mistralrs-core/src/pipeline/chat_template.rs:582-589 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/chat_template.rs:511` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) mistralrs-core/src/pipeline/hf.rs:655 — mistralrs-core/src/pipeline/hf.rs:655-662 | mistralrs-core/src/pipeline/hf.rs:679-686 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (8 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1308 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1308-1315 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4927-4934 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1308` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6502 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6502-6509 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6781-6788 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6502` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (8 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:2761 — mistralrs-core/src/pipeline/multimodal.rs:2761-2768 | mistralrs-core/src/pipeline/normal.rs:2325-2332 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (8 lines × 2) mistralrs-core/src/reasoning_parsers/harmony.rs:349 — mistralrs-core/src/reasoning_parsers/harmony.rs:349-356 | mistralrs-core/src/reasoning_parsers/harmony.rs:388-395 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • + 70 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (6 lines × 2) · ×95
  • Duplicated block (6 lines × 2) mistralrs-cli/src/commands/bench.rs:69 — mistralrs-cli/src/commands/bench.rs:69-74 | mistralrs-cli/src/commands/serve.rs:921-926 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-cli/src/commands/bench.rs:69` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) mistralrs-cli/src/commands/serve.rs:932 — mistralrs-cli/src/commands/serve.rs:932-939 | mistralrs-cli/src/commands/serve.rs:968-973 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (6 lines × 2) mistralrs-code-exec/src/lib.rs:497 — mistralrs-code-exec/src/lib.rs:497-502 | mistralrs-code-exec/src/lib.rs:547-552 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-code-exec/src/lib.rs:497` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) mistralrs-code-exec/src/shell.rs:480 — mistralrs-code-exec/src/shell.rs:480-485 | mistralrs-server-core/src/skills.rs:676-681 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-code-exec/src/shell.rs:480` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) mistralrs-core/src/attention/backends/cpu/full.rs:515 — mistralrs-core/src/attention/backends/cpu/full.rs:515-520 | mistralrs-core/src/attention/backends/cpu/single_q.rs:314-319 — before extracting anything, compare `mistralrs-core/src/attention/backends/cpu/full.rs` and `mistralrs-core/src/attention/backends/cpu/single_q.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 44 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/attention/backends/cpu/full.rs:515` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) mistralrs-core/src/cuda/gdn.rs:1736 — mistralrs-core/src/cuda/gdn.rs:1736-1741 | mistralrs-core/src/cuda/gdn.rs:5967-5972 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (6 lines × 2) mistralrs-core/src/cuda/gdn.rs:1761 — mistralrs-core/src/cuda/gdn.rs:1761-1766 | mistralrs-core/src/cuda/gdn.rs:1805-1810 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (6 lines × 2) mistralrs-core/src/cuda/gdn.rs:1980 — mistralrs-core/src/cuda/gdn.rs:1980-1985 | mistralrs-core/src/cuda/gdn.rs:3159-3164 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (6 lines × 2) mistralrs-core/src/cuda/gdn.rs:4622 — mistralrs-core/src/cuda/gdn.rs:4622-4627 | mistralrs-core/src/cuda/gdn.rs:4629-4634 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/gdn.rs:4622` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (6 lines × 2) mistralrs-core/src/cuda/moe.rs:60 — mistralrs-core/src/cuda/moe.rs:60-65 | mistralrs-core/src/cuda/moe.rs:67-72 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/moe.rs:60` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) mistralrs-core/src/cuda/ssm.rs:40 — mistralrs-core/src/cuda/ssm.rs:40-46 | mistralrs-core/src/metal/ssm.rs:136-141 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (6 lines × 2) mistralrs-core/src/diffusion_models/t5/mod.rs:261 — mistralrs-core/src/diffusion_models/t5/mod.rs:261-266 | mistralrs-core/src/diffusion_models/t5/mod.rs:275-280 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/diffusion_models/t5/mod.rs:261` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) mistralrs-core/src/distributed.rs:465 — mistralrs-core/src/distributed.rs:465-470 | mistralrs-core/src/distributed.rs:680-686 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/distributed.rs:465` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (6 lines × 2) mistralrs-core/src/embedding_models/embedding_gemma.rs:523 — mistralrs-core/src/embedding_models/embedding_gemma.rs:523-528 | mistralrs-core/src/embedding_models/qwen3_embedding.rs:471-476 — before extracting anything, compare `mistralrs-core/src/embedding_models/embedding_gemma.rs` and `mistralrs-core/src/embedding_models/qwen3_embedding.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 40 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/embedding_gemma.rs:523` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/embedding_models/qwen3_embedding.rs:478` calls `pp`, `add` and `mistralrs-core/src/embedding_models/embedding_gemma.rs:530` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (6 lines × 2) mistralrs-core/src/gdn/backend.rs:1103 — mistralrs-core/src/gdn/backend.rs:1103-1108 | mistralrs-core/src/models/granite.rs:1191-1196 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/gdn/backend.rs:1103` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) mistralrs-core/src/gguf/gguf_tokenizer.rs:528 — mistralrs-core/src/gguf/gguf_tokenizer.rs:528-533 | mistralrs-core/src/gguf/gguf_tokenizer.rs:636-641 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/gguf/gguf_tokenizer.rs:528` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) mistralrs-core/src/kv_cache/hybrid_cache.rs:1276 — mistralrs-core/src/kv_cache/hybrid_cache.rs:1276-1281 | mistralrs-core/src/kv_cache/hybrid_cache.rs:1904-1909 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/kv_cache/hybrid_cache.rs:1276` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `self` to `&mut` in one and `crate) fn disable_gdn_deferred_state(&mut` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (6 lines × 2) mistralrs-core/src/model_loader.rs:414 — mistralrs-core/src/model_loader.rs:414-419 | mistralrs-core/src/model_loader.rs:431-436 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/model_loader.rs:414` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/model_loader.rs:413` calls `unwrap_or_default` and `mistralrs-core/src/model_loader.rs:430` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (6 lines × 2) mistralrs-core/src/models/flint.rs:801 — mistralrs-core/src/models/flint.rs:801-806 | mistralrs-core/src/models/lfm2.rs:1060-1065 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/lfm2.rs` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 104 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/flint.rs:801` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) mistralrs-core/src/models/lfm2.rs:1244 — mistralrs-core/src/models/lfm2.rs:1244-1249 | mistralrs-core/src/models/qwen3_next.rs:1051-1057 — before extracting anything, compare `mistralrs-core/src/models/lfm2.rs` and `mistralrs-core/src/models/qwen3_next.rs` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 161 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/lfm2.rs:1244` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) mistralrs-core/src/ops.rs:3917 — mistralrs-core/src/ops.rs:3917-3922 | mistralrs-core/src/ops.rs:4044-4049 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:3917` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:281 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:281-286 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:174-179 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` and `mistralrs-core/src/pipeline/loaders/normal_loaders.rs` as WHOLE FILES: this scan already matched 34 separate duplicated blocks between them, totalling at least 445 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:281` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) mistralrs-core/src/sequence.rs:2102 — mistralrs-core/src/sequence.rs:2102-2107 | mistralrs-core/src/sequence.rs:2134-2139 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/sequence.rs:2102` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (6 lines × 2) mistralrs-core/src/utils/varbuilder_utils.rs:98 — mistralrs-core/src/utils/varbuilder_utils.rs:98-103 | mistralrs-core/src/utils/varbuilder_utils.rs:134-139 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/utils/varbuilder_utils.rs:98` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) mistralrs-core/src/vision_models/gemma3/mod.rs:179 — mistralrs-core/src/vision_models/gemma3/mod.rs:179-184 | mistralrs-core/src/vision_models/mistral3/mod.rs:323-328 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3/mod.rs:179` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • + 70 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (7 lines × 2) · ×94
  • Duplicated block (7 lines × 2) mistralrs-core/src/attention/backends/cpu/avx.rs:68 — mistralrs-core/src/attention/backends/cpu/avx.rs:68-74 | mistralrs-core/src/attention/backends/cpu/avx.rs:86-92 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/attention/backends/cpu/avx.rs:68` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) mistralrs-core/src/attention/mod.rs:518 — mistralrs-core/src/attention/mod.rs:518-524 | mistralrs-core/src/attention/mod.rs:541-547 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) mistralrs-core/src/cuda/dflash_context.rs:97 — mistralrs-core/src/cuda/dflash_context.rs:97-103 | mistralrs-core/src/speculative/dflash.rs:868-874 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (7 lines × 2) mistralrs-core/src/cuda/dflash_context.rs:125 — mistralrs-core/src/cuda/dflash_context.rs:125-131 | mistralrs-core/src/speculative/dflash.rs:895-901 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/dflash_context.rs:125` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) mistralrs-core/src/cuda/dflash_context.rs:187 — mistralrs-core/src/cuda/dflash_context.rs:187-193 | mistralrs-core/src/cuda/dflash_context.rs:313-319 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) mistralrs-core/src/cuda/speculative_rejection.rs:733 — mistralrs-core/src/cuda/speculative_rejection.rs:733-739 | mistralrs-core/src/cuda/speculative_rejection.rs:770-776 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/speculative_rejection.rs:733` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) mistralrs-core/src/kv_cache/hybrid_cache.rs:111 — mistralrs-core/src/kv_cache/hybrid_cache.rs:111-117 | mistralrs-core/src/kv_cache/hybrid_cache.rs:300-306 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/kv_cache/hybrid_cache.rs:111` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) mistralrs-core/src/kv_cache/mod.rs:1464 — mistralrs-core/src/kv_cache/mod.rs:1464-1470 | mistralrs-core/src/kv_cache/mod.rs:1565-1571 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/kv_cache/mod.rs:1464` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) mistralrs-core/src/layers.rs:835 — mistralrs-core/src/layers.rs:835-841 | mistralrs-core/src/layers.rs:842-848 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) mistralrs-core/src/lib.rs:2487 — mistralrs-core/src/lib.rs:2487-2493 | mistralrs-core/src/lib.rs:2514-2520 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/lib.rs:2487` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) mistralrs-core/src/metal/gdn.rs:792 — mistralrs-core/src/metal/gdn.rs:792-798 | mistralrs-core/src/metal/ssm.rs:182-188 — before extracting anything, compare `mistralrs-core/src/metal/gdn.rs` and `mistralrs-core/src/metal/ssm.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 68 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 2) mistralrs-core/src/models/glm4_moe.rs:408 — mistralrs-core/src/models/glm4_moe.rs:408-414 | mistralrs-core/src/models/glm4_moe_lite.rs:501-507 — before extracting anything, compare `mistralrs-core/src/models/glm4_moe.rs` and `mistralrs-core/src/models/glm4_moe_lite.rs` as WHOLE FILES: this scan already matched 44 separate duplicated blocks between them, totalling at least 596 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (7 lines × 2) mistralrs-core/src/models/qwen3_next.rs:629 — mistralrs-core/src/models/qwen3_next.rs:629-635 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:466-472 — before extracting anything, compare `mistralrs-core/src/models/qwen3_next.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/text.rs` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 461 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/qwen3_next.rs:629` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) mistralrs-core/src/moe/experts/backends.rs:837 — mistralrs-core/src/moe/experts/backends.rs:837-843 | mistralrs-core/src/moe/experts/backends.rs:987-993 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/moe/experts/backends.rs:837` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (7 lines × 2) mistralrs-core/src/ops.rs:2021 — mistralrs-core/src/ops.rs:2021-2027 | mistralrs-core/src/ops.rs:2147-2153 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) mistralrs-core/src/ops.rs:2686 — mistralrs-core/src/ops.rs:2686-2692 | mistralrs-core/src/ops.rs:3504-3510 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) mistralrs-core/src/ops.rs:2987 — mistralrs-core/src/ops.rs:2987-2993 | mistralrs-core/src/ops.rs:3505-3511 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) mistralrs-core/src/ops.rs:4637 — mistralrs-core/src/ops.rs:4637-4643 | mistralrs-core/src/ops.rs:6458-6464 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:4637` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/ops.rs:6455` calls `contiguous` and `mistralrs-core/src/ops.rs:4635` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 2) mistralrs-core/src/ops.rs:5783 — mistralrs-core/src/ops.rs:5783-5789 | mistralrs-core/src/ops.rs:6219-6225 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:5783` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/ops.rs:6215` calls `device_ptr`, `add`, `start_offset` and `mistralrs-core/src/ops.rs:5781` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 2) mistralrs-core/src/pipeline/embedding.rs:248 — mistralrs-core/src/pipeline/embedding.rs:248-254 | mistralrs-core/src/pipeline/gguf.rs:1317-1323 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/embedding.rs:248` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (7 lines × 2) mistralrs-core/src/pipeline/inputs_processor.rs:930 — mistralrs-core/src/pipeline/inputs_processor.rs:930-936 | mistralrs-quant/src/distributed/layers.rs:2181-2188 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/inputs_processor.rs:930` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6252 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6252-6258 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9799-9805 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) mistralrs-core/src/speculative/cache.rs:312 — mistralrs-core/src/speculative/cache.rs:312-318 | mistralrs-core/src/speculative/paged_rows.rs:259-265 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/speculative/cache.rs:312` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) mistralrs-core/src/utils/tiktoken.rs:99 — mistralrs-core/src/utils/tiktoken.rs:99-108 | mistralrs-core/src/utils/tokenizer.rs:109-115 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/utils/tiktoken.rs:99` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/utils/tiktoken.rs:96` calls `token_bytes_to_string`, `insert` and `mistralrs-core/src/utils/tokenizer.rs:108` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 2) mistralrs-core/src/vision_models/gemma3/mod.rs:130 — mistralrs-core/src/vision_models/gemma3/mod.rs:130-136 | REDACTED:136-142 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3/mod.rs:130` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • + 69 more in this group — see findings.md.
D1 · Cyclomatic Complexity · mistralrs_core · ×84
  • mistralrs_core::pipeline::sampling::finish_or_add_toks_to_seq (cyclomatic 77) mistralrs-core/src/pipeline/sampling.rs:189 — mistralrs_core::pipeline::sampling::finish_or_add_toks_to_seq has cyclomatic complexity 77 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_core::gguf::normal_bindings::bind_block_tensor (cyclomatic 72) mistralrs-core/src/gguf/normal_bindings.rs:118 — mistralrs_core::gguf::normal_bindings::bind_block_tensor has cyclomatic complexity 72 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • mistralrs_core::cuda::gdn::speculative_recurrence_checkpoints_cuda::cuda_fwd (cyclomatic 66) mistralrs-core/src/cuda/gdn.rs:3821 — mistralrs_core::cuda::gdn::speculative_recurrence_checkpoints_cuda::cuda_fwd has cyclomatic complexity 66 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • mistralrs_core::pipeline::isq::gguf_imatrix_names (cyclomatic 60) mistralrs-core/src/pipeline/isq.rs:1405 — mistralrs_core::pipeline::isq::gguf_imatrix_names has cyclomatic complexity 60 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • mistralrs_core::vision_models::qwen3_vl::get_rope_index (cyclomatic 55) mistralrs-core/src/vision_models/qwen3_vl/mod.rs:55 — mistralrs_core::vision_models::qwen3_vl::get_rope_index has cyclomatic complexity 55 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_core::pipeline::inputs_processor::text_models_inputs_processor::make_prompt_chunk (cyclomatic 54) mistralrs-core/src/pipeline/inputs_processor.rs:872 — mistralrs_core::pipeline::inputs_processor::text_models_inputs_processor::make_prompt_chunk has cyclomatic complexity 54 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_core::ops::try_cuda_qk_rms_norm_rope (cyclomatic 43) mistralrs-core/src/ops.rs:5585 — mistralrs_core::ops::try_cuda_qk_rms_norm_rope has cyclomatic complexity 43 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • mistralrs_core::ops::try_cuda_qk_rms_norm_rope_positions (cyclomatic 43) mistralrs-core/src/ops.rs:6014 — mistralrs_core::ops::try_cuda_qk_rms_norm_rope_positions has cyclomatic complexity 43 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • mistralrs_core::diagnostics::run_doctor (cyclomatic 41) mistralrs-core/src/diagnostics.rs:415 — mistralrs_core::diagnostics::run_doctor has cyclomatic complexity 41 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_core::pipeline::paths::get_adapter_paths (cyclomatic 40) mistralrs-core/src/pipeline/paths.rs:75 — mistralrs_core::pipeline::paths::get_adapter_paths has cyclomatic complexity 40 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_core::engine::agentic_loop::agentic_loop (cyclomatic 39) mistralrs-core/src/engine/agentic_loop.rs:1256 — mistralrs_core::engine::agentic_loop::agentic_loop has cyclomatic complexity 39 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_core::ops::cuda_dflash_sample_select (cyclomatic 39) mistralrs-core/src/ops.rs:1710 — mistralrs_core::ops::cuda_dflash_sample_select has cyclomatic complexity 39 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • mistralrs_core::pipeline::isq_flow::plan::resolve_and_install_isq_plan (cyclomatic 38) mistralrs-core/src/pipeline/isq_flow/plan.rs:141 — mistralrs_core::pipeline::isq_flow::plan::resolve_and_install_isq_plan has cyclomatic complexity 38 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • mistralrs_core::pipeline::loaders::auto_device_map::get_device_layers_attempt (cyclomatic 38) mistralrs-core/src/pipeline/loaders/auto_device_map.rs:262 — mistralrs_core::pipeline::loaders::auto_device_map::get_device_layers_attempt has cyclomatic complexity 38 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_core::ops::try_cuda_qkv_rms_norm_rope_positions (cyclomatic 37) mistralrs-core/src/ops.rs:6347 — mistralrs_core::ops::try_cuda_qkv_rms_norm_rope_positions has cyclomatic complexity 37 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • mistralrs_core::ops::cuda_topk_logits_packed_batched_with_workspace (cyclomatic 35) mistralrs-core/src/ops.rs:1040 — mistralrs_core::ops::cuda_topk_logits_packed_batched_with_workspace has cyclomatic complexity 35 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • mistralrs_core::cuda::gdn::speculative_conv_checkpoints_cuda::cuda_fwd (cyclomatic 34) mistralrs-core/src/cuda/gdn.rs:3517 — mistralrs_core::cuda::gdn::speculative_conv_checkpoints_cuda::cuda_fwd has cyclomatic complexity 34 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
  • mistralrs_core::model_loader::loader_from_model_selected (cyclomatic 32) mistralrs-core/src/model_loader.rs:292 — mistralrs_core::model_loader::loader_from_model_selected has cyclomatic complexity 32 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_core::ops::cuda_dflash_greedy_select (cyclomatic 32) mistralrs-core/src/ops.rs:1493 — mistralrs_core::ops::cuda_dflash_greedy_select has cyclomatic complexity 32 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • mistralrs_core::attention::backends::cpu::mask::mask_offset (cyclomatic 31) mistralrs-core/src/attention/backends/cpu/mask.rs:65 — mistralrs_core::attention::backends::cpu::mask::mask_offset has cyclomatic complexity 31 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_core::cuda::speculative_rejection::sparse_rejection_cuda_submit (cyclomatic 31) mistralrs-core/src/cuda/speculative_rejection.rs:904 — mistralrs_core::cuda::speculative_rejection::sparse_rejection_cuda_submit has cyclomatic complexity 31 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_core::pipeline::sampling::sample_sequence (cyclomatic 31) mistralrs-core/src/pipeline/sampling.rs:1450 — mistralrs_core::pipeline::sampling::sample_sequence has cyclomatic complexity 31 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_core::attention::backends::cpu::full::compute_tiled_qblock (cyclomatic 30) mistralrs-core/src/attention/backends/cpu/full.rs:195 — mistralrs_core::attention::backends::cpu::full::compute_tiled_qblock has cyclomatic complexity 30 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_core::ops::cuda_rms_norm_residual_then_rms_norm (cyclomatic 30) mistralrs-core/src/ops.rs:5337 — mistralrs_core::ops::cuda_rms_norm_residual_then_rms_norm has cyclomatic complexity 30 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • mistralrs_core::pipeline::paths::get_chat_template (cyclomatic 30) mistralrs-core/src/pipeline/paths.rs:568 — mistralrs_core::pipeline::paths::get_chat_template has cyclomatic complexity 30 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • + 59 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (5 lines × 2) · ×84
  • Duplicated block (5 lines × 2) mistralrs-cli/src/commands/bench.rs:319 — mistralrs-cli/src/commands/bench.rs:319-323 | mistralrs-cli/src/commands/bench.rs:336-340 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-cli/src/commands/bench.rs:319` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) mistralrs-cli/src/commands/quantize.rs:357 — mistralrs-cli/src/commands/quantize.rs:357-361 | mistralrs-cli/src/commands/quantize.rs:367-371 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (5 lines × 2) mistralrs-cli/src/commands/serve.rs:605 — mistralrs-cli/src/commands/serve.rs:605-609 | mistralrs-cli/src/commands/serve.rs:665-669 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-cli/src/commands/serve.rs:605` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) mistralrs-core/src/attention/backends/cpu/avx.rs:75 — mistralrs-core/src/attention/backends/cpu/avx.rs:75-79 | mistralrs-core/src/attention/backends/cpu/avx.rs:334-338 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/attention/backends/cpu/avx.rs:75` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) mistralrs-core/src/cuda/gdn.rs:1978 — mistralrs-core/src/cuda/gdn.rs:1978-1982 | mistralrs-core/src/cuda/gdn.rs:3617-3623 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/gdn.rs:1978` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) mistralrs-core/src/cuda/gdn.rs:2283 — mistralrs-core/src/cuda/gdn.rs:2283-2288 | mistralrs-core/src/cuda/gdn.rs:2781-2785 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/gdn.rs:2283` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) mistralrs-core/src/cuda/gdn.rs:5965 — mistralrs-core/src/cuda/gdn.rs:5965-5969 | mistralrs-core/src/cuda/gdn.rs:6209-6213 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/gdn.rs:5965` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) mistralrs-core/src/gdn/backend.rs:989 — mistralrs-core/src/gdn/backend.rs:989-993 | mistralrs-core/src/gdn/backend.rs:1126-1130 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/gdn/backend.rs:989` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) mistralrs-core/src/matformer.rs:101 — mistralrs-core/src/matformer.rs:101-105 | mistralrs-core/src/matformer.rs:120-124 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/matformer.rs:101` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) mistralrs-core/src/models/gpt_oss.rs:951 — mistralrs-core/src/models/gpt_oss.rs:951-955 | mistralrs-core/src/vision_models/mllama/text.rs:982-987 — before extracting anything, compare `mistralrs-core/src/models/gpt_oss.rs` and `mistralrs-core/src/vision_models/mllama/text.rs` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 103 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gpt_oss.rs:951` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) mistralrs-core/src/models/lfm3.rs:1253 — mistralrs-core/src/models/lfm3.rs:1253-1258 | mistralrs-core/src/xlora_models/gemma2.rs:639-643 — before extracting anything, compare `mistralrs-core/src/models/lfm3.rs` and `mistralrs-core/src/xlora_models/gemma2.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 31 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/lfm3.rs:1253` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) mistralrs-core/src/ops.rs:621 — mistralrs-core/src/ops.rs:621-625 | mistralrs-core/src/ops.rs:779-783 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:621` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) mistralrs-core/src/ops.rs:4672 — mistralrs-core/src/ops.rs:4672-4676 | mistralrs-core/src/ops.rs:5505-5509 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:4672` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/ops.rs:5512` calls `device_ptr` and `mistralrs-core/src/ops.rs:4678` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 2) mistralrs-core/src/pipeline/inputs_processor.rs:1372 — mistralrs-core/src/pipeline/inputs_processor.rs:1372-1376 | mistralrs-core/src/pipeline/inputs_processor.rs:1383-1387 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/inputs_processor.rs:1372` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/pipeline/inputs_processor.rs:1382` calls `insert`, `location`, `clone` and `mistralrs-core/src/pipeline/inputs_processor.rs:1371` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 2) mistralrs-core/src/pipeline/mod.rs:1304 — mistralrs-core/src/pipeline/mod.rs:1304-1308 | mistralrs-core/src/pipeline/mod.rs:1362-1366 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (5 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:1670 — mistralrs-core/src/pipeline/multimodal.rs:1670-1674 | mistralrs-core/src/pipeline/normal.rs:1545-1549 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (5 lines × 2) mistralrs-core/src/vision_models/gemma3n/audio.rs:1069 — mistralrs-core/src/vision_models/gemma3n/audio.rs:1069-1074 | mistralrs-core/src/vision_models/gemma4/audio.rs:850-854 — `mistralrs-core/src/vision_models/gemma3n/audio.rs` and `mistralrs-core/src/vision_models/gemma4/audio.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 20 separate duplicated blocks between them, totalling at least 352 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (5 lines × 2) mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1496 — mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1496-1503 | mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1761-1765 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1496` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:646 — mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:646-650 | mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:664-669 — before extracting anything, compare `mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs` and `mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 222 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (5 lines × 2) mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:59 — mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:59-63 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:228-232 — before extracting anything, compare `mistralrs-core/src/vision_models/llava/llava_llm/llama.rs` and `mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 216 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (5 lines × 2) mistralrs-core/src/vision_models/qwen3_vl/mod.rs:78 — mistralrs-core/src/vision_models/qwen3_vl/mod.rs:78-82 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:92-96 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_vl/mod.rs:78` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) mistralrs-paged-attn/src/cuda/backend/gather_kv.rs:164 — mistralrs-paged-attn/src/cuda/backend/gather_kv.rs:164-170 | mistralrs-paged-attn/src/cuda/backend/gather_kv.rs:176-180 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/cuda/backend/gather_kv.rs:164` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) mistralrs-paged-attn/src/cuda/backend/gather_kv.rs:229 — mistralrs-paged-attn/src/cuda/backend/gather_kv.rs:229-235 | mistralrs-paged-attn/src/cuda/backend/gather_kv.rs:242-246 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/cuda/backend/gather_kv.rs:229` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) mistralrs-pyo3/src/lib.rs:102 — mistralrs-pyo3/src/lib.rs:102-107 | mistralrs-pyo3/src/lib.rs:124-128 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (5 lines × 2) mistralrs-quant/src/afq/ops.rs:796 — mistralrs-quant/src/afq/ops.rs:796-803 | mistralrs-quant/src/afq/ops.rs:919-923 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/afq/ops.rs:796` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • + 59 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (10 lines × 2) · ×82
  • Duplicated block (10 lines × 2) mistralrs-cli/src/commands/quantize.rs:562 — mistralrs-cli/src/commands/quantize.rs:562-571 | mistralrs-cli/src/commands/quantize.rs:609-618 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10 lines × 2) mistralrs-core/src/cuda/gdn.rs:4435 — mistralrs-core/src/cuda/gdn.rs:4435-4444 | mistralrs-core/src/cuda/gdn.rs:4818-4827 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/gdn.rs:4435` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) mistralrs-core/src/diffusion_models/clip/text.rs:220 — mistralrs-core/src/diffusion_models/clip/text.rs:220-229 | mistralrs-core/src/vision_models/clip.rs:251-260 — before extracting anything, compare `mistralrs-core/src/diffusion_models/clip/text.rs` and `mistralrs-core/src/vision_models/clip.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 36 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (10 lines × 2) mistralrs-core/src/distributed.rs:175 — mistralrs-core/src/distributed.rs:175-184 | mistralrs-core/src/distributed.rs:221-230 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/distributed.rs:175` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) mistralrs-core/src/engine/agentic_loop.rs:568 — mistralrs-core/src/engine/agentic_loop.rs:568-577 | mistralrs-core/src/engine/agentic_loop.rs:768-777 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/engine/agentic_loop.rs:568` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/engine/agentic_loop.rs:767` calls `Some` and `mistralrs-core/src/engine/agentic_loop.rs:567` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10 lines × 2) mistralrs-core/src/kv_cache/hybrid_cache.rs:2094 — mistralrs-core/src/kv_cache/hybrid_cache.rs:2094-2103 | mistralrs-core/src/kv_cache/hybrid_cache.rs:4072-4081 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10 lines × 2) mistralrs-core/src/layers.rs:3080 — mistralrs-core/src/layers.rs:3080-3089 | mistralrs-core/src/layers.rs:3213-3222 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/layers.rs:3080` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) mistralrs-core/src/models/gpt_oss.rs:837 — mistralrs-core/src/models/gpt_oss.rs:837-846 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6362-6371 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gpt_oss.rs:837` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) mistralrs-core/src/models/granite.rs:1417 — mistralrs-core/src/models/granite.rs:1417-1426 | mistralrs-core/src/models/granite.rs:1437-1446 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/granite.rs:1417` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) mistralrs-core/src/models/lfm2.rs:899 — mistralrs-core/src/models/lfm2.rs:899-908 | mistralrs-core/src/models/lfm3.rs:773-782 — before extracting anything, compare `mistralrs-core/src/models/lfm2.rs` and `mistralrs-core/src/models/lfm3.rs` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 402 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (10 lines × 2) mistralrs-core/src/models/lfm2.rs:1245 — mistralrs-core/src/models/lfm2.rs:1245-1254 | mistralrs-core/src/models/lfm3.rs:1256-1265 — before extracting anything, compare `mistralrs-core/src/models/lfm2.rs` and `mistralrs-core/src/models/lfm3.rs` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 402 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/lfm2.rs:1245` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) mistralrs-core/src/models/qwen3_next.rs:692 — mistralrs-core/src/models/qwen3_next.rs:692-701 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:474-483 — before extracting anything, compare `mistralrs-core/src/models/qwen3_next.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/text.rs` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 461 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/qwen3_next.rs:692` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) mistralrs-core/src/moe/experts/backends.rs:770 — mistralrs-core/src/moe/experts/backends.rs:770-779 | mistralrs-core/src/moe/experts/backends.rs:817-826 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/moe/experts/backends.rs:770` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (10 lines × 2) mistralrs-core/src/moe/experts/mod.rs:110 — mistralrs-core/src/moe/experts/mod.rs:110-119 | mistralrs-core/src/moe/experts/mod.rs:201-210 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/moe/experts/mod.rs:109` calls `pp`, `set_device`, `clone` and `mistralrs-core/src/moe/experts/mod.rs:200` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10 lines × 2) mistralrs-core/src/ops.rs:3897 — mistralrs-core/src/ops.rs:3897-3906 | mistralrs-core/src/ops.rs:4024-4033 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:3897` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) mistralrs-core/src/ops.rs:4518 — mistralrs-core/src/ops.rs:4518-4527 | mistralrs-core/src/ops.rs:5496-5505 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:4518` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) mistralrs-core/src/ops.rs:6039 — mistralrs-core/src/ops.rs:6039-6048 | mistralrs-core/src/ops.rs:6378-6387 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10 lines × 2) mistralrs-core/src/paged_attention/cache_engine.rs:307 — mistralrs-core/src/paged_attention/cache_engine.rs:307-316 | mistralrs-core/src/paged_attention/cache_engine.rs:393-402 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/paged_attention/cache_engine.rs:307` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) mistralrs-core/src/paged_attention/layers/paged_attention.rs:685 — mistralrs-core/src/paged_attention/layers/paged_attention.rs:685-694 | mistralrs-core/src/paged_attention/layers/paged_attention.rs:735-744 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10 lines × 2) mistralrs-core/src/pipeline/embedding.rs:273 — mistralrs-core/src/pipeline/embedding.rs:273-282 | mistralrs-core/src/pipeline/normal.rs:759-768 — before extracting anything, compare `mistralrs-core/src/pipeline/embedding.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 178 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/embedding.rs:273` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7806 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7806-7815 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:8328-8337 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7806` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:1612 — mistralrs-core/src/pipeline/multimodal.rs:1612-1621 | mistralrs-core/src/pipeline/normal.rs:279-288 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:1612` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) mistralrs-core/src/pipeline/paths.rs:172 — mistralrs-core/src/pipeline/paths.rs:172-181 | mistralrs-core/src/pipeline/paths.rs:252-261 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/paths.rs:172` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (10 lines × 2) mistralrs-core/src/speculative/dflash.rs:2654 — mistralrs-core/src/speculative/dflash.rs:2654-2663 | mistralrs-core/src/speculative/dflash.rs:3533-3542 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/speculative/dflash.rs:2654` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) mistralrs-core/src/speculative/verifier.rs:562 — mistralrs-core/src/speculative/verifier.rs:562-571 | mistralrs-core/src/speculative/verifier.rs:575-584 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/speculative/verifier.rs:562` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • + 57 more in this group — see findings.md.
D3 · God Classes · ClassTooLong · ×78
  • ClassTooLong: MistralRs mistralrs-core/src/lib.rs:462 — ClassTooLong — 1664 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 81 methods, 3 blocks, lines 462-3045. The bar is 400 significant lines; this is 1264 over it, 4.16× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: Engine mistralrs-core/src/engine/mod.rs:205 — ClassTooLong — 1631 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 23 methods, 3 blocks, lines 205-2619. The bar is 400 significant lines; this is 1231 over it, 4.08× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: DFlashDraftModel mistralrs-core/src/speculative/dflash.rs:1285 — ClassTooLong — 1393 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 40 methods, 2 blocks, lines 1285-3860. The bar is 400 significant lines; this is 993 over it, 3.48× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: MultimodalPipeline mistralrs-core/src/pipeline/multimodal.rs:217 — ClassTooLong — 1389 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 12 methods, 10 blocks, lines 217-3517. The bar is 400 significant lines; this is 989 over it, 3.47× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: HybridCache mistralrs-core/src/kv_cache/hybrid_cache.rs:1082 — ClassTooLong — 1186 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 70 methods, 5 blocks, lines 1082-4229. The bar is 400 significant lines; this is 786 over it, 2.97× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: Sampler mistralrs-core/src/sampler.rs:304 — ClassTooLong — 1135 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 44 methods, 2 blocks, lines 304-2237. The bar is 400 significant lines; this is 735 over it, 2.84× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: PagedAttentionScheduler mistralrs-core/src/paged_attention/scheduler.rs:109 — ClassTooLong — 1119 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 35 methods, 4 blocks, lines 109-1602. The bar is 400 significant lines; this is 719 over it, 2.80× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: Runner mistralrs-pyo3/src/lib.rs:605 — ClassTooLong — 1091 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 36 methods, 3 blocks, lines 605-2630. The bar is 400 significant lines; this is 691 over it, 2.73× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: GridImageProcessor mistralrs-core/src/vision_models/grid_processor.rs:65 — ClassTooLong — 1084 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 9 methods, 5 blocks, lines 65-2164. The bar is 400 significant lines; this is 684 over it, 2.71× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: Phi4MMInputsProcessor mistralrs-core/src/vision_models/phi4/inputs_processor.rs:262 — ClassTooLong — 1083 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 14 methods, 5 blocks, lines 262-1714. The bar is 400 significant lines; this is 683 over it, 2.71× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: Sequence mistralrs-core/src/sequence.rs:753 — ClassTooLong — 1075 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 163 methods, 2 blocks, lines 753-2368. The bar is 400 significant lines; this is 675 over it, 2.69× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: NormalPipeline mistralrs-core/src/pipeline/normal.rs:112 — ClassTooLong — 1043 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 10 methods, 10 blocks, lines 112-2953. The bar is 400 significant lines; this is 643 over it, 2.61× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: MultimodalLoader mistralrs-core/src/pipeline/multimodal.rs:244 — ClassTooLong — 1036 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 1 methods, 3 blocks, lines 244-1729. The bar is 400 significant lines; this is 636 over it, 2.59× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: Pipeline mistralrs-core/src/pipeline/mod.rs:1981 — ClassTooLong — 1025 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 34 methods. The bar is 400 significant lines; this is 625 over it, 2.56× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: Gemma4ImageProcessor mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:169 — ClassTooLong — 981 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 14 methods, 4 blocks, lines 169-1796. The bar is 400 significant lines; this is 581 over it, 2.45× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: Qwen2_5VLImageProcessor mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:55 — ClassTooLong — 886 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 2 methods, 4 blocks, lines 55-1198. The bar is 400 significant lines; this is 486 over it, 2.22× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: Qwen2VLImageProcessor mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:49 — ClassTooLong — 886 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 2 methods, 4 blocks, lines 49-1763. The bar is 400 significant lines; this is 486 over it, 2.22× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: GGUFLoader mistralrs-core/src/pipeline/gguf.rs:125 — ClassTooLong — 880 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 9 methods, 3 blocks, lines 125-1485. The bar is 400 significant lines; this is 480 over it, 2.20× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: BlockwiseFP8Linear mistralrs-quant/src/blockwise_fp8/mod.rs:34 — ClassTooLong — 862 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 7 methods, 5 blocks, lines 34-1253. The bar is 400 significant lines; this is 462 over it, 2.16× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: Qwen3_5TextModel mistralrs-core/src/vision_models/qwen3_5/text.rs:778 — ClassTooLong — 861 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 29 methods, 5 blocks, lines 778-1910. The bar is 400 significant lines; this is 461 over it, 2.15× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: Nvfp4Layer mistralrs-quant/src/nvfp4/mod.rs:84 — ClassTooLong — 852 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 22 methods, 4 blocks, lines 84-1317. The bar is 400 significant lines; this is 452 over it, 2.13× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: TextModel mistralrs-core/src/vision_models/gemma4/text.rs:1528 — ClassTooLong — 832 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 21 methods, 4 blocks, lines 1528-2695. The bar is 400 significant lines; this is 432 over it, 2.08× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: NormalLoader mistralrs-core/src/pipeline/normal.rs:376 — ClassTooLong — 831 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 0 methods, 2 blocks, lines 376-1602. The bar is 400 significant lines; this is 431 over it, 2.08× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: Model mistralrs/src/model.rs:80 — ClassTooLong — 827 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 68 methods, 2 blocks, lines 80-1319. The bar is 400 significant lines; this is 427 over it, 2.07× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: Gemma4Model mistralrs-core/src/vision_models/gemma4/mod.rs:201 — ClassTooLong — 781 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 4 methods, 5 blocks, lines 201-1263. The bar is 400 significant lines; this is 381 over it, 1.95× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • + 53 more in this group — see findings.md.
D15 · Churn × Complexity Hotspots · Hotspot · ×75
  • Hotspot: mistralrs-core/src/engine/mod.rs mistralrs-core/src/engine/mod.rs:1157 — mistralrs-core/src/engine/mod.rs changed 21 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 147 in Engine::run at line 1157. 4 of those changes were fix/bug commits, and the other 17 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-08-10..2026-11-08, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-10 21:43:10 -05:00' --until='2026-11-08 21:43:10 -05:00' --full-history --no-merges -- mistralrs-core/src/engine/mod.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: mistralrs-core/src/pipeline/multimodal.rs mistralrs-core/src/pipeline/multimodal.rs:526 — mistralrs-core/src/pipeline/multimodal.rs changed 29 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 100 in MultimodalLoader::load_model_from_path at line 526. 3 of those changes were fix/bug commits, and the other 26 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-08-10..2026-11-08, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-10 21:43:10 -05:00' --until='2026-11-08 21:43:10 -05:00' --full-history --no-merges -- mistralrs-core/src/pipeline/multimodal.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: mistralrs-core/src/pipeline/mod.rs mistralrs-core/src/pipeline/mod.rs:2255 — mistralrs-core/src/pipeline/mod.rs changed 25 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 110 in Pipeline::submit_step at line 2255. 3 of those changes were fix/bug commits, and the other 22 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-08-10..2026-11-08, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-10 21:43:10 -05:00' --until='2026-11-08 21:43:10 -05:00' --full-history --no-merges -- mistralrs-core/src/pipeline/mod.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: mistralrs-core/src/pipeline/normal.rs mistralrs-core/src/pipeline/normal.rs:659 — mistralrs-core/src/pipeline/normal.rs changed 21 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 68 in NormalLoader::load_model_from_path at line 659. 2 of those changes were fix/bug commits, and the other 19 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-08-10..2026-11-08, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-10 21:43:10 -05:00' --until='2026-11-08 21:43:10 -05:00' --full-history --no-merges -- mistralrs-core/src/pipeline/normal.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: mistralrs-core/src/engine/add_request.rs mistralrs-core/src/engine/add_request.rs:156 — mistralrs-core/src/engine/add_request.rs changed 11 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 125 in Engine::add_request at line 156. 1 of those changes was a fix/bug commit, and the other 10 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-08-10..2026-11-08, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-10 21:43:10 -05:00' --until='2026-11-08 21:43:10 -05:00' --full-history --no-merges -- mistralrs-core/src/engine/add_request.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: mistralrs-core/src/pipeline/sampling.rs mistralrs-core/src/pipeline/sampling.rs:189 — mistralrs-core/src/pipeline/sampling.rs changed 14 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 77 in mistralrs_core::pipeline::sampling::finish_or_add_toks_to_seq at line 189. 3 of those changes were fix/bug commits, and the other 11 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-08-10..2026-11-08, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-10 21:43:10 -05:00' --until='2026-11-08 21:43:10 -05:00' --full-history --no-merges -- mistralrs-core/src/pipeline/sampling.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: mistralrs-core/src/paged_attention/scheduler.rs mistralrs-core/src/paged_attention/scheduler.rs:930 — mistralrs-core/src/paged_attention/scheduler.rs changed 15 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 50 in PagedAttentionScheduler::schedule at line 930. 1 of those changes was a fix/bug commit, and the other 14 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-08-10..2026-11-08, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-10 21:43:10 -05:00' --until='2026-11-08 21:43:10 -05:00' --full-history --no-merges -- mistralrs-core/src/paged_attention/scheduler.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: mistralrs-core/src/vision_models/qwen3_5/text.rs mistralrs-core/src/vision_models/qwen3_5/text.rs:1358 — mistralrs-core/src/vision_models/qwen3_5/text.rs changed 17 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 44 in Qwen3_5TextModel::forward_embeds at line 1358. 2 of those changes were fix/bug commits, and the other 15 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-08-10..2026-11-08, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-10 21:43:10 -05:00' --until='2026-11-08 21:43:10 -05:00' --full-history --no-merges -- mistralrs-core/src/vision_models/qwen3_5/text.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: mistralrs-server-core/src/chat_completion.rs mistralrs-server-core/src/chat_completion.rs:605 — mistralrs-server-core/src/chat_completion.rs changed 12 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 60 in mistralrs_server_core::chat_completion::parse_request at line 605. 1 of those changes was a fix/bug commit, and the other 11 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-08-10..2026-11-08, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-10 21:43:10 -05:00' --until='2026-11-08 21:43:10 -05:00' --full-history --no-merges -- mistralrs-server-core/src/chat_completion.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: mistralrs-core/src/cuda/gdn.rs mistralrs-core/src/cuda/gdn.rs:3813 — mistralrs-core/src/cuda/gdn.rs changed 10 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 68 in mistralrs_core::cuda::gdn::speculative_recurrence_checkpoints_cuda at line 3813. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-10..2026-11-08, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-10 21:43:10 -05:00' --until='2026-11-08 21:43:10 -05:00' --full-history --no-merges -- mistralrs-core/src/cuda/gdn.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: mistralrs-core/src/paged_attention/layers/paged_attention.rs mistralrs-core/src/paged_attention/layers/paged_attention.rs:1412 — mistralrs-core/src/paged_attention/layers/paged_attention.rs changed 11 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 51 in PagedAttention::try_prefix_gather_prefill at line 1412. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-10..2026-11-08, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-10 21:43:10 -05:00' --until='2026-11-08 21:43:10 -05:00' --full-history --no-merges -- mistralrs-core/src/paged_attention/layers/paged_attention.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: mistralrs-core/src/pipeline/inputs_processor.rs mistralrs-core/src/pipeline/inputs_processor.rs:872 — mistralrs-core/src/pipeline/inputs_processor.rs changed 10 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 54 in mistralrs_core::pipeline::inputs_processor::text_models_inputs_processor::make_prompt_chunk at line 872. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-10..2026-11-08, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-10 21:43:10 -05:00' --until='2026-11-08 21:43:10 -05:00' --full-history --no-merges -- mistralrs-core/src/pipeline/inputs_processor.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: mistralrs-pyo3/src/lib.rs mistralrs-pyo3/src/lib.rs:1264 — mistralrs-pyo3/src/lib.rs changed 14 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 35 in Runner::new at line 1264. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-10..2026-11-08, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-10 21:43:10 -05:00' --until='2026-11-08 21:43:10 -05:00' --full-history --no-merges -- mistralrs-pyo3/src/lib.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: mistralrs-core/src/vision_models/qwen3_5/speculative.rs mistralrs-core/src/vision_models/qwen3_5/speculative.rs:304 — mistralrs-core/src/vision_models/qwen3_5/speculative.rs changed 12 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 34 in Qwen3_5Model::dflash_propose at line 304. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-10..2026-11-08, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-10 21:43:10 -05:00' --until='2026-11-08 21:43:10 -05:00' --full-history --no-merges -- mistralrs-core/src/vision_models/qwen3_5/speculative.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: mistralrs-core/src/ops.rs mistralrs-core/src/ops.rs:5585 — mistralrs-core/src/ops.rs changed 9 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 43 in mistralrs_core::ops::try_cuda_qk_rms_norm_rope at line 5585. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-10..2026-11-08, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-10 21:43:10 -05:00' --until='2026-11-08 21:43:10 -05:00' --full-history --no-merges -- mistralrs-core/src/ops.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: mistralrs-core/src/vision_models/qwen3_vl/mod.rs mistralrs-core/src/vision_models/qwen3_vl/mod.rs:55 — mistralrs-core/src/vision_models/qwen3_vl/mod.rs changed 7 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 55 in mistralrs_core::vision_models::qwen3_vl::get_rope_index at line 55. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-10..2026-11-08, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-10 21:43:10 -05:00' --until='2026-11-08 21:43:10 -05:00' --full-history --no-merges -- mistralrs-core/src/vision_models/qwen3_vl/mod.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: mistralrs-core/src/vision_models/qwen3_5/mod.rs mistralrs-core/src/vision_models/qwen3_5/mod.rs:118 — mistralrs-core/src/vision_models/qwen3_5/mod.rs changed 12 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 31 in Qwen3_5Model::forward at line 118. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-10..2026-11-08, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-10 21:43:10 -05:00' --until='2026-11-08 21:43:10 -05:00' --full-history --no-merges -- mistralrs-core/src/vision_models/qwen3_5/mod.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: mistralrs-server-core/src/responses.rs mistralrs-server-core/src/responses.rs:1158 — mistralrs-server-core/src/responses.rs changed 10 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 37 in OpenResponsesStreamer::poll_next at line 1158. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-10..2026-11-08, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-10 21:43:10 -05:00' --until='2026-11-08 21:43:10 -05:00' --full-history --no-merges -- mistralrs-server-core/src/responses.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: mistralrs-core/src/pipeline/gguf.rs mistralrs-core/src/pipeline/gguf.rs:1227 — mistralrs-core/src/pipeline/gguf.rs changed 14 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 25 in GGUFLoader::load_model_from_path at line 1227. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-10..2026-11-08, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-10 21:43:10 -05:00' --until='2026-11-08 21:43:10 -05:00' --full-history --no-merges -- mistralrs-core/src/pipeline/gguf.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: mistralrs-core/src/pipeline/loaders/auto_device_map.rs mistralrs-core/src/pipeline/loaders/auto_device_map.rs:262 — mistralrs-core/src/pipeline/loaders/auto_device_map.rs changed 9 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 38 in mistralrs_core::pipeline::loaders::auto_device_map::get_device_layers_attempt at line 262. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-10..2026-11-08, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-10 21:43:10 -05:00' --until='2026-11-08 21:43:10 -05:00' --full-history --no-merges -- mistralrs-core/src/pipeline/loaders/auto_device_map.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: mistralrs-core/src/pipeline/embedding.rs mistralrs-core/src/pipeline/embedding.rs:209 — mistralrs-core/src/pipeline/embedding.rs changed 9 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 37 in EmbeddingLoader::load_model_from_path at line 209. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-10..2026-11-08, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-10 21:43:10 -05:00' --until='2026-11-08 21:43:10 -05:00' --full-history --no-merges -- mistralrs-core/src/pipeline/embedding.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: mistralrs-core/src/pipeline/cuda_graph.rs mistralrs-core/src/pipeline/cuda_graph.rs:89 — mistralrs-core/src/pipeline/cuda_graph.rs changed 17 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 19 in CudaGraphCaptureMemory::shape at line 89. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-10..2026-11-08, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-10 21:43:10 -05:00' --until='2026-11-08 21:43:10 -05:00' --full-history --no-merges -- mistralrs-core/src/pipeline/cuda_graph.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: mistralrs-core/src/vision_models/grid_processor.rs mistralrs-core/src/vision_models/grid_processor.rs:1139 — mistralrs-core/src/vision_models/grid_processor.rs changed 5 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 58 in GridImageProcessor::process_inputs at line 1139. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-10..2026-11-08, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-10 21:43:10 -05:00' --until='2026-11-08 21:43:10 -05:00' --full-history --no-merges -- mistralrs-core/src/vision_models/grid_processor.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: mistralrs-core/src/gguf/normal_bindings.rs mistralrs-core/src/gguf/normal_bindings.rs:118 — mistralrs-core/src/gguf/normal_bindings.rs changed 4 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 72 in mistralrs_core::gguf::normal_bindings::bind_block_tensor at line 118. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-10..2026-11-08, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-10 21:43:10 -05:00' --until='2026-11-08 21:43:10 -05:00' --full-history --no-merges -- mistralrs-core/src/gguf/normal_bindings.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: mistralrs-core/src/vision_models/gemma4/text.rs mistralrs-core/src/vision_models/gemma4/text.rs:2107 — mistralrs-core/src/vision_models/gemma4/text.rs changed 7 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 39 in TextModel::forward_embeds_scaled at line 2107. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-10..2026-11-08, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-10 21:43:10 -05:00' --until='2026-11-08 21:43:10 -05:00' --full-history --no-merges -- mistralrs-core/src/vision_models/gemma4/text.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • + 50 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (13 lines × 2) · ×69
  • Duplicated block (13 lines × 2) mistralrs-cli/src/commands/doctor.rs:28 — mistralrs-cli/src/commands/doctor.rs:28-40 | mistralrs-core/src/diagnostics.rs:433-445 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (13 lines × 2) mistralrs-cli/src/commands/quant/gguf_discovery.rs:136 — mistralrs-cli/src/commands/quant/gguf_discovery.rs:136-148 | mistralrs-cli/src/commands/quant/gguf_discovery.rs:161-173 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-cli/src/commands/quant/gguf_discovery.rs:136` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) mistralrs-cli/src/commands/run/interactive.rs:1895 — mistralrs-cli/src/commands/run/interactive.rs:1895-1907 | mistralrs-cli/src/commands/run/interactive.rs:2021-2033 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-cli/src/commands/run/interactive.rs:1895` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) mistralrs-core/src/diffusion_models/clip/text.rs:142 — mistralrs-core/src/diffusion_models/clip/text.rs:142-154 | mistralrs-core/src/vision_models/clip.rs:175-187 — before extracting anything, compare `mistralrs-core/src/diffusion_models/clip/text.rs` and `mistralrs-core/src/vision_models/clip.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 36 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (13 lines × 2) mistralrs-core/src/embedding_models/embedding_gemma.rs:185 — mistralrs-core/src/embedding_models/embedding_gemma.rs:185-197 | mistralrs-core/src/vision_models/gemma3/text.rs:158-170 — before extracting anything, compare `mistralrs-core/src/embedding_models/embedding_gemma.rs` and `mistralrs-core/src/vision_models/gemma3/text.rs` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 286 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/embedding_gemma.rs:185` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) mistralrs-core/src/engine/add_request.rs:1174 — mistralrs-core/src/engine/add_request.rs:1174-1186 | mistralrs-core/src/engine/add_request.rs:1211-1223 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note first that the copies are not typed on the same thing: the declarations holding them bind `request` to `TokenizationRequest` in one and `DetokenizationRequest` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (13 lines × 2) mistralrs-core/src/gguf/normal_config.rs:1421 — mistralrs-core/src/gguf/normal_config.rs:1421-1433 | mistralrs-core/src/gguf/normal_config.rs:2459-2471 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/gguf/normal_config.rs:1421` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) mistralrs-core/src/kv_cache/mod.rs:1204 — mistralrs-core/src/kv_cache/mod.rs:1204-1216 | mistralrs-core/src/kv_cache/mod.rs:1352-1364 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/kv_cache/mod.rs:1202` calls `cache`, `hybrid`, `num_layers` and `mistralrs-core/src/kv_cache/mod.rs:1351` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (13 lines × 2) mistralrs-core/src/layers.rs:1037 — mistralrs-core/src/layers.rs:1037-1049 | mistralrs-core/src/layers.rs:2315-2327 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (13 lines × 2) mistralrs-core/src/layers.rs:1193 — mistralrs-core/src/layers.rs:1193-1205 | mistralrs-core/src/layers.rs:1283-1295 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/layers.rs:1193` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (13 lines × 2) mistralrs-core/src/lora/loralinear.rs:146 — mistralrs-core/src/lora/loralinear.rs:146-158 | mistralrs-core/src/lora/qloralinear.rs:191-203 — before extracting anything, compare `mistralrs-core/src/lora/loralinear.rs` and `mistralrs-core/src/lora/qloralinear.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 151 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (13 lines × 2) mistralrs-core/src/model_loader.rs:765 — mistralrs-core/src/model_loader.rs:765-777 | mistralrs-core/src/toml_selector.rs:1041-1053 — before extracting anything, compare `mistralrs-core/src/model_loader.rs` and `mistralrs-core/src/toml_selector.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 199 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/model_loader.rs:765` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (13 lines × 2) mistralrs-core/src/models/flint.rs:436 — mistralrs-core/src/models/flint.rs:436-448 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:288-300 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 194 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/flint.rs:436` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (13 lines × 2) mistralrs-core/src/models/gemma2.rs:581 — mistralrs-core/src/models/gemma2.rs:581-593 | mistralrs-core/src/vision_models/gemma3/text.rs:752-764 — before extracting anything, compare `mistralrs-core/src/models/gemma2.rs` and `mistralrs-core/src/vision_models/gemma3/text.rs` as WHOLE FILES: this scan already matched 34 separate duplicated blocks between them, totalling at least 411 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma2.rs:581` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (13 lines × 2) mistralrs-core/src/models/glm4_moe.rs:867 — mistralrs-core/src/models/glm4_moe.rs:867-879 | mistralrs-core/src/models/glm4_moe.rs:907-919 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (13 lines × 2) mistralrs-core/src/models/lfm2.rs:1137 — mistralrs-core/src/models/lfm2.rs:1137-1149 | mistralrs-core/src/models/lfm3.rs:1059-1071 — before extracting anything, compare `mistralrs-core/src/models/lfm2.rs` and `mistralrs-core/src/models/lfm3.rs` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 402 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/lfm2.rs:1137` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) mistralrs-core/src/pipeline/amoe.rs:128 — mistralrs-core/src/pipeline/amoe.rs:128-140 | mistralrs-core/src/pipeline/amoe.rs:170-182 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/amoe.rs:128` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (13 lines × 2) mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:506 — mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:506-518 | mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:708-720 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:506` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1001 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1001-1013 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1033-1045 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1001` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (13 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1688 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1688-1700 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1996-2008 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (13 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6898 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6898-6910 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7343-7355 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (13 lines × 2) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1816 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1816-1828 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2725-2737 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (13 lines × 2) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3690 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3690-3702 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5248-5260 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3690` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:1884 — mistralrs-core/src/pipeline/multimodal.rs:1884-1896 | mistralrs-core/src/pipeline/normal.rs:1734-1746 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (13 lines × 2) mistralrs-core/src/pipeline/prompt_chunks.rs:69 — mistralrs-core/src/pipeline/prompt_chunks.rs:69-81 | mistralrs-core/src/pipeline/prompt_chunks.rs:106-118 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/prompt_chunks.rs:69` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • + 44 more in this group — see findings.md.
D2 · Cognitive Complexity · mistralrs_quant · ×66
  • mistralrs_quant::metal_kernels::afq_qmm_dispatch (cognitive 68) mistralrs-quant/src/metal_kernels/mod.rs:1024 — mistralrs_quant::metal_kernels::afq_qmm_dispatch has cognitive complexity 68 (threshold 15). Drivers by points: if/else 35 (50 pts), boolean chains 16, match/switch 1 (2 pts) (nesting depth added 16). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
  • mistralrs_quant::afq::ops::afq_mm_op (cognitive 60) mistralrs-quant/src/afq/ops.rs:335 — mistralrs_quant::afq::ops::afq_mm_op has cognitive complexity 60 (threshold 15). Drivers by points: if/else 24 (43 pts), boolean chains 6, match/switch 2 (6 pts), loops 1 (5 pts) (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_quant::cutile::routed_lora::routed_lora_kernel::routed_lora_one_shot (cognitive 56) mistralrs-quant/src/cutile/routed_lora.rs:69 — mistralrs_quant::cutile::routed_lora::routed_lora_kernel::routed_lora_one_shot has cognitive complexity 56 (threshold 15). Drivers by points: if/else 20 (43 pts), loops 2 (8 pts), boolean chains 5 (nesting depth added 29). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • mistralrs_quant::gptq::gptq_cuda::gptq_linear (cognitive 50) mistralrs-quant/src/gptq/gptq_cuda.rs:452 — mistralrs_quant::gptq::gptq_cuda::gptq_linear has cognitive complexity 50 (threshold 15). Drivers by points: if/else 32 (41 pts), boolean chains 5, loops 2 (4 pts) (nesting depth added 11). Of this number, 42 points are the body's own statements and 8 belong to 2 function items inside it that branch. This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
  • mistralrs_quant::mxfp4::ops::mxfp4_indexed_moe_gemm (cognitive 44) mistralrs-quant/src/mxfp4/ops.rs:313 — mistralrs_quant::mxfp4::ops::mxfp4_indexed_moe_gemm has cognitive complexity 44 (threshold 15). Drivers by points: if/else 25 (30 pts), match/switch 9 (12 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • mistralrs_quant::gguf::weight_source::infer_binding_shape (cognitive 39) mistralrs-quant/src/gguf/weight_source.rs:1193 — mistralrs_quant::gguf::weight_source::infer_binding_shape has cognitive complexity 39 (threshold 15). Drivers by points: if/else 14 (30 pts), boolean chains 4, loops 2 (4 pts), match/switch 1 (nesting depth added 18). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • mistralrs_quant::metal_kernels::call_copy_gpu_inplace (cognitive 36) mistralrs-quant/src/metal_kernels/mod.rs:2457 — mistralrs_quant::metal_kernels::call_copy_gpu_inplace has cognitive complexity 36 (threshold 15). Drivers by points: if/else 20 (32 pts), match/switch 4 (nesting depth added 12). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
  • mistralrs_quant::bitsandbytes::op::d_dequantize_nf4 (cognitive 35) mistralrs-quant/src/bitsandbytes/op.rs:28 — mistralrs_quant::bitsandbytes::op::d_dequantize_nf4 has cognitive complexity 35 (threshold 15). Drivers by points: if/else 23 (35 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_quant::cutile::fused_moe::fused_moe::fused_moe_kernel (cognitive 34) mistralrs-quant/src/cutile/fused_moe.rs:36 — mistralrs_quant::cutile::fused_moe::fused_moe::fused_moe_kernel has cognitive complexity 34 (threshold 15). Drivers by points: if/else 18 (31 pts), loops 1 (3 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_quant::cutile::fused_moe_fp8::fused_moe_fp8::fused_moe_fp8_kernel (cognitive 34) mistralrs-quant/src/cutile/fused_moe_fp8.rs:48 — mistralrs_quant::cutile::fused_moe_fp8::fused_moe_fp8::fused_moe_fp8_kernel has cognitive complexity 34 (threshold 15). Drivers by points: if/else 18 (31 pts), loops 1 (3 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_quant::lora::dynamic::expert_cuda::launch_projection (cognitive 34) mistralrs-quant/src/lora/dynamic/expert_cuda.rs:784 — mistralrs_quant::lora::dynamic::expert_cuda::launch_projection has cognitive complexity 34 (threshold 15). Drivers by points: if/else 14 (21 pts), match/switch 4 (7 pts), loops 3 (4 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_quant::metal_kernels::prepare::prepare_afq (cognitive 34) mistralrs-quant/src/metal_kernels/prepare.rs:16 — mistralrs_quant::metal_kernels::prepare::prepare_afq has cognitive complexity 34 (threshold 15). Drivers by points: if/else 13 (22 pts), loops 6 (11 pts), boolean chains 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_quant::cutile::tune::tune (cognitive 33) mistralrs-quant/src/cutile/tune.rs:509 — mistralrs_quant::cutile::tune::tune has cognitive complexity 33 (threshold 15). Drivers by points: if/else 10 (16 pts), match/switch 5 (11 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_quant::mxfp4::ops::mxfp4_matmul (cognitive 32) mistralrs-quant/src/mxfp4/ops.rs:16 — mistralrs_quant::mxfp4::ops::mxfp4_matmul has cognitive complexity 32 (threshold 15). Drivers by points: if/else 17 (21 pts), match/switch 8 (11 pts) (nesting depth added 7). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • mistralrs_quant::lora::dynamic::expert::add_expert_delta_reference (cognitive 31) mistralrs-quant/src/lora/dynamic/expert.rs:705 — mistralrs_quant::lora::dynamic::expert::add_expert_delta_reference has cognitive complexity 31 (threshold 15). Drivers by points: if/else 16 (23 pts), boolean chains 4, match/switch 2 (3 pts), loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_quant::mxfp4::metal_ops::mxfp4_indexed_moe_gemm (cognitive 30) mistralrs-quant/src/mxfp4/metal_ops.rs:173 — mistralrs_quant::mxfp4::metal_ops::mxfp4_indexed_moe_gemm has cognitive complexity 30 (threshold 15). Drivers by points: if/else 19 (24 pts), boolean chains 4, match/switch 2 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • mistralrs_quant::cutile::nvfp4_matmul::prepare_gather_with (cognitive 27) mistralrs-quant/src/cutile/nvfp4_matmul.rs:924 — mistralrs_quant::cutile::nvfp4_matmul::prepare_gather_with has cognitive complexity 27 (threshold 15). Drivers by points: if/else 24 (25 pts), boolean chains 1, match/switch 1 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • mistralrs_quant::cutile::nvfp4::validate_input (cognitive 25) mistralrs-quant/src/cutile/nvfp4.rs:195 — mistralrs_quant::cutile::nvfp4::validate_input has cognitive complexity 25 (threshold 15). Drivers by points: if/else 15 (17 pts), boolean chains 5, match/switch 1 (2 pts), loops 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • mistralrs_quant::rotary::cuda::launch_rotary (cognitive 25) mistralrs-quant/src/rotary/mod.rs:916 — mistralrs_quant::rotary::cuda::launch_rotary has cognitive complexity 25 (threshold 15). Drivers by points: if/else 15 (17 pts), boolean chains 5, match/switch 2 (3 pts) (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • mistralrs_quant::blockwise_fp8::ops::fused_add_rms_norm_quantized_impl (cognitive 24) mistralrs-quant/src/blockwise_fp8/ops.rs:1733 — mistralrs_quant::blockwise_fp8::ops::fused_add_rms_norm_quantized_impl has cognitive complexity 24 (threshold 15). Drivers by points: if/else 19, boolean chains 5. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • mistralrs_quant::cutile::nvfp4_matmul::launch_dense (cognitive 24) mistralrs-quant/src/cutile/nvfp4_matmul.rs:602 — mistralrs_quant::cutile::nvfp4_matmul::launch_dense has cognitive complexity 24 (threshold 15). Drivers by points: if/else 21 (22 pts), match/switch 2 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • mistralrs_quant::fp8_config::compressed_tensors_spec (cognitive 24) mistralrs-quant/src/fp8_config.rs:1093 — mistralrs_quant::fp8_config::compressed_tensors_spec has cognitive complexity 24 (threshold 15). Drivers by points: if/else 12 (16 pts), boolean chains 4, match/switch 3 (4 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_quant::gguf::group::cuda::dense (cognitive 24) mistralrs-quant/src/gguf/group.rs:142 — mistralrs_quant::gguf::group::cuda::dense has cognitive complexity 24 (threshold 15). Drivers by points: if/else 9 (17 pts), match/switch 2 (5 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_quant::gguf::fast_mmvq::fused_qkv_optional (cognitive 23) mistralrs-quant/src/gguf/fast_mmvq.rs:1051 — mistralrs_quant::gguf::fast_mmvq::fused_qkv_optional has cognitive complexity 23 (threshold 15). Drivers by points: if/else 17, boolean chains 5, match/switch 1. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • mistralrs_quant::cutile::nvfp4_gemv::launch (cognitive 22) mistralrs-quant/src/cutile/nvfp4_gemv.rs:255 — mistralrs_quant::cutile::nvfp4_gemv::launch has cognitive complexity 22 (threshold 15). Drivers by points: if/else 15 (17 pts), match/switch 2 (3 pts), boolean chains 2 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • + 41 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (12 lines × 2) · ×65
  • Duplicated block (12 lines × 2) mistralrs-cli/src/commands/quantize.rs:224 — mistralrs-cli/src/commands/quantize.rs:224-235 | mistralrs-cli/src/commands/serve.rs:1140-1151 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (12 lines × 2) mistralrs-cli/src/commands/quantize.rs:659 — mistralrs-cli/src/commands/quantize.rs:659-670 | mistralrs-cli/src/commands/quantize.rs:694-705 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (12 lines × 2) mistralrs-core/src/cuda/dflash_context.rs:237 — mistralrs-core/src/cuda/dflash_context.rs:237-248 | mistralrs-core/src/cuda/dflash_context.rs:362-373 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/dflash_context.rs:237` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (12 lines × 2) mistralrs-core/src/kv_cache/mod.rs:267 — mistralrs-core/src/kv_cache/mod.rs:267-278 | mistralrs-core/src/kv_cache/mod.rs:281-292 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/kv_cache/mod.rs:267` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (12 lines × 2) mistralrs-core/src/model_loader.rs:904 — mistralrs-core/src/model_loader.rs:904-915 | mistralrs-core/src/toml_selector.rs:1224-1235 — before extracting anything, compare `mistralrs-core/src/model_loader.rs` and `mistralrs-core/src/toml_selector.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 199 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/model_loader.rs:904` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (12 lines × 2) mistralrs-core/src/models/deepseek2.rs:110 — mistralrs-core/src/models/deepseek2.rs:110-121 | mistralrs-core/src/models/deepseek3.rs:111-122 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (12 lines × 2) mistralrs-core/src/models/glm4.rs:462 — mistralrs-core/src/models/glm4.rs:462-473 | mistralrs-core/src/models/glm4_moe.rs:747-758 — before extracting anything, compare `mistralrs-core/src/models/glm4.rs` and `mistralrs-core/src/models/glm4_moe.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 359 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/glm4.rs:462` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) mistralrs-core/src/models/glm4_moe.rs:187 — mistralrs-core/src/models/glm4_moe.rs:187-198 | mistralrs-core/src/models/gpt_oss.rs:170-181 — before extracting anything, compare `mistralrs-core/src/models/glm4_moe.rs` and `mistralrs-core/src/models/gpt_oss.rs` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 199 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/glm4_moe.rs:187` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (12 lines × 2) mistralrs-core/src/models/phi3_5_moe.rs:444 — mistralrs-core/src/models/phi3_5_moe.rs:444-455 | mistralrs-core/src/models/starcoder2.rs:369-380 — before extracting anything, compare `mistralrs-core/src/models/phi3_5_moe.rs` and `mistralrs-core/src/models/starcoder2.rs` as WHOLE FILES: this scan already matched 31 separate duplicated blocks between them, totalling at least 373 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (12 lines × 2) mistralrs-core/src/models/qwen3_next.rs:356 — mistralrs-core/src/models/qwen3_next.rs:356-367 | mistralrs-core/src/vision_models/qwen3_5/text.rs:406-417 — before extracting anything, compare `mistralrs-core/src/models/qwen3_next.rs` and `mistralrs-core/src/vision_models/qwen3_5/text.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 176 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/qwen3_next.rs:356` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) mistralrs-core/src/paged_attention/cache_engine.rs:302 — mistralrs-core/src/paged_attention/cache_engine.rs:302-313 | mistralrs-core/src/paged_attention/cache_engine.rs:490-501 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/paged_attention/cache_engine.rs:302` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (12 lines × 2) mistralrs-core/src/paged_attention/layers/paged_attention.rs:2635 — mistralrs-core/src/paged_attention/layers/paged_attention.rs:2635-2646 | mistralrs-core/src/paged_attention/layers/paged_attention.rs:2655-2666 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/paged_attention/layers/paged_attention.rs:2635` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) mistralrs-core/src/pipeline/embedding.rs:232 — mistralrs-core/src/pipeline/embedding.rs:232-243 | mistralrs-core/src/pipeline/normal.rs:703-714 — before extracting anything, compare `mistralrs-core/src/pipeline/embedding.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 178 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/embedding.rs:232` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/pipeline/normal.rs:716` calls `clone` and `mistralrs-core/src/pipeline/embedding.rs:246` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12 lines × 2) mistralrs-core/src/pipeline/loaders/checkpoint_inventory.rs:99 — mistralrs-core/src/pipeline/loaders/checkpoint_inventory.rs:99-110 | mistralrs-core/src/pipeline/loaders/checkpoint_inventory.rs:128-139 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/pipeline/loaders/checkpoint_inventory.rs:126` calls `Fn` and `mistralrs-core/src/pipeline/loaders/checkpoint_inventory.rs:97` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:864 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:864-875 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5504-5522 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:864` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (12 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5403 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5403-5414 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5427-5438 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5403` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (12 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9158 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9158-9169 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9173-9184 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9158` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:10258 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:10258-10269 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6899-6910 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` and `mistralrs-core/src/pipeline/loaders/normal_loaders.rs` as WHOLE FILES: this scan already matched 34 separate duplicated blocks between them, totalling at least 445 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:10258` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3985 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3985-3996 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4236-4247 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (12 lines × 2) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5567 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5567-5578 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6843-6854 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5567` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:671 — mistralrs-core/src/pipeline/multimodal.rs:671-682 | mistralrs-core/src/pipeline/normal.rs:709-720 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:671` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:2853 — mistralrs-core/src/pipeline/multimodal.rs:2853-2864 | mistralrs-core/src/pipeline/normal.rs:2515-2526 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:2853` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/pipeline/normal.rs:2514` calls `is_xlora` and `mistralrs-core/src/pipeline/multimodal.rs:2852` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12 lines × 2) mistralrs-core/src/response.rs:533 — mistralrs-core/src/response.rs:533-544 | mistralrs-core/src/response.rs:551-562 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/response.rs:533` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) mistralrs-core/src/speculative/dflash.rs:2063 — mistralrs-core/src/speculative/dflash.rs:2063-2074 | mistralrs-core/src/speculative/dflash.rs:2102-2113 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/speculative/dflash.rs:2063` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) mistralrs-core/src/tools/parsers/deepseek.rs:67 — mistralrs-core/src/tools/parsers/deepseek.rs:67-78 | mistralrs-core/src/tools/parsers/harmony.rs:24-35 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/tools/parsers/deepseek.rs:67` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • + 40 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (11 lines × 2) · ×59
  • Duplicated block (11 lines × 2) mistralrs-cli/src/args/mod.rs:888 — mistralrs-cli/src/args/mod.rs:888-898 | mistralrs-cli/src/args/mod.rs:979-989 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (11 lines × 2) mistralrs-cli/src/commands/run/mod.rs:115 — mistralrs-cli/src/commands/run/mod.rs:115-125 | mistralrs-cli/src/commands/serve.rs:129-139 — before extracting anything, compare `mistralrs-cli/src/commands/run/mod.rs` and `mistralrs-cli/src/commands/serve.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 49 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-cli/src/commands/serve.rs:127` calls `default` and `mistralrs-cli/src/commands/run/mod.rs:113` does not — after which the two agree again for 5 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (11 lines × 2) mistralrs-core/src/distributed.rs:267 — mistralrs-core/src/distributed.rs:267-277 | mistralrs-core/src/distributed.rs:307-317 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/distributed.rs:267` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) mistralrs-core/src/gguf/normal_config.rs:261 — mistralrs-core/src/gguf/normal_config.rs:261-271 | mistralrs-core/src/gguf/normal_config.rs:322-332 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (11 lines × 2) mistralrs-core/src/models/glm4_moe.rs:735 — mistralrs-core/src/models/glm4_moe.rs:735-745 | mistralrs-core/src/models/granite.rs:1974-1984 — before extracting anything, compare `mistralrs-core/src/models/glm4_moe.rs` and `mistralrs-core/src/models/granite.rs` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 233 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/glm4_moe.rs:735` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) mistralrs-core/src/models/lfm2.rs:1111 — mistralrs-core/src/models/lfm2.rs:1111-1121 | mistralrs-core/src/models/lfm3.rs:1023-1033 — before extracting anything, compare `mistralrs-core/src/models/lfm2.rs` and `mistralrs-core/src/models/lfm3.rs` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 402 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/lfm2.rs:1111` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (11 lines × 2) mistralrs-core/src/models/phi2.rs:442 — mistralrs-core/src/models/phi2.rs:442-452 | mistralrs-core/src/xlora_models/phi2.rs:413-423 — `mistralrs-core/src/models/phi2.rs` and `mistralrs-core/src/xlora_models/phi2.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 7 separate duplicated blocks between them, totalling at least 85 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (11 lines × 2) mistralrs-core/src/ops.rs:934 — mistralrs-core/src/ops.rs:934-944 | mistralrs-core/src/ops.rs:1016-1026 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (11 lines × 2) mistralrs-core/src/ops.rs:1066 — mistralrs-core/src/ops.rs:1066-1076 | mistralrs-core/src/ops.rs:1301-1311 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (11 lines × 2) mistralrs-core/src/ops.rs:5743 — mistralrs-core/src/ops.rs:5743-5753 | mistralrs-core/src/ops.rs:6173-6183 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:5743` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) mistralrs-core/src/paged_attention/layers/paged_attention.rs:1807 — mistralrs-core/src/paged_attention/layers/paged_attention.rs:1807-1817 | mistralrs-core/src/paged_attention/layers/paged_attention.rs:1828-1839 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/paged_attention/layers/paged_attention.rs:1828` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (11 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1328 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1328-1338 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1357-1367 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1328` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (11 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3108 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3108-3118 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3137-3147 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3108` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (11 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3457 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3457-3467 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3486-3496 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3457` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (11 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9326 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9326-9336 | mistralrs-core/src/vision_models/voxtral/mod.rs:708-718 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (11 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:2823 — mistralrs-core/src/pipeline/multimodal.rs:2823-2833 | mistralrs-core/src/pipeline/normal.rs:2435-2445 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:2823` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) mistralrs-core/src/pipeline/prompt_chunks.rs:57 — mistralrs-core/src/pipeline/prompt_chunks.rs:57-67 | mistralrs-core/src/pipeline/prompt_chunks.rs:93-103 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/prompt_chunks.rs:57` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (11 lines × 2) mistralrs-core/src/vision_models/gemma4/mod.rs:141 — mistralrs-core/src/vision_models/gemma4/mod.rs:141-151 | mistralrs-core/src/vision_models/gemma4/mod.rs:153-163 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma4/mod.rs:141` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) mistralrs-core/src/vision_models/gemma4/mod.rs:441 — mistralrs-core/src/vision_models/gemma4/mod.rs:441-451 | mistralrs-core/src/vision_models/phi3/mod.rs:979-989 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma4/mod.rs:441` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (11 lines × 2) mistralrs-core/src/vision_models/grid_processor.rs:494 — mistralrs-core/src/vision_models/grid_processor.rs:494-504 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:277-287 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 51 separate duplicated blocks between them, totalling at least 1008 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:494` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (11 lines × 2) REDACTED:490 — REDACTED:490-500 | REDACTED:845-855 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:490` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (11 lines × 2) REDACTED:593 — REDACTED:593-603 | mistralrs-core/src/vision_models/siglip.rs:401-411 — before extracting anything, compare `REDACTED` and `mistralrs-core/src/vision_models/siglip.rs` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 256 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (11 lines × 2) mistralrs-core/src/vision_models/lfm3_vl/mod.rs:246 — mistralrs-core/src/vision_models/lfm3_vl/mod.rs:246-256 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:515-525 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (11 lines × 2) mistralrs-core/src/vision_models/llama4/vision.rs:273 — mistralrs-core/src/vision_models/llama4/vision.rs:273-283 | mistralrs-core/src/vision_models/mllama/vision.rs:294-304 — `mistralrs-core/src/vision_models/llama4/vision.rs` and `mistralrs-core/src/vision_models/mllama/vision.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 6 separate duplicated blocks between them, totalling at least 67 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (11 lines × 2) mistralrs-core/src/vision_models/llava/llava15.rs:183 — mistralrs-core/src/vision_models/llava/llava15.rs:183-193 | mistralrs-core/src/vision_models/llava/llava_next.rs:143-153 — before extracting anything, compare `mistralrs-core/src/vision_models/llava/llava15.rs` and `mistralrs-core/src/vision_models/llava/llava_next.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 109 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/vision_models/llava/llava_next.rs:155` calls `get`, `to_device` and `mistralrs-core/src/vision_models/llava/llava15.rs:195` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • + 34 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (16 lines × 2) · ×49
  • Duplicated block (16 lines × 2) mistralrs-cli/src/commands/run/interactive.rs:968 — mistralrs-cli/src/commands/run/interactive.rs:968-983 | mistralrs-cli/src/commands/run/interactive.rs:1756-1771 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-cli/src/commands/run/interactive.rs:968` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-cli/src/commands/run/interactive.rs:1753` calls `clone` and `mistralrs-cli/src/commands/run/interactive.rs:967` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (16 lines × 2) mistralrs-cli/src/commands/run/interactive.rs:1956 — mistralrs-cli/src/commands/run/interactive.rs:1956-1971 | mistralrs-cli/src/commands/run/interactive.rs:2079-2094 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-cli/src/commands/run/interactive.rs:1956` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (16 lines × 2) mistralrs-core/src/gdn/layer.rs:137 — mistralrs-core/src/gdn/layer.rs:137-152 | mistralrs-core/src/gdn/layer.rs:161-176 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (16 lines × 2) mistralrs-core/src/gdn/projection.rs:125 — mistralrs-core/src/gdn/projection.rs:125-140 | mistralrs-core/src/gdn/projection.rs:157-172 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/gdn/projection.rs:125` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (16 lines × 2) mistralrs-core/src/metal/gdn.rs:841 — mistralrs-core/src/metal/gdn.rs:841-856 | mistralrs-core/src/metal/gdn.rs:880-895 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/metal/gdn.rs:841` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/metal/gdn.rs:840` calls `set_input_buffer`, `Some` and `mistralrs-core/src/metal/gdn.rs:878` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (16 lines × 2) mistralrs-core/src/models/flint.rs:817 — mistralrs-core/src/models/flint.rs:817-832 | mistralrs-core/src/models/qwen3_moe.rs:616-631 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/qwen3_moe.rs` as WHOLE FILES: this scan already matched 43 separate duplicated blocks between them, totalling at least 479 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/flint.rs:817` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) mistralrs-core/src/models/granite.rs:2069 — mistralrs-core/src/models/granite.rs:2069-2084 | mistralrs-core/src/models/smollm3.rs:437-452 — before extracting anything, compare `mistralrs-core/src/models/granite.rs` and `mistralrs-core/src/models/smollm3.rs` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 260 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (16 lines × 2) mistralrs-core/src/models/qwen2.rs:393 — mistralrs-core/src/models/qwen2.rs:393-408 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:473-488 — before extracting anything, compare `mistralrs-core/src/models/qwen2.rs` and `mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 162 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (16 lines × 2) mistralrs-core/src/ops.rs:1618 — mistralrs-core/src/ops.rs:1618-1633 | mistralrs-core/src/ops.rs:1870-1885 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:1618` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (16 lines × 2) mistralrs-core/src/ops.rs:5791 — mistralrs-core/src/ops.rs:5791-5806 | mistralrs-core/src/ops.rs:6227-6242 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:5791` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) mistralrs-core/src/pipeline/embedding.rs:505 — mistralrs-core/src/pipeline/embedding.rs:505-520 | mistralrs-core/src/pipeline/multimodal.rs:1075-1090 — before extracting anything, compare `mistralrs-core/src/pipeline/embedding.rs` and `mistralrs-core/src/pipeline/multimodal.rs` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 178 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/embedding.rs:505` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (16 lines × 2) mistralrs-core/src/pipeline/inputs_processor.rs:2215 — mistralrs-core/src/pipeline/inputs_processor.rs:2215-2230 | mistralrs-core/src/pipeline/inputs_processor.rs:2304-2319 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/inputs_processor.rs:2215` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1709 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1709-1724 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1745-1760 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1709` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (16 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2356 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2356-2371 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2394-2409 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2356` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (16 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5045 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5045-5060 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5456-5471 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (16 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6944 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6944-6959 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7408-7423 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6944` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:791 — mistralrs-core/src/pipeline/multimodal.rs:791-806 | mistralrs-core/src/pipeline/normal.rs:803-818 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:791` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:818 — mistralrs-core/src/pipeline/multimodal.rs:818-833 | mistralrs-core/src/pipeline/multimodal.rs:888-903 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:818` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:2736 — mistralrs-core/src/pipeline/multimodal.rs:2736-2751 | mistralrs-core/src/pipeline/normal.rs:2303-2318 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:2736` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/pipeline/multimodal.rs:2752` calls `drop` and `mistralrs-core/src/pipeline/normal.rs:2319` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (16 lines × 2) mistralrs-core/src/pipeline/normal.rs:824 — mistralrs-core/src/pipeline/normal.rs:824-839 | mistralrs-core/src/pipeline/normal.rs:894-909 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/normal.rs:824` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) mistralrs-core/src/tools/parsers/liquid.rs:300 — mistralrs-core/src/tools/parsers/liquid.rs:300-315 | mistralrs-core/src/tools/parsers/liquid.rs:338-353 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/tools/parsers/liquid.rs:300` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) mistralrs-core/src/utils/gguf_metadata.rs:329 — mistralrs-core/src/utils/gguf_metadata.rs:329-344 | mistralrs-core/src/utils/gguf_metadata.rs:378-393 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (16 lines × 2) mistralrs-core/src/vision_models/grid_processor.rs:686 — mistralrs-core/src/vision_models/grid_processor.rs:686-701 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:638-653 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 51 separate duplicated blocks between them, totalling at least 1008 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:686` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:634 — mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:634-649 | mistralrs-core/src/vision_models/llama4/inputs_processor.rs:577-592 — before extracting anything, compare `mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs` and `mistralrs-core/src/vision_models/llama4/inputs_processor.rs` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 152 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:634` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (16 lines × 2) mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:468 — mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:468-483 | mistralrs-core/src/vision_models/phi3/phi3_inputs_processor.rs:420-435 — before extracting anything, compare `mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs` and `mistralrs-core/src/vision_models/phi3/phi3_inputs_processor.rs` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 288 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:468` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • + 24 more in this group — see findings.md.
D1 · Cyclomatic Complexity · mistralrs_quant · ×46
  • mistralrs_quant::afq::ops::cuda_backend::afq_mm_op (cyclomatic 55) mistralrs-quant/src/afq/ops.rs:2588 — mistralrs_quant::afq::ops::cuda_backend::afq_mm_op has cyclomatic complexity 55 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • mistralrs_quant::gguf::cuda::indexed_moe_fused_decode (cyclomatic 52) mistralrs-quant/src/gguf/cuda.rs:1468 — mistralrs_quant::gguf::cuda::indexed_moe_fused_decode has cyclomatic complexity 52 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • mistralrs_quant::metal_kernels::afq_qmm_dispatch (cyclomatic 41) mistralrs-quant/src/metal_kernels/mod.rs:1024 — mistralrs_quant::metal_kernels::afq_qmm_dispatch has cyclomatic complexity 41 (threshold 15). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
  • mistralrs_quant::afq::ops::cuda_backend::afq_quantize_op (cyclomatic 36) mistralrs-quant/src/afq/ops.rs:1706 — mistralrs_quant::afq::ops::cuda_backend::afq_quantize_op has cyclomatic complexity 36 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing. This is NOT this file's highest cyclomatic complexity: mistralrs_quant::afq::ops::cuda_backend::afq_dequantize_op (cyclomatic 52) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
  • mistralrs_quant::gguf::weight_source::infer_binding_shape (cyclomatic 34) mistralrs-quant/src/gguf/weight_source.rs:1193 — mistralrs_quant::gguf::weight_source::infer_binding_shape has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_quant::afq::ops::afq_mm_op (cyclomatic 30) mistralrs-quant/src/afq/ops.rs:335 — mistralrs_quant::afq::ops::afq_mm_op has cyclomatic complexity 30 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: mistralrs_quant::afq::ops::cuda_backend::afq_dequantize_op (cyclomatic 52) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
  • mistralrs_quant::mxfp4::ops::mxfp4_indexed_moe_gemm (cyclomatic 28) mistralrs-quant/src/mxfp4/ops.rs:313 — mistralrs_quant::mxfp4::ops::mxfp4_indexed_moe_gemm has cyclomatic complexity 28 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • mistralrs_quant::gptq::gptq_cuda::gptq_linear (cyclomatic 26) mistralrs-quant/src/gptq/gptq_cuda.rs:452 — mistralrs_quant::gptq::gptq_cuda::gptq_linear has cyclomatic complexity 26 (threshold 15). Of this number, 22 points are the body's own statements and 4 belong to 2 function items inside it that branch. This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
  • mistralrs_quant::lora::dynamic::expert_cuda::launch_projection (cyclomatic 26) mistralrs-quant/src/lora/dynamic/expert_cuda.rs:784 — mistralrs_quant::lora::dynamic::expert_cuda::launch_projection has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_quant::gguf::quantize::quantize_cpu (cyclomatic 25) mistralrs-quant/src/gguf/quantize.rs:16 — mistralrs_quant::gguf::quantize::quantize_cpu has cyclomatic complexity 25 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • mistralrs_quant::mxfp4::metal_ops::mxfp4_indexed_moe_gemm (cyclomatic 25) mistralrs-quant/src/mxfp4/metal_ops.rs:173 — mistralrs_quant::mxfp4::metal_ops::mxfp4_indexed_moe_gemm has cyclomatic complexity 25 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • mistralrs_quant::fp8_config::compressed_tensors_spec (cyclomatic 24) mistralrs-quant/src/fp8_config.rs:1093 — mistralrs_quant::fp8_config::compressed_tensors_spec has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_quant::gguf::fast_mmvq::fused_qkv_optional (cyclomatic 24) mistralrs-quant/src/gguf/fast_mmvq.rs:1051 — mistralrs_quant::gguf::fast_mmvq::fused_qkv_optional has cyclomatic complexity 24 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This is NOT this file's highest cyclomatic complexity: mistralrs_quant::gguf::fast_mmvq::fused_glu_launcher (cyclomatic 31) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
  • mistralrs_quant::blockwise_fp8::ops::fused_add_rms_norm_quantized_impl (cyclomatic 23) mistralrs-quant/src/blockwise_fp8/ops.rs:1733 — mistralrs_quant::blockwise_fp8::ops::fused_add_rms_norm_quantized_impl has cyclomatic complexity 23 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • mistralrs_quant::lora::dynamic::expert::add_expert_delta_reference (cyclomatic 23) mistralrs-quant/src/lora/dynamic/expert.rs:705 — mistralrs_quant::lora::dynamic::expert::add_expert_delta_reference has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_quant::gguf::fast_mmq::shared_lhs (cyclomatic 22) mistralrs-quant/src/gguf/fast_mmq.rs:569 — mistralrs_quant::gguf::fast_mmq::shared_lhs has cyclomatic complexity 22 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • mistralrs_quant::afq::group::gate_up (cyclomatic 21) mistralrs-quant/src/afq/group.rs:70 — mistralrs_quant::afq::group::gate_up has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • mistralrs_quant::cutile::fp8_w8a8::launch (cyclomatic 21) mistralrs-quant/src/cutile/fp8_w8a8.rs:451 — mistralrs_quant::cutile::fp8_w8a8::launch has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • mistralrs_quant::cutile::nvfp4::validate_input (cyclomatic 21) mistralrs-quant/src/cutile/nvfp4.rs:195 — mistralrs_quant::cutile::nvfp4::validate_input has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • mistralrs_quant::cutile::routed_lora::routed_lora_kernel::routed_lora_one_shot (cyclomatic 21) mistralrs-quant/src/cutile/routed_lora.rs:69 — mistralrs_quant::cutile::routed_lora::routed_lora_kernel::routed_lora_one_shot has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_quant::metal_kernels::call_scan (cyclomatic 21) mistralrs-quant/src/metal_kernels/mod.rs:2089 — mistralrs_quant::metal_kernels::call_scan has cyclomatic complexity 21 (threshold 15). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
  • mistralrs_quant::rotary::cuda::launch_rotary (cyclomatic 21) mistralrs-quant/src/rotary/mod.rs:916 — mistralrs_quant::rotary::cuda::launch_rotary has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • mistralrs_quant::routed_gemv::cuda::launch (cyclomatic 21) mistralrs-quant/src/routed_gemv/cuda.rs:382 — mistralrs_quant::routed_gemv::cuda::launch has cyclomatic complexity 21 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • mistralrs_quant::cutile::qsa_decode::decode_shape (cyclomatic 20) mistralrs-quant/src/cutile/qsa_decode.rs:439 — mistralrs_quant::cutile::qsa_decode::decode_shape has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • mistralrs_quant::cutile::tune::tune (cyclomatic 20) mistralrs-quant/src/cutile/tune.rs:509 — mistralrs_quant::cutile::tune::tune has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • + 21 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (15 lines × 2) · ×45
  • Duplicated block (15 lines × 2) mistralrs-cli/src/commands/config.rs:81 — mistralrs-cli/src/commands/config.rs:81-95 | mistralrs-cli/src/commands/config.rs:245-259 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-cli/src/commands/config.rs:81` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-cli/src/commands/config.rs:97` calls `Some`, `with_default_model_id` and `mistralrs-cli/src/commands/config.rs:261` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (15 lines × 2) mistralrs-core/src/attention/backends/cpu/neon.rs:372 — mistralrs-core/src/attention/backends/cpu/neon.rs:372-386 | mistralrs-core/src/attention/backends/cpu/neon.rs:611-625 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/attention/backends/cpu/neon.rs:372` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (15 lines × 2) mistralrs-core/src/distributed.rs:650 — mistralrs-core/src/distributed.rs:650-664 | mistralrs-core/src/distributed.rs:692-706 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (15 lines × 2) mistralrs-core/src/engine/add_request.rs:1158 — mistralrs-core/src/engine/add_request.rs:1158-1172 | mistralrs-core/src/engine/add_request.rs:1195-1209 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note first that the copies are not typed on the same thing: the declarations holding them bind `request` to `TokenizationRequest` in one and `DetokenizationRequest` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (15 lines × 2) mistralrs-core/src/engine/agentic_loop.rs:1491 — mistralrs-core/src/engine/agentic_loop.rs:1491-1505 | mistralrs-core/src/engine/agentic_loop.rs:1558-1572 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/engine/agentic_loop.rs:1491` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) mistralrs-core/src/gguf/normal_config.rs:710 — mistralrs-core/src/gguf/normal_config.rs:710-724 | mistralrs-core/src/gguf/normal_config.rs:899-913 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (15 lines × 2) mistralrs-core/src/metal/gdn.rs:223 — mistralrs-core/src/metal/gdn.rs:223-237 | mistralrs-core/src/metal/gdn.rs:328-342 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/metal/gdn.rs:223` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) mistralrs-core/src/metal/gdn.rs:799 — mistralrs-core/src/metal/gdn.rs:799-813 | mistralrs-core/src/metal/gdn.rs:889-903 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/metal/gdn.rs:888` calls `set_bytes` and `mistralrs-core/src/metal/gdn.rs:798` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (15 lines × 2) mistralrs-core/src/model_loader.rs:851 — mistralrs-core/src/model_loader.rs:851-865 | mistralrs-core/src/toml_selector.rs:1129-1143 — before extracting anything, compare `mistralrs-core/src/model_loader.rs` and `mistralrs-core/src/toml_selector.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 199 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/model_loader.rs:851` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (15 lines × 2) mistralrs-core/src/models/granite.rs:1051 — mistralrs-core/src/models/granite.rs:1051-1065 | mistralrs-core/src/models/granite.rs:1222-1236 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (15 lines × 2) mistralrs-core/src/models/granite.rs:2138 — mistralrs-core/src/models/granite.rs:2138-2152 | mistralrs-core/src/models/qwen3_next.rs:929-943 — before extracting anything, compare `mistralrs-core/src/models/granite.rs` and `mistralrs-core/src/models/qwen3_next.rs` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 167 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/granite.rs:2138` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) mistralrs-core/src/models/lfm2.rs:658 — mistralrs-core/src/models/lfm2.rs:658-672 | mistralrs-core/src/models/lfm3.rs:661-675 — before extracting anything, compare `mistralrs-core/src/models/lfm2.rs` and `mistralrs-core/src/models/lfm3.rs` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 402 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (15 lines × 2) mistralrs-core/src/ops.rs:2085 — mistralrs-core/src/ops.rs:2085-2099 | mistralrs-core/src/ops.rs:2242-2256 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:2085` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/ops.rs:2240` calls `drop` and `mistralrs-core/src/ops.rs:2083` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (15 lines × 2) mistralrs-core/src/paged_attention/encoder_cache.rs:227 — mistralrs-core/src/paged_attention/encoder_cache.rs:227-241 | mistralrs-core/src/paged_attention/encoder_cache.rs:360-374 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/paged_attention/encoder_cache.rs:227` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3180 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3180-3194 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3529-3543 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3180` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (15 lines × 2) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1004 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1004-1018 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2384-2398 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1004` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:1463 — mistralrs-core/src/pipeline/multimodal.rs:1463-1477 | mistralrs-core/src/pipeline/normal.rs:1506-1520 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:1463` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:1745 — mistralrs-core/src/pipeline/multimodal.rs:1745-1759 | mistralrs-core/src/pipeline/normal.rs:1615-1629 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (15 lines × 2) mistralrs-core/src/vision_models/gemma3n/text.rs:1367 — mistralrs-core/src/vision_models/gemma3n/text.rs:1367-1381 | mistralrs-core/src/vision_models/gemma3n/text.rs:1391-1405 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3n/text.rs:1367` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:258 — mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:258-272 | mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:523-537 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:258` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1685 — mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1685-1699 | mistralrs-core/src/vision_models/grid_processor.rs:1811-1825 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1685` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) mistralrs-core/src/vision_models/gemma4/text.rs:601 — mistralrs-core/src/vision_models/gemma4/text.rs:601-615 | mistralrs-core/src/vision_models/gemma4/text.rs:634-648 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma4/text.rs:601` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) mistralrs-core/src/vision_models/grid_processor.rs:837 — mistralrs-core/src/vision_models/grid_processor.rs:837-851 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:560-574 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 51 separate duplicated blocks between them, totalling at least 1008 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (15 lines × 2) mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:349 — mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:349-363 | mistralrs-core/src/vision_models/llama4/inputs_processor.rs:201-215 — before extracting anything, compare `mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs` and `mistralrs-core/src/vision_models/llama4/inputs_processor.rs` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 152 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:349` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) REDACTED:461 — REDACTED:461-475 | REDACTED:816-830 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:461` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `REDACTED:815` calls `to_dtype` and `REDACTED:460` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • + 20 more in this group — see findings.md.
D17 · Explicit Debt · TodoComment · ×40
  • TodoComment mistralrs-vision/src/ops.rs:18 — // TODO(EricLBuehler): https://github.com/huggingface/candle/pull/2223 will make this nicer
  • TodoComment mistralrs-server-core/src/mistralrs_for_server_builder.rs:1334 — // TODO: replace with best device? — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment mistralrs-quant/src/lib.rs:979 — // TODO(EricLBuehler): Optimize this by using the gemm parameter? — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment mistralrs-quant/src/lib.rs:986 — // TODO(EricLBuehler): Optimize this by using the gemm parameter? — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment mistralrs-quant/src/unquantized/mod.rs:436 — // TODO just warn? — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment mistralrs-quant/src/unquantized/mod.rs:469 — // TODO just warn? — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment mistralrs-quant/src/unquantized/mod.rs:561 — // TODO just warn? — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment mistralrs-quant/src/blockwise_fp8/mod.rs:1093 — // TODO just warn? — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment mistralrs-quant/src/blockwise_fp8/mod.rs:1127 — // TODO just warn? — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment mistralrs-quant/src/blockwise_fp8/mod.rs:1184 — // TODO just warn? — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment mistralrs-quant/src/hqq/quantize.rs:29 — // TODO we need min_all — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment mistralrs-quant/src/gptq/gptq_cuda.rs:354 — // TODO — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment mistralrs-core/src/request.rs:317 — // TODO — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment mistralrs-core/src/request.rs:319 — // TODO — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment mistralrs-core/src/pipeline/ggml.rs:589 — // TODO — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment mistralrs-core/src/models/quantized_llama.rs:221 — // TODO — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment mistralrs-quant/src/bitsandbytes/mod.rs:122 — // TODO: can `nested_blocksize` be None, default to 64 like bnb? — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment mistralrs-flash-attn/src/flash.rs:85 — // TODO: Handle head sizes that are not a multiple of 8 via some padding. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment mistralrs-flash-attn/src/flash.rs:610 — // TODO: Handle head sizes that are not a multiple of 8 via some padding. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment mistralrs-core/src/utils/model_config.rs:78 — // TODO: `from_mmaped_safetensors` has `xlora_paths` as the 2nd param (_valid but params need to be named better_) — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment mistralrs-core/src/utils/progress.rs:64 — // TODO: Should `is_silent` instead be referenced as a global read-only state? (`AtomicBool`) — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment mistralrs-core/src/utils/varbuilder_utils.rs:181 — // TODO(EricLBuehler): separation of concerns. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment mistralrs-core/src/utils/varbuilder_utils.rs:212 — // TODO(EricLBuehler): separation of concerns. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment mistralrs-core/src/utils/varbuilder_utils.rs:314 — // TODO: Add better context to describe intent / requirement: — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment mistralrs-core/src/speech_models/bs1770.rs:390 — // TODO: Should this branch be marked cold? — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • + 15 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (14 lines × 2) · ×37
  • Duplicated block (14 lines × 2) mistralrs-core/src/attention/backends/cpu/full.rs:655 — mistralrs-core/src/attention/backends/cpu/full.rs:655-668 | mistralrs-core/src/attention/backends/cpu/single_q.rs:342-355 — before extracting anything, compare `mistralrs-core/src/attention/backends/cpu/full.rs` and `mistralrs-core/src/attention/backends/cpu/single_q.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 44 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (14 lines × 2) mistralrs-core/src/cuda/gdn.rs:991 — mistralrs-core/src/cuda/gdn.rs:991-1004 | mistralrs-core/src/cuda/gdn.rs:1117-1130 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/gdn.rs:991` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 2) mistralrs-core/src/gdn/projection.rs:141 — mistralrs-core/src/gdn/projection.rs:141-154 | mistralrs-core/src/gdn/projection.rs:216-229 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (14 lines × 2) mistralrs-core/src/model_loader.rs:575 — mistralrs-core/src/model_loader.rs:575-588 | mistralrs-core/src/toml_selector.rs:907-920 — before extracting anything, compare `mistralrs-core/src/model_loader.rs` and `mistralrs-core/src/toml_selector.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 199 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/model_loader.rs:575` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (14 lines × 2) mistralrs-core/src/models/granite.rs:1292 — mistralrs-core/src/models/granite.rs:1292-1305 | mistralrs-core/src/models/granite.rs:1314-1327 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/granite.rs:1292` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 2) mistralrs-core/src/models/lfm2.rs:1291 — mistralrs-core/src/models/lfm2.rs:1291-1304 | mistralrs-core/src/models/lfm3.rs:1306-1319 — before extracting anything, compare `mistralrs-core/src/models/lfm2.rs` and `mistralrs-core/src/models/lfm3.rs` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 402 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/lfm2.rs:1291` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/models/lfm2.rs:1290` calls `batch_kind` and `mistralrs-core/src/models/lfm3.rs:1305` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14 lines × 2) mistralrs-core/src/models/starcoder2.rs:341 — mistralrs-core/src/models/starcoder2.rs:341-354 | mistralrs-core/src/xlora_models/starcoder2.rs:328-341 — `mistralrs-core/src/models/starcoder2.rs` and `mistralrs-core/src/xlora_models/starcoder2.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 7 separate duplicated blocks between them, totalling at least 73 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/starcoder2.rs:341` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (14 lines × 2) mistralrs-core/src/ops.rs:3071 — mistralrs-core/src/ops.rs:3071-3084 | mistralrs-core/src/ops.rs:3530-3543 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:3071` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/ops.rs:3069` calls `memcpy_dtoh` and `mistralrs-core/src/ops.rs:3529` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14 lines × 2) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1765 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1765-1778 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6105-6118 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1765` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 2) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4031 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4031-4044 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4294-4307 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4031` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:490 — mistralrs-core/src/pipeline/multimodal.rs:490-503 | mistralrs-core/src/pipeline/normal.rs:623-636 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:490` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/pipeline/multimodal.rs:489` calls `validate_dynamic_lora` and `mistralrs-core/src/pipeline/normal.rs:622` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14 lines × 2) mistralrs-core/src/vision_models/gemma3n/text.rs:1796 — mistralrs-core/src/vision_models/gemma3n/text.rs:1796-1809 | mistralrs-core/src/vision_models/gemma3n/text.rs:1902-1915 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3n/text.rs:1796` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 2) mistralrs-core/src/vision_models/llama4/inputs_processor.rs:653 — mistralrs-core/src/vision_models/llama4/inputs_processor.rs:653-666 | mistralrs-core/src/vision_models/mllama/inputs_processor.rs:509-523 — `mistralrs-core/src/vision_models/llama4/inputs_processor.rs` and `mistralrs-core/src/vision_models/mllama/inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 4 separate duplicated blocks between them, totalling at least 66 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/llama4/inputs_processor.rs:653` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (14 lines × 2) mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:189 — mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:189-202 | mistralrs-core/src/vision_models/phi3/phi3_inputs_processor.rs:145-158 — before extracting anything, compare `mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs` and `mistralrs-core/src/vision_models/phi3/phi3_inputs_processor.rs` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 288 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:189` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 2) mistralrs-core/src/vision_models/phi3/mod.rs:611 — mistralrs-core/src/vision_models/phi3/mod.rs:611-624 | mistralrs-core/src/vision_models/phi4/image_embedding.rs:234-247 — before extracting anything, compare `mistralrs-core/src/vision_models/phi3/mod.rs` and `mistralrs-core/src/vision_models/phi4/image_embedding.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 98 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/phi3/mod.rs:611` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (14 lines × 2) mistralrs-core/src/vision_models/phi3/mod.rs:1168 — mistralrs-core/src/vision_models/phi3/mod.rs:1168-1181 | mistralrs-core/src/vision_models/phi4/image_embedding.rs:825-838 — before extracting anything, compare `mistralrs-core/src/vision_models/phi3/mod.rs` and `mistralrs-core/src/vision_models/phi4/image_embedding.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 98 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (14 lines × 2) mistralrs-core/src/vision_models/phi3/phi3_inputs_processor.rs:247 — mistralrs-core/src/vision_models/phi3/phi3_inputs_processor.rs:247-260 | mistralrs-core/src/vision_models/phi3/phi3_inputs_processor.rs:440-453 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (14 lines × 2) mistralrs-core/src/vision_models/qwen2_5_vl/config.rs:101 — mistralrs-core/src/vision_models/qwen2_5_vl/config.rs:101-114 | mistralrs-core/src/vision_models/qwen2vl/config.rs:75-88 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen2_5_vl/config.rs:101` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 2) mistralrs-core/src/vision_models/qwen3_5/text.rs:1187 — mistralrs-core/src/vision_models/qwen3_5/text.rs:1187-1200 | mistralrs-core/src/vision_models/qwen4_exp/text.rs:731-744 — `mistralrs-core/src/vision_models/qwen3_5/text.rs` and `mistralrs-core/src/vision_models/qwen4_exp/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 7 separate duplicated blocks between them, totalling at least 83 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit. Note first that the copies are not typed on the same thing: the declarations holding them bind `rows` to `&[crate::speculative::SpeculativeCommitRow]` in one and `&[SpeculativeCommitRow]` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (14 lines × 2) mistralrs-quant/src/blockwise_fp8/ops.rs:824 — mistralrs-quant/src/blockwise_fp8/ops.rs:824-837 | mistralrs-quant/src/blockwise_fp8/ops.rs:944-957 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/blockwise_fp8/ops.rs:824` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (14 lines × 2) mistralrs-quant/src/blockwise_fp8/ops.rs:844 — mistralrs-quant/src/blockwise_fp8/ops.rs:844-857 | mistralrs-quant/src/blockwise_fp8/ops.rs:962-975 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/blockwise_fp8/ops.rs:844` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (14 lines × 2) mistralrs-quant/src/gguf/fast_mmvq.rs:919 — mistralrs-quant/src/gguf/fast_mmvq.rs:919-932 | mistralrs-quant/src/gguf/fast_mmvq.rs:1166-1179 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/gguf/fast_mmvq.rs:919` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 2) mistralrs-quant/src/gguf/fast_mmvq.rs:958 — mistralrs-quant/src/gguf/fast_mmvq.rs:958-971 | mistralrs-quant/src/gguf/fast_mmvq.rs:1221-1234 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/gguf/fast_mmvq.rs:958` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 2) mistralrs-quant/src/gguf/fast_mmvq.rs:997 — mistralrs-quant/src/gguf/fast_mmvq.rs:997-1010 | mistralrs-quant/src/gguf/fast_mmvq.rs:1276-1289 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/gguf/fast_mmvq.rs:997` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 2) mistralrs-quant/src/gptq/gptq_cpu.rs:20 — mistralrs-quant/src/gptq/gptq_cpu.rs:20-33 | mistralrs-quant/src/gptq/gptq_cuda.rs:338-351 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/gptq/gptq_cpu.rs:20` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • + 12 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (18 lines × 2) · ×35
  • Duplicated block (18 lines × 2) mistralrs-core/src/adapter/runtime.rs:677 — mistralrs-core/src/adapter/runtime.rs:677-694 | mistralrs-core/src/adapter/runtime.rs:718-735 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (18 lines × 2) mistralrs-core/src/attention/backends/cpu/neon.rs:403 — mistralrs-core/src/attention/backends/cpu/neon.rs:403-420 | mistralrs-core/src/attention/backends/cpu/neon.rs:640-657 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/attention/backends/cpu/neon.rs:403` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) mistralrs-core/src/cuda/gdn.rs:1988 — mistralrs-core/src/cuda/gdn.rs:1988-2005 | mistralrs-core/src/cuda/gdn.rs:6212-6229 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (18 lines × 2) mistralrs-core/src/cuda/gdn.rs:4990 — mistralrs-core/src/cuda/gdn.rs:4990-5007 | mistralrs-core/src/cuda/gdn.rs:5239-5256 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/gdn.rs:4990` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (18 lines × 2) mistralrs-core/src/embedding_models/qwen3_embedding.rs:357 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:357-374 | mistralrs-core/src/models/qwen3.rs:430-447 — `mistralrs-core/src/embedding_models/qwen3_embedding.rs` and `mistralrs-core/src/models/qwen3.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 26 separate duplicated blocks between them, totalling at least 364 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/qwen3_embedding.rs:357` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (18 lines × 2) mistralrs-core/src/models/glm4_moe_lite.rs:1012 — mistralrs-core/src/models/glm4_moe_lite.rs:1012-1029 | mistralrs-core/src/models/glm4_moe_lite.rs:1055-1072 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/glm4_moe_lite.rs:1012` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) mistralrs-core/src/models/hunyuan_v1_dense.rs:543 — mistralrs-core/src/models/hunyuan_v1_dense.rs:543-560 | mistralrs-core/src/models/hunyuan_v1_moe.rs:1037-1054 — before extracting anything, compare `mistralrs-core/src/models/hunyuan_v1_dense.rs` and `mistralrs-core/src/models/hunyuan_v1_moe.rs` as WHOLE FILES: this scan already matched 55 separate duplicated blocks between them, totalling at least 766 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (18 lines × 2) mistralrs-core/src/models/mistral.rs:533 — mistralrs-core/src/models/mistral.rs:533-550 | mistralrs-core/src/models/mixtral.rs:488-505 — before extracting anything, compare `mistralrs-core/src/models/mistral.rs` and `mistralrs-core/src/models/mixtral.rs` as WHOLE FILES: this scan already matched 47 separate duplicated blocks between them, totalling at least 619 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/mistral.rs:533` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) mistralrs-core/src/models/phi2.rs:453 — mistralrs-core/src/models/phi2.rs:453-470 | mistralrs-core/src/xlora_models/phi2.rs:426-443 — `mistralrs-core/src/models/phi2.rs` and `mistralrs-core/src/xlora_models/phi2.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 7 separate duplicated blocks between them, totalling at least 85 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/xlora_models/phi2.rs:424` calls `with_capacity`, `pp` and `mistralrs-core/src/models/phi2.rs:452` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (18 lines × 2) mistralrs-core/src/pipeline/gguf.rs:815 — mistralrs-core/src/pipeline/gguf.rs:815-832 | mistralrs-core/src/pipeline/gguf.rs:946-963 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/gguf.rs:815` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) mistralrs-core/src/pipeline/inputs_processor.rs:2242 — mistralrs-core/src/pipeline/inputs_processor.rs:2242-2259 | mistralrs-core/src/pipeline/inputs_processor.rs:2278-2295 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/inputs_processor.rs:2242` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) mistralrs-core/src/pipeline/loaders/lfm3.rs:171 — mistralrs-core/src/pipeline/loaders/lfm3.rs:171-188 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:7080-7097 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/lfm3.rs` and `mistralrs-core/src/pipeline/loaders/normal_loaders.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/lfm3.rs:171` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1840 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1840-1857 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2140-2157 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1840` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:2096 — mistralrs-core/src/pipeline/multimodal.rs:2096-2113 | mistralrs-core/src/pipeline/normal.rs:2393-2410 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:2096` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/pipeline/normal.rs:2392` calls `drop` and `mistralrs-core/src/pipeline/multimodal.rs:2095` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (18 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:2282 — mistralrs-core/src/pipeline/multimodal.rs:2282-2299 | mistralrs-core/src/pipeline/normal.rs:2023-2040 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:2282` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) mistralrs-core/src/vision_models/gemma3n/audio.rs:517 — mistralrs-core/src/vision_models/gemma3n/audio.rs:517-534 | mistralrs-core/src/vision_models/gemma4/audio.rs:583-600 — `mistralrs-core/src/vision_models/gemma3n/audio.rs` and `mistralrs-core/src/vision_models/gemma4/audio.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 20 separate duplicated blocks between them, totalling at least 352 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3n/audio.rs:517` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (18 lines × 2) mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1778 — mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1778-1795 | mistralrs-core/src/vision_models/mistral3/inputs_processor.rs:774-791 — `mistralrs-core/src/vision_models/gemma4/inputs_processor.rs` and `mistralrs-core/src/vision_models/mistral3/inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 9 separate duplicated blocks between them, totalling at least 132 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1778` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) mistralrs-core/src/vision_models/gemma4/mod.rs:400 — mistralrs-core/src/vision_models/gemma4/mod.rs:400-417 | mistralrs-core/src/vision_models/gemma4/mod.rs:713-730 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma4/mod.rs:400` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (18 lines × 2) mistralrs-core/src/vision_models/grid_processor.rs:226 — mistralrs-core/src/vision_models/grid_processor.rs:226-243 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:215-232 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 51 separate duplicated blocks between them, totalling at least 1008 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (18 lines × 2) mistralrs-core/src/vision_models/grid_processor.rs:599 — mistralrs-core/src/vision_models/grid_processor.rs:599-616 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:385-402 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 51 separate duplicated blocks between them, totalling at least 1008 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:599` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) REDACTED:654 — REDACTED:654-671 | mistralrs-core/src/vision_models/siglip.rs:485-502 — before extracting anything, compare `REDACTED` and `mistralrs-core/src/vision_models/siglip.rs` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 256 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (18 lines × 2) mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:437 — mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:437-454 | mistralrs-core/src/vision_models/mistral3/inputs_processor.rs:269-286 — `mistralrs-core/src/vision_models/idefics3/inputs_processor.rs` and `mistralrs-core/src/vision_models/mistral3/inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 13 separate duplicated blocks between them, totalling at least 194 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (18 lines × 2) mistralrs-core/src/vision_models/idefics3/vision.rs:325 — mistralrs-core/src/vision_models/idefics3/vision.rs:325-342 | mistralrs-core/src/vision_models/siglip.rs:336-353 — before extracting anything, compare `mistralrs-core/src/vision_models/idefics3/vision.rs` and `mistralrs-core/src/vision_models/siglip.rs` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 276 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit. Note first that the copies are not typed on the same thing: the declarations holding them bind `config` to `Idefics3VisionConfig` in one and `SiglipVisionConfig` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (18 lines × 2) mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:288 — mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:288-305 | mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:324-341 — before extracting anything, compare `mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs` and `mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 222 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (18 lines × 2) mistralrs-core/src/vision_models/llava/llava_next.rs:442 — mistralrs-core/src/vision_models/llava/llava_next.rs:442-459 | mistralrs-core/src/vision_models/phi3/mod.rs:1104-1121 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/llava/llava_next.rs:442` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • + 10 more in this group — see findings.md.
D4 · Code Duplication · Members sharing a duplicated core (4 members, 50+ identical tokens) · ×34
  • Members sharing a duplicated core (4 members, 50+ identical tokens) mistralrs-cli/src/commands/config.rs:38 — mistralrs-cli/src/commands/config.rs:38-201 | mistralrs-cli/src/commands/config.rs:203-316 | mistralrs-cli/src/commands/run/mod.rs:41-191 | mistralrs-cli/src/commands/serve.rs:45-221 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) mistralrs-core/src/distributed.rs:174 — mistralrs-core/src/distributed.rs:174-218 | mistralrs-core/src/distributed.rs:220-264 | mistralrs-core/src/distributed.rs:266-304 | mistralrs-core/src/distributed.rs:306-344 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) mistralrs-core/src/models/deepseek2.rs:615 — mistralrs-core/src/models/deepseek2.rs:615-663 | mistralrs-core/src/models/deepseek3.rs:678-726 | mistralrs-core/src/models/glm4_moe.rs:520-566 | mistralrs-core/src/models/glm4_moe_lite.rs:624-672 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) mistralrs-core/src/models/deepseek2.rs:665 — mistralrs-core/src/models/deepseek2.rs:665-682 | mistralrs-core/src/models/deepseek3.rs:728-745 | mistralrs-core/src/models/glm4_moe.rs:568-582 | mistralrs-core/src/models/glm4_moe_lite.rs:674-691 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) mistralrs-core/src/models/deepseek2.rs:779 — mistralrs-core/src/models/deepseek2.rs:779-790 | mistralrs-core/src/models/deepseek3.rs:842-853 | mistralrs-core/src/models/glm4_moe.rs:679-690 | mistralrs-core/src/models/glm4_moe_lite.rs:789-800 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) mistralrs-core/src/models/granite.rs:648 — mistralrs-core/src/models/granite.rs:648-678 | mistralrs-core/src/models/lfm2.rs:589-620 | mistralrs-core/src/models/qwen3_next.rs:539-571 | mistralrs-core/src/vision_models/qwen3_5/packed_gdn.rs:20-50 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) mistralrs-core/src/models/granite.rs:1630 — mistralrs-core/src/models/granite.rs:1630-1694 | mistralrs-core/src/models/llama.rs:165-231 | mistralrs-core/src/models/smollm3.rs:182-248 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:139-204 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) mistralrs-core/src/models/llama.rs:519 — mistralrs-core/src/models/llama.rs:519-530 | mistralrs-core/src/models/smollm3.rs:538-549 | mistralrs-core/src/vision_models/llama4/text.rs:1018-1029 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:505-516 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) mistralrs-core/src/models/phi3.rs:534 — mistralrs-core/src/models/phi3.rs:534-565 | mistralrs-core/src/models/phi3_5_moe.rs:607-638 | mistralrs-core/src/vision_models/phi3/mod.rs:1327-1367 | mistralrs-core/src/vision_models/phi4/mod.rs:456-529 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) mistralrs-core/src/models/qwen3_next.rs:968 — mistralrs-core/src/models/qwen3_next.rs:968-1129 | mistralrs-core/src/vision_models/qwen3_5/text.rs:1367-1710 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:799-934 | mistralrs-core/src/vision_models/qwen4_exp/text.rs:817-1116 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) mistralrs-core/src/pipeline/cuda_graph.rs:3861 — mistralrs-core/src/pipeline/cuda_graph.rs:3861-3871 | mistralrs-core/src/pipeline/cuda_graph.rs:3879-3889 | mistralrs-core/src/pipeline/cuda_graph.rs:3898-3908 | mistralrs-core/src/pipeline/cuda_graph.rs:3917-3927 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:64 — mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:64-85 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:338-359 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:10386-10406 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:193-214 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:729 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:729-740 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1864-1875 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2556-2567 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4382-4393 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2998 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2998-3061 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3331-3394 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4572-4630 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4891-4947 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3173 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3173-3254 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3506-3587 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4733-4814 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5045-5125 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) mistralrs-core/src/sampler.rs:1168 — mistralrs-core/src/sampler.rs:1168-1195 | mistralrs-core/src/sampler.rs:1204-1275 | mistralrs-core/src/sampler.rs:1654-1744 | mistralrs-core/src/sampler.rs:1863-1890 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:396 — mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:396-690 | mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1039-1699 | mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:436-712 | mistralrs-core/src/vision_models/mistral3/inputs_processor.rs:268-481 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) mistralrs-core/src/vision_models/grid_processor.rs:1844 — mistralrs-core/src/vision_models/grid_processor.rs:1844-1874 | mistralrs-core/src/vision_models/grid_processor.rs:1884-1923 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:984-1013 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1549-1578 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:222 — mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:222-264 | mistralrs-core/src/vision_models/llama4/inputs_processor.rs:226-265 | mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:181-202 | mistralrs-core/src/vision_models/phi3/phi3_inputs_processor.rs:137-158 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) REDACTED:686 — REDACTED:686-704 | mistralrs-core/src/vision_models/idefics3/vision.rs:505-523 | mistralrs-core/src/vision_models/lfm2_vl/vision.rs:384-400 | mistralrs-core/src/vision_models/siglip.rs:528-546 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:287 — mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:287-630 | mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:323-648 | mistralrs-core/src/vision_models/phi3/phi3_inputs_processor.rs:296-567 | mistralrs-core/src/vision_models/phi4/inputs_processor.rs:343-572 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:243 — mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:243-307 | mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:323-648 | mistralrs-core/src/vision_models/phi3/phi3_inputs_processor.rs:224-280 | mistralrs-core/src/vision_models/phi3/phi3_inputs_processor.rs:296-567 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:471 — mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:471-488 | mistralrs-core/src/vision_models/qwen2vl/mod.rs:627-644 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:1082-1099 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:526-543 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) mistralrs-core/src/xlora_models/gemma.rs:152 — mistralrs-core/src/xlora_models/gemma.rs:152-219 | mistralrs-core/src/xlora_models/mistral.rs:146-209 | mistralrs-core/src/xlora_models/mixtral.rs:59-122 | mistralrs-core/src/xlora_models/phi3.rs:58-99 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:62 — mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:62-93 | mistralrs-quant/src/gguf/cuda.rs:118-145 | mistralrs-quant/src/gguf/fast_mmq.rs:385-409 | mistralrs-quant/src/gguf/fast_mmvq.rs:118-144 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • + 9 more in this group — see findings.md.
D4 · Code Duplication · Edited copy of a member (14 corresponding lines) · ×29
  • Edited copy of a member (14 corresponding lines) mistralrs-quant/src/safetensors.rs:372 — mistralrs-quant/src/safetensors.rs:372-390 | mistralrs-quant/src/safetensors.rs:412-447 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) mistralrs-core/src/vision_models/llava/llava_llm/mod.rs:38 — mistralrs-core/src/vision_models/llava/llava_llm/mod.rs:38-51 | mistralrs-core/src/xlora_models/quantized_phi3.rs:241-254 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) mistralrs-core/src/attention/backends/cpu/avx.rs:466 — mistralrs-core/src/attention/backends/cpu/avx.rs:466-479 | mistralrs-core/src/attention/backends/cpu/avx.rs:721-734 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) mistralrs-quant/src/lib.rs:1001 — mistralrs-quant/src/lib.rs:1001-1014 | mistralrs-quant/src/lib.rs:1016-1029 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) mistralrs-code-exec/src/shell.rs:477 — mistralrs-code-exec/src/shell.rs:477-490 | mistralrs-server-core/src/skills.rs:673-686 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) mistralrs-core/src/attention/backends/sinks.rs:108 — mistralrs-core/src/attention/backends/sinks.rs:108-139 | mistralrs-quant/src/rotary/mod.rs:869-882 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) mistralrs-core/src/pipeline/loaders/lfm3.rs:27 — mistralrs-core/src/pipeline/loaders/lfm3.rs:27-40 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5417-5430 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) REDACTED:538 — REDACTED:538-551 | REDACTED:736-750 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) mistralrs-quant/src/distributed/layers.rs:727 — mistralrs-quant/src/distributed/layers.rs:727-744 | mistralrs-quant/src/distributed/layers.rs:1309-1322 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) mistralrs-quant/src/distributed/mod.rs:437 — mistralrs-quant/src/distributed/mod.rs:437-453 | mistralrs-quant/src/distributed/mod.rs:494-507 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) mistralrs-core/src/adapter/runtime.rs:604 — mistralrs-core/src/adapter/runtime.rs:604-617 | mistralrs-core/src/adapter/runtime.rs:623-643 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) mistralrs-core/src/attention/backends/cpu/full.rs:47 — mistralrs-core/src/attention/backends/cpu/full.rs:47-60 | mistralrs-core/src/attention/backends/cpu/full.rs:62-75 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) mistralrs-paged-attn/src/cuda/backend/flash_attn_sinks.rs:340 — mistralrs-paged-attn/src/cuda/backend/flash_attn_sinks.rs:340-353 | mistralrs-paged-attn/src/cuda/backend/flash_attn_sinks.rs:409-425 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) mistralrs-core/src/vision_models/lfm2_vl/mod.rs:234 — mistralrs-core/src/vision_models/lfm2_vl/mod.rs:234-248 | mistralrs-core/src/vision_models/lfm3_vl/mod.rs:317-330 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) mistralrs-core/src/search/mod.rs:116 — mistralrs-core/src/search/mod.rs:116-131 | mistralrs-core/src/search/mod.rs:135-148 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) mistralrs-core/src/sequence.rs:194 — mistralrs-core/src/sequence.rs:194-208 | mistralrs-core/src/sequence.rs:241-254 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) mistralrs-server-core/src/openai.rs:138 — mistralrs-server-core/src/openai.rs:138-151 | mistralrs-server-core/src/openai.rs:157-171 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) mistralrs-core/src/speech_models/dia/model.rs:264 — mistralrs-core/src/speech_models/dia/model.rs:264-285 | REDACTED:910-923 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) mistralrs-cli/src/commands/quantize.rs:200 — mistralrs-cli/src/commands/quantize.rs:200-213 | mistralrs-cli/src/commands/serve.rs:1116-1129 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:10255 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:10255-10269 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6897-6910 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) mistralrs/src/anymoe.rs:41 — mistralrs/src/anymoe.rs:41-54 | mistralrs/src/anymoe.rs:65-78 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) mistralrs-core/src/gguf/normal_config.rs:653 — mistralrs-core/src/gguf/normal_config.rs:653-666 | mistralrs-core/src/gguf/normal_config.rs:2743-2756 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) mistralrs-core/src/pipeline/cuda_graph.rs:2911 — mistralrs-core/src/pipeline/cuda_graph.rs:2911-2925 | mistralrs-core/src/pipeline/cuda_graph.rs:2930-2943 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) mistralrs-core/src/speculative/proposer.rs:394 — mistralrs-core/src/speculative/proposer.rs:394-407 | mistralrs-core/src/speculative/proposer.rs:413-427 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) mistralrs-core/src/speculative/dflash.rs:2163 — mistralrs-core/src/speculative/dflash.rs:2163-2176 | mistralrs-core/src/speculative/dflash.rs:2755-2770 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • + 4 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (19 lines × 2) · ×28
  • Duplicated block (19 lines × 2) mistralrs-cli/src/commands/run/interactive.rs:892 — mistralrs-cli/src/commands/run/interactive.rs:892-910 | mistralrs-cli/src/commands/run/interactive.rs:1574-1592 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-cli/src/commands/run/interactive.rs:892` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (19 lines × 2) mistralrs-cli/src/commands/run/interactive.rs:937 — mistralrs-cli/src/commands/run/interactive.rs:937-955 | mistralrs-cli/src/commands/run/interactive.rs:1619-1637 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-cli/src/commands/run/interactive.rs:937` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-cli/src/commands/run/interactive.rs:1616` calls `clear` and `mistralrs-cli/src/commands/run/interactive.rs:936` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (19 lines × 2) mistralrs-cli/src/commands/run/interactive.rs:1909 — mistralrs-cli/src/commands/run/interactive.rs:1909-1927 | mistralrs-cli/src/commands/run/interactive.rs:2035-2053 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-cli/src/commands/run/interactive.rs:1909` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (19 lines × 2) mistralrs-core/src/cuda/gdn.rs:1028 — mistralrs-core/src/cuda/gdn.rs:1028-1046 | mistralrs-core/src/cuda/gdn.rs:1274-1292 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/gdn.rs:1028` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (19 lines × 2) mistralrs-core/src/cuda/gdn.rs:3828 — mistralrs-core/src/cuda/gdn.rs:3828-3846 | mistralrs-core/src/cuda/gdn.rs:4381-4399 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/gdn.rs:3828` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note first that the copies are not typed on the same thing: the declarations holding them bind `context` to `GdnSpeculativeRecurrenceCheckpoints<'_>` in one and `GdnDeferredRecurrence<'_>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (19 lines × 2) mistralrs-core/src/model_loader.rs:493 — mistralrs-core/src/model_loader.rs:493-511 | mistralrs-core/src/toml_selector.rs:1189-1207 — before extracting anything, compare `mistralrs-core/src/model_loader.rs` and `mistralrs-core/src/toml_selector.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 199 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/model_loader.rs:493` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (19 lines × 2) mistralrs-core/src/models/gemma.rs:275 — mistralrs-core/src/models/gemma.rs:275-293 | mistralrs-core/src/models/gemma2.rs:326-344 — before extracting anything, compare `mistralrs-core/src/models/gemma.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 707 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma.rs:275` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (19 lines × 2) mistralrs-core/src/models/phi3.rs:298 — mistralrs-core/src/models/phi3.rs:298-316 | mistralrs-core/src/vision_models/phi3/mod.rs:389-407 — before extracting anything, compare `mistralrs-core/src/models/phi3.rs` and `mistralrs-core/src/vision_models/phi3/mod.rs` as WHOLE FILES: this scan already matched 50 separate duplicated blocks between them, totalling at least 638 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (19 lines × 2) mistralrs-core/src/models/qwen3_next.rs:416 — mistralrs-core/src/models/qwen3_next.rs:416-434 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:322-340 — before extracting anything, compare `mistralrs-core/src/models/qwen3_next.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/text.rs` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 461 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/qwen3_next.rs:416` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (19 lines × 2) mistralrs-core/src/ops.rs:1680 — mistralrs-core/src/ops.rs:1680-1698 | mistralrs-core/src/ops.rs:1951-1969 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:1680` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (19 lines × 2) mistralrs-core/src/ops.rs:4705 — mistralrs-core/src/ops.rs:4705-4723 | mistralrs-core/src/ops.rs:5548-5566 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:4705` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (19 lines × 2) mistralrs-core/src/ops.rs:5808 — mistralrs-core/src/ops.rs:5808-5826 | mistralrs-core/src/ops.rs:6244-6262 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:5808` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (19 lines × 2) mistralrs-core/src/pipeline/inputs_processor.rs:2675 — mistralrs-core/src/pipeline/inputs_processor.rs:2675-2693 | mistralrs-core/src/pipeline/inputs_processor.rs:2824-2842 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/inputs_processor.rs:2675` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (19 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:721 — mistralrs-core/src/pipeline/multimodal.rs:721-739 | mistralrs-core/src/pipeline/normal.rs:1098-1116 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (19 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:1898 — mistralrs-core/src/pipeline/multimodal.rs:1898-1916 | mistralrs-core/src/pipeline/normal.rs:1748-1766 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (19 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:1918 — mistralrs-core/src/pipeline/multimodal.rs:1918-1936 | mistralrs-core/src/pipeline/normal.rs:1768-1786 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (19 lines × 2) mistralrs-core/src/prefix_cacher.rs:443 — mistralrs-core/src/prefix_cacher.rs:443-461 | mistralrs-core/src/prefix_cacher.rs:471-489 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/prefix_cacher.rs:443` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/prefix_cacher.rs:490` calls `clear` and `mistralrs-core/src/prefix_cacher.rs:462` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (19 lines × 2) mistralrs-core/src/speculative/driver.rs:219 — mistralrs-core/src/speculative/driver.rs:219-237 | mistralrs-core/src/speculative/driver.rs:242-261 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/speculative/driver.rs:219` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (19 lines × 2) mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:858 — mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:858-876 | mistralrs-core/src/vision_models/gemma3n/inputs_processor.rs:776-794 — `mistralrs-core/src/vision_models/gemma3/inputs_processor.rs` and `mistralrs-core/src/vision_models/gemma3n/inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 4 separate duplicated blocks between them, totalling at least 75 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:858` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (19 lines × 2) mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:395 — mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:395-413 | mistralrs-core/src/vision_models/phi3/phi3_inputs_processor.rs:362-380 — before extracting anything, compare `mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs` and `mistralrs-core/src/vision_models/phi3/phi3_inputs_processor.rs` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 288 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:395` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (19 lines × 2) mistralrs-paged-attn/src/cuda/backend/mla.rs:773 — mistralrs-paged-attn/src/cuda/backend/mla.rs:773-791 | mistralrs-paged-attn/src/cuda/backend/mla.rs:811-829 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/cuda/backend/mla.rs:773` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (19 lines × 2) mistralrs-quant/src/cublaslt/matmul.rs:469 — mistralrs-quant/src/cublaslt/matmul.rs:469-487 | mistralrs-quant/src/cublaslt/matmul.rs:568-586 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-quant/src/cublaslt/matmul.rs:489` calls `device_ptr_mut`, `stream` and `mistralrs-quant/src/cublaslt/matmul.rs:588` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (19 lines × 2) mistralrs-quant/src/cutile/fp8_w8a16.rs:456 — mistralrs-quant/src/cutile/fp8_w8a16.rs:456-474 | mistralrs-quant/src/cutile/fp8_w8a8.rs:544-562 — before extracting anything, compare `mistralrs-quant/src/cutile/fp8_w8a16.rs` and `mistralrs-quant/src/cutile/fp8_w8a8.rs` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 212 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cutile/fp8_w8a16.rs:456` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (19 lines × 2) mistralrs-quant/src/distributed/layers.rs:440 — mistralrs-quant/src/distributed/layers.rs:440-458 | mistralrs-quant/src/distributed/layers.rs:814-832 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/distributed/layers.rs:440` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (19 lines × 2) mistralrs-quant/src/mxfp4/ops.rs:494 — mistralrs-quant/src/mxfp4/ops.rs:494-512 | mistralrs-quant/src/mxfp4/ops.rs:562-580 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/mxfp4/ops.rs:494` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • + 3 more in this group — see findings.md.
D4 · Code Duplication · Edited copy of a member (17 corresponding lines) · ×26
  • Edited copy of a member (17 corresponding lines) mistralrs-core/src/models/lfm3.rs:542 — mistralrs-core/src/models/lfm3.rs:542-572 | mistralrs-core/src/models/phi3.rs:143-236 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) mistralrs-core/src/models/lfm3.rs:542 — mistralrs-core/src/models/lfm3.rs:542-572 | mistralrs-core/src/vision_models/phi3/mod.rs:235-327 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) mistralrs-core/src/models/lfm3.rs:542 — mistralrs-core/src/models/lfm3.rs:542-572 | mistralrs-core/src/vision_models/phi4/mod.rs:104-196 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) mistralrs-core/src/models/lfm3.rs:542 — mistralrs-core/src/models/lfm3.rs:542-572 | mistralrs-core/src/vision_models/voxtral/encoder.rs:79-123 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) mistralrs-core/src/models/lfm3.rs:542 — mistralrs-core/src/models/lfm3.rs:542-572 | mistralrs-core/src/vision_models/voxtral/mod.rs:126-208 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) mistralrs-core/src/models/lfm3.rs:542 — mistralrs-core/src/models/lfm3.rs:542-572 | mistralrs-core/src/xlora_models/gemma.rs:232-298 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) mistralrs-core/src/models/lfm3.rs:542 — mistralrs-core/src/models/lfm3.rs:542-572 | mistralrs-core/src/xlora_models/gemma2.rs:237-305 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) mistralrs-core/src/models/lfm3.rs:542 — mistralrs-core/src/models/lfm3.rs:542-572 | mistralrs-core/src/xlora_models/mistral.rs:222-294 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) mistralrs-core/src/models/lfm3.rs:542 — mistralrs-core/src/models/lfm3.rs:542-572 | mistralrs-core/src/xlora_models/mixtral.rs:135-207 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) mistralrs-core/src/models/lfm3.rs:542 — mistralrs-core/src/models/lfm3.rs:542-572 | mistralrs-core/src/xlora_models/phi2.rs:217-288 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) mistralrs-core/src/models/lfm3.rs:542 — mistralrs-core/src/models/lfm3.rs:542-572 | mistralrs-core/src/xlora_models/phi3.rs:113-182 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) mistralrs-core/src/models/lfm3.rs:542 — mistralrs-core/src/models/lfm3.rs:542-572 | mistralrs-core/src/xlora_models/starcoder2.rs:209-283 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) mistralrs-core/src/vision_models/llava/llava_next.rs:203 — mistralrs-core/src/vision_models/llava/llava_next.rs:203-222 | mistralrs-core/src/vision_models/llava/utils.rs:65-81 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) mistralrs-quant/src/build_support/cuda_headers.rs:9 — mistralrs-quant/src/build_support/cuda_headers.rs:9-28 | mistralrs-quant/src/build_support/deepgemm_jit_bundle.rs:9-25 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) mistralrs-core/src/kv_cache/hybrid_cache.rs:1799 — mistralrs-core/src/kv_cache/hybrid_cache.rs:1799-1821 | mistralrs-core/src/speculative/gdn_transitions.rs:164-180 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) mistralrs-quant/src/mxfp4/mod.rs:872 — mistralrs-quant/src/mxfp4/mod.rs:872-889 | mistralrs-quant/src/unquantized/mod.rs:665-681 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3686 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3686-3702 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5241-5260 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) mistralrs-core/src/mla/projection.rs:69 — mistralrs-core/src/mla/projection.rs:69-85 | mistralrs-core/src/mla/projection.rs:87-103 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) mistralrs-core/src/tools/parsers/liquid.rs:103 — mistralrs-core/src/tools/parsers/liquid.rs:103-119 | mistralrs-core/src/tools/parsers/liquid.rs:203-219 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) mistralrs-core/src/gguf/multimodal_bindings.rs:587 — mistralrs-core/src/gguf/multimodal_bindings.rs:587-603 | mistralrs-core/src/gguf/multimodal_bindings.rs:611-628 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1377 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1377-1394 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2756-2772 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) mistralrs-flash-attn/src/flash.rs:1045 — mistralrs-flash-attn/src/flash.rs:1045-1064 | mistralrs-flash-attn/src/flash.rs:1107-1123 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) mistralrs-flash-attn/src/flash.rs:900 — mistralrs-flash-attn/src/flash.rs:900-919 | mistralrs-flash-attn/src/flash.rs:960-976 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) mistralrs-flash-attn/src/flash.rs:994 — mistralrs-flash-attn/src/flash.rs:994-1010 | mistralrs-flash-attn/src/flash.rs:1168-1184 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) mistralrs-core/src/pipeline/ggml.rs:112 — mistralrs-core/src/pipeline/ggml.rs:112-129 | mistralrs-core/src/pipeline/gguf.rs:304-320 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • + 1 more in this group — see findings.md.
D4 · Code Duplication · Edited copy of a member (12 corresponding lines) · ×26
  • Edited copy of a member (12 corresponding lines) mistralrs-quant/src/metal_kernels/mod.rs:1737 — mistralrs-quant/src/metal_kernels/mod.rs:1737-1774 | mistralrs-quant/src/metal_kernels/mod.rs:2660-2795 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) mistralrs-core/src/attention/backends/cpu/elem.rs:371 — mistralrs-core/src/attention/backends/cpu/elem.rs:371-382 | mistralrs-core/src/attention/backends/cpu/elem.rs:401-415 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) mistralrs-cli/src/ui/handlers/api.rs:399 — mistralrs-cli/src/ui/handlers/api.rs:399-410 | mistralrs-cli/src/ui/handlers/api.rs:420-436 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) mistralrs-server-core/src/skills.rs:853 — mistralrs-server-core/src/skills.rs:853-864 | mistralrs-server-core/src/skills.rs:923-936 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) mistralrs-core/src/cuda/gdn.rs:426 — mistralrs-core/src/cuda/gdn.rs:426-437 | mistralrs-core/src/cuda/gdn.rs:567-578 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) mistralrs-core/src/vision_models/gemma3n/audio.rs:1002 — mistralrs-core/src/vision_models/gemma3n/audio.rs:1002-1021 | mistralrs-core/src/vision_models/gemma4/audio.rs:492-503 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) mistralrs-core/src/pipeline/mod.rs:1210 — mistralrs-core/src/pipeline/mod.rs:1210-1223 | mistralrs-quant/src/lora/dynamic/expert.rs:840-851 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) mistralrs-core/src/layers.rs:1629 — mistralrs-core/src/layers.rs:1629-1640 | mistralrs-core/src/layers.rs:1940-1951 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) mistralrs-core/src/cuda/speculative_rejection.rs:795 — mistralrs-core/src/cuda/speculative_rejection.rs:795-806 | mistralrs-core/src/cuda/speculative_rejection.rs:813-824 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) mistralrs-core/src/vision_models/idefics3/vision.rs:389 — mistralrs-core/src/vision_models/idefics3/vision.rs:389-400 | mistralrs-core/src/vision_models/llama4/vision.rs:293-307 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) mistralrs-core/src/decision.rs:86 — mistralrs-core/src/decision.rs:86-97 | mistralrs-core/src/decision.rs:99-110 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) mistralrs-core/src/diffusion_models/processor.rs:76 — mistralrs-core/src/diffusion_models/processor.rs:76-90 | mistralrs-core/src/pipeline/speech.rs:136-147 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) mistralrs-cli/src/commands/uqff.rs:471 — mistralrs-cli/src/commands/uqff.rs:471-483 | mistralrs-quant/src/uqff/report.rs:1662-1673 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) mistralrs-core/src/embedding_models/qwen3_embedding.rs:278 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:278-290 | mistralrs-core/src/vision_models/voxtral/encoder.rs:186-197 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) mistralrs-core/src/pipeline/isq_flow/drive.rs:33 — mistralrs-core/src/pipeline/isq_flow/drive.rs:33-44 | mistralrs-core/src/pipeline/isq_flow/drive.rs:58-72 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) mistralrs-core/src/vision_models/qwen3_5/text.rs:1170 — mistralrs-core/src/vision_models/qwen3_5/text.rs:1170-1181 | mistralrs-core/src/vision_models/qwen4_exp/text.rs:714-727 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) mistralrs-core/src/kv_cache/hybrid_cache.rs:785 — mistralrs-core/src/kv_cache/hybrid_cache.rs:785-796 | mistralrs-core/src/kv_cache/hybrid_cache.rs:832-843 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) mistralrs-core/src/pipeline/hf/client.rs:114 — mistralrs-core/src/pipeline/hf/client.rs:114-125 | mistralrs-core/src/pipeline/hf/client.rs:174-185 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) mistralrs-quant/src/nvfp4/prepare.rs:58 — mistralrs-quant/src/nvfp4/prepare.rs:58-69 | mistralrs-quant/src/nvfp4/prepare.rs:76-87 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4649 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4649-4665 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4966-4977 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) mistralrs-quant/src/fp8_config.rs:420 — mistralrs-quant/src/fp8_config.rs:420-431 | mistralrs-quant/src/lib.rs:787-798 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) mistralrs-core/src/paged_attention/config.rs:103 — mistralrs-core/src/paged_attention/config.rs:103-114 | mistralrs-core/src/paged_attention/config.rs:120-131 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9208 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9208-9225 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9231-9242 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) mistralrs-core/src/xlora_models/phi2.rs:93 — mistralrs-core/src/xlora_models/phi2.rs:93-104 | mistralrs-core/src/xlora_models/starcoder2.rs:86-97 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) mistralrs/src/diffusion_model.rs:27 — mistralrs/src/diffusion_model.rs:27-38 | mistralrs/src/speech_model.rs:29-42 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • + 1 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (17 lines × 2) · ×26
  • Duplicated block (17 lines × 2) mistralrs-cli/src/commands/run/interactive.rs:278 — mistralrs-cli/src/commands/run/interactive.rs:278-294 | mistralrs-cli/src/commands/run/interactive.rs:462-478 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-cli/src/commands/run/interactive.rs:278` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (17 lines × 2) mistralrs-cli/src/commands/run/mod.rs:95 — mistralrs-cli/src/commands/run/mod.rs:95-111 | mistralrs-cli/src/commands/serve.rs:107-123 — before extracting anything, compare `mistralrs-cli/src/commands/run/mod.rs` and `mistralrs-cli/src/commands/serve.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 49 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-cli/src/commands/run/mod.rs:95` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 2) mistralrs-core/src/mla/forward.rs:572 — mistralrs-core/src/mla/forward.rs:572-588 | mistralrs-core/src/mla/forward.rs:590-606 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (17 lines × 2) mistralrs-core/src/model_loader.rs:363 — mistralrs-core/src/model_loader.rs:363-379 | mistralrs-core/src/toml_selector.rs:846-862 — before extracting anything, compare `mistralrs-core/src/model_loader.rs` and `mistralrs-core/src/toml_selector.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 199 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/model_loader.rs:363` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note first that the copies are not typed on the same thing: the declarations holding them bind `args` to `LoaderBuilder` in one and `TomlLoaderInnerParams` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (17 lines × 2) mistralrs-core/src/models/glm4_moe.rs:235 — mistralrs-core/src/models/glm4_moe.rs:235-251 | mistralrs-core/src/models/hunyuan_v1_moe.rs:337-353 — before extracting anything, compare `mistralrs-core/src/models/glm4_moe.rs` and `mistralrs-core/src/models/hunyuan_v1_moe.rs` as WHOLE FILES: this scan already matched 24 separate duplicated blocks between them, totalling at least 266 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/glm4_moe.rs:235` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 2) mistralrs-core/src/models/granite.rs:2245 — mistralrs-core/src/models/granite.rs:2245-2261 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:532-548 — before extracting anything, compare `mistralrs-core/src/models/granite.rs` and `mistralrs-core/src/vision_models/llava/llava_llm/llama.rs` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 151 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (17 lines × 2) mistralrs-core/src/ops.rs:5838 — mistralrs-core/src/ops.rs:5838-5854 | mistralrs-core/src/ops.rs:6601-6617 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/ops.rs:5855` calls `from` and `mistralrs-core/src/ops.rs:6618` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (17 lines × 2) mistralrs-core/src/pipeline/ggml.rs:557 — mistralrs-core/src/pipeline/ggml.rs:557-573 | mistralrs-core/src/pipeline/gguf.rs:1603-1619 — before extracting anything, compare `mistralrs-core/src/pipeline/ggml.rs` and `mistralrs-core/src/pipeline/gguf.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 75 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/ggml.rs:557` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4175 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4175-4191 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4210-4226 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4175` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (17 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:1779 — mistralrs-core/src/pipeline/multimodal.rs:1779-1795 | mistralrs-core/src/pipeline/normal.rs:1649-1665 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (17 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:1828 — mistralrs-core/src/pipeline/multimodal.rs:1828-1844 | mistralrs-core/src/pipeline/normal.rs:1690-1706 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (17 lines × 2) mistralrs-core/src/tools/state.rs:291 — mistralrs-core/src/tools/state.rs:291-307 | mistralrs-core/src/tools/state.rs:339-355 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/tools/state.rs:291` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 2) mistralrs-core/src/vision_models/qwen3_5/text.rs:1721 — mistralrs-core/src/vision_models/qwen3_5/text.rs:1721-1737 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:945-961 — `mistralrs-core/src/vision_models/qwen3_5/text.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 26 separate duplicated blocks between them, totalling at least 469 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_5/text.rs:1721` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 2) mistralrs-core/src/xlora_models/gemma.rs:82 — mistralrs-core/src/xlora_models/gemma.rs:82-98 | mistralrs-core/src/xlora_models/gemma2.rs:76-92 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/gemma2.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 498 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma.rs:82` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 2) mistralrs-core/src/xlora_models/mistral.rs:523 — mistralrs-core/src/xlora_models/mistral.rs:523-539 | mistralrs-core/src/xlora_models/mixtral.rs:653-669 — before extracting anything, compare `mistralrs-core/src/xlora_models/mistral.rs` and `mistralrs-core/src/xlora_models/mixtral.rs` as WHOLE FILES: this scan already matched 53 separate duplicated blocks between them, totalling at least 787 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/mistral.rs:523` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (17 lines × 2) mistralrs-core/src/xlora_models/quantized_llama.rs:734 — mistralrs-core/src/xlora_models/quantized_llama.rs:734-750 | mistralrs-core/src/xlora_models/quantized_phi3.rs:396-412 — before extracting anything, compare `mistralrs-core/src/xlora_models/quantized_llama.rs` and `mistralrs-core/src/xlora_models/quantized_phi3.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 219 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/quantized_llama.rs:734` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/xlora_models/quantized_phi3.rs:413` calls `Some` and `mistralrs-core/src/xlora_models/quantized_llama.rs:751` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (17 lines × 2) mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:284 — mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:284-300 | mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:683-699 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:284` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 2) mistralrs-quant/src/afq/mod.rs:607 — mistralrs-quant/src/afq/mod.rs:607-623 | mistralrs-quant/src/afq/mod.rs:656-672 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/afq/mod.rs:607` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 2) mistralrs-quant/src/distributed/layers.rs:1426 — mistralrs-quant/src/distributed/layers.rs:1426-1442 | mistralrs-quant/src/distributed/layers.rs:1642-1658 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/distributed/layers.rs:1426` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 2) mistralrs-quant/src/lora/dynamic/expert.rs:605 — mistralrs-quant/src/lora/dynamic/expert.rs:605-621 | mistralrs-quant/src/lora/dynamic/expert.rs:646-662 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (17 lines × 2) mistralrs/src/model_builder_trait.rs:735 — mistralrs/src/model_builder_trait.rs:735-751 | mistralrs/src/model_builder_trait.rs:1479-1495 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (17 lines × 2) mistralrs-core/src/engine/agentic_loop.rs:1467 — mistralrs-core/src/engine/agentic_loop.rs:1467-1483 | mistralrs-core/src/engine/agentic_loop.rs:1538-1554 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/engine/agentic_loop.rs:1467` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (17 lines × 2) mistralrs/src/messages.rs:518 — mistralrs/src/messages.rs:518-534 | mistralrs/src/messages.rs:1228-1244 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs/src/messages.rs:1228` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 2) mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:481 — mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:481-497 | mistralrs-paged-attn/src/metal/backend/paged_attention.rs:701-717 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:481` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 2) mistralrs-quant/src/cutile/fp8_w8a16.rs:516 — mistralrs-quant/src/cutile/fp8_w8a16.rs:516-532 | mistralrs-quant/src/cutile/fp8_w8a8.rs:615-631 — before extracting anything, compare `mistralrs-quant/src/cutile/fp8_w8a16.rs` and `mistralrs-quant/src/cutile/fp8_w8a8.rs` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 212 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cutile/fp8_w8a16.rs:516` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • + 1 more in this group — see findings.md.
D4 · Code Duplication · Edited copy of a member (19 corresponding lines) · ×25
  • Edited copy of a member (19 corresponding lines) mistralrs-core/src/vision_models/idefics3/vision.rs:242 — mistralrs-core/src/vision_models/idefics3/vision.rs:242-269 | mistralrs-core/src/vision_models/siglip.rs:246-267 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) mistralrs-core/src/vision_models/gemma3n/mod.rs:59 — mistralrs-core/src/vision_models/gemma3n/mod.rs:59-89 | mistralrs-core/src/vision_models/gemma3n/mod.rs:180-198 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) mistralrs-core/src/models/glm4.rs:75 — mistralrs-core/src/models/glm4.rs:75-95 | mistralrs-core/src/models/glm4_moe.rs:104-122 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) mistralrs-paged-attn/src/metal/kernels/mod.rs:159 — mistralrs-paged-attn/src/metal/kernels/mod.rs:159-177 | mistralrs-quant/src/metal_kernels/mod.rs:167-188 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) mistralrs-core/src/pipeline/hf.rs:654 — mistralrs-core/src/pipeline/hf.rs:654-672 | mistralrs-core/src/pipeline/hf.rs:678-696 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) mistralrs-core/src/pipeline/cuda_graph.rs:2613 — mistralrs-core/src/pipeline/cuda_graph.rs:2613-2631 | mistralrs-core/src/speculative/dflash.rs:1635-1653 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) mistralrs-core/src/speech_models/dia/dac.rs:97 — mistralrs-core/src/speech_models/dia/dac.rs:97-115 | mistralrs-core/src/speech_models/dia/dac.rs:143-163 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) mistralrs-server-core/src/responses.rs:2361 — mistralrs-server-core/src/responses.rs:2361-2379 | mistralrs-server-core/src/responses.rs:2434-2454 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) mistralrs-quant/src/afq/mod.rs:387 — mistralrs-quant/src/afq/mod.rs:387-405 | mistralrs-quant/src/mxfp4/mod.rs:217-235 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) mistralrs-core/src/models/phi2.rs:124 — mistralrs-core/src/models/phi2.rs:124-142 | mistralrs-core/src/models/starcoder2.rs:106-124 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) mistralrs-core/src/gguf/multimodal_bindings.rs:314 — mistralrs-core/src/gguf/multimodal_bindings.rs:314-333 | mistralrs-core/src/gguf/multimodal_bindings.rs:516-534 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) mistralrs-core/src/vision_models/grid_processor.rs:540 — mistralrs-core/src/vision_models/grid_processor.rs:540-558 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:326-344 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) mistralrs-core/src/vision_models/lfm2_vl/inputs_processor.rs:189 — mistralrs-core/src/vision_models/lfm2_vl/inputs_processor.rs:189-207 | mistralrs-core/src/vision_models/phi4/inputs_processor.rs:1415-1433 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5400 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5400-5419 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5424-5442 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6697 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6697-6715 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7135-7157 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) mistralrs-quant/src/lora/dynamic/execution.rs:399 — mistralrs-quant/src/lora/dynamic/execution.rs:399-417 | mistralrs-quant/src/lora/dynamic/execution.rs:482-506 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) mistralrs-core/src/vision_models/llava/llava15.rs:317 — mistralrs-core/src/vision_models/llava/llava15.rs:317-335 | mistralrs-core/src/vision_models/llava/llava_next.rs:516-536 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) mistralrs-core/src/vision_models/qwen3_5/text.rs:1202 — mistralrs-core/src/vision_models/qwen3_5/text.rs:1202-1220 | mistralrs-core/src/vision_models/qwen4_exp/text.rs:614-636 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) mistralrs-core/src/utils/unvarbuilder.rs:153 — mistralrs-core/src/utils/unvarbuilder.rs:153-171 | mistralrs-core/src/utils/unvarbuilder.rs:183-201 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) mistralrs-core/src/pipeline/response.rs:111 — mistralrs-core/src/pipeline/response.rs:111-132 | mistralrs-core/src/pipeline/response.rs:137-155 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) mistralrs-core/src/sequence.rs:666 — mistralrs-core/src/sequence.rs:666-684 | mistralrs-core/src/sequence.rs:1337-1361 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) mistralrs-core/src/layers.rs:2898 — mistralrs-core/src/layers.rs:2898-2917 | mistralrs-core/src/layers.rs:2969-2987 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) mistralrs-quant/src/gguf/mod.rs:468 — mistralrs-quant/src/gguf/mod.rs:468-487 | mistralrs-quant/src/gptq/gptq_cpu.rs:15-33 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) mistralrs-quant/src/gguf/fast_mmq.rs:1210 — mistralrs-quant/src/gguf/fast_mmq.rs:1210-1228 | mistralrs-quant/src/gguf/fast_mmq.rs:1243-1261 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) mistralrs-core/src/sampler.rs:90 — mistralrs-core/src/sampler.rs:90-108 | mistralrs-core/src/sampler.rs:114-132 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Duplicated block (6 lines × 3) · ×24
  • Duplicated block (6 lines × 3) mistralrs-cli/src/commands/bench.rs:157 — mistralrs-cli/src/commands/bench.rs:157-162 | mistralrs-cli/src/commands/config.rs:283-288 | mistralrs-cli/src/commands/run/mod.rs:127-132 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-cli/src/commands/run/mod.rs:134` calls `Some` and `mistralrs-cli/src/commands/config.rs:291` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (6 lines × 3) mistralrs-core/src/cuda/gdn.rs:1744 — mistralrs-core/src/cuda/gdn.rs:1744-1749 | mistralrs-core/src/cuda/gdn.rs:5987-5992 | mistralrs-core/src/cuda/moe.rs:56-61 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/cuda/gdn.rs:1742` calls `stride` and `mistralrs-core/src/cuda/moe.rs:54` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (6 lines × 3) mistralrs-core/src/cuda/gdn.rs:1987 — mistralrs-core/src/cuda/gdn.rs:1987-1992 | mistralrs-core/src/cuda/gdn.rs:3168-3173 | mistralrs-core/src/cuda/gdn.rs:6211-6216 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/cuda/gdn.rs:3174` calls `stride` and `mistralrs-core/src/cuda/gdn.rs:6218` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (6 lines × 3) mistralrs-core/src/cuda/gdn.rs:1994 — mistralrs-core/src/cuda/gdn.rs:1994-1999 | mistralrs-core/src/cuda/gdn.rs:3178-3183 | mistralrs-core/src/cuda/gdn.rs:6218-6223 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (6 lines × 3) mistralrs-core/src/embedding_models/qwen3_embedding.rs:455 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:455-460 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:524-529 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:645-650 — before extracting anything, compare `mistralrs-core/src/embedding_models/qwen3_embedding.rs` and `mistralrs-core/src/vision_models/qwen3_vl/text.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 79 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/qwen3_embedding.rs:455` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 3) mistralrs-core/src/layers.rs:1644 — mistralrs-core/src/layers.rs:1644-1649 | mistralrs-core/src/layers.rs:1807-1815 | mistralrs-core/src/layers.rs:1955-1960 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (6 lines × 3) mistralrs-core/src/models/granite.rs:1570 — mistralrs-core/src/models/granite.rs:1570-1575 | mistralrs-core/src/vision_models/phi3/mod.rs:272-277 | mistralrs-core/src/vision_models/phi4/mod.rs:141-146 — before extracting anything, compare `mistralrs-core/src/models/granite.rs` and `mistralrs-core/src/vision_models/phi3/mod.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 135 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/granite.rs:1570` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 3) mistralrs-core/src/pipeline/embedding.rs:247 — mistralrs-core/src/pipeline/embedding.rs:247-252 | mistralrs-core/src/pipeline/gguf.rs:1316-1321 | mistralrs-core/src/pipeline/multimodal.rs:681-686 — before extracting anything, compare `mistralrs-core/src/pipeline/embedding.rs` and `mistralrs-core/src/pipeline/multimodal.rs` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 178 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/embedding.rs:247` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/pipeline/multimodal.rs:678` calls `clone` and `mistralrs-core/src/pipeline/embedding.rs:244` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (6 lines × 3) mistralrs-core/src/vision_models/muse_glimmer/mod.rs:338 — mistralrs-core/src/vision_models/muse_glimmer/mod.rs:338-343 | mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:432-437 | mistralrs-core/src/vision_models/qwen2vl/mod.rs:588-593 — `mistralrs-core/src/vision_models/muse_glimmer/mod.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 66 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (6 lines × 3) mistralrs-paged-attn/src/cuda/backend/flash_attn_sinks.rs:28 — mistralrs-paged-attn/src/cuda/backend/flash_attn_sinks.rs:28-33 | mistralrs-quant/src/utils/ops.rs:2231-2236 | mistralrs-quant/src/utils/ops.rs:2455-2460 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/cuda/backend/flash_attn_sinks.rs:28` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 3) mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:66 — mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:66-71 | mistralrs-quant/src/gguf/fast_mmq.rs:394-399 | mistralrs-quant/src/gguf/fast_mmvq.rs:127-132 — before extracting anything, compare `mistralrs-quant/src/gguf/fast_mmq.rs` and `mistralrs-quant/src/gguf/fast_mmvq.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 62 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:66` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 3) mistralrs-quant/src/metal_kernels/mod.rs:486 — mistralrs-quant/src/metal_kernels/mod.rs:486-491 | mistralrs-quant/src/metal_kernels/mod.rs:661-669 | mistralrs-quant/src/metal_kernels/mod.rs:3309-3319 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/metal_kernels/mod.rs:486` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (6 lines × 3) mistralrs-quant/src/metal_kernels/mod.rs:1392 — mistralrs-quant/src/metal_kernels/mod.rs:1392-1397 | mistralrs-quant/src/metal_kernels/mod.rs:1403-1408 | mistralrs-quant/src/metal_kernels/mod.rs:1438-1443 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/metal_kernels/mod.rs:1392` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-quant/src/metal_kernels/mod.rs:1398` calls `set_param` and `mistralrs-quant/src/metal_kernels/mod.rs:1409` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (6 lines × 3) mistralrs-quant/src/metal_kernels/mod.rs:1606 — mistralrs-quant/src/metal_kernels/mod.rs:1606-1611 | mistralrs-quant/src/metal_kernels/mod.rs:1685-1690 | mistralrs-quant/src/metal_kernels/mod.rs:4783-4788 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/metal_kernels/mod.rs:1606` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-quant/src/metal_kernels/mod.rs:4781` calls `set_input_buffer`, `Some` and `mistralrs-quant/src/metal_kernels/mod.rs:1604` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (6 lines × 3) mistralrs-quant/src/gemv/mod.rs:366 — mistralrs-quant/src/gemv/mod.rs:366-371 | mistralrs-quant/src/gemv/mod.rs:437-442 | mistralrs-quant/src/gemv/mod.rs:508-513 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/gemv/mod.rs:366` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 3) mistralrs-core/src/gguf/multimodal_binding_utils.rs:131 — mistralrs-core/src/gguf/multimodal_binding_utils.rs:131-136 | mistralrs-core/src/gguf/multimodal_bindings.rs:652-657 | mistralrs-core/src/gguf/qwen_multimodal_bindings.rs:870-875 — before extracting anything, compare `mistralrs-core/src/gguf/multimodal_binding_utils.rs` and `mistralrs-core/src/gguf/qwen_multimodal_bindings.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 40 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/gguf/multimodal_binding_utils.rs:131` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 3) mistralrs-core/src/models/phi3.rs:281 — mistralrs-core/src/models/phi3.rs:281-286 | mistralrs-core/src/vision_models/phi3/mod.rs:372-377 | mistralrs-core/src/vision_models/phi4/mod.rs:235-240 — before extracting anything, compare `mistralrs-core/src/models/phi3.rs` and `mistralrs-core/src/vision_models/phi3/mod.rs` as WHOLE FILES: this scan already matched 50 separate duplicated blocks between them, totalling at least 638 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (6 lines × 3) mistralrs-core/src/pipeline/ggml.rs:507 — mistralrs-core/src/pipeline/ggml.rs:507-512 | mistralrs-core/src/pipeline/gguf.rs:1545-1550 | mistralrs-core/src/pipeline/normal.rs:1727-1732 — before extracting anything, compare `mistralrs-core/src/pipeline/ggml.rs` and `mistralrs-core/src/pipeline/gguf.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 75 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (6 lines × 3) mistralrs-core/src/pipeline/loaders/lfm3_audio.rs:213 — mistralrs-core/src/pipeline/loaders/lfm3_audio.rs:213-218 | mistralrs-core/src/pipeline/loaders/lfm3_omni.rs:147-152 | mistralrs-core/src/pipeline/loaders/lfm3_vl.rs:235-240 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/lfm3_audio.rs:213` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 3) mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:211 — mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:211-216 | mistralrs-core/src/vision_models/qwen2vl/vision.rs:182-187 | mistralrs-core/src/vision_models/qwen3_vl/vision.rs:244-249 — `mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs` and `mistralrs-core/src/vision_models/qwen2vl/vision.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 15 separate duplicated blocks between them, totalling at least 182 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (6 lines × 3) mistralrs-quant/src/blockwise_fp8/deepgemm.rs:443 — mistralrs-quant/src/blockwise_fp8/deepgemm.rs:443-450 | mistralrs-quant/src/blockwise_fp8/ops.rs:1777-1784 | mistralrs-quant/src/cutile/fp8_w8a16.rs:418-423 — before extracting anything, compare `mistralrs-quant/src/blockwise_fp8/deepgemm.rs` and `mistralrs-quant/src/blockwise_fp8/ops.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 65 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/blockwise_fp8/deepgemm.rs:443` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 3) mistralrs-cli/src/ui/handlers/api.rs:206 — mistralrs-cli/src/ui/handlers/api.rs:206-211 | mistralrs-cli/src/ui/handlers/api.rs:258-263 | mistralrs-cli/src/ui/handlers/api.rs:310-315 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-cli/src/ui/handlers/api.rs:206` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 3) mistralrs-quant/src/cutile/hyper_connection.rs:324 — mistralrs-quant/src/cutile/hyper_connection.rs:324-329 | mistralrs-quant/src/cutile/mxfp8_gemm.rs:397-402 | mistralrs-quant/src/cutile/mxfp8_gemm.rs:462-467 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cutile/hyper_connection.rs:324` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-quant/src/cutile/mxfp8_gemm.rs:460` calls `stream` and `mistralrs-quant/src/cutile/mxfp8_gemm.rs:395` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (6 lines × 3) mistralrs-core/src/tools/parsers/atem.rs:377 — mistralrs-core/src/tools/parsers/atem.rs:377-382 | mistralrs-core/src/tools/parsers/deepseek.rs:57-62 | mistralrs-core/src/tools/parsers/harmony.rs:13-18 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/tools/parsers/atem.rs:377` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (5 lines × 3) · ×24
  • Duplicated block (5 lines × 3) mistralrs-core/src/cuda/gdn.rs:2229 — mistralrs-core/src/cuda/gdn.rs:2229-2234 | mistralrs-core/src/cuda/gdn.rs:2240-2244 | mistralrs-core/src/cuda/gdn.rs:2250-2254 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/gdn.rs:2229` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 3) mistralrs-core/src/metal/gdn.rs:191 — mistralrs-core/src/metal/gdn.rs:191-195 | mistralrs-core/src/metal/gdn.rs:306-310 | mistralrs-core/src/metal/ssm.rs:168-172 — before extracting anything, compare `mistralrs-core/src/metal/gdn.rs` and `mistralrs-core/src/metal/ssm.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 68 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/metal/gdn.rs:196` calls `set_label` and `mistralrs-core/src/metal/ssm.rs:173` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 3) mistralrs-core/src/metal/gdn.rs:606 — mistralrs-core/src/metal/gdn.rs:606-610 | mistralrs-core/src/metal/gdn.rs:782-786 | mistralrs-core/src/metal/gdn.rs:968-972 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (5 lines × 3) mistralrs-core/src/models/deepseek3.rs:504 — mistralrs-core/src/models/deepseek3.rs:504-508 | mistralrs-core/src/models/glm4_moe.rs:429-433 | mistralrs-core/src/models/glm4_moe_lite.rs:525-529 — before extracting anything, compare `mistralrs-core/src/models/deepseek3.rs` and `mistralrs-core/src/models/glm4_moe.rs` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 479 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: the declarations holding them bind `cfg` to `&DeepSeekV3Config` in one and `&Glm4MoeConfig` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (5 lines × 3) mistralrs-core/src/models/lfm2.rs:1313 — mistralrs-core/src/models/lfm2.rs:1313-1317 | mistralrs-core/src/models/lfm2.rs:1356-1361 | mistralrs-core/src/models/lfm3.rs:1332-1336 — before extracting anything, compare `mistralrs-core/src/models/lfm2.rs` and `mistralrs-core/src/models/lfm3.rs` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 402 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/lfm2.rs:1313` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 3) mistralrs-core/src/models/phi3.rs:144 — mistralrs-core/src/models/phi3.rs:144-148 | mistralrs-core/src/vision_models/phi3/mod.rs:236-240 | mistralrs-core/src/vision_models/phi4/mod.rs:105-109 — before extracting anything, compare `mistralrs-core/src/models/phi3.rs` and `mistralrs-core/src/vision_models/phi3/mod.rs` as WHOLE FILES: this scan already matched 50 separate duplicated blocks between them, totalling at least 638 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (5 lines × 3) mistralrs-core/src/moe/experts/backends.rs:888 — mistralrs-core/src/moe/experts/backends.rs:888-892 | mistralrs-core/src/moe/experts/backends.rs:963-967 | mistralrs-quant/src/moe/cutlass.rs:149-153 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
  • Duplicated block (5 lines × 3) mistralrs-core/src/ops.rs:4215 — mistralrs-core/src/ops.rs:4215-4219 | mistralrs-core/src/ops.rs:4843-4849 | mistralrs-quant/src/metal_fp8.rs:75-80 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:4843` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (5 lines × 3) mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:359 — mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:359-363 | mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:505-509 | mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:526-530 — `mistralrs-core/src/vision_models/gemma3/inputs_processor.rs` and `mistralrs-core/src/vision_models/idefics3/inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 10 separate duplicated blocks between them, totalling at least 146 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:359` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 3) mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:930 — mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:930-934 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:544-548 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:665-669 — `mistralrs-core/src/vision_models/qwen3_5_moe/text.rs` and `mistralrs-core/src/vision_models/qwen3_vl/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 18 separate duplicated blocks between them, totalling at least 207 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:930` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 3) mistralrs-quant/src/afq/ops.rs:1746 — mistralrs-quant/src/afq/ops.rs:1746-1750 | mistralrs-quant/src/afq/ops.rs:1864-1868 | mistralrs-quant/src/afq/ops.rs:1982-1986 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/afq/ops.rs:1982` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (5 lines × 3) mistralrs-quant/src/blockwise_fp8/deepgemm.rs:506 — mistralrs-quant/src/blockwise_fp8/deepgemm.rs:506-511 | mistralrs-quant/src/blockwise_fp8/deepgemm.rs:599-604 | mistralrs-quant/src/gguf/gated_mix.rs:93-97 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
  • Duplicated block (5 lines × 3) mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:338 — mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:338-342 | mistralrs-core/src/vision_models/qwen2vl/vision.rs:310-314 | mistralrs-core/src/vision_models/qwen3_vl/vision.rs:411-415 — `mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs` and `mistralrs-core/src/vision_models/qwen2vl/vision.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 15 separate duplicated blocks between them, totalling at least 182 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (5 lines × 3) mistralrs-quant/src/gptq/gptq_cuda.rs:106 — mistralrs-quant/src/gptq/gptq_cuda.rs:106-110 | mistralrs-quant/src/gptq/gptq_cuda.rs:129-134 | mistralrs-quant/src/gptq/gptq_cuda.rs:151-156 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (5 lines × 3) mistralrs-quant/src/gptq/gptq_cuda.rs:117 — mistralrs-quant/src/gptq/gptq_cuda.rs:117-122 | mistralrs-quant/src/gptq/gptq_cuda.rs:130-134 | mistralrs-quant/src/gptq/gptq_cuda.rs:152-156 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/gptq/gptq_cuda.rs:117` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (5 lines × 3) mistralrs-core/src/moe/experts/backends.rs:888 — mistralrs-core/src/moe/experts/backends.rs:888-892 | mistralrs-core/src/moe/experts/backends.rs:963-967 | mistralrs-quant/src/moe/cuda.rs:104-108 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
  • Duplicated block (5 lines × 3) mistralrs-quant/src/blockwise_fp8/ops.rs:707 — mistralrs-quant/src/blockwise_fp8/ops.rs:707-711 | mistralrs-quant/src/mxfp4/ops.rs:103-107 | mistralrs-quant/src/mxfp4/ops.rs:457-461 — `mistralrs-quant/src/blockwise_fp8/ops.rs` and `mistralrs-quant/src/mxfp4/ops.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 8 separate duplicated blocks between them, totalling at least 59 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-quant/src/mxfp4/ops.rs:102` calls `layout` and `mistralrs-quant/src/mxfp4/ops.rs:456` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 3) mistralrs-core/src/cuda/gdn.rs:3408 — mistralrs-core/src/cuda/gdn.rs:3408-3412 | mistralrs-core/src/cuda/gdn.rs:5102-5106 | mistralrs-core/src/cuda/gdn.rs:5138-5142 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (5 lines × 3) mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:499 — mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:499-503 | mistralrs-paged-attn/src/cuda/backend/gather_kv.rs:234-238 | mistralrs-paged-attn/src/cuda/backend/gather_kv.rs:245-249 — before extracting anything, compare `mistralrs-paged-attn/src/cuda/backend/flashinfer.rs` and `mistralrs-paged-attn/src/cuda/backend/gather_kv.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 39 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (5 lines × 3) mistralrs-core/src/gguf/multimodal_binding_utils.rs:120 — mistralrs-core/src/gguf/multimodal_binding_utils.rs:120-124 | mistralrs-core/src/gguf/normal_bindings.rs:959-963 | mistralrs-core/src/gguf/qwen_multimodal_bindings.rs:314-318 — before extracting anything, compare `mistralrs-core/src/gguf/multimodal_binding_utils.rs` and `mistralrs-core/src/gguf/qwen_multimodal_bindings.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 40 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/gguf/multimodal_binding_utils.rs:120` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 3) mistralrs-paged-attn/src/cuda/backend/flash_attn_sinks.rs:137 — mistralrs-paged-attn/src/cuda/backend/flash_attn_sinks.rs:137-141 | mistralrs-paged-attn/src/cuda/backend/flash_attn_sinks.rs:306-310 | mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:440-444 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/cuda/backend/flash_attn_sinks.rs:137` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 3) mistralrs-cli/src/commands/run/interactive.rs:1506 — mistralrs-cli/src/commands/run/interactive.rs:1506-1510 | mistralrs-pyo3/src/stream.rs:83-87 | mistralrs-server-core/src/chat_completion.rs:494-498 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
  • Duplicated block (5 lines × 3) mistralrs-core/src/vision_models/gemma3n/mod.rs:85 — mistralrs-core/src/vision_models/gemma3n/mod.rs:85-89 | mistralrs-core/src/vision_models/gemma3n/mod.rs:194-198 | mistralrs-core/src/vision_models/multimodal_layout.rs:344-348 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3n/mod.rs:85` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 3) mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:135 — mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:135-139 | mistralrs-core/src/vision_models/qwen2vl/vision.rs:106-110 | mistralrs-core/src/vision_models/qwen3_vl/vision.rs:138-142 — `mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs` and `mistralrs-core/src/vision_models/qwen2vl/vision.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 15 separate duplicated blocks between them, totalling at least 182 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (11 lines × 3) · ×23
  • Duplicated block (11 lines × 3) mistralrs-core/src/cuda/gdn.rs:971 — mistralrs-core/src/cuda/gdn.rs:971-981 | mistralrs-core/src/cuda/gdn.rs:1095-1105 | mistralrs-core/src/cuda/gdn.rs:1206-1216 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/gdn.rs:971` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 3) mistralrs-core/src/embedding_models/embedding_gemma.rs:437 — mistralrs-core/src/embedding_models/embedding_gemma.rs:437-447 | mistralrs-core/src/vision_models/gemma3/text.rs:496-506 | mistralrs-core/src/vision_models/gemma3n/text.rs:1436-1446 — before extracting anything, compare `mistralrs-core/src/embedding_models/embedding_gemma.rs` and `mistralrs-core/src/vision_models/gemma3/text.rs` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 286 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (11 lines × 3) mistralrs-core/src/gdn/weights.rs:223 — mistralrs-core/src/gdn/weights.rs:223-233 | mistralrs-core/src/gdn/weights.rs:252-262 | mistralrs-core/src/gdn/weights.rs:293-303 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/gdn/weights.rs:223` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (11 lines × 3) mistralrs-core/src/models/phi3.rs:183 — mistralrs-core/src/models/phi3.rs:183-193 | mistralrs-core/src/vision_models/phi3/mod.rs:274-284 | mistralrs-core/src/vision_models/phi4/mod.rs:143-153 — before extracting anything, compare `mistralrs-core/src/models/phi3.rs` and `mistralrs-core/src/vision_models/phi3/mod.rs` as WHOLE FILES: this scan already matched 50 separate duplicated blocks between them, totalling at least 638 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/phi3.rs:183` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 3) mistralrs-core/src/models/qwen3_next.rs:196 — mistralrs-core/src/models/qwen3_next.rs:196-208 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:101-113 | mistralrs-core/src/vision_models/qwen4_exp/qsa.rs:119-129 — before extracting anything, compare `mistralrs-core/src/models/qwen3_next.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/text.rs` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 461 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (11 lines × 3) mistralrs-core/src/ops.rs:202 — mistralrs-core/src/ops.rs:202-212 | mistralrs-core/src/ops.rs:525-535 | mistralrs-core/src/ops.rs:649-659 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (11 lines × 3) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1338 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1338-1348 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3118-3128 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3467-3477 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1338` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 3) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7817 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7817-7827 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:8339-8349 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6599-6609 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` and `mistralrs-core/src/pipeline/loaders/normal_loaders.rs` as WHOLE FILES: this scan already matched 34 separate duplicated blocks between them, totalling at least 445 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (11 lines × 3) mistralrs-core/src/vision_models/gemma3/text.rs:451 — mistralrs-core/src/vision_models/gemma3/text.rs:451-461 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:407-417 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:527-537 — `mistralrs-core/src/vision_models/gemma3/text.rs` and `mistralrs-core/src/vision_models/qwen3_vl/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 15 separate duplicated blocks between them, totalling at least 140 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3/text.rs:451` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 3) mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1240 — mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1240-1256 | mistralrs-core/src/vision_models/phi4/inputs_processor.rs:630-640 | mistralrs-core/src/vision_models/phi4/inputs_processor.rs:866-881 — `mistralrs-core/src/vision_models/gemma4/inputs_processor.rs` and `mistralrs-core/src/vision_models/phi4/inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 46 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1240` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (11 lines × 3) mistralrs-core/src/vision_models/grid_processor.rs:2067 — mistralrs-core/src/vision_models/grid_processor.rs:2067-2077 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:1132-1142 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1697-1707 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:2067` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 3) REDACTED:638 — REDACTED:638-648 | mistralrs-core/src/vision_models/idefics3/vision.rs:436-446 | mistralrs-core/src/vision_models/siglip.rs:454-464 — before extracting anything, compare `REDACTED` and `mistralrs-core/src/vision_models/idefics3/vision.rs` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 221 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:638` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `config` to `&VisionConfig` in one and `&Idefics3VisionConfig` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (11 lines × 3) mistralrs-quant/src/gemv/mod.rs:350 — mistralrs-quant/src/gemv/mod.rs:350-360 | mistralrs-quant/src/gemv/mod.rs:422-432 | mistralrs-quant/src/gemv/mod.rs:493-503 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (11 lines × 3) mistralrs-quant/src/hqq/mod.rs:268 — mistralrs-quant/src/hqq/mod.rs:268-278 | mistralrs-quant/src/hqq/mod.rs:362-372 | mistralrs-quant/src/hqq/mod.rs:511-521 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/hqq/mod.rs:268` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 3) mistralrs-quant/src/metal_kernels/mod.rs:1796 — mistralrs-quant/src/metal_kernels/mod.rs:1796-1806 | mistralrs-quant/src/metal_kernels/mod.rs:1861-1871 | mistralrs-quant/src/metal_kernels/mod.rs:1931-1941 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/metal_kernels/mod.rs:1796` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (11 lines × 3) mistralrs-quant/src/cutile/routed_lora.rs:165 — mistralrs-quant/src/cutile/routed_lora.rs:165-175 | mistralrs-quant/src/cutile/routed_lora.rs:193-203 | mistralrs-quant/src/cutile/routed_lora.rs:216-226 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cutile/routed_lora.rs:165` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 3) mistralrs-core/src/models/qwen2.rs:131 — mistralrs-core/src/models/qwen2.rs:131-141 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:26-36 | mistralrs-core/src/vision_models/qwen2vl/text.rs:27-37 — before extracting anything, compare `mistralrs-core/src/models/qwen2.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/text.rs` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 319 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/qwen2.rs:131` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 3) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:962 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:962-972 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3752-3762 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1847-1857 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` and `mistralrs-core/src/pipeline/loaders/normal_loaders.rs` as WHOLE FILES: this scan already matched 34 separate duplicated blocks between them, totalling at least 445 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (11 lines × 3) mistralrs-core/src/cuda/gdn.rs:5337 — mistralrs-core/src/cuda/gdn.rs:5337-5347 | mistralrs-core/src/cuda/gdn.rs:5537-5548 | mistralrs-core/src/cuda/gdn.rs:5764-5774 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/gdn.rs:5337` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (11 lines × 3) mistralrs-core/src/sampler.rs:1298 — mistralrs-core/src/sampler.rs:1298-1309 | mistralrs-core/src/sampler.rs:1541-1551 | mistralrs-core/src/sampler.rs:1708-1718 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/sampler.rs:1298` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (11 lines × 3) mistralrs-core/src/ops.rs:4417 — mistralrs-core/src/ops.rs:4417-4427 | mistralrs-core/src/ops.rs:4602-4612 | mistralrs-core/src/ops.rs:5365-5375 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:4417` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/ops.rs:5364` calls `dtype` and `mistralrs-core/src/ops.rs:4416` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (11 lines × 3) mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:808 — mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:808-818 | mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:211-221 | mistralrs-core/src/vision_models/phi3/phi3_inputs_processor.rs:167-177 — before extracting anything, compare `mistralrs-core/src/vision_models/gemma4/inputs_processor.rs` and `mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 45 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:808` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 3) mistralrs-quant/src/distributed/layers.rs:2198 — mistralrs-quant/src/distributed/layers.rs:2198-2208 | mistralrs-quant/src/distributed/layers.rs:2214-2224 | mistralrs-quant/src/distributed/layers.rs:2230-2240 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/distributed/layers.rs:2198` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (10 lines × 3) · ×23
  • Duplicated block (10 lines × 3) mistralrs-core/src/cuda/gdn.rs:1717 — mistralrs-core/src/cuda/gdn.rs:1717-1726 | mistralrs-core/src/cuda/gdn.rs:5949-5958 | mistralrs-core/src/cuda/gdn.rs:6193-6202 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/gdn.rs:1717` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 3) mistralrs-core/src/metal/gdn.rs:843 — mistralrs-core/src/metal/gdn.rs:843-852 | mistralrs-core/src/metal/gdn.rs:882-891 | mistralrs-core/src/metal/ssm.rs:184-193 — before extracting anything, compare `mistralrs-core/src/metal/gdn.rs` and `mistralrs-core/src/metal/ssm.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 68 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/metal/gdn.rs:840` calls `set_input_buffer`, `Some` and `mistralrs-core/src/metal/gdn.rs:878` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10 lines × 3) mistralrs-core/src/ops.rs:5889 — mistralrs-core/src/ops.rs:5889-5898 | mistralrs-core/src/ops.rs:6334-6343 | mistralrs-core/src/ops.rs:6652-6661 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:5889` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 3) mistralrs-core/src/pipeline/embedding.rs:573 — mistralrs-core/src/pipeline/embedding.rs:573-582 | mistralrs-core/src/pipeline/multimodal.rs:1110-1119 | mistralrs-core/src/pipeline/normal.rs:1136-1145 — before extracting anything, compare `mistralrs-core/src/pipeline/embedding.rs` and `mistralrs-core/src/pipeline/multimodal.rs` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 178 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/embedding.rs:573` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 3) mistralrs-core/src/pipeline/ggml.rs:557 — mistralrs-core/src/pipeline/ggml.rs:557-566 | mistralrs-core/src/pipeline/gguf.rs:1592-1601 | mistralrs-core/src/pipeline/gguf.rs:1603-1612 — before extracting anything, compare `mistralrs-core/src/pipeline/ggml.rs` and `mistralrs-core/src/pipeline/gguf.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 75 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/ggml.rs:557` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 3) mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:634 — mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:634-643 | mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:653-662 | mistralrs-core/src/vision_models/mistral3/inputs_processor.rs:422-431 — `mistralrs-core/src/vision_models/gemma3/inputs_processor.rs` and `mistralrs-core/src/vision_models/idefics3/inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 10 separate duplicated blocks between them, totalling at least 146 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:634` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 3) mistralrs-core/src/vision_models/gemma4/mod.rs:389 — mistralrs-core/src/vision_models/gemma4/mod.rs:389-398 | mistralrs-core/src/vision_models/gemma4/mod.rs:565-574 | mistralrs-core/src/vision_models/gemma4/mod.rs:702-711 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma4/mod.rs:389` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 3) mistralrs-core/src/vision_models/grid_processor.rs:1759 — mistralrs-core/src/vision_models/grid_processor.rs:1759-1768 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:914-923 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1479-1488 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (10 lines × 3) mistralrs-core/src/vision_models/grid_processor.rs:2013 — mistralrs-core/src/vision_models/grid_processor.rs:2013-2022 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:1076-1085 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1641-1650 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:1086` calls `context` and `mistralrs-core/src/vision_models/grid_processor.rs:2024` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10 lines × 3) mistralrs-core/src/vision_models/llama4/vision.rs:202 — mistralrs-core/src/vision_models/llama4/vision.rs:202-211 | mistralrs-core/src/vision_models/mllama/text.rs:566-575 | mistralrs-core/src/vision_models/mllama/vision.rs:221-230 — `mistralrs-core/src/vision_models/llama4/vision.rs` and `mistralrs-core/src/vision_models/mllama/vision.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 6 separate duplicated blocks between them, totalling at least 67 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/llama4/vision.rs:202` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 3) mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:139 — mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:139-148 | mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:325-334 | mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:613-622 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:139` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 3) mistralrs-paged-attn/src/cuda/backend/mla.rs:47 — mistralrs-paged-attn/src/cuda/backend/mla.rs:47-56 | mistralrs-paged-attn/src/cuda/backend/mla.rs:334-343 | mistralrs-paged-attn/src/cuda/backend/mla.rs:689-698 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/cuda/backend/mla.rs:47` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 3) mistralrs-pyo3/src/lib.rs:2206 — mistralrs-pyo3/src/lib.rs:2206-2215 | mistralrs-pyo3/src/lib.rs:2238-2247 | mistralrs-pyo3/src/lib.rs:2617-2626 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-pyo3/src/lib.rs:2206` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (10 lines × 3) mistralrs-quant/src/bitsandbytes/op.rs:449 — mistralrs-quant/src/bitsandbytes/op.rs:449-458 | mistralrs-quant/src/bitsandbytes/op.rs:462-471 | mistralrs-quant/src/bitsandbytes/op.rs:475-484 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/bitsandbytes/op.rs:449` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 3) mistralrs-quant/src/blockwise_fp8/deepgemm.rs:527 — mistralrs-quant/src/blockwise_fp8/deepgemm.rs:527-536 | mistralrs-quant/src/blockwise_fp8/deepgemm.rs:630-639 | mistralrs-quant/src/blockwise_fp8/ops.rs:2061-2070 — before extracting anything, compare `mistralrs-quant/src/blockwise_fp8/deepgemm.rs` and `mistralrs-quant/src/blockwise_fp8/ops.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 65 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/blockwise_fp8/deepgemm.rs:527` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 3) mistralrs-quant/src/blockwise_fp8/ops.rs:78 — mistralrs-quant/src/blockwise_fp8/ops.rs:78-87 | mistralrs-quant/src/blockwise_fp8/ops.rs:394-403 | mistralrs-quant/src/blockwise_fp8/ops.rs:427-436 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/blockwise_fp8/ops.rs:78` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (10 lines × 3) mistralrs-quant/src/moe/cuda.rs:246 — mistralrs-quant/src/moe/cuda.rs:246-255 | mistralrs-quant/src/moe/cuda.rs:282-291 | mistralrs-quant/src/moe/cuda.rs:323-332 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/moe/cuda.rs:246` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 3) mistralrs-quant/src/cutile/fused_moe_fp8.rs:281 — mistralrs-quant/src/cutile/fused_moe_fp8.rs:281-290 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:292-301 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:302-313 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cutile/fused_moe_fp8.rs:302` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (10 lines × 3) mistralrs-quant/src/cutile/fused_moe_fp8.rs:326 — mistralrs-quant/src/cutile/fused_moe_fp8.rs:326-335 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:337-346 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:347-358 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cutile/fused_moe_fp8.rs:347` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (10 lines × 3) mistralrs-quant/src/cutile/fused_moe.rs:374 — mistralrs-quant/src/cutile/fused_moe.rs:374-383 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:371-380 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:409-418 — before extracting anything, compare `mistralrs-quant/src/cutile/fused_moe.rs` and `mistralrs-quant/src/cutile/fused_moe_fp8.rs` as WHOLE FILES: this scan already matched 24 separate duplicated blocks between them, totalling at least 298 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (10 lines × 3) mistralrs-core/src/vision_models/gemma4/mod.rs:526 — mistralrs-core/src/vision_models/gemma4/mod.rs:526-535 | mistralrs-core/src/vision_models/gemma4/mod.rs:649-658 | mistralrs-core/src/vision_models/gemma4/mod.rs:839-848 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma4/mod.rs:526` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 3) mistralrs-core/src/vision_models/muse_glimmer/mod.rs:177 — mistralrs-core/src/vision_models/muse_glimmer/mod.rs:177-186 | mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:157-166 | mistralrs-core/src/vision_models/qwen2vl/mod.rs:180-189 — `mistralrs-core/src/vision_models/muse_glimmer/mod.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 66 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/muse_glimmer/mod.rs:177` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 3) mistralrs-quant/src/metal_kernels/mod.rs:2851 — mistralrs-quant/src/metal_kernels/mod.rs:2851-2860 | mistralrs-quant/src/metal_kernels/mod.rs:2931-2940 | mistralrs-quant/src/metal_kernels/mod.rs:2966-2975 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/metal_kernels/mod.rs:2851` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-quant/src/metal_kernels/mod.rs:2942` calls `set_output_buffer`, `Some` and `mistralrs-quant/src/metal_kernels/mod.rs:2977` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (7 lines × 3) · ×23
  • Duplicated block (7 lines × 3) mistralrs-core/src/cuda/gdn.rs:4261 — mistralrs-core/src/cuda/gdn.rs:4261-4267 | mistralrs-core/src/cuda/gdn.rs:4722-4728 | mistralrs-core/src/cuda/gdn.rs:6150-6156 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/gdn.rs:4261` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 3) mistralrs-core/src/models/gemma2.rs:590 — mistralrs-core/src/models/gemma2.rs:590-596 | mistralrs-core/src/vision_models/gemma3/text.rs:761-767 | mistralrs-core/src/vision_models/gemma3n/text.rs:1929-1935 — before extracting anything, compare `mistralrs-core/src/models/gemma2.rs` and `mistralrs-core/src/vision_models/gemma3/text.rs` as WHOLE FILES: this scan already matched 34 separate duplicated blocks between them, totalling at least 411 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma2.rs:590` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 3) mistralrs-core/src/models/granite.rs:313 — mistralrs-core/src/models/granite.rs:313-319 | mistralrs-core/src/xlora_models/mixtral.rs:383-389 | mistralrs-core/src/xlora_models/quantized_llama.rs:123-129 — before extracting anything, compare `mistralrs-core/src/xlora_models/mixtral.rs` and `mistralrs-core/src/xlora_models/quantized_llama.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 118 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/granite.rs:313` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 3) mistralrs-core/src/pipeline/embedding.rs:637 — mistralrs-core/src/pipeline/embedding.rs:637-643 | mistralrs-core/src/pipeline/multimodal.rs:1409-1415 | mistralrs-core/src/pipeline/normal.rs:1452-1458 — before extracting anything, compare `mistralrs-core/src/pipeline/embedding.rs` and `mistralrs-core/src/pipeline/multimodal.rs` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 178 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/embedding.rs:637` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 3) mistralrs-core/src/pipeline/inputs_processor.rs:1148 — mistralrs-core/src/pipeline/inputs_processor.rs:1148-1154 | mistralrs-core/src/pipeline/inputs_processor.rs:1165-1171 | mistralrs-core/src/pipeline/inputs_processor.rs:1245-1251 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/inputs_processor.rs:1148` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 3) mistralrs-core/src/pipeline/isq.rs:1192 — mistralrs-core/src/pipeline/isq.rs:1192-1198 | mistralrs-core/src/pipeline/isq.rs:1201-1207 | mistralrs-core/src/pipeline/isq.rs:1210-1216 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/isq.rs:1192` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 3) mistralrs-core/src/vision_models/gemma4/mod.rs:374 — mistralrs-core/src/vision_models/gemma4/mod.rs:374-380 | mistralrs-core/src/vision_models/gemma4/mod.rs:558-564 | mistralrs-core/src/vision_models/gemma4/mod.rs:686-692 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (7 lines × 3) mistralrs-core/src/vision_models/grid_processor.rs:1474 — mistralrs-core/src/vision_models/grid_processor.rs:1474-1480 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:668-674 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1276-1282 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:1474` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 3) REDACTED:612 — REDACTED:612-618 | mistralrs-core/src/vision_models/idefics3/vision.rs:409-415 | mistralrs-core/src/vision_models/siglip.rs:420-426 — before extracting anything, compare `REDACTED` and `mistralrs-core/src/vision_models/idefics3/vision.rs` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 221 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit. Note first that the copies are not typed on the same thing: the declarations holding them bind `config` to `&VisionConfig` in one and `&Idefics3VisionConfig` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (7 lines × 3) mistralrs-paged-attn/src/cuda/backend/gather_kv.rs:15 — mistralrs-paged-attn/src/cuda/backend/gather_kv.rs:15-21 | mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:40-46 | mistralrs-paged-attn/src/metal/backend/mod.rs:51-57 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/cuda/backend/gather_kv.rs:15` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 3) mistralrs-paged-attn/src/metal/kernels/mod.rs:573 — mistralrs-paged-attn/src/metal/kernels/mod.rs:573-579 | mistralrs-paged-attn/src/metal/kernels/mod.rs:717-723 | mistralrs-paged-attn/src/metal/kernels/mod.rs:987-993 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/metal/kernels/mod.rs:573` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 3) mistralrs-quant/src/blockwise_fp8/mod.rs:576 — mistralrs-quant/src/blockwise_fp8/mod.rs:576-582 | mistralrs-quant/src/blockwise_fp8/mod.rs:622-628 | mistralrs-quant/src/blockwise_fp8/mod.rs:914-920 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (7 lines × 3) mistralrs-quant/src/lora/dynamic/moe_cuda.rs:1012 — mistralrs-quant/src/lora/dynamic/moe_cuda.rs:1012-1018 | mistralrs-quant/src/lora/dynamic/moe_cuda.rs:1031-1037 | mistralrs-quant/src/lora/dynamic/moe_cuda.rs:1050-1056 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/lora/dynamic/moe_cuda.rs:1012` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 3) mistralrs-quant/src/lora/dynamic/moe_cuda.rs:1075 — mistralrs-quant/src/lora/dynamic/moe_cuda.rs:1075-1081 | mistralrs-quant/src/lora/dynamic/moe_cuda.rs:1095-1101 | mistralrs-quant/src/lora/dynamic/moe_cuda.rs:1115-1121 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/lora/dynamic/moe_cuda.rs:1075` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 3) mistralrs-quant/src/utils/ops.rs:622 — mistralrs-quant/src/utils/ops.rs:622-628 | mistralrs-quant/src/utils/ops.rs:635-641 | mistralrs-quant/src/utils/ops.rs:648-654 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/utils/ops.rs:622` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 3) mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:267 — mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:267-273 | mistralrs-core/src/vision_models/qwen2vl/vision.rs:239-245 | mistralrs-core/src/vision_models/qwen3_vl/vision.rs:303-309 — `mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs` and `mistralrs-core/src/vision_models/qwen2vl/vision.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 15 separate duplicated blocks between them, totalling at least 182 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (7 lines × 3) mistralrs-core/src/kv_cache/mod.rs:510 — mistralrs-core/src/kv_cache/mod.rs:510-516 | mistralrs-core/src/kv_cache/mod.rs:541-547 | mistralrs-core/src/kv_cache/mod.rs:654-660 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/kv_cache/mod.rs:510` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 3) mistralrs-core/src/gguf/multimodal_binding_utils.rs:96 — mistralrs-core/src/gguf/multimodal_binding_utils.rs:96-102 | mistralrs-core/src/gguf/multimodal_bindings.rs:85-91 | mistralrs-core/src/gguf/qwen_multimodal_bindings.rs:270-276 — before extracting anything, compare `mistralrs-core/src/gguf/multimodal_binding_utils.rs` and `mistralrs-core/src/gguf/qwen_multimodal_bindings.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 40 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 3) mistralrs-core/src/models/llama.rs:590 — mistralrs-core/src/models/llama.rs:590-596 | mistralrs-core/src/models/smollm3.rs:609-615 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:603-609 — before extracting anything, compare `mistralrs-core/src/models/llama.rs` and `mistralrs-core/src/models/smollm3.rs` as WHOLE FILES: this scan already matched 47 separate duplicated blocks between them, totalling at least 727 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 3) mistralrs-core/src/models/llama.rs:597 — mistralrs-core/src/models/llama.rs:597-603 | mistralrs-core/src/models/smollm3.rs:616-622 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:610-616 — before extracting anything, compare `mistralrs-core/src/models/llama.rs` and `mistralrs-core/src/models/smollm3.rs` as WHOLE FILES: this scan already matched 47 separate duplicated blocks between them, totalling at least 727 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 3) REDACTED:620 — REDACTED:620-626 | mistralrs-core/src/vision_models/idefics3/vision.rs:417-423 | mistralrs-core/src/vision_models/lfm2_vl/vision.rs:338-344 — before extracting anything, compare `REDACTED` and `mistralrs-core/src/vision_models/idefics3/vision.rs` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 221 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 3) mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:273 — mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:273-279 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:126-135 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:692-701 — `mistralrs-core/src/vision_models/gemma3/inputs_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 5 separate duplicated blocks between them, totalling at least 92 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (7 lines × 3) mistralrs-paged-attn/src/cuda/backend/flash_attn_sinks.rs:78 — mistralrs-paged-attn/src/cuda/backend/flash_attn_sinks.rs:78-84 | mistralrs-paged-attn/src/cuda/backend/flash_attn_sinks.rs:246-252 | mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:250-256 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/cuda/backend/flash_attn_sinks.rs:78` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
R4 · Test Coverage · No test reaches this file · ×23
  • No test reaches this file mistralrs-cli/webui/src/lib/types.ts:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file mistralrs-cli/webui/src/lib/components/ChatInput.svelte:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file mistralrs-cli/webui/src/lib/components/FileCard.svelte:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file mistralrs-cli/webui/src/lib/components/AssistantMessage.svelte:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file mistralrs-cli/webui/src/lib/components/UserMessage.svelte:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file mistralrs-cli/webui/src/lib/components/VideoFrames.svelte:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file mistralrs-cli/webui/src/lib/components/CodeExecution.svelte:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file mistralrs-cli/webui/src/lib/components/ModelBar.svelte:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file mistralrs-cli/webui/src/App.svelte:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file mistralrs-cli/webui/src/lib/components/ParamPopover.svelte:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file mistralrs-cli/webui/src/lib/components/MessageList.svelte:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file mistralrs-cli/webui/src/lib/components/Sidebar.svelte:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file mistralrs-cli/webui/src/lib/components/ToolsPanel.svelte:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file mistralrs-cli/webui/src/lib/components/AgentApproval.svelte:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file mistralrs-cli/webui/src/lib/components/ShellTool.svelte:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file mistralrs-cli/webui/src/lib/components/SettingsPanel.svelte:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file mistralrs-cli/webui/src/lib/components/ThinkingBlock.svelte:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file mistralrs-cli/webui/src/lib/ui.ts:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file mistralrs-cli/webui/src/lib/components/CustomTool.svelte:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file mistralrs-cli/webui/src/lib/components/SearchResult.svelte:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file mistralrs-cli/webui/src/main.ts:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file mistralrs-cli/webui/src/lib/components/Brand.svelte:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
  • No test reaches this file mistralrs-cli/webui/src/lib/components/Notice.svelte:1 — No test imports this module directly or transitively. Import reachability cannot see a test that executes a file by path instead of importing it, nor one that drives it through a running browser by navigating to a URL — if neither does, no test reaches this one.
D2 · Cognitive Complexity · mistralrs_cli · ×22
  • mistralrs_cli::commands::run::interactive::print_agentic_progress (cognitive 93) mistralrs-cli/src/commands/run/interactive.rs:1111 — mistralrs_cli::commands::run::interactive::print_agentic_progress has cognitive complexity 93 (threshold 15). Drivers by points: loops 11 (41 pts), if/else 14 (35 pts), match/switch 7 (17 pts) (nesting depth added 61). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_cli::commands::run::interactive::multimodal_interactive_mode (cognitive 88) mistralrs-cli/src/commands/run/interactive.rs:1529 — mistralrs_cli::commands::run::interactive::multimodal_interactive_mode has cognitive complexity 88 (threshold 15). Drivers by points: if/else 15 (38 pts), loops 7 (25 pts), match/switch 7 (23 pts), boolean chains 2 (nesting depth added 57). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_cli::commands::bench::run_bench (cognitive 70) mistralrs-cli/src/commands/bench.rs:80 — mistralrs_cli::commands::bench::run_bench has cognitive complexity 70 (threshold 15). Drivers by points: if/else 28 (48 pts), loops 9 (20 pts), boolean chains 2 (nesting depth added 31). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_cli::commands::doctor::run_doctor (cognitive 49) mistralrs-cli/src/commands/doctor.rs:6 — mistralrs_cli::commands::doctor::run_doctor has cognitive complexity 49 (threshold 15). Drivers by points: if/else 30 (41 pts), match/switch 2 (5 pts), loops 2 (3 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_cli::commands::run::interactive::stream_assistant_response (cognitive 35) mistralrs-cli/src/commands/run/interactive.rs:1415 — mistralrs_cli::commands::run::interactive::stream_assistant_response has cognitive complexity 35 (threshold 15). Drivers by points: if/else 9 (30 pts), boolean chains 2, match/switch 1 (2 pts), loops 1 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_cli::commands::serve::apply_quant_resolution (cognitive 35) mistralrs-cli/src/commands/serve.rs:978 — mistralrs_cli::commands::serve::apply_quant_resolution has cognitive complexity 35 (threshold 15). Drivers by points: if/else 17 (26 pts), boolean chains 9 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_cli::commands::run::interactive::agent_approval_callback (cognitive 29) mistralrs-cli/src/commands/run/interactive.rs:1321 — mistralrs_cli::commands::run::interactive::agent_approval_callback has cognitive complexity 29 (threshold 15). Drivers by points: if/else 9 (17 pts), loops 3 (10 pts), match/switch 1 (2 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_cli::commands::run::interactive::text_interactive_mode (cognitive 28) mistralrs-cli/src/commands/run/interactive.rs:869 — mistralrs_cli::commands::run::interactive::text_interactive_mode has cognitive complexity 28 (threshold 15). Drivers by points: if/else 9 (19 pts), match/switch 3 (7 pts), boolean chains 1, loops 1 (nesting depth added 14). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • mistralrs_cli::commands::quantize::generate_model_card (cognitive 26) mistralrs-cli/src/commands/quantize.rs:379 — mistralrs_cli::commands::quantize::generate_model_card has cognitive complexity 26 (threshold 15). Drivers by points: if/else 13 (24 pts), loops 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_cli::commands::quantize::run_quantize (cognitive 25) mistralrs-cli/src/commands/quantize.rs:238 — mistralrs_cli::commands::quantize::run_quantize has cognitive complexity 25 (threshold 15). Drivers by points: if/else 12 (19 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_cli::commands::tune::run_tune (cognitive 25) mistralrs-cli/src/commands/tune.rs:14 — mistralrs_cli::commands::tune::run_tune has cognitive complexity 25 (threshold 15). Drivers by points: if/else 12 (15 pts), loops 3 (5 pts), match/switch 3 (5 pts) (nesting depth added 7). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • mistralrs_cli::commands::uqff::uqff_groups (cognitive 25) mistralrs-cli/src/commands/uqff.rs:332 — mistralrs_cli::commands::uqff::uqff_groups has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (18 pts), loops 4 (7 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_cli::commands::quantize::resolve_gguf_source (cognitive 24) mistralrs-cli/src/commands/quantize.rs:105 — mistralrs_cli::commands::quantize::resolve_gguf_source has cognitive complexity 24 (threshold 15). Drivers by points: if/else 10 (19 pts), boolean chains 5 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_cli::commands::quant::gguf_discovery::resolve_gguf_projector (cognitive 23) mistralrs-cli/src/commands/quant/gguf_discovery.rs:208 — mistralrs_cli::commands::quant::gguf_discovery::resolve_gguf_projector has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (13 pts), match/switch 2 (6 pts), loops 2 (4 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_cli::commands::run::interactive::handle_sampling_command (cognitive 22) mistralrs-cli/src/commands/run/interactive.rs:743 — mistralrs_cli::commands::run::interactive::handle_sampling_command has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (12 pts), match/switch 3 (9 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_cli::commands::serve::convert_to_model_selected (cognitive 21) mistralrs-cli/src/commands/serve.rs:296 — mistralrs_cli::commands::serve::convert_to_model_selected has cognitive complexity 21 (threshold 15). Drivers by points: if/else 4 (11 pts), match/switch 4 (9 pts), boolean chains 1 (nesting depth added 12). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • mistralrs_cli::commands::quant::gguf_discovery::build_groups (cognitive 20) mistralrs-cli/src/commands/quant/gguf_discovery.rs:394 — mistralrs_cli::commands::quant::gguf_discovery::build_groups has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (16 pts), boolean chains 3, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_cli::commands::uqff::natural_sort_key (cognitive 20) mistralrs-cli/src/commands/uqff.rs:1260 — mistralrs_cli::commands::uqff::natural_sort_key has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (19 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_cli::commands::run::interactive::oneshot_multimodal (cognitive 18) mistralrs-cli/src/commands/run/interactive.rs:338 — mistralrs_cli::commands::run::interactive::oneshot_multimodal has cognitive complexity 18 (threshold 15). Drivers by points: match/switch 5 (8 pts), loops 6, if/else 3, boolean chains 1 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_cli::config::validate_config (cognitive 18) mistralrs-cli/src/config/mod.rs:152 — mistralrs_cli::config::validate_config has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (11 pts), match/switch 2 (4 pts), boolean chains 2, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_cli::commands::config::build_model_configs (cognitive 16) mistralrs-cli/src/commands/config.rs:318 — mistralrs_cli::commands::config::build_model_configs has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (11 pts), match/switch 1 (3 pts), loops 2 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
  • mistralrs_cli::commands::quant::gguf_discovery::resolve_group (cognitive 16) mistralrs-cli/src/commands/quant/gguf_discovery.rs:445 — mistralrs_cli::commands::quant::gguf_discovery::resolve_group has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D4 · Code Duplication · Edited copy of a member (15 corresponding lines) · ×22
  • Edited copy of a member (15 corresponding lines) mistralrs-quant/src/metal_kernels/mod.rs:1322 — mistralrs-quant/src/metal_kernels/mod.rs:1322-1448 | mistralrs-quant/src/metal_kernels/mod.rs:1493-1540 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) mistralrs-quant/src/distributed/mod.rs:973 — mistralrs-quant/src/distributed/mod.rs:973-989 | mistralrs-quant/src/distributed/mod.rs:1095-1109 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) mistralrs-core/src/pipeline/multimodal.rs:2850 — mistralrs-core/src/pipeline/multimodal.rs:2850-2864 | mistralrs-core/src/pipeline/normal.rs:2511-2526 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) mistralrs-core/src/kv_cache/hybrid_cache.rs:248 — mistralrs-core/src/kv_cache/hybrid_cache.rs:248-273 | mistralrs-core/src/kv_cache/hybrid_cache.rs:407-421 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) mistralrs-core/src/response.rs:530 — mistralrs-core/src/response.rs:530-544 | mistralrs-core/src/response.rs:548-562 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) mistralrs-core/src/gguf/normal_config.rs:1176 — mistralrs-core/src/gguf/normal_config.rs:1176-1190 | mistralrs-core/src/gguf/normal_config.rs:1307-1322 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) mistralrs-core/src/gguf/multimodal_bindings.rs:455 — mistralrs-core/src/gguf/multimodal_bindings.rs:455-469 | mistralrs-core/src/gguf/multimodal_bindings.rs:540-558 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) mistralrs-core/src/paged_attention/mod.rs:504 — mistralrs-core/src/paged_attention/mod.rs:504-520 | mistralrs-core/src/paged_attention/mod.rs:526-540 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) mistralrs-core/src/pipeline/loaders/lfm3.rs:95 — mistralrs-core/src/pipeline/loaders/lfm3.rs:95-109 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6974-6993 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) REDACTED:637 — REDACTED:637-651 | mistralrs-core/src/vision_models/siglip.rs:453-467 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) mistralrs-core/src/kv_cache/mod.rs:373 — mistralrs-core/src/kv_cache/mod.rs:373-387 | mistralrs-core/src/kv_cache/mod.rs:389-403 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1414 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1414-1428 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2794-2808 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) mistralrs-core/src/vision_models/qwen3_5/text.rs:1095 — mistralrs-core/src/vision_models/qwen3_5/text.rs:1095-1109 | mistralrs-core/src/vision_models/qwen4_exp/text.rs:652-666 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:286 — mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:286-300 | mistralrs-core/src/vision_models/llama4/inputs_processor.rs:320-334 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:114 — mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:114-128 | mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:688-702 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:503 — mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:503-518 | mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:706-720 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9154 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9154-9169 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9170-9184 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) mistralrs-core/src/pipeline/cuda_graph.rs:2310 — mistralrs-core/src/pipeline/cuda_graph.rs:2310-2324 | mistralrs-core/src/speculative/dflash.rs:1671-1685 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) mistralrs-server-core/src/handler_core.rs:179 — mistralrs-server-core/src/handler_core.rs:179-193 | mistralrs-server-core/src/lora_adapters.rs:609-623 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) mistralrs-quant/src/cublaslt/api.rs:262 — mistralrs-quant/src/cublaslt/api.rs:262-279 | mistralrs-quant/src/cublaslt/api.rs:556-570 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) scripts/convert_awq_marlin.py:86 — scripts/convert_awq_marlin.py:86-101 | scripts/convert_awq_marlin.py:111-125 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) scripts/production_soak.py:367 — scripts/production_soak.py:367-381 | scripts/production_soak.py:399-420 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (11 corresponding lines) · ×22
  • Edited copy of a member (11 corresponding lines) mistralrs-core/src/gguf/normal_config.rs:1254 — mistralrs-core/src/gguf/normal_config.rs:1254-1264 | mistralrs-core/src/gguf/normal_config.rs:1379-1389 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) mistralrs-quant/src/gguf/cuda.rs:1296 — mistralrs-quant/src/gguf/cuda.rs:1296-1306 | mistralrs-quant/src/gguf/cuda.rs:1356-1366 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) mistralrs-core/src/files/store.rs:133 — mistralrs-core/src/files/store.rs:133-143 | mistralrs-core/src/files/store.rs:146-156 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) mistralrs-cli/src/commands/uqff.rs:406 — mistralrs-cli/src/commands/uqff.rs:406-417 | mistralrs-cli/src/commands/uqff.rs:419-429 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:289 — mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:289-299 | mistralrs-core/src/vision_models/qwen2vl/vision.rs:261-271 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) mistralrs-core/src/speculative/dflash.rs:2882 — mistralrs-core/src/speculative/dflash.rs:2882-2892 | mistralrs-core/src/speculative/dflash.rs:2894-2906 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) mistralrs-core/src/engine/admission.rs:112 — mistralrs-core/src/engine/admission.rs:112-126 | mistralrs-core/src/engine/admission.rs:128-138 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:280 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:280-290 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:173-183 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) mistralrs-core/src/sequence.rs:2101 — mistralrs-core/src/sequence.rs:2101-2111 | mistralrs-core/src/sequence.rs:2133-2143 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) mistralrs/src/model_builder_trait.rs:105 — mistralrs/src/model_builder_trait.rs:105-115 | mistralrs/src/model_builder_trait.rs:129-140 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) mistralrs-core/src/diffusion_models/clip/text.rs:266 — mistralrs-core/src/diffusion_models/clip/text.rs:266-276 | mistralrs-core/src/vision_models/clip.rs:306-317 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) mistralrs-core/src/tuning.rs:167 — mistralrs-core/src/tuning.rs:167-177 | mistralrs-core/src/tuning.rs:216-227 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) mistralrs-core/src/lib.rs:1973 — mistralrs-core/src/lib.rs:1973-1983 | mistralrs-core/src/lib.rs:1985-1995 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) mistralrs-paged-attn/src/metal/kernels/mod.rs:259 — mistralrs-paged-attn/src/metal/kernels/mod.rs:259-270 | mistralrs-quant/src/metal_kernels/fp8.rs:51-61 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) mistralrs-server-core/src/embeddings.rs:42 — mistralrs-server-core/src/embeddings.rs:42-52 | mistralrs-server-core/src/image_generation.rs:35-45 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2337 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2337-2347 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3089-3099 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) mistralrs-quant/src/metal_kernels/mod.rs:1012 — mistralrs-quant/src/metal_kernels/mod.rs:1012-1022 | mistralrs-quant/src/metal_kernels/mod.rs:3697-3707 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4838 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4838-4848 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5201-5211 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) mistralrs-core/src/kv_cache/hybrid_cache.rs:815 — mistralrs-core/src/kv_cache/hybrid_cache.rs:815-825 | mistralrs-core/src/kv_cache/hybrid_cache.rs:863-873 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:10048 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:10048-10058 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:10738-10748 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) mistralrs-pyo3/src/lib.rs:368 — mistralrs-pyo3/src/lib.rs:368-378 | mistralrs-server-core/src/mistralrs_for_server_builder.rs:1443-1453 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) mistralrs-core/src/pipeline/embedding.rs:128 — mistralrs-core/src/pipeline/embedding.rs:128-138 | mistralrs-core/src/pipeline/normal.rs:455-468 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (9 corresponding lines) · ×22
  • Edited copy of a member (9 corresponding lines) mistralrs-quant/src/cutile/qsa.rs:588 — mistralrs-quant/src/cutile/qsa.rs:588-596 | mistralrs-quant/src/cutile/qsa_decode.rs:569-577 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) mistralrs-quant/src/mxfp8/mod.rs:211 — mistralrs-quant/src/mxfp8/mod.rs:211-219 | mistralrs-quant/src/nvfp4/mod.rs:920-934 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) mistralrs-cli/src/commands/serve.rs:878 — mistralrs-cli/src/commands/serve.rs:878-886 | mistralrs-cli/src/commands/serve.rs:890-898 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) mistralrs-quant/src/distributed/layers.rs:761 — mistralrs-quant/src/distributed/layers.rs:761-769 | mistralrs-quant/src/distributed/layers.rs:1339-1347 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) mistralrs-core/src/diffusion_models/clip/text.rs:238 — mistralrs-core/src/diffusion_models/clip/text.rs:238-246 | mistralrs-core/src/vision_models/clip.rs:269-277 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) mistralrs-core/src/models/lfm2.rs:704 — mistralrs-core/src/models/lfm2.rs:704-716 | mistralrs-core/src/models/lfm2.rs:718-726 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) mistralrs-quant/src/distributed/mod.rs:175 — mistralrs-quant/src/distributed/mod.rs:175-183 | mistralrs-quant/src/distributed/mod.rs:185-193 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) mistralrs-core/src/models/gemma.rs:60 — mistralrs-core/src/models/gemma.rs:60-68 | mistralrs-core/src/models/gemma2.rs:91-100 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) mistralrs-core/src/vision_models/grid_processor.rs:451 — mistralrs-core/src/vision_models/grid_processor.rs:451-459 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:234-242 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) mistralrs-core/src/gguf/lfm3_vl_config.rs:275 — mistralrs-core/src/gguf/lfm3_vl_config.rs:275-283 | mistralrs-core/src/gguf/qwen4exp.rs:564-572 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) mistralrs-core/src/sequence.rs:2016 — mistralrs-core/src/sequence.rs:2016-2024 | mistralrs-core/src/sequence.rs:2056-2064 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) mistralrs-core/src/vision_models/mod.rs:142 — mistralrs-core/src/vision_models/mod.rs:142-150 | mistralrs-core/src/vision_models/mod.rs:167-179 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) mistralrs-core/src/layers.rs:3780 — mistralrs-core/src/layers.rs:3780-3788 | mistralrs-core/src/layers.rs:3790-3803 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) mistralrs-core/src/models/phi2.rs:399 — mistralrs-core/src/models/phi2.rs:399-407 | mistralrs-core/src/xlora_models/phi2.rs:357-374 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) mistralrs-core/src/pipeline/multimodal.rs:2760 — mistralrs-core/src/pipeline/multimodal.rs:2760-2768 | mistralrs-core/src/pipeline/normal.rs:2324-2332 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) mistralrs-core/src/sequence.rs:1155 — mistralrs-core/src/sequence.rs:1155-1163 | mistralrs-core/src/sequence.rs:1165-1173 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) mistralrs-code-exec/src/lib.rs:84 — mistralrs-code-exec/src/lib.rs:84-93 | mistralrs-code-exec/src/shell.rs:45-53 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) mistralrs-mcp/src/transport.rs:974 — mistralrs-mcp/src/transport.rs:974-982 | mistralrs-mcp/src/transport.rs:1009-1023 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) mistralrs-core/src/vision_models/qwen3_5/config.rs:426 — mistralrs-core/src/vision_models/qwen3_5/config.rs:426-434 | mistralrs-core/src/vision_models/qwen3_5/text.rs:1342-1350 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) mistralrs-core/src/vision_models/lfm2_vl/inputs_processor.rs:121 — mistralrs-core/src/vision_models/lfm2_vl/inputs_processor.rs:121-131 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:10304-10312 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:59 — mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:59-67 | mistralrs-core/src/vision_models/qwen2vl/vision.rs:59-67 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) mistralrs-core/src/vision_models/qwen3_5/speculative.rs:907 — mistralrs-core/src/vision_models/qwen3_5/speculative.rs:907-915 | mistralrs-core/src/vision_models/qwen4_exp/speculative.rs:233-241 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Duplicated block (22 lines × 2) · ×22
  • Duplicated block (22 lines × 2) mistralrs-cli/src/commands/run/interactive.rs:1191 — mistralrs-cli/src/commands/run/interactive.rs:1191-1212 | mistralrs-cli/src/commands/run/interactive.rs:1276-1297 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (22 lines × 2) mistralrs-core/src/model_loader.rs:834 — mistralrs-core/src/model_loader.rs:834-855 | mistralrs-core/src/model_loader.rs:867-888 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/model_loader.rs:834` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (22 lines × 2) mistralrs-core/src/models/llama.rs:380 — mistralrs-core/src/models/llama.rs:380-401 | mistralrs-core/src/models/smollm3.rs:396-417 — before extracting anything, compare `mistralrs-core/src/models/llama.rs` and `mistralrs-core/src/models/smollm3.rs` as WHOLE FILES: this scan already matched 47 separate duplicated blocks between them, totalling at least 727 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/llama.rs:380` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (22 lines × 2) mistralrs-core/src/models/phi3.rs:206 — mistralrs-core/src/models/phi3.rs:206-227 | mistralrs-core/src/models/phi3_5_moe.rs:233-254 — before extracting anything, compare `mistralrs-core/src/models/phi3.rs` and `mistralrs-core/src/models/phi3_5_moe.rs` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 343 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/phi3.rs:206` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (22 lines × 2) mistralrs-core/src/models/qwen3_moe.rs:628 — mistralrs-core/src/models/qwen3_moe.rs:628-649 | mistralrs-core/src/models/starcoder2.rs:452-473 — before extracting anything, compare `mistralrs-core/src/models/qwen3_moe.rs` and `mistralrs-core/src/models/starcoder2.rs` as WHOLE FILES: this scan already matched 29 separate duplicated blocks between them, totalling at least 374 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/qwen3_moe.rs:628` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/models/qwen3_moe.rs:650` calls `clone` and `mistralrs-core/src/models/starcoder2.rs:474` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (22 lines × 2) mistralrs-core/src/ops.rs:3969 — mistralrs-core/src/ops.rs:3969-3990 | mistralrs-core/src/ops.rs:4093-4114 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:3969` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (22 lines × 2) mistralrs-core/src/ops.rs:5641 — mistralrs-core/src/ops.rs:5641-5662 | mistralrs-core/src/ops.rs:6076-6097 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:5641` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (22 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9567 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9567-9588 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:10796-10817 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9567` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (22 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:10611 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:10611-10632 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:7131-7152 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` and `mistralrs-core/src/pipeline/loaders/normal_loaders.rs` as WHOLE FILES: this scan already matched 34 separate duplicated blocks between them, totalling at least 445 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:10611` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (22 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:866 — mistralrs-core/src/pipeline/multimodal.rs:866-887 | mistralrs-core/src/pipeline/normal.rs:872-893 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:866` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (22 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:3117 — mistralrs-core/src/pipeline/multimodal.rs:3117-3138 | mistralrs-core/src/pipeline/normal.rs:2715-2736 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (22 lines × 2) mistralrs-core/src/vision_models/gemma4/mod.rs:422 — mistralrs-core/src/vision_models/gemma4/mod.rs:422-443 | mistralrs-core/src/vision_models/gemma4/mod.rs:735-756 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma4/mod.rs:422` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (22 lines × 2) mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:271 — mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:271-292 | mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:508-529 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (22 lines × 2) mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:278 — mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:278-299 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:584-605 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:278` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (22 lines × 2) mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:844 — mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:844-865 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1192-1213 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:844` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (22 lines × 2) mistralrs-core/src/xlora_models/mistral.rs:575 — mistralrs-core/src/xlora_models/mistral.rs:575-596 | mistralrs-core/src/xlora_models/mixtral.rs:705-726 — before extracting anything, compare `mistralrs-core/src/xlora_models/mistral.rs` and `mistralrs-core/src/xlora_models/mixtral.rs` as WHOLE FILES: this scan already matched 53 separate duplicated blocks between them, totalling at least 787 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/mistral.rs:575` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (22 lines × 2) mistralrs-paged-attn/src/cuda/backend/mla.rs:397 — mistralrs-paged-attn/src/cuda/backend/mla.rs:397-418 | mistralrs-paged-attn/src/cuda/backend/mla.rs:730-751 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/cuda/backend/mla.rs:397` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (22 lines × 2) mistralrs-pyo3/src/lib.rs:821 — mistralrs-pyo3/src/lib.rs:821-842 | mistralrs-pyo3/src/lib.rs:869-890 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-pyo3/src/lib.rs:821` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (22 lines × 2) mistralrs-quant/src/cutile/fused_moe.rs:512 — mistralrs-quant/src/cutile/fused_moe.rs:512-533 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:956-977 — before extracting anything, compare `mistralrs-quant/src/cutile/fused_moe.rs` and `mistralrs-quant/src/cutile/fused_moe_fp8.rs` as WHOLE FILES: this scan already matched 24 separate duplicated blocks between them, totalling at least 298 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cutile/fused_moe.rs:512` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (22 lines × 2) mistralrs-quant/src/distributed/layers.rs:460 — mistralrs-quant/src/distributed/layers.rs:460-481 | mistralrs-quant/src/distributed/layers.rs:834-855 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/distributed/layers.rs:460` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (22 lines × 2) mistralrs-quant/src/cutile/nvfp4_gemv.rs:63 — mistralrs-quant/src/cutile/nvfp4_gemv.rs:63-84 | mistralrs-quant/src/cutile/nvfp4_gemv.rs:167-188 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cutile/nvfp4_gemv.rs:63` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (22 lines × 2) mistralrs-quant/src/cublaslt/matmul.rs:494 — mistralrs-quant/src/cublaslt/matmul.rs:494-515 | mistralrs-quant/src/cublaslt/matmul.rs:591-612 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cublaslt/matmul.rs:494` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-quant/src/cublaslt/matmul.rs:590` calls `device_ptr_mut`, `stream` and `mistralrs-quant/src/cublaslt/matmul.rs:493` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Edited copy of a member (13 corresponding lines) · ×20
  • Edited copy of a member (13 corresponding lines) mistralrs-code-exec/src/session.rs:202 — mistralrs-code-exec/src/session.rs:202-214 | mistralrs-code-exec/src/shell.rs:413-425 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) mistralrs-core/src/vision_models/gemma3n/audio.rs:1064 — mistralrs-core/src/vision_models/gemma3n/audio.rs:1064-1079 | mistralrs-core/src/vision_models/gemma4/audio.rs:846-858 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) mistralrs-quant/src/blockwise_fp8/deepgemm.rs:80 — mistralrs-quant/src/blockwise_fp8/deepgemm.rs:80-92 | mistralrs-quant/src/cutile/tune.rs:1008-1022 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) mistralrs-core/src/gguf/normal_config.rs:1162 — mistralrs-core/src/gguf/normal_config.rs:1162-1174 | mistralrs-core/src/gguf/normal_config.rs:1609-1621 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) mistralrs-core/src/diffusion_models/clip/text.rs:205 — mistralrs-core/src/diffusion_models/clip/text.rs:205-217 | mistralrs-core/src/vision_models/clip.rs:236-248 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) mistralrs-core/src/xlora_models/phi3.rs:242 — mistralrs-core/src/xlora_models/phi3.rs:242-259 | mistralrs-core/src/xlora_models/quantized_phi3.rs:100-112 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) mistralrs-core/src/attention/backends/cpu/neon.rs:282 — mistralrs-core/src/attention/backends/cpu/neon.rs:282-295 | mistralrs-core/src/attention/backends/cpu/neon.rs:527-539 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) mistralrs-quant/src/gguf/fast_mmq.rs:814 — mistralrs-quant/src/gguf/fast_mmq.rs:814-826 | mistralrs-quant/src/gguf/fast_mmq.rs:834-846 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) mistralrs/src/model.rs:1001 — mistralrs/src/model.rs:1001-1013 | mistralrs/src/model.rs:1142-1155 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) mistralrs-core/src/gguf/lfm3_vl_config.rs:258 — mistralrs-core/src/gguf/lfm3_vl_config.rs:258-273 | mistralrs-core/src/gguf/qwen4exp.rs:514-526 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) mistralrs-core/src/pipeline/cuda_graph.rs:2945 — mistralrs-core/src/pipeline/cuda_graph.rs:2945-2957 | mistralrs-core/src/pipeline/cuda_graph.rs:2990-3008 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) mistralrs-core/src/sampler.rs:419 — mistralrs-core/src/sampler.rs:419-431 | mistralrs-core/src/sampler.rs:505-517 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) mistralrs-core/src/models/qwen3_next.rs:1186 — mistralrs-core/src/models/qwen3_next.rs:1186-1198 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:523-535 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) mistralrs-core/src/vision_models/qwen2vl/mod.rs:62 — mistralrs-core/src/vision_models/qwen2vl/mod.rs:62-74 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:592-604 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) mistralrs-server-core/src/metrics.rs:677 — mistralrs-server-core/src/metrics.rs:677-689 | mistralrs-server-core/src/mistralrs_server_router_builder.rs:475-487 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) mistralrs-core/src/vision_models/qwen4_exp/qsa.rs:719 — mistralrs-core/src/vision_models/qwen4_exp/qsa.rs:719-731 | mistralrs-core/src/vision_models/qwen4_exp/qsa.rs:734-746 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) mistralrs-core/src/vision_models/gemma3n/vision.rs:323 — mistralrs-core/src/vision_models/gemma3n/vision.rs:323-335 | mistralrs-core/src/vision_models/gemma3n/vision.rs:713-728 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) mistralrs-quant/src/cutile/fp8_gemm.rs:157 — mistralrs-quant/src/cutile/fp8_gemm.rs:157-169 | mistralrs-quant/src/cutile/mod.rs:359-371 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) mistralrs-quant/src/distributed/mod.rs:881 — mistralrs-quant/src/distributed/mod.rs:881-893 | mistralrs-quant/src/distributed/mod.rs:1003-1018 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) mistralrs-core/src/reasoning_parsers/harmony.rs:345 — mistralrs-core/src/reasoning_parsers/harmony.rs:345-357 | mistralrs-core/src/reasoning_parsers/harmony.rs:386-398 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Duplicated block (8 lines × 3) · ×20
  • Duplicated block (8 lines × 3) mistralrs-cli/src/args/mod.rs:466 — mistralrs-cli/src/args/mod.rs:466-473 | mistralrs-cli/src/commands/serve.rs:901-908 | mistralrs-cli/src/commands/serve.rs:911-918 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit. Note first that the copies are not typed on the same thing: the declarations holding them bind `model_type` to `&mut ModelType` in one and `&ModelType` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (8 lines × 3) mistralrs-core/src/model_loader.rs:448 — mistralrs-core/src/model_loader.rs:448-455 | mistralrs-core/src/model_loader.rs:909-916 | mistralrs-core/src/toml_selector.rs:1229-1236 — before extracting anything, compare `mistralrs-core/src/model_loader.rs` and `mistralrs-core/src/toml_selector.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 199 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/model_loader.rs:448` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 3) mistralrs-core/src/models/gemma2.rs:575 — mistralrs-core/src/models/gemma2.rs:575-582 | mistralrs-core/src/models/qwen2.rs:603-610 | mistralrs-core/src/vision_models/gemma3/text.rs:745-752 — before extracting anything, compare `mistralrs-core/src/models/gemma2.rs` and `mistralrs-core/src/models/qwen2.rs` as WHOLE FILES: this scan already matched 38 separate duplicated blocks between them, totalling at least 475 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma2.rs:575` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 3) mistralrs-core/src/models/phi2.rs:452 — mistralrs-core/src/models/phi2.rs:452-460 | mistralrs-core/src/vision_models/mllama/text.rs:790-798 | mistralrs-core/src/xlora_models/llama.rs:569-576 — before extracting anything, compare `mistralrs-core/src/models/phi2.rs` and `mistralrs-core/src/vision_models/mllama/text.rs` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 85 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/phi2.rs:452` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 3) mistralrs-core/src/moe/experts/backends.rs:922 — mistralrs-core/src/moe/experts/backends.rs:922-929 | mistralrs-core/src/moe/experts/backends.rs:997-1004 | mistralrs-quant/src/moe/cutlass.rs:157-164 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/moe/experts/backends.rs:922` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 3) mistralrs-core/src/ops.rs:4494 — mistralrs-core/src/ops.rs:4494-4501 | mistralrs-core/src/ops.rs:4657-4664 | mistralrs-core/src/ops.rs:5461-5468 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:4494` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/ops.rs:4492` calls `as_ref`, `storage_and_layout` and `mistralrs-core/src/ops.rs:4655` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (8 lines × 3) mistralrs-core/src/pipeline/embedding.rs:237 — mistralrs-core/src/pipeline/embedding.rs:237-244 | mistralrs-core/src/pipeline/multimodal.rs:670-677 | mistralrs-core/src/pipeline/normal.rs:708-715 — before extracting anything, compare `mistralrs-core/src/pipeline/embedding.rs` and `mistralrs-core/src/pipeline/multimodal.rs` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 178 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/pipeline/multimodal.rs:678` calls `clone` and `mistralrs-core/src/pipeline/embedding.rs:246` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (8 lines × 3) mistralrs-core/src/pipeline/loaders/lfm3.rs:219 — mistralrs-core/src/pipeline/loaders/lfm3.rs:219-227 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:10620-10627 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:7140-7147 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/lfm3.rs` and `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 35 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/lfm3.rs:219` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (8 lines × 3) mistralrs-core/src/sampler.rs:1225 — mistralrs-core/src/sampler.rs:1225-1232 | mistralrs-core/src/sampler.rs:1757-1764 | mistralrs-core/src/sampler.rs:1928-1935 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (8 lines × 3) REDACTED:229 — REDACTED:229-236 | mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:118-125 | mistralrs-core/src/vision_models/qwen2vl/mod.rs:141-148 — `mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs` and `mistralrs-core/src/vision_models/qwen2vl/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 16 separate duplicated blocks between them, totalling at least 396 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:229` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 3) mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:82 — mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:82-89 | mistralrs-core/src/vision_models/qwen2vl/text.rs:83-90 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:70-77 — `mistralrs-core/src/vision_models/qwen2_5_vl/text.rs` and `mistralrs-core/src/vision_models/qwen2vl/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 42 separate duplicated blocks between them, totalling at least 716 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (8 lines × 3) mistralrs-core/src/vision_models/qwen3_5/packed_visual.rs:147 — mistralrs-core/src/vision_models/qwen3_5/packed_visual.rs:147-154 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:920-927 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:366-373 — `mistralrs-core/src/vision_models/qwen3_vl/mod.rs` and `mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 25 separate duplicated blocks between them, totalling at least 658 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (8 lines × 3) mistralrs-quant/src/afq/ops.rs:143 — mistralrs-quant/src/afq/ops.rs:143-150 | mistralrs-quant/src/afq/ops.rs:387-394 | mistralrs-quant/src/afq/ops.rs:434-441 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (8 lines × 3) mistralrs-quant/src/gguf/mod.rs:477 — mistralrs-quant/src/gguf/mod.rs:477-484 | mistralrs-quant/src/gptq/gptq_cpu.rs:21-28 | mistralrs-quant/src/gptq/gptq_cuda.rs:339-346 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
  • Duplicated block (8 lines × 3) mistralrs/src/model.rs:356 — mistralrs/src/model.rs:356-363 | mistralrs/src/model.rs:426-433 | mistralrs/src/model.rs:514-521 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs/src/model.rs:356` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (8 lines × 3) mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:408 — mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:408-415 | mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:448-455 | mistralrs-core/src/vision_models/mistral3/inputs_processor.rs:280-287 — `mistralrs-core/src/vision_models/gemma3/inputs_processor.rs` and `mistralrs-core/src/vision_models/idefics3/inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 10 separate duplicated blocks between them, totalling at least 146 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:408` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 3) mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:579 — mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:579-586 | mistralrs-paged-attn/src/cuda/backend/gather_kv.rs:109-116 | mistralrs-paged-attn/src/metal/backend/gather_kv.rs:64-71 — before extracting anything, compare `mistralrs-paged-attn/src/cuda/backend/flashinfer.rs` and `mistralrs-paged-attn/src/cuda/backend/gather_kv.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 39 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (8 lines × 3) mistralrs-core/src/cuda/gdn.rs:965 — mistralrs-core/src/cuda/gdn.rs:965-972 | mistralrs-core/src/cuda/gdn.rs:1089-1096 | mistralrs-core/src/cuda/gdn.rs:1193-1200 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/cuda/gdn.rs:963` calls `and_then`, `checked_mul` and `mistralrs-core/src/cuda/gdn.rs:1087` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (8 lines × 3) mistralrs-core/src/pipeline/cuda_graph.rs:3610 — mistralrs-core/src/pipeline/cuda_graph.rs:3610-3617 | mistralrs-core/src/pipeline/cuda_graph.rs:3655-3662 | mistralrs-core/src/pipeline/cuda_graph.rs:3700-3707 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/cuda_graph.rs:3610` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (8 lines × 3) mistralrs-core/src/ops.rs:90 — mistralrs-core/src/ops.rs:90-97 | mistralrs-core/src/ops.rs:595-602 | mistralrs-core/src/ops.rs:757-764 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:90` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/ops.rs:98` calls `BF16`, `device_ptr`, `F16` and `mistralrs-core/src/ops.rs:603` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D3 · God Classes · TooManyFields · ×19
  • TooManyFields: PreProcessorConfig mistralrs-core/src/vision_models/preprocessor_config.rs:10 — TooManyFields — 78 stored fields beside 2 methods. The bar is 30 stored fields; this is 48 over it, 2.60× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
  • TooManyFields: Sequence mistralrs-core/src/sequence.rs:753 — TooManyFields — 68 stored fields beside 163 methods. The bar is 30 stored fields; this is 38 over it, 2.27× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
  • TooManyFields: TextConfig mistralrs-core/src/vision_models/qwen4_exp/config.rs:46 — TooManyFields — 44 stored fields beside 15 methods. The bar is 30 stored fields; this is 14 over it, 1.47× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
  • TooManyFields: GgufModelBuilder mistralrs/src/gguf.rs:12 — TooManyFields — 43 stored fields beside 49 methods. The bar is 30 stored fields; this is 13 over it, 1.43× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
  • TooManyFields: ChatCompletionRequest mistralrs-pyo3/src/requests.rs:300 — TooManyFields — 43 stored fields beside 3 methods. The bar is 30 stored fields; this is 13 over it, 1.43× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
  • TooManyFields: ChatCompletionRequest mistralrs-server-core/src/openai.rs:1136 — TooManyFields — 42 stored fields. The bar is 30 stored fields; this is 12 over it, 1.40× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
  • TooManyFields: ResponsesCreateRequest mistralrs-server-core/src/openai.rs:1876 — TooManyFields — 42 stored fields. The bar is 30 stored fields; this is 12 over it, 1.40× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
  • TooManyFields: OpenResponsesCreateRequest mistralrs-server-core/src/responses.rs:469 — TooManyFields — 42 stored fields. The bar is 30 stored fields; this is 12 over it, 1.40× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
  • TooManyFields: ModelBuilder mistralrs/src/auto_model.rs:43 — TooManyFields — 40 stored fields beside 10 methods. The bar is 30 stored fields; this is 10 over it, 1.33× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
  • TooManyFields: TextModelBuilder mistralrs/src/text_model.rs:18 — TooManyFields — 39 stored fields beside 10 methods. The bar is 30 stored fields; this is 9 over it, 1.30× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
  • TooManyFields: MultimodalModelBuilder mistralrs/src/multimodal_model.rs:18 — TooManyFields — 38 stored fields beside 9 methods. The bar is 30 stored fields; this is 8 over it, 1.27× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
  • TooManyFields: AnthropicMessagesRequest mistralrs-server-core/src/anthropic.rs:84 — TooManyFields — 38 stored fields beside 2 methods. The bar is 30 stored fields; this is 8 over it, 1.27× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
  • TooManyFields: MistralRsForServerBuilder mistralrs-server-core/src/mistralrs_for_server_builder.rs:178 — TooManyFields — 35 stored fields beside 57 methods. The bar is 30 stored fields; this is 5 over it, 1.17× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
  • TooManyFields: FlashAttnKargs mistralrs-quant/src/metal_kernels/mod.rs:4224 — TooManyFields — 35 stored fields. The bar is 30 stored fields; this is 5 over it, 1.17× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
  • TooManyFields: Gemma4TextConfig mistralrs-core/src/vision_models/gemma4/config.rs:53 — TooManyFields — 34 stored fields beside 5 methods. The bar is 30 stored fields; this is 4 over it, 1.13× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
  • TooManyFields: Config mistralrs-core/src/models/hunyuan_v1_moe.rs:117 — TooManyFields — 34 stored fields beside 4 methods. The bar is 30 stored fields; this is 4 over it, 1.13× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
  • TooManyFields: Fa3Fp8DecodeParams mistralrs-paged-attn/src/cuda/ffi.rs:29 — TooManyFields — 33 stored fields. The bar is 30 stored fields; this is 3 over it, 1.10× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
  • TooManyFields: NormalRequest mistralrs-core/src/request.rs:528 — TooManyFields — 32 stored fields beside 8 methods. The bar is 30 stored fields; this is 2 over it, 1.07× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
  • TooManyFields: ConformerEncoderConfig mistralrs-core/src/vision_models/conformer/config.rs:70 — TooManyFields — 31 stored fields beside 1 method. The bar is 30 stored fields; this is 1 over it, 1.03× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
D4 · Code Duplication · Edited copy of a member (10 corresponding lines) · ×19
  • Edited copy of a member (10 corresponding lines) mistralrs-core/src/diagnostics.rs:396 — mistralrs-core/src/diagnostics.rs:396-408 | mistralrs-quant/src/build_support/cuda_toolkit.rs:26-35 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) mistralrs-core/src/vision_models/voxtral/encoder.rs:133 — mistralrs-core/src/vision_models/voxtral/encoder.rs:133-144 | mistralrs-core/src/vision_models/voxtral/mod.rs:224-233 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) mistralrs-quant/src/cublaslt/api.rs:480 — mistralrs-quant/src/cublaslt/api.rs:480-491 | mistralrs-quant/src/cublaslt/api.rs:519-528 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) mistralrs-core/src/gdn/layer.rs:260 — mistralrs-core/src/gdn/layer.rs:260-269 | mistralrs-core/src/gdn/layer.rs:275-285 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) mistralrs-core/src/vision_models/gemma3n/audio.rs:1127 — mistralrs-core/src/vision_models/gemma3n/audio.rs:1127-1136 | mistralrs-core/src/vision_models/gemma4/audio.rs:900-911 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) mistralrs-core/src/pipeline/cuda_graph.rs:1256 — mistralrs-core/src/pipeline/cuda_graph.rs:1256-1265 | mistralrs-core/src/pipeline/cuda_graph.rs:1267-1276 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) mistralrs-core/src/attention/backends/cpu/neon.rs:423 — mistralrs-core/src/attention/backends/cpu/neon.rs:423-432 | mistralrs-core/src/attention/backends/cpu/neon.rs:661-670 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) mistralrs-core/src/pipeline/multimodal.rs:1799 — mistralrs-core/src/pipeline/multimodal.rs:1799-1808 | mistralrs-core/src/pipeline/multimodal.rs:1809-1818 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) mistralrs-quant/src/lora/dynamic/execution.rs:557 — mistralrs-quant/src/lora/dynamic/execution.rs:557-566 | mistralrs-quant/src/lora/dynamic/execution.rs:568-577 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) mistralrs-core/src/gguf/lfm2_vl_bindings.rs:121 — mistralrs-core/src/gguf/lfm2_vl_bindings.rs:121-132 | mistralrs-core/src/gguf/muse_glimmer_bindings.rs:174-183 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) mistralrs-core/src/diffusion_models/clip/text.rs:177 — mistralrs-core/src/diffusion_models/clip/text.rs:177-186 | mistralrs-core/src/vision_models/clip.rs:208-217 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) mistralrs-core/src/sampler.rs:1056 — mistralrs-core/src/sampler.rs:1056-1069 | mistralrs-core/src/sampler.rs:1084-1093 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) mistralrs-core/src/sampler.rs:1100 — mistralrs-core/src/sampler.rs:1100-1109 | mistralrs-core/src/sampler.rs:1117-1131 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:54 — mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:54-63 | mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:56-65 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) mistralrs-core/src/lib.rs:784 — mistralrs-core/src/lib.rs:784-793 | mistralrs-core/src/lib.rs:799-808 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) mistralrs-server-core/src/completion_core.rs:42 — mistralrs-server-core/src/completion_core.rs:42-51 | mistralrs-server-core/src/responses.rs:819-828 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) mistralrs-pyo3/src/lib.rs:475 — mistralrs-pyo3/src/lib.rs:475-484 | mistralrs-server-core/src/lora_adapters.rs:484-494 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) mistralrs-core/src/pipeline/loaders/lfm3_omni.rs:99 — mistralrs-core/src/pipeline/loaders/lfm3_omni.rs:99-109 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3732-3741 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) scripts/generate_favicons.py:37 — scripts/generate_favicons.py:37-46 | scripts/generate_og_image.py:35-45 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D2 · Cognitive Complexity · mistralrs_server_core · ×18
  • mistralrs_server_core::chat_completion::parse_request (cognitive 143) mistralrs-server-core/src/chat_completion.rs:605 — mistralrs_server_core::chat_completion::parse_request has cognitive complexity 143 (threshold 15). Drivers by points: if/else 24 (64 pts), match/switch 14 (42 pts), loops 10 (33 pts), boolean chains 4 (nesting depth added 91). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_server_core::responses::create_response (cognitive 64) mistralrs-server-core/src/responses.rs:2046 — mistralrs_server_core::responses::create_response has cognitive complexity 64 (threshold 15). Drivers by points: if/else 16 (39 pts), loops 4 (14 pts), match/switch 6 (10 pts), boolean chains 1 (nesting depth added 37). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • mistralrs_server_core::responses::convert_input_items_to_messages (cognitive 51) mistralrs-server-core/src/responses.rs:130 — mistralrs_server_core::responses::convert_input_items_to_messages has cognitive complexity 51 (threshold 15). Drivers by points: match/switch 6 (25 pts), if/else 8 (21 pts), loops 2 (5 pts) (nesting depth added 35). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • mistralrs_server_core::audio_history::decorate_responses (cognitive 46) mistralrs-server-core/src/audio_history.rs:334 — mistralrs_server_core::audio_history::decorate_responses has cognitive complexity 46 (threshold 15). Drivers by points: if/else 7 (27 pts), loops 4 (11 pts), match/switch 3 (7 pts), boolean chains 1 (nesting depth added 31). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_server_core::metrics::observe_http (cognitive 30) mistralrs-server-core/src/metrics.rs:214 — mistralrs_server_core::metrics::observe_http has cognitive complexity 30 (threshold 15). Drivers by points: if/else 13 (17 pts), match/switch 4 (7 pts), boolean chains 6 (nesting depth added 7). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • mistralrs_server_core::embeddings::embeddings (cognitive 28) mistralrs-server-core/src/embeddings.rs:62 — mistralrs_server_core::embeddings::embeddings has cognitive complexity 28 (threshold 15). Drivers by points: if/else 9 (15 pts), match/switch 5 (9 pts), loops 2 (4 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_server_core::chat_completion::serialize_agentic_data (cognitive 26) mistralrs-server-core/src/chat_completion.rs:147 — mistralrs_server_core::chat_completion::serialize_agentic_data has cognitive complexity 26 (threshold 15). Drivers by points: if/else 20 (25 pts), match/switch 1 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
  • mistralrs_server_core::speech_generation::speech_stream (cognitive 25) mistralrs-server-core/src/speech_generation.rs:508 — mistralrs_server_core::speech_generation::speech_stream has cognitive complexity 25 (threshold 15). Drivers by points: if/else 7 (19 pts), loops 2 (4 pts), match/switch 1 (2 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_server_core::openai::normalize_openai_tools (cognitive 24) mistralrs-server-core/src/openai.rs:1054 — mistralrs_server_core::openai::normalize_openai_tools has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (13 pts), match/switch 2 (6 pts), loops 2 (4 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_server_core::video::decode_video_ffmpeg (cognitive 24) mistralrs-server-core/src/video.rs:167 — mistralrs_server_core::video::decode_video_ffmpeg has cognitive complexity 24 (threshold 15). Drivers by points: if/else 13 (18 pts), match/switch 2 (4 pts), loops 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_server_core::handlers::models (cognitive 22) mistralrs-server-core/src/handlers.rs:48 — mistralrs_server_core::handlers::models has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (11 pts), match/switch 4 (8 pts), loops 2, boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_server_core::mistralrs_for_server_builder::init_mapper (cognitive 22) mistralrs-server-core/src/mistralrs_for_server_builder.rs:1361 — mistralrs_server_core::mistralrs_for_server_builder::init_mapper has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (14 pts), loops 2 (7 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_server_core::chat_completion::process_non_streaming_response_with_model (cognitive 19) mistralrs-server-core/src/chat_completion.rs:1356 — mistralrs_server_core::chat_completion::process_non_streaming_response_with_model has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (16 pts), match/switch 1 (2 pts), loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_server_core::chat_completion::chatcompletions (cognitive 18) mistralrs-server-core/src/chat_completion.rs:1188 — mistralrs_server_core::chat_completion::chatcompletions has cognitive complexity 18 (threshold 15). Drivers by points: if/else 12 (13 pts), match/switch 3, boolean chains 2 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • mistralrs_server_core::chat_completion::record_agentic_progress (cognitive 17) mistralrs-server-core/src/chat_completion.rs:268 — mistralrs_server_core::chat_completion::record_agentic_progress has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (14 pts), match/switch 2 (3 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_server_core::skills::parse_upload (cognitive 17) mistralrs-server-core/src/skills.rs:457 — mistralrs_server_core::skills::parse_upload has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (12 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_server_core::anthropic::anthropic_response_from_chat (cognitive 16) mistralrs-server-core/src/anthropic.rs:1173 — mistralrs_server_core::anthropic::anthropic_response_from_chat has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (13 pts), loops 1 (3 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_server_core::responses::chat_response_to_response_resource (cognitive 16) mistralrs-server-core/src/responses.rs:1718 — mistralrs_server_core::responses::chat_response_to_response_resource has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (12 pts), loops 2 (4 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D4 · Code Duplication · Edited copy of a member (8 corresponding lines) · ×18
  • Edited copy of a member (8 corresponding lines) mistralrs-core/src/speech_models/dia/dac.rs:20 — mistralrs-core/src/speech_models/dia/dac.rs:20-27 | mistralrs-core/src/speech_models/dia/dac.rs:36-47 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (8 corresponding lines) mistralrs-server-core/src/files.rs:234 — mistralrs-server-core/src/files.rs:234-241 | mistralrs-server-core/src/files.rs:284-294 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (8 corresponding lines) mistralrs-core/src/vision_models/lfm3_omni/audio.rs:289 — mistralrs-core/src/vision_models/lfm3_omni/audio.rs:289-296 | mistralrs-core/src/vision_models/lfm3_omni/generation.rs:187-195 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (8 corresponding lines) mistralrs-core/src/vision_models/lfm3_omni/audio.rs:345 — mistralrs-core/src/vision_models/lfm3_omni/audio.rs:345-352 | mistralrs-core/src/vision_models/lfm3_omni/generation.rs:338-345 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (8 corresponding lines) mistralrs-core/src/vision_models/gemma3n/audio.rs:240 — mistralrs-core/src/vision_models/gemma3n/audio.rs:240-250 | mistralrs-core/src/vision_models/gemma4/audio.rs:73-80 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (8 corresponding lines) mistralrs-core/src/cuda/dflash_context.rs:96 — mistralrs-core/src/cuda/dflash_context.rs:96-103 | mistralrs-core/src/speculative/dflash.rs:867-874 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (8 corresponding lines) mistralrs-core/src/tuning.rs:380 — mistralrs-core/src/tuning.rs:380-387 | mistralrs-core/src/tuning.rs:391-398 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (8 corresponding lines) mistralrs-core/src/attention/mod.rs:240 — mistralrs-core/src/attention/mod.rs:240-247 | mistralrs-core/src/layers_utils.rs:3-10 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (8 corresponding lines) mistralrs-core/src/vision_models/llama4/inputs_processor.rs:374 — mistralrs-core/src/vision_models/llama4/inputs_processor.rs:374-390 | mistralrs-core/src/vision_models/phi4/inputs_processor.rs:320-327 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (8 corresponding lines) mistralrs-core/src/device_map/mappers.rs:134 — mistralrs-core/src/device_map/mappers.rs:134-141 | mistralrs-core/src/device_map/mappers.rs:351-360 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (8 corresponding lines) mistralrs-quant/src/mxfp8/mod.rs:386 — mistralrs-quant/src/mxfp8/mod.rs:386-393 | mistralrs-quant/src/nvfp4/mod.rs:1266-1273 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (8 corresponding lines) mistralrs-core/src/paged_attention/scheduler.rs:1537 — mistralrs-core/src/paged_attention/scheduler.rs:1537-1544 | mistralrs-core/src/scheduler/default_scheduler.rs:386-393 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (8 corresponding lines) mistralrs-core/src/gdn/norm.rs:32 — mistralrs-core/src/gdn/norm.rs:32-42 | mistralrs-core/src/models/granite.rs:756-763 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (8 corresponding lines) mistralrs-core/src/pipeline/hf/client.rs:37 — mistralrs-core/src/pipeline/hf/client.rs:37-44 | mistralrs-server-core/src/lora_adapters.rs:413-422 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (8 corresponding lines) mistralrs-core/src/vision_models/gemma3/text.rs:590 — mistralrs-core/src/vision_models/gemma3/text.rs:590-597 | mistralrs-core/src/vision_models/gemma4/text.rs:1910-1917 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (8 corresponding lines) mistralrs-quant/src/cutile/gdn_prefill.rs:598 — mistralrs-quant/src/cutile/gdn_prefill.rs:598-607 | mistralrs-quant/src/cutile/mxfp8_gemm.rs:480-487 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (8 corresponding lines) mistralrs-quant/src/cutile/fused_moe.rs:751 — mistralrs-quant/src/cutile/fused_moe.rs:751-758 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:640-648 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (8 corresponding lines) REDACTED:1470 — REDACTED:1470-1478 | REDACTED:422-429 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Duplicated block (21 lines × 2) · ×18
  • Duplicated block (21 lines × 2) mistralrs-cli/src/commands/config.rs:102 — mistralrs-cli/src/commands/config.rs:102-122 | mistralrs-cli/src/commands/config.rs:262-282 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-cli/src/commands/config.rs:102` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `cfg` to `crate::config::ServeConfig` in one and `crate::config::RunConfig` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (21 lines × 2) mistralrs-cli/src/commands/run/interactive.rs:316 — mistralrs-cli/src/commands/run/interactive.rs:316-336 | mistralrs-cli/src/commands/run/interactive.rs:500-520 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-cli/src/commands/run/interactive.rs:316` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (21 lines × 2) mistralrs-core/src/diffusion_models/flux/model.rs:314 — mistralrs-core/src/diffusion_models/flux/model.rs:314-334 | mistralrs-core/src/diffusion_models/flux/model.rs:546-566 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/diffusion_models/flux/model.rs:314` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (21 lines × 2) mistralrs-core/src/embedding_models/embedding_gemma.rs:526 — mistralrs-core/src/embedding_models/embedding_gemma.rs:526-546 | mistralrs-core/src/vision_models/gemma3/text.rs:845-865 — before extracting anything, compare `mistralrs-core/src/embedding_models/embedding_gemma.rs` and `mistralrs-core/src/vision_models/gemma3/text.rs` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 286 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/embedding_gemma.rs:526` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/vision_models/gemma3/text.rs:843` calls `pp` and `mistralrs-core/src/embedding_models/embedding_gemma.rs:523` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (21 lines × 2) mistralrs-core/src/layers.rs:1124 — mistralrs-core/src/layers.rs:1124-1144 | mistralrs-core/src/layers.rs:1483-1503 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/layers.rs:1124` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note first that the copies are not typed on the same thing: the declarations holding them bind `cfg` to `&llama4::TextConfig` in one and `&smollm3::Config` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (21 lines × 2) mistralrs-core/src/models/deepseek3.rs:1054 — mistralrs-core/src/models/deepseek3.rs:1054-1074 | mistralrs-core/src/models/deepseek3.rs:1095-1115 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek3.rs:1054` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (21 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6648 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6648-6668 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7049-7069 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6648` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (21 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7526 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7526-7546 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:8001-8021 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7526` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (21 lines × 2) mistralrs-core/src/speculative/dflash.rs:1894 — mistralrs-core/src/speculative/dflash.rs:1894-1914 | mistralrs-core/src/speculative/dflash.rs:1987-2007 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (21 lines × 2) mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:313 — mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:313-333 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:622-642 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (21 lines × 2) mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:879 — mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:879-899 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1230-1250 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (21 lines × 2) mistralrs-core/src/xlora_models/phi2.rs:315 — mistralrs-core/src/xlora_models/phi2.rs:315-335 | mistralrs-core/src/xlora_models/starcoder2.rs:311-331 — before extracting anything, compare `mistralrs-core/src/xlora_models/phi2.rs` and `mistralrs-core/src/xlora_models/starcoder2.rs` as WHOLE FILES: this scan already matched 22 separate duplicated blocks between them, totalling at least 309 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/phi2.rs:315` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (21 lines × 2) mistralrs-quant/src/blockwise_fp8/ops.rs:1104 — mistralrs-quant/src/blockwise_fp8/ops.rs:1104-1124 | mistralrs-quant/src/blockwise_fp8/ops.rs:1139-1159 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/blockwise_fp8/ops.rs:1104` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (21 lines × 2) mistralrs-quant/src/metal_kernels/mod.rs:3951 — mistralrs-quant/src/metal_kernels/mod.rs:3951-3971 | mistralrs-quant/src/metal_kernels/mod.rs:4041-4061 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/metal_kernels/mod.rs:3951` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (21 lines × 2) mistralrs/src/model_builder_trait.rs:628 — mistralrs/src/model_builder_trait.rs:628-648 | mistralrs/src/model_builder_trait.rs:1101-1121 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs/src/model_builder_trait.rs:628` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs/src/model_builder_trait.rs:649` calls `is_some` and `mistralrs/src/model_builder_trait.rs:1122` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (21 lines × 2) mistralrs-quant/src/cutile/qsa.rs:379 — mistralrs-quant/src/cutile/qsa.rs:379-399 | mistralrs-quant/src/cutile/qsa_decode.rs:190-210 — before extracting anything, compare `mistralrs-quant/src/cutile/qsa.rs` and `mistralrs-quant/src/cutile/qsa_decode.rs` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 134 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (21 lines × 2) mistralrs-quant/src/cutile/qsa.rs:487 — mistralrs-quant/src/cutile/qsa.rs:487-507 | mistralrs-quant/src/cutile/qsa_decode.rs:300-320 — before extracting anything, compare `mistralrs-quant/src/cutile/qsa.rs` and `mistralrs-quant/src/cutile/qsa_decode.rs` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 134 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (21 lines × 2) scripts/production_soak.py:3216 — scripts/production_soak.py:3216-3236 | scripts/production_soak.py:4112-4132 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `scripts/production_soak.py:3216` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (17 lines × 3) · ×18
  • Duplicated block (17 lines × 3) mistralrs-core/src/layers.rs:1172 — mistralrs-core/src/layers.rs:1172-1188 | mistralrs-core/src/layers.rs:1262-1278 | mistralrs-core/src/layers.rs:1531-1547 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/layers.rs:1172` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 3) mistralrs-core/src/models/deepseek2.rs:439 — mistralrs-core/src/models/deepseek2.rs:439-455 | mistralrs-core/src/models/deepseek3.rs:440-456 | mistralrs-core/src/models/glm4_moe_lite.rs:404-420 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:439` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 3) mistralrs-core/src/models/glm4.rs:535 — mistralrs-core/src/models/glm4.rs:535-551 | mistralrs-core/src/models/qwen3.rs:494-510 | mistralrs-core/src/models/qwen3_moe.rs:674-690 — before extracting anything, compare `mistralrs-core/src/models/glm4.rs` and `mistralrs-core/src/models/qwen3.rs` as WHOLE FILES: this scan already matched 54 separate duplicated blocks between them, totalling at least 648 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/glm4.rs:535` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 3) mistralrs-core/src/models/llama.rs:440 — mistralrs-core/src/models/llama.rs:440-456 | mistralrs-core/src/models/smollm3.rs:463-479 | mistralrs-core/src/vision_models/llama4/text.rs:876-892 — before extracting anything, compare `mistralrs-core/src/models/llama.rs` and `mistralrs-core/src/models/smollm3.rs` as WHOLE FILES: this scan already matched 47 separate duplicated blocks between them, totalling at least 727 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/llama.rs:440` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/vision_models/llama4/text.rs:875` calls `clone` and `mistralrs-core/src/models/llama.rs:439` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (17 lines × 3) mistralrs-core/src/ops.rs:131 — mistralrs-core/src/ops.rs:131-147 | mistralrs-core/src/ops.rs:169-185 | mistralrs-core/src/ops.rs:207-223 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:131` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 3) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1148 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1148-1164 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3987-4003 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1959-1975 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` and `mistralrs-core/src/pipeline/loaders/normal_loaders.rs` as WHOLE FILES: this scan already matched 34 separate duplicated blocks between them, totalling at least 445 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1148` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 3) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2709 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2709-2725 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3418-3434 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4137-4153 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2709` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 3) mistralrs-core/src/vision_models/grid_processor.rs:1014 — mistralrs-core/src/vision_models/grid_processor.rs:1014-1030 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:237-253 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:803-819 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:1014` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 3) mistralrs-core/src/vision_models/grid_processor.rs:1121 — mistralrs-core/src/vision_models/grid_processor.rs:1121-1137 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:334-350 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:900-916 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:1121` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 3) mistralrs-core/src/vision_models/grid_processor.rs:1449 — mistralrs-core/src/vision_models/grid_processor.rs:1449-1465 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:643-659 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1251-1267 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:1449` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 3) mistralrs-core/src/vision_models/qwen3_5/mod.rs:529 — mistralrs-core/src/vision_models/qwen3_5/mod.rs:529-545 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:544-560 | mistralrs-core/src/vision_models/qwen4_exp/mod.rs:524-540 — `mistralrs-core/src/vision_models/qwen3_5/mod.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 24 separate duplicated blocks between them, totalling at least 425 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (17 lines × 3) mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:82 — mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:82-98 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:634-650 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:80-96 — `mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs` and `mistralrs-core/src/vision_models/qwen3_vl/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 17 separate duplicated blocks between them, totalling at least 266 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:82` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 3) mistralrs-quant/src/distributed/mod.rs:562 — mistralrs-quant/src/distributed/mod.rs:562-578 | mistralrs-quant/src/distributed/mod.rs:593-609 | mistralrs-quant/src/distributed/mod.rs:624-640 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/distributed/mod.rs:562` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 3) mistralrs-quant/src/distributed/mod.rs:711 — mistralrs-quant/src/distributed/mod.rs:711-727 | mistralrs-quant/src/distributed/mod.rs:742-758 | mistralrs-quant/src/distributed/mod.rs:773-789 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/distributed/mod.rs:711` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 3) mistralrs-quant/src/utils/ops.rs:1639 — mistralrs-quant/src/utils/ops.rs:1639-1655 | mistralrs-quant/src/utils/ops.rs:1667-1683 | mistralrs-quant/src/utils/ops.rs:1695-1711 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/utils/ops.rs:1639` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 3) mistralrs-quant/src/utils/ops.rs:1774 — mistralrs-quant/src/utils/ops.rs:1774-1790 | mistralrs-quant/src/utils/ops.rs:1800-1816 | mistralrs-quant/src/utils/ops.rs:1826-1842 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/utils/ops.rs:1774` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 3) mistralrs-quant/src/utils/ops.rs:2034 — mistralrs-quant/src/utils/ops.rs:2034-2050 | mistralrs-quant/src/utils/ops.rs:2063-2079 | mistralrs-quant/src/utils/ops.rs:2092-2108 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/utils/ops.rs:2034` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 3) mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:598 — mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:598-614 | mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:613-629 | mistralrs-core/src/vision_models/phi3/phi3_inputs_processor.rs:534-550 — before extracting anything, compare `mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs` and `mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 222 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:598` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (9 lines × 3) · ×18
  • Duplicated block (9 lines × 3) mistralrs-cli/src/commands/serve.rs:731 — mistralrs-cli/src/commands/serve.rs:731-739 | mistralrs-cli/src/commands/serve.rs:763-771 | mistralrs-cli/src/commands/serve.rs:796-804 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-cli/src/commands/serve.rs:731` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 3) mistralrs-core/src/lora/mod.rs:163 — mistralrs-core/src/lora/mod.rs:163-171 | mistralrs-core/src/lora/mod.rs:215-223 | mistralrs-core/src/lora/qloralinear.rs:41-49 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
  • Duplicated block (9 lines × 3) mistralrs-core/src/models/hunyuan_v1_dense.rs:514 — mistralrs-core/src/models/hunyuan_v1_dense.rs:514-522 | mistralrs-core/src/models/hunyuan_v1_moe.rs:1008-1016 | mistralrs-core/src/models/phi2.rs:532-540 — before extracting anything, compare `mistralrs-core/src/models/hunyuan_v1_dense.rs` and `mistralrs-core/src/models/hunyuan_v1_moe.rs` as WHOLE FILES: this scan already matched 55 separate duplicated blocks between them, totalling at least 766 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/hunyuan_v1_dense.rs:514` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 3) mistralrs-core/src/paged_attention/cache_engine.rs:258 — mistralrs-core/src/paged_attention/cache_engine.rs:258-267 | mistralrs-core/src/paged_attention/cache_engine.rs:307-315 | mistralrs-core/src/paged_attention/cache_engine.rs:393-401 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/paged_attention/cache_engine.rs:258` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 3) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7364 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7364-7372 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:8380-8388 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5347-5355 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` and `mistralrs-core/src/pipeline/loaders/normal_loaders.rs` as WHOLE FILES: this scan already matched 34 separate duplicated blocks between them, totalling at least 445 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (9 lines × 3) mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:328 — mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:328-336 | mistralrs-core/src/vision_models/qwen2vl/vision.rs:300-308 | mistralrs-core/src/vision_models/qwen3_vl/vision.rs:401-409 — `mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs` and `mistralrs-core/src/vision_models/qwen2vl/vision.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 15 separate duplicated blocks between them, totalling at least 182 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (9 lines × 3) mistralrs-core/src/xlora_models/gemma.rs:549 — mistralrs-core/src/xlora_models/gemma.rs:549-557 | mistralrs-core/src/xlora_models/mistral.rs:543-551 | mistralrs-core/src/xlora_models/mixtral.rs:673-681 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/mistral.rs` as WHOLE FILES: this scan already matched 37 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma.rs:549` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (9 lines × 3) mistralrs-pyo3/src/lib.rs:1585 — mistralrs-pyo3/src/lib.rs:1585-1593 | mistralrs-pyo3/src/lib.rs:1861-1869 | mistralrs-pyo3/src/lib.rs:2351-2359 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-pyo3/src/lib.rs:1585` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `request` to `Py<ChatCompletionRequest>` in one and `Py<CompletionRequest>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (9 lines × 3) mistralrs-quant/src/blockwise_fp8/mod.rs:1116 — mistralrs-quant/src/blockwise_fp8/mod.rs:1116-1124 | mistralrs-quant/src/pertensor_fp8/mod.rs:674-682 | mistralrs-quant/src/unquantized/mod.rs:459-467 — `mistralrs-quant/src/blockwise_fp8/mod.rs` and `mistralrs-quant/src/pertensor_fp8/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 186 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/blockwise_fp8/mod.rs:1116` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-quant/src/blockwise_fp8/mod.rs:1125` calls `acquire` and `mistralrs-quant/src/unquantized/mod.rs:468` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 3) mistralrs-quant/src/cutile/fp8_gemm.rs:361 — mistralrs-quant/src/cutile/fp8_gemm.rs:361-369 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:928-936 | mistralrs-quant/src/cutile/gdn_prefill.rs:722-730 — before extracting anything, compare `mistralrs-quant/src/cutile/fp8_gemm.rs` and `mistralrs-quant/src/cutile/fused_moe_fp8.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 70 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cutile/fp8_gemm.rs:361` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (9 lines × 3) mistralrs-quant/src/cutile/fp8_w8a16.rs:65 — mistralrs-quant/src/cutile/fp8_w8a16.rs:65-73 | mistralrs-quant/src/cutile/fp8_w8a16.rs:113-121 | mistralrs-quant/src/cutile/fp8_w8a8.rs:67-75 — before extracting anything, compare `mistralrs-quant/src/cutile/fp8_w8a16.rs` and `mistralrs-quant/src/cutile/fp8_w8a8.rs` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 212 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cutile/fp8_w8a16.rs:65` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-quant/src/cutile/fp8_w8a16.rs:74` calls `convert_tile` and `mistralrs-quant/src/cutile/fp8_w8a8.rs:76` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 3) mistralrs-quant/src/gguf/fast_mmvq.rs:438 — mistralrs-quant/src/gguf/fast_mmvq.rs:438-446 | mistralrs-quant/src/gguf/fast_mmvq.rs:895-903 | mistralrs-quant/src/gguf/fast_mmvq.rs:1138-1146 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-quant/src/gguf/fast_mmvq.rs:894` calls `cuda_stream` and `mistralrs-quant/src/gguf/fast_mmvq.rs:436` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 3) mistralrs-quant/src/hqq/mod.rs:187 — mistralrs-quant/src/hqq/mod.rs:187-195 | mistralrs-quant/src/hqq/mod.rs:272-280 | mistralrs-quant/src/hqq/mod.rs:442-450 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/hqq/mod.rs:187` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (9 lines × 3) mistralrs-core/src/attention/backends/cpu/avx.rs:315 — mistralrs-core/src/attention/backends/cpu/avx.rs:315-323 | mistralrs-core/src/attention/backends/cpu/neon.rs:383-391 | mistralrs-core/src/attention/backends/cpu/neon.rs:622-630 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/attention/backends/cpu/avx.rs:315` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 3) mistralrs-quant/src/afq/mod.rs:221 — mistralrs-quant/src/afq/mod.rs:221-229 | mistralrs-quant/src/gguf/mod.rs:802-810 | mistralrs-quant/src/unquantized/mod.rs:647-655 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
  • Duplicated block (9 lines × 3) mistralrs-core/src/pipeline/loaders/lfm3_d1.rs:60 — mistralrs-core/src/pipeline/loaders/lfm3_d1.rs:60-68 | mistralrs-core/src/pipeline/loaders/lfm3_omni.rs:55-63 | mistralrs-core/src/pipeline/loaders/lfm3_vl.rs:110-118 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/lfm3_d1.rs:60` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 3) mistralrs-core/src/ops.rs:4405 — mistralrs-core/src/ops.rs:4405-4413 | mistralrs-core/src/ops.rs:4590-4598 | mistralrs-core/src/ops.rs:5349-5358 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (9 lines × 3) mistralrs-quant/src/gguf/fast_mmq.rs:629 — mistralrs-quant/src/gguf/fast_mmq.rs:629-637 | mistralrs-quant/src/gguf/fast_mmq.rs:899-907 | mistralrs-quant/src/gguf/fast_mmq.rs:1368-1376 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/gguf/fast_mmq.rs:629` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-quant/src/gguf/fast_mmq.rs:910` calls `cu_stream` and `mistralrs-quant/src/gguf/fast_mmq.rs:640` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D2 · Cognitive Complexity · Model · ×17
  • Model::prepare_inputs_labels_for_multimodal (cognitive 55) mistralrs-core/src/vision_models/llava/llava_next.rs:224 — Model::prepare_inputs_labels_for_multimodal has cognitive complexity 55 (threshold 15). Drivers by points: if/else 20 (32 pts), loops 9 (19 pts), boolean chains 4 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Model::forward_hidden (cognitive 42) mistralrs-core/src/models/lfm3.rs:1170 — Model::forward_hidden has cognitive complexity 42 (threshold 15). Drivers by points: if/else 18 (36 pts), boolean chains 3, match/switch 1 (2 pts), loops 1 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Model::forward (cognitive 42) mistralrs-core/src/models/qwen3_next.rs:964 — Model::forward has cognitive complexity 42 (threshold 15). Drivers by points: if/else 19 (38 pts), match/switch 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Model::forward_embeds (cognitive 32) mistralrs-core/src/models/lfm2.rs:1172 — Model::forward_embeds has cognitive complexity 32 (threshold 15). Drivers by points: if/else 13 (27 pts), boolean chains 2, match/switch 1 (2 pts), loops 1 (nesting depth added 15). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • Model::create_anymoe_layers (cognitive 27) mistralrs-core/src/models/gemma.rs:577 — Model::create_anymoe_layers has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (19 pts), loops 4 (5 pts), match/switch 1 (3 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Model::create_anymoe_layers (cognitive 27) mistralrs-core/src/models/gemma2.rs:694 — Model::create_anymoe_layers has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (19 pts), loops 4 (5 pts), match/switch 1 (3 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Model::create_anymoe_layers (cognitive 27) mistralrs-core/src/models/glm4.rs:696 — Model::create_anymoe_layers has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (19 pts), loops 4 (5 pts), match/switch 1 (3 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Model::create_anymoe_layers (cognitive 27) mistralrs-core/src/models/hunyuan_v1_dense.rs:664 — Model::create_anymoe_layers has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (19 pts), loops 4 (5 pts), match/switch 1 (3 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Model::create_anymoe_layers (cognitive 27) mistralrs-core/src/models/mistral.rs:705 — Model::create_anymoe_layers has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (19 pts), loops 4 (5 pts), match/switch 1 (3 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Model::create_anymoe_layers (cognitive 27) mistralrs-core/src/models/qwen2.rs:708 — Model::create_anymoe_layers has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (19 pts), loops 4 (5 pts), match/switch 1 (3 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Model::create_anymoe_layers (cognitive 27) mistralrs-core/src/models/qwen3.rs:682 — Model::create_anymoe_layers has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (19 pts), loops 4 (5 pts), match/switch 1 (3 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Model::create_anymoe_layers (cognitive 27) mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:661 — Model::create_anymoe_layers has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (19 pts), loops 4 (5 pts), match/switch 1 (3 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Model::create_anymoe_layers (cognitive 22) mistralrs-core/src/models/phi2.rs:653 — Model::create_anymoe_layers has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (14 pts), loops 4 (5 pts), match/switch 1 (3 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Model::create_anymoe_layers (cognitive 22) mistralrs-core/src/models/phi3.rs:648 — Model::create_anymoe_layers has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (14 pts), loops 4 (5 pts), match/switch 1 (3 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Model::create_anymoe_layers (cognitive 22) mistralrs-core/src/models/starcoder2.rs:644 — Model::create_anymoe_layers has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (14 pts), loops 4 (5 pts), match/switch 1 (3 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Model::create_anymoe_layers (cognitive 22) mistralrs-core/src/vision_models/phi3/mod.rs:1484 — Model::create_anymoe_layers has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (14 pts), loops 4 (5 pts), match/switch 1 (3 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Model::new_inner (cognitive 16) mistralrs-core/src/models/lfm3.rs:904 — Model::new_inner has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (12 pts), loops 2, match/switch 2 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D4 · Code Duplication · Duplicated block (23 lines × 2) · ×17
  • Duplicated block (23 lines × 2) mistralrs-core/src/lib.rs:1463 — mistralrs-core/src/lib.rs:1463-1485 | mistralrs-core/src/lib.rs:1519-1541 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/lib.rs:1463` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (23 lines × 2) mistralrs-core/src/lora/loralinear.rs:82 — mistralrs-core/src/lora/loralinear.rs:82-104 | mistralrs-core/src/lora/qloralinear.rs:131-153 — before extracting anything, compare `mistralrs-core/src/lora/loralinear.rs` and `mistralrs-core/src/lora/qloralinear.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 151 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/lora/loralinear.rs:82` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (23 lines × 2) mistralrs-core/src/ops.rs:5864 — mistralrs-core/src/ops.rs:5864-5886 | mistralrs-core/src/ops.rs:6301-6323 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (23 lines × 2) mistralrs-core/src/pipeline/inputs_processor.rs:2789 — mistralrs-core/src/pipeline/inputs_processor.rs:2789-2811 | mistralrs-core/src/pipeline/inputs_processor.rs:2838-2860 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/inputs_processor.rs:2789` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (23 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:538 — mistralrs-core/src/pipeline/multimodal.rs:538-560 | mistralrs-core/src/pipeline/normal.rs:670-692 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (23 lines × 2) mistralrs-core/src/toml_selector.rs:1111 — mistralrs-core/src/toml_selector.rs:1111-1133 | mistralrs-core/src/toml_selector.rs:1145-1167 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/toml_selector.rs:1111` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (23 lines × 2) mistralrs-core/src/vision_models/gemma4/mod.rs:461 — mistralrs-core/src/vision_models/gemma4/mod.rs:461-483 | mistralrs-core/src/vision_models/gemma4/mod.rs:774-796 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma4/mod.rs:461` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (23 lines × 2) mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:242 — mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:242-264 | mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:508-530 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (23 lines × 2) mistralrs-paged-attn/src/metal/backend/paged_attention.rs:435 — mistralrs-paged-attn/src/metal/backend/paged_attention.rs:435-457 | mistralrs-paged-attn/src/metal/backend/paged_attention.rs:822-844 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/metal/backend/paged_attention.rs:435` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (23 lines × 2) mistralrs-quant/src/blockwise_fp8/ops.rs:1291 — mistralrs-quant/src/blockwise_fp8/ops.rs:1291-1313 | mistralrs-quant/src/blockwise_fp8/ops.rs:1330-1352 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/blockwise_fp8/ops.rs:1291` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (23 lines × 2) mistralrs-quant/src/gguf/fast_mmvq.rs:489 — mistralrs-quant/src/gguf/fast_mmvq.rs:489-511 | mistralrs-quant/src/gguf/fast_mmvq.rs:946-968 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/gguf/fast_mmvq.rs:489` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (23 lines × 2) mistralrs-quant/src/gguf/fast_mmvq.rs:531 — mistralrs-quant/src/gguf/fast_mmvq.rs:531-553 | mistralrs-quant/src/gguf/fast_mmvq.rs:985-1007 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/gguf/fast_mmvq.rs:531` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (23 lines × 2) mistralrs/src/model_builder_trait.rs:573 — mistralrs/src/model_builder_trait.rs:573-595 | mistralrs/src/model_builder_trait.rs:652-674 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs/src/model_builder_trait.rs:573` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (23 lines × 2) mistralrs/src/model_builder_trait.rs:1278 — mistralrs/src/model_builder_trait.rs:1278-1300 | mistralrs/src/model_builder_trait.rs:1345-1367 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs/src/model_builder_trait.rs:1278` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note first that the copies are not typed on the same thing: the declarations holding them bind `builder` to `crate::DiffusionModelBuilder` in one and `crate::SpeechModelBuilder` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs/src/model_builder_trait.rs:1343` calls `clone` and `mistralrs/src/model_builder_trait.rs:1276` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (23 lines × 2) mistralrs-quant/src/gguf/fast_mmq.rs:458 — mistralrs-quant/src/gguf/fast_mmq.rs:458-480 | mistralrs-quant/src/gguf/fast_mmq.rs:538-560 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (23 lines × 2) scripts/production_soak.py:7709 — scripts/production_soak.py:7709-7731 | scripts/production_soak.py:10388-10410 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `scripts/production_soak.py:7709` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (23 lines × 2) scripts/production_soak.py:12982 — scripts/production_soak.py:12982-13004 | scripts/production_soak.py:13153-13175 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `scripts/production_soak.py:12982` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (20 lines × 2) · ×17
  • Duplicated block (20 lines × 2) mistralrs-core/src/cuda/gdn.rs:5408 — mistralrs-core/src/cuda/gdn.rs:5408-5427 | mistralrs-core/src/cuda/gdn.rs:5584-5603 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/gdn.rs:5408` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (20 lines × 2) mistralrs-core/src/distributed.rs:282 — mistralrs-core/src/distributed.rs:282-301 | mistralrs-core/src/distributed.rs:322-341 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/distributed.rs:282` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (20 lines × 2) mistralrs-core/src/embedding_models/embedding_gemma.rs:208 — mistralrs-core/src/embedding_models/embedding_gemma.rs:208-227 | mistralrs-core/src/embedding_models/qwen3_embedding.rs:181-200 — before extracting anything, compare `mistralrs-core/src/embedding_models/embedding_gemma.rs` and `mistralrs-core/src/embedding_models/qwen3_embedding.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 40 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (20 lines × 2) mistralrs-core/src/ops.rs:5707 — mistralrs-core/src/ops.rs:5707-5726 | mistralrs-core/src/ops.rs:6130-6149 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (20 lines × 2) mistralrs-core/src/pipeline/embedding.rs:297 — mistralrs-core/src/pipeline/embedding.rs:297-316 | mistralrs-core/src/pipeline/embedding.rs:324-343 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/pipeline/embedding.rs:323` calls `conservative_pack_factor`, `pack_factor` and `mistralrs-core/src/pipeline/embedding.rs:296` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (20 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2821 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2821-2840 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4245-4264 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2821` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (20 lines × 2) mistralrs-core/src/tools/parsers/gemma4.rs:293 — mistralrs-core/src/tools/parsers/gemma4.rs:293-312 | mistralrs-core/src/tools/parsers/gemma4.rs:334-353 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/tools/parsers/gemma4.rs:293` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (20 lines × 2) mistralrs-core/src/vision_models/llama4/vision.rs:226 — mistralrs-core/src/vision_models/llama4/vision.rs:226-245 | mistralrs-core/src/vision_models/mllama/vision.rs:245-264 — `mistralrs-core/src/vision_models/llama4/vision.rs` and `mistralrs-core/src/vision_models/mllama/vision.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 6 separate duplicated blocks between them, totalling at least 67 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit. Note first that the copies are not typed on the same thing: the declarations holding them bind `cfg` to `&VisionConfig` in one and `&MLlamaVisionConfig` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (20 lines × 2) mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:669 — mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:669-688 | mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:698-717 — before extracting anything, compare `mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs` and `mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 222 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:669` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (20 lines × 2) mistralrs-core/src/vision_models/phi3/mod.rs:591 — mistralrs-core/src/vision_models/phi3/mod.rs:591-610 | mistralrs-core/src/vision_models/phi3/mod.rs:623-642 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/phi3/mod.rs:591` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (20 lines × 2) mistralrs-core/src/vision_models/phi4/image_embedding.rs:214 — mistralrs-core/src/vision_models/phi4/image_embedding.rs:214-233 | mistralrs-core/src/vision_models/phi4/image_embedding.rs:246-265 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/phi4/image_embedding.rs:214` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (20 lines × 2) mistralrs-pyo3/src/lib.rs:990 — mistralrs-pyo3/src/lib.rs:990-1009 | mistralrs-pyo3/src/lib.rs:1021-1040 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-pyo3/src/lib.rs:990` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (20 lines × 2) mistralrs-quant/src/cublaslt/mod.rs:157 — mistralrs-quant/src/cublaslt/mod.rs:157-176 | mistralrs-quant/src/cublaslt/mod.rs:210-229 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cublaslt/mod.rs:157` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (20 lines × 2) mistralrs-quant/src/gguf/fast_mmq.rs:387 — mistralrs-quant/src/gguf/fast_mmq.rs:387-406 | mistralrs-quant/src/gguf/fast_mmvq.rs:120-139 — before extracting anything, compare `mistralrs-quant/src/gguf/fast_mmq.rs` and `mistralrs-quant/src/gguf/fast_mmvq.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 62 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (20 lines × 2) mistralrs-core/src/layers.rs:881 — mistralrs-core/src/layers.rs:881-900 | mistralrs-core/src/layers.rs:2217-2236 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/layers.rs:881` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `cfg` to `&PhiRopeConfig` in one and `&Phi4MMConfig` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (20 lines × 2) mistralrs-core/src/models/gemma2.rs:563 — mistralrs-core/src/models/gemma2.rs:563-582 | mistralrs-core/src/models/qwen2.rs:592-611 — before extracting anything, compare `mistralrs-core/src/models/gemma2.rs` and `mistralrs-core/src/models/qwen2.rs` as WHOLE FILES: this scan already matched 38 separate duplicated blocks between them, totalling at least 475 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma2.rs:563` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (20 lines × 2) scripts/production_soak.py:5130 — scripts/production_soak.py:5130-5149 | scripts/production_soak.py:10153-10172 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `scripts/production_soak.py:5130` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D3 · God Classes · TooManyMethods · ×16
  • TooManyMethods: Sequence mistralrs-core/src/sequence.rs:753 — TooManyMethods — 163 methods. The bar is 30 methods; this is 133 over it, 5.43× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: MistralRs mistralrs-core/src/lib.rs:462 — TooManyMethods — 81 methods. The bar is 30 methods; this is 51 over it, 2.70× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: HybridCache mistralrs-core/src/kv_cache/hybrid_cache.rs:1082 — TooManyMethods — 70 methods. The bar is 30 methods; this is 40 over it, 2.33× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: Model mistralrs/src/model.rs:80 — TooManyMethods — 68 methods. The bar is 30 methods; this is 38 over it, 2.27× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: MistralRsForServerBuilder mistralrs-server-core/src/mistralrs_for_server_builder.rs:178 — TooManyMethods — 57 methods. The bar is 30 methods; this is 27 over it, 1.90× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: RequestBuilder mistralrs/src/messages.rs:571 — TooManyMethods — 51 methods. The bar is 30 methods; this is 21 over it, 1.70× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: GgufModelBuilder mistralrs/src/gguf.rs:12 — TooManyMethods — 49 methods. The bar is 30 methods; this is 19 over it, 1.63× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: Sampler mistralrs-core/src/sampler.rs:304 — TooManyMethods — 44 methods. The bar is 30 methods; this is 14 over it, 1.47× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: RecurrentStatePool mistralrs-core/src/kv_cache/hybrid_cache.rs:466 — TooManyMethods — 41 methods. The bar is 30 methods; this is 11 over it, 1.37× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: DFlashDraftModel mistralrs-core/src/speculative/dflash.rs:1285 — TooManyMethods — 40 methods. The bar is 30 methods; this is 10 over it, 1.33× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: Runner mistralrs-pyo3/src/lib.rs:605 — TooManyMethods — 36 methods. The bar is 30 methods; this is 6 over it, 1.20× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: PagedAttentionScheduler mistralrs-core/src/paged_attention/scheduler.rs:109 — TooManyMethods — 35 methods. The bar is 30 methods; this is 5 over it, 1.17× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: File mistralrs-core/src/files/mod.rs:90 — TooManyMethods — 34 methods. The bar is 30 methods; this is 4 over it, 1.13× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: ShardedVarBuilder mistralrs-quant/src/uqff/mod.rs:341 — TooManyMethods — 34 methods. The bar is 30 methods; this is 4 over it, 1.13× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: ChatStore mistralrs-cli/webui/src/lib/stores/chat.svelte.ts:133 — TooManyMethods — 32 methods. The bar is 30 methods; this is 2 over it, 1.07× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: BlockPool mistralrs-core/src/paged_attention/block_pool.rs:543 — TooManyMethods — 32 methods. The bar is 30 methods; this is 2 over it, 1.07× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
D4 · Code Duplication · Edited copy of a member (21 corresponding lines) · ×16
  • Edited copy of a member (21 corresponding lines) mistralrs-core/src/models/lfm3.rs:542 — mistralrs-core/src/models/lfm3.rs:542-572 | mistralrs-core/src/models/qwen3.rs:192-282 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (21 corresponding lines) mistralrs-core/src/models/lfm3.rs:542 — mistralrs-core/src/models/lfm3.rs:542-572 | mistralrs-core/src/models/qwen3_moe.rs:195-285 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (21 corresponding lines) mistralrs-core/src/models/lfm3.rs:542 — mistralrs-core/src/models/lfm3.rs:542-572 | mistralrs-core/src/vision_models/gemma3/text.rs:182-302 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (21 corresponding lines) mistralrs-core/src/models/lfm3.rs:542 — mistralrs-core/src/models/lfm3.rs:542-572 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:194-287 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (21 corresponding lines) mistralrs-core/src/models/lfm3.rs:542 — mistralrs-core/src/models/lfm3.rs:542-572 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:300-390 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (21 corresponding lines) mistralrs-pyo3/src/util.rs:148 — mistralrs-pyo3/src/util.rs:148-168 | mistralrs-pyo3/src/util.rs:170-190 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (21 corresponding lines) mistralrs-core/src/vision_models/gemma3n/audio.rs:1202 — mistralrs-core/src/vision_models/gemma3n/audio.rs:1202-1232 | mistralrs-core/src/vision_models/gemma4/audio.rs:963-983 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (21 corresponding lines) mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:610 — mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:610-632 | mistralrs-core/src/vision_models/mistral3/inputs_processor.rs:59-79 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (21 corresponding lines) mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:308 — mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:308-334 | mistralrs-core/src/vision_models/llama4/inputs_processor.rs:340-360 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (21 corresponding lines) mistralrs-core/src/gguf/normal_bindings.rs:455 — mistralrs-core/src/gguf/normal_bindings.rs:455-475 | mistralrs-core/src/gguf/qwen_multimodal_bindings.rs:788-812 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (21 corresponding lines) mistralrs-core/src/vision_models/gemma3n/audio_processing.rs:122 — mistralrs-core/src/vision_models/gemma3n/audio_processing.rs:122-146 | mistralrs-core/src/vision_models/voxtral/audio_processing.rs:87-107 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (21 corresponding lines) mistralrs-core/src/vision_models/lfm2_vl/inputs_processor.rs:622 — mistralrs-core/src/vision_models/lfm2_vl/inputs_processor.rs:622-644 | mistralrs-core/src/vision_models/mistral3/inputs_processor.rs:232-252 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (21 corresponding lines) mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:26 — mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:26-46 | mistralrs-core/src/vision_models/qwen2vl/vision.rs:26-46 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (21 corresponding lines) mistralrs-core/src/pipeline/hf/client.rs:82 — mistralrs-core/src/pipeline/hf/client.rs:82-104 | mistralrs-core/src/pipeline/hf/client.rs:144-164 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (21 corresponding lines) mistralrs-core/src/pipeline/auto.rs:569 — mistralrs-core/src/pipeline/auto.rs:569-590 | mistralrs-core/src/pipeline/auto.rs:602-622 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (21 corresponding lines) mistralrs-core/src/vision_models/muse_glimmer/config.rs:128 — mistralrs-core/src/vision_models/muse_glimmer/config.rs:128-148 | mistralrs-core/src/vision_models/muse_glimmer/config.rs:246-266 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Duplicated block (25 lines × 2) · ×16
  • Duplicated block (25 lines × 2) mistralrs-cli/src/commands/run/interactive.rs:1010 — mistralrs-cli/src/commands/run/interactive.rs:1010-1034 | mistralrs-cli/src/commands/run/interactive.rs:1798-1822 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-cli/src/commands/run/interactive.rs:1010` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-cli/src/commands/run/interactive.rs:1009` calls `clone` and `mistralrs-cli/src/commands/run/interactive.rs:1797` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (25 lines × 2) mistralrs-core/src/models/qwen3.rs:480 — mistralrs-core/src/models/qwen3.rs:480-504 | mistralrs-core/src/models/qwen3_moe.rs:660-684 — before extracting anything, compare `mistralrs-core/src/models/qwen3.rs` and `mistralrs-core/src/models/qwen3_moe.rs` as WHOLE FILES: this scan already matched 62 separate duplicated blocks between them, totalling at least 803 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/qwen3.rs:480` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (25 lines × 2) mistralrs-core/src/pipeline/inputs_processor.rs:2732 — mistralrs-core/src/pipeline/inputs_processor.rs:2732-2756 | mistralrs-core/src/pipeline/inputs_processor.rs:2776-2800 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (25 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:2175 — mistralrs-core/src/pipeline/multimodal.rs:2175-2199 | mistralrs-core/src/pipeline/normal.rs:1936-1960 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/pipeline/multimodal.rs:2174` calls `has_speculative_proposer` and `mistralrs-core/src/pipeline/normal.rs:1935` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (25 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:2670 — mistralrs-core/src/pipeline/multimodal.rs:2670-2694 | mistralrs-core/src/pipeline/normal.rs:2272-2296 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:2670` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (25 lines × 2) mistralrs-core/src/sampler.rs:1171 — mistralrs-core/src/sampler.rs:1171-1195 | mistralrs-core/src/sampler.rs:1251-1275 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/sampler.rs:1171` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (25 lines × 2) mistralrs-core/src/vision_models/grid_processor.rs:1096 — mistralrs-core/src/vision_models/grid_processor.rs:1096-1120 | mistralrs-core/src/vision_models/grid_processor.rs:1424-1448 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (25 lines × 2) mistralrs-core/src/vision_models/qwen3_5/text.rs:852 — mistralrs-core/src/vision_models/qwen3_5/text.rs:852-876 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:548-572 — `mistralrs-core/src/vision_models/qwen3_5/text.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 26 separate duplicated blocks between them, totalling at least 469 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_5/text.rs:852` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (25 lines × 2) mistralrs-core/src/vision_models/qwen3_vl/mod.rs:977 — mistralrs-core/src/vision_models/qwen3_vl/mod.rs:977-1001 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:423-447 — `mistralrs-core/src/vision_models/qwen3_vl/mod.rs` and `mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 25 separate duplicated blocks between them, totalling at least 658 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_vl/mod.rs:977` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/vision_models/qwen3_vl/mod.rs:1004` calls `pub` and `mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:450` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (25 lines × 2) mistralrs-core/src/xlora_models/classifier.rs:118 — mistralrs-core/src/xlora_models/classifier.rs:118-142 | mistralrs-core/src/xlora_models/classifier.rs:210-234 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/classifier.rs:118` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (25 lines × 2) mistralrs-pyo3/src/lib.rs:2013 — mistralrs-pyo3/src/lib.rs:2013-2037 | mistralrs-pyo3/src/lib.rs:2080-2104 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-pyo3/src/lib.rs:2013` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (25 lines × 2) mistralrs-quant/src/distributed/layers.rs:2095 — mistralrs-quant/src/distributed/layers.rs:2095-2119 | mistralrs-quant/src/distributed/layers.rs:2260-2284 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/distributed/layers.rs:2095` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (25 lines × 2) mistralrs-quant/src/moe/cutlass.rs:261 — mistralrs-quant/src/moe/cutlass.rs:261-285 | mistralrs-quant/src/moe/cutlass.rs:305-329 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/moe/cutlass.rs:261` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (25 lines × 2) mistralrs-paged-attn/src/cuda/backend/gather_kv.rs:109 — mistralrs-paged-attn/src/cuda/backend/gather_kv.rs:109-133 | mistralrs-paged-attn/src/metal/backend/gather_kv.rs:64-88 — before extracting anything, compare `mistralrs-paged-attn/src/cuda/backend/gather_kv.rs` and `mistralrs-paged-attn/src/metal/backend/gather_kv.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 48 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (25 lines × 2) mistralrs-core/src/vision_models/grid_processor.rs:506 — mistralrs-core/src/vision_models/grid_processor.rs:506-530 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:289-313 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 51 separate duplicated blocks between them, totalling at least 1008 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:506` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (25 lines × 2) mistralrs-core/src/models/lfm2.rs:1261 — mistralrs-core/src/models/lfm2.rs:1261-1285 | mistralrs-core/src/models/lfm3.rs:1276-1300 — before extracting anything, compare `mistralrs-core/src/models/lfm2.rs` and `mistralrs-core/src/models/lfm3.rs` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 402 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/lfm2.rs:1261` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (15 lines × 3) · ×16
  • Duplicated block (15 lines × 3) mistralrs-core/src/models/mistral.rs:536 — mistralrs-core/src/models/mistral.rs:536-550 | mistralrs-core/src/models/mixtral.rs:491-505 | mistralrs-core/src/models/starcoder2.rs:492-506 — before extracting anything, compare `mistralrs-core/src/models/mistral.rs` and `mistralrs-core/src/models/mixtral.rs` as WHOLE FILES: this scan already matched 47 separate duplicated blocks between them, totalling at least 619 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/mistral.rs:536` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/models/mixtral.rs:490` calls `clone` and `mistralrs-core/src/models/starcoder2.rs:491` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (15 lines × 3) mistralrs-core/src/models/mixtral.rs:407 — mistralrs-core/src/models/mixtral.rs:407-421 | mistralrs-core/src/models/phi3.rs:409-423 | mistralrs-core/src/models/qwen2.rs:434-448 — before extracting anything, compare `mistralrs-core/src/models/mixtral.rs` and `mistralrs-core/src/models/phi3.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 337 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/mixtral.rs:407` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 3) mistralrs-core/src/models/phi3.rs:340 — mistralrs-core/src/models/phi3.rs:340-354 | mistralrs-core/src/vision_models/phi3/mod.rs:431-445 | mistralrs-core/src/vision_models/phi4/mod.rs:260-274 — before extracting anything, compare `mistralrs-core/src/models/phi3.rs` and `mistralrs-core/src/vision_models/phi3/mod.rs` as WHOLE FILES: this scan already matched 50 separate duplicated blocks between them, totalling at least 638 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/phi3.rs:340` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 3) mistralrs-core/src/models/phi3.rs:504 — mistralrs-core/src/models/phi3.rs:504-518 | mistralrs-core/src/models/phi3_5_moe.rs:576-590 | mistralrs-core/src/vision_models/phi3/mod.rs:1285-1300 — before extracting anything, compare `mistralrs-core/src/models/phi3.rs` and `mistralrs-core/src/models/phi3_5_moe.rs` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 343 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/phi3.rs:504` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 3) mistralrs-core/src/pipeline/ggml.rs:138 — mistralrs-core/src/pipeline/ggml.rs:138-152 | mistralrs-core/src/pipeline/gguf.rs:348-362 | mistralrs-core/src/pipeline/normal.rs:483-497 — before extracting anything, compare `mistralrs-core/src/pipeline/ggml.rs` and `mistralrs-core/src/pipeline/gguf.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 75 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/gguf.rs:348` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 3) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1367 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1367-1381 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3147-3161 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3496-3510 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1367` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 3) mistralrs-core/src/utils/gguf_metadata.rs:313 — mistralrs-core/src/utils/gguf_metadata.rs:313-327 | mistralrs-core/src/utils/gguf_metadata.rs:346-360 | mistralrs-core/src/utils/gguf_metadata.rs:362-376 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (15 lines × 3) mistralrs-core/src/vision_models/grid_processor.rs:863 — mistralrs-core/src/vision_models/grid_processor.rs:863-877 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:38-52 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:586-600 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:863` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 3) mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:546 — mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:546-560 | mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:563-577 | mistralrs-core/src/vision_models/qwen2vl/vision.rs:421-435 — `mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs` and `mistralrs-core/src/vision_models/qwen2vl/vision.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 15 separate duplicated blocks between them, totalling at least 182 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:546` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 3) mistralrs-core/src/xlora_models/mistral.rs:195 — mistralrs-core/src/xlora_models/mistral.rs:195-209 | mistralrs-core/src/xlora_models/mixtral.rs:108-122 | mistralrs-core/src/xlora_models/phi3.rs:85-99 — before extracting anything, compare `mistralrs-core/src/xlora_models/mistral.rs` and `mistralrs-core/src/xlora_models/mixtral.rs` as WHOLE FILES: this scan already matched 53 separate duplicated blocks between them, totalling at least 787 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/mistral.rs:195` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 3) mistralrs-quant/src/blockwise_fp8/ops.rs:208 — mistralrs-quant/src/blockwise_fp8/ops.rs:208-222 | mistralrs-quant/src/blockwise_fp8/ops.rs:230-244 | mistralrs-quant/src/blockwise_fp8/ops.rs:252-266 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/blockwise_fp8/ops.rs:208` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 3) mistralrs-quant/src/cutile/nvfp4_gemv.rs:306 — mistralrs-quant/src/cutile/nvfp4_gemv.rs:306-320 | mistralrs-quant/src/cutile/nvfp4_matmul.rs:1135-1149 | mistralrs-quant/src/nvfp4/decode.rs:107-121 — before extracting anything, compare `mistralrs-quant/src/cutile/nvfp4_gemv.rs` and `mistralrs-quant/src/cutile/nvfp4_matmul.rs` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 98 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cutile/nvfp4_gemv.rs:306` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-quant/src/cutile/nvfp4_matmul.rs:1134` calls `unwrap_or` and `mistralrs-quant/src/nvfp4/decode.rs:106` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (15 lines × 3) mistralrs-quant/src/gemv/mod.rs:384 — mistralrs-quant/src/gemv/mod.rs:384-398 | mistralrs-quant/src/gemv/mod.rs:455-469 | mistralrs-quant/src/gemv/mod.rs:526-540 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/gemv/mod.rs:384` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 3) mistralrs-core/src/pipeline/embedding.rs:192 — mistralrs-core/src/pipeline/embedding.rs:192-206 | mistralrs-core/src/pipeline/multimodal.rs:509-523 | mistralrs-core/src/pipeline/normal.rs:642-656 — before extracting anything, compare `mistralrs-core/src/pipeline/embedding.rs` and `mistralrs-core/src/pipeline/multimodal.rs` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 178 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/embedding.rs:192` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 3) REDACTED:690 — REDACTED:690-704 | mistralrs-core/src/vision_models/idefics3/vision.rs:509-523 | mistralrs-core/src/vision_models/siglip.rs:532-546 — before extracting anything, compare `REDACTED` and `mistralrs-core/src/vision_models/idefics3/vision.rs` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 221 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:690` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 3) mistralrs-core/src/vision_models/grid_processor.rs:1720 — mistralrs-core/src/vision_models/grid_processor.rs:1720-1734 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:886-900 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1451-1465 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:1720` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (8 lines × 4) · ×16
  • Duplicated block (8 lines × 4) mistralrs-cli/src/commands/config.rs:101 — mistralrs-cli/src/commands/config.rs:101-108 | mistralrs-cli/src/commands/config.rs:261-268 | mistralrs-cli/src/commands/run/mod.rs:106-113 | mistralrs-cli/src/commands/serve.rs:118-125 — before extracting anything, compare `mistralrs-cli/src/commands/config.rs` and `mistralrs-cli/src/commands/serve.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 60 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-cli/src/commands/serve.rs:127` calls `default` and `mistralrs-cli/src/commands/run/mod.rs:116` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (8 lines × 4) mistralrs-core/src/models/lfm2.rs:1115 — mistralrs-core/src/models/lfm2.rs:1115-1122 | mistralrs-core/src/models/qwen3_next.rs:921-929 | mistralrs-core/src/vision_models/qwen3_5/text.rs:1032-1040 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:744-752 — before extracting anything, compare `mistralrs-core/src/models/lfm2.rs` and `mistralrs-core/src/models/qwen3_next.rs` as WHOLE FILES: this scan already matched 15 separate duplicated blocks between them, totalling at least 161 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/lfm2.rs:1115` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (8 lines × 4) mistralrs-core/src/models/phi3.rs:424 — mistralrs-core/src/models/phi3.rs:424-431 | mistralrs-core/src/vision_models/gemma3/text.rs:450-458 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:406-414 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:526-534 — before extracting anything, compare `mistralrs-core/src/models/phi3.rs` and `mistralrs-core/src/vision_models/gemma3/text.rs` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 199 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/phi3.rs:424` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (8 lines × 4) mistralrs-core/src/vision_models/qwen3_5/mod.rs:192 — mistralrs-core/src/vision_models/qwen3_5/mod.rs:192-199 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:175-182 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:699-706 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:145-152 — `mistralrs-core/src/vision_models/qwen3_5/mod.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 24 separate duplicated blocks between them, totalling at least 425 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_5/mod.rs:192` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 4) mistralrs-core/src/vision_models/qwen3_5/mod.rs:255 — mistralrs-core/src/vision_models/qwen3_5/mod.rs:255-262 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:238-245 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:776-783 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:222-229 — `mistralrs-core/src/vision_models/qwen3_5/mod.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 24 separate duplicated blocks between them, totalling at least 425 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_5/mod.rs:255` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 4) mistralrs-quant/src/hqq/mod.rs:174 — mistralrs-quant/src/hqq/mod.rs:174-181 | mistralrs-quant/src/hqq/mod.rs:258-265 | mistralrs-quant/src/hqq/mod.rs:352-359 | mistralrs-quant/src/hqq/mod.rs:501-508 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/hqq/mod.rs:174` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 4) mistralrs-quant/src/metal_kernels/mod.rs:1592 — mistralrs-quant/src/metal_kernels/mod.rs:1592-1600 | mistralrs-quant/src/metal_kernels/mod.rs:1668-1676 | mistralrs-quant/src/metal_kernels/mod.rs:2720-2727 | mistralrs-quant/src/metal_kernels/mod.rs:2854-2862 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/metal_kernels/mod.rs:1592` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-quant/src/metal_kernels/mod.rs:2852` calls `type_to_name` and `mistralrs-quant/src/metal_kernels/mod.rs:1591` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (8 lines × 4) mistralrs-core/src/ops.rs:1123 — mistralrs-core/src/ops.rs:1123-1130 | mistralrs-core/src/ops.rs:1352-1359 | mistralrs-core/src/ops.rs:2046-2053 | mistralrs-core/src/ops.rs:2179-2186 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/ops.rs:1120` calls `try_from`, `map_err` and `mistralrs-core/src/ops.rs:2043` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (8 lines × 4) mistralrs-server-core/src/chat_completion.rs:1447 — mistralrs-server-core/src/chat_completion.rs:1447-1454 | mistralrs-server-core/src/completions.rs:459-466 | mistralrs-server-core/src/image_generation.rs:187-194 | mistralrs-server-core/src/speech_generation.rs:442-449 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-server-core/src/chat_completion.rs:1447` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-server-core/src/completions.rs:457` calls `ImageGeneration` and `mistralrs-server-core/src/image_generation.rs:185` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (8 lines × 4) mistralrs-core/src/pipeline/cuda_graph.rs:3862 — mistralrs-core/src/pipeline/cuda_graph.rs:3862-3869 | mistralrs-core/src/pipeline/cuda_graph.rs:3880-3887 | mistralrs-core/src/pipeline/cuda_graph.rs:3899-3906 | mistralrs-core/src/pipeline/cuda_graph.rs:3918-3925 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (8 lines × 4) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7449 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7449-7456 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7924-7931 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:8466-8473 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6686-6693 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` and `mistralrs-core/src/pipeline/loaders/normal_loaders.rs` as WHOLE FILES: this scan already matched 34 separate duplicated blocks between them, totalling at least 445 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7449` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 4) mistralrs-quant/src/gguf/fast_mmq.rs:619 — mistralrs-quant/src/gguf/fast_mmq.rs:619-626 | mistralrs-quant/src/gguf/fast_mmq.rs:889-896 | mistralrs-quant/src/gguf/fast_mmq.rs:1358-1365 | mistralrs-quant/src/gguf/fast_mmvq.rs:878-887 — before extracting anything, compare `mistralrs-quant/src/gguf/fast_mmq.rs` and `mistralrs-quant/src/gguf/fast_mmvq.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 62 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/gguf/fast_mmvq.rs:878` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 4) mistralrs-quant/src/cutile/nvfp4_matmul.rs:647 — mistralrs-quant/src/cutile/nvfp4_matmul.rs:647-655 | mistralrs-quant/src/cutile/nvfp4_matmul.rs:692-699 | mistralrs-quant/src/embedding/packing.rs:35-43 | mistralrs-quant/src/nvfp4/portable.rs:310-318 — before extracting anything, compare `mistralrs-quant/src/cutile/nvfp4_matmul.rs` and `mistralrs-quant/src/nvfp4/portable.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 64 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cutile/nvfp4_matmul.rs:647` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 4) mistralrs-quant/src/utils/ops.rs:156 — mistralrs-quant/src/utils/ops.rs:156-163 | mistralrs-quant/src/utils/ops.rs:756-763 | mistralrs-quant/src/utils/ops.rs:857-865 | mistralrs-quant/src/utils/ops.rs:964-972 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (8 lines × 4) mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:805 — mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:805-812 | mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:208-215 | mistralrs-core/src/vision_models/phi3/phi3_inputs_processor.rs:164-171 | mistralrs-core/src/vision_models/phi4/inputs_processor.rs:245-252 — before extracting anything, compare `mistralrs-core/src/vision_models/gemma4/inputs_processor.rs` and `mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 45 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:805` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 4) scripts/production_soak.py:3966 — scripts/production_soak.py:3966-3973 | scripts/production_soak.py:3977-3984 | scripts/production_soak.py:4028-4035 | scripts/production_soak.py:4088-4095 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
D2 · Cognitive Complexity · mistralrs_paged_attn · ×15
  • mistralrs_paged_attn::metal::backend::paged_prefill::metal_paged_prefill (cognitive 61) mistralrs-paged-attn/src/metal/backend/paged_prefill.rs:434 — mistralrs_paged_attn::metal::backend::paged_prefill::metal_paged_prefill has cognitive complexity 61 (threshold 15). Drivers by points: if/else 23 (35 pts), boolean chains 13, loops 8 (11 pts), match/switch 2 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_paged_attn::cuda::backend::flashinfer::flashinfer_decode (cognitive 52) mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:241 — mistralrs_paged_attn::cuda::backend::flashinfer::flashinfer_decode has cognitive complexity 52 (threshold 15). Drivers by points: if/else 21 (24 pts), match/switch 19 (21 pts), boolean chains 6, loops 1 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • mistralrs_paged_attn::cuda::backend::cache::copy_blocks (cognitive 46) mistralrs-paged-attn/src/cuda/backend/cache.rs:26 — mistralrs_paged_attn::cuda::backend::cache::copy_blocks has cognitive complexity 46 (threshold 15). Drivers by points: if/else 18 (27 pts), boolean chains 9, loops 5 (7 pts), match/switch 2 (3 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_paged_attn::cuda::backend::gather_kv::gather_kv_cache (cognitive 31) mistralrs-paged-attn/src/cuda/backend/gather_kv.rs:54 — mistralrs_paged_attn::cuda::backend::gather_kv::gather_kv_cache has cognitive complexity 31 (threshold 15). Drivers by points: match/switch 14 (16 pts), if/else 15 (nesting depth added 2). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • mistralrs_paged_attn::cuda::backend::mla::flashinfer_mla_decode (cognitive 30) mistralrs-paged-attn/src/cuda/backend/mla.rs:227 — mistralrs_paged_attn::cuda::backend::mla::flashinfer_mla_decode has cognitive complexity 30 (threshold 15). Drivers by points: match/switch 14, if/else 11, boolean chains 5. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • mistralrs_paged_attn::cuda::backend::paged_attention::update_cache (cognitive 26) mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:538 — mistralrs_paged_attn::cuda::backend::paged_attention::update_cache has cognitive complexity 26 (threshold 15). Drivers by points: if/else 12 (14 pts), match/switch 9 (11 pts), boolean chains 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • mistralrs_paged_attn::metal::backend::paged_attention::reshape_and_cache (cognitive 25) mistralrs-paged-attn/src/metal/backend/paged_attention.rs:767 — mistralrs_paged_attn::metal::backend::paged_attention::reshape_and_cache has cognitive complexity 25 (threshold 15). Drivers by points: match/switch 9 (11 pts), if/else 8 (10 pts), boolean chains 4 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_paged_attn::metal::backend::paged_attention::prepare_decode_kernels (cognitive 22) mistralrs-paged-attn/src/metal/backend/paged_attention.rs:16 — mistralrs_paged_attn::metal::backend::paged_attention::prepare_decode_kernels has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (12 pts), loops 3 (6 pts), match/switch 1 (3 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_paged_attn::cuda::backend::fa3::fa3_prepare_paged_metadata (cognitive 20) mistralrs-paged-attn/src/cuda/backend/fa3.rs:108 — mistralrs_paged_attn::cuda::backend::fa3::fa3_prepare_paged_metadata has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (9 pts), match/switch 7, boolean chains 3, loops 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
  • mistralrs_paged_attn::cuda::backend::flashinfer::gather_kv_cache_flashinfer (cognitive 19) mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:550 — mistralrs_paged_attn::cuda::backend::flashinfer::gather_kv_cache_flashinfer has cognitive complexity 19 (threshold 15). Drivers by points: match/switch 10, if/else 8, boolean chains 1. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • mistralrs_paged_attn::metal::backend::cache::swap_blocks (cognitive 19) mistralrs-paged-attn/src/metal/backend/cache.rs:112 — mistralrs_paged_attn::metal::backend::cache::swap_blocks has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (11 pts), loops 2 (4 pts), match/switch 2 (3 pts), boolean chains 1 (nesting depth added 8). Of this number, 17 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mistralrs_paged_attn::metal::backend::gather_kv::gather_kv_cache (cognitive 18) mistralrs-paged-attn/src/metal/backend/gather_kv.rs:9 — mistralrs_paged_attn::metal::backend::gather_kv::gather_kv_cache has cognitive complexity 18 (threshold 15). Drivers by points: match/switch 10 (12 pts), if/else 6 (nesting depth added 2). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • mistralrs_paged_attn::cuda::backend::cache::swap_blocks (cognitive 17) mistralrs-paged-attn/src/cuda/backend/cache.rs:264 — mistralrs_paged_attn::cuda::backend::cache::swap_blocks has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (10 pts), loops 2 (4 pts), match/switch 2 (3 pts) (nesting depth added 8). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • mistralrs_paged_attn::cuda::backend::flashinfer::reshape_and_cache_flashinfer (cognitive 17) mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:71 — mistralrs_paged_attn::cuda::backend::flashinfer::reshape_and_cache_flashinfer has cognitive complexity 17 (threshold 15). Drivers by points: match/switch 9, if/else 6, boolean chains 2. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • mistralrs_paged_attn::cuda::backend::mla::concat_and_cache_mla (cognitive 16) mistralrs-paged-attn/src/cuda/backend/mla.rs:10 — mistralrs_paged_attn::cuda::backend::mla::concat_and_cache_mla has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7, match/switch 7, boolean chains 2. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D4 · Code Duplication · Edited copy of a member (18 corresponding lines) · ×15
  • Edited copy of a member (18 corresponding lines) mistralrs-core/src/matformer.rs:95 — mistralrs-core/src/matformer.rs:95-112 | mistralrs-core/src/matformer.rs:114-133 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) mistralrs-core/src/gguf/normal_config.rs:1201 — mistralrs-core/src/gguf/normal_config.rs:1201-1218 | mistralrs-core/src/gguf/normal_config.rs:1391-1409 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:721 — mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:721-745 | mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:752-769 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) mistralrs-core/src/vision_models/grid_processor.rs:465 — mistralrs-core/src/vision_models/grid_processor.rs:465-482 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:248-265 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) mistralrs-code-exec/src/lib.rs:311 — mistralrs-code-exec/src/lib.rs:311-337 | mistralrs-code-exec/src/shell.rs:334-351 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1864 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1864-1881 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2164-2181 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) mistralrs-core/src/tools/parsers/deepseek.rs:37 — mistralrs-core/src/tools/parsers/deepseek.rs:37-54 | mistralrs-core/src/tools/parsers/harmony.rs:61-81 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5596 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5596-5613 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:11026-11043 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:10131 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:10131-10149 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:10155-10172 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) mistralrs-core/src/sampler.rs:1780 — mistralrs-core/src/sampler.rs:1780-1797 | mistralrs-core/src/speculative/verifier.rs:1393-1410 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5561 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5561-5578 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6832-6854 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) mistralrs-core/src/models/granite.rs:2424 — mistralrs-core/src/models/granite.rs:2424-2441 | mistralrs-core/src/models/granite.rs:2442-2459 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) mistralrs-server-core/src/anthropic.rs:1293 — mistralrs-server-core/src/anthropic.rs:1293-1310 | mistralrs-server-core/src/anthropic.rs:1312-1329 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) mistralrs-core/src/kv_cache/hybrid_cache.rs:910 — mistralrs-core/src/kv_cache/hybrid_cache.rs:910-927 | mistralrs-core/src/kv_cache/hybrid_cache.rs:1338-1355 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) scripts/convert_awq_marlin.py:30 — scripts/convert_awq_marlin.py:30-47 | scripts/convert_awq_marlin.py:56-78 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Duplicated block (13 lines × 3) · ×15
  • Duplicated block (13 lines × 3) mistralrs-core/src/embedding_models/embedding_gemma.rs:539 — mistralrs-core/src/embedding_models/embedding_gemma.rs:539-551 | mistralrs-core/src/models/gemma2.rs:610-622 | mistralrs-core/src/vision_models/gemma3/text.rs:858-870 — before extracting anything, compare `mistralrs-core/src/embedding_models/embedding_gemma.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 175 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/embedding_gemma.rs:539` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 3) mistralrs-core/src/models/gemma.rs:208 — mistralrs-core/src/models/gemma.rs:208-223 | mistralrs-core/src/models/phi2.rs:304-319 | mistralrs-core/src/vision_models/gemma3/text.rs:258-270 — before extracting anything, compare `mistralrs-core/src/models/gemma.rs` and `mistralrs-core/src/models/phi2.rs` as WHOLE FILES: this scan already matched 36 separate duplicated blocks between them, totalling at least 418 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma.rs:208` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 3) mistralrs-core/src/models/qwen3_next.rs:1086 — mistralrs-core/src/models/qwen3_next.rs:1086-1098 | mistralrs-core/src/vision_models/qwen3_5/text.rs:1551-1563 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:887-899 — before extracting anything, compare `mistralrs-core/src/models/qwen3_next.rs` and `mistralrs-core/src/vision_models/qwen3_5/text.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 176 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (13 lines × 3) mistralrs-core/src/pipeline/cuda_graph.rs:3619 — mistralrs-core/src/pipeline/cuda_graph.rs:3619-3631 | mistralrs-core/src/pipeline/cuda_graph.rs:3664-3676 | mistralrs-core/src/pipeline/cuda_graph.rs:3709-3721 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/cuda_graph.rs:3619` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (13 lines × 3) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1671 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1671-1683 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1979-1991 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4908-4920 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (13 lines × 3) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4786 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4786-4798 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1076-1088 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6655-6667 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` and `mistralrs-core/src/pipeline/loaders/normal_loaders.rs` as WHOLE FILES: this scan already matched 34 separate duplicated blocks between them, totalling at least 445 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4786` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 3) mistralrs-core/src/vision_models/grid_processor.rs:1036 — mistralrs-core/src/vision_models/grid_processor.rs:1036-1048 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:256-268 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:822-834 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:1036` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 3) mistralrs-core/src/vision_models/grid_processor.rs:1362 — mistralrs-core/src/vision_models/grid_processor.rs:1362-1374 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:562-574 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1170-1182 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:1362` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 3) mistralrs-core/src/vision_models/grid_processor.rs:1963 — mistralrs-core/src/vision_models/grid_processor.rs:1963-1975 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:1044-1056 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1609-1621 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:1963` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 3) mistralrs-core/src/vision_models/qwen3_5/config.rs:382 — mistralrs-core/src/vision_models/qwen3_5/config.rs:382-394 | mistralrs-core/src/vision_models/qwen3_5_moe/config.rs:192-204 | mistralrs-core/src/vision_models/qwen4_exp/config.rs:372-384 — `mistralrs-core/src/vision_models/qwen3_5/config.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/config.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 2 separate duplicated blocks between them, totalling at least 101 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/vision_models/qwen3_5/config.rs:396` calls `linear_key_dim` and `mistralrs-core/src/vision_models/qwen4_exp/config.rs:386` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (13 lines × 3) mistralrs-core/src/xlora_models/classifier.rs:46 — mistralrs-core/src/xlora_models/classifier.rs:46-58 | mistralrs-core/src/xlora_models/classifier.rs:109-121 | mistralrs-core/src/xlora_models/classifier.rs:201-213 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/classifier.rs:46` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 3) mistralrs-quant/src/safetensors.rs:745 — mistralrs-quant/src/safetensors.rs:745-757 | mistralrs-quant/src/safetensors.rs:795-807 | mistralrs-quant/src/safetensors.rs:870-882 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (13 lines × 3) mistralrs-core/src/vision_models/grid_processor.rs:1934 — mistralrs-core/src/vision_models/grid_processor.rs:1934-1946 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:1023-1035 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1588-1600 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:1934` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 3) mistralrs-core/src/vision_models/grid_processor.rs:1376 — mistralrs-core/src/vision_models/grid_processor.rs:1376-1388 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:576-588 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1184-1196 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:1376` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (13 lines × 3) mistralrs-core/src/models/granite.rs:2195 — mistralrs-core/src/models/granite.rs:2195-2207 | mistralrs-core/src/models/lfm2.rs:1184-1196 | mistralrs-core/src/models/lfm3.rs:1179-1191 — before extracting anything, compare `mistralrs-core/src/models/granite.rs` and `mistralrs-core/src/models/lfm2.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 79 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/models/lfm2.rs:1197` calls `is_none` and `mistralrs-core/src/models/granite.rs:2208` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D1 · Cyclomatic Complexity · mistralrs_paged_attn · ×14
  • mistralrs_paged_attn::cuda::backend::flashinfer::flashinfer_decode (cyclomatic 54) mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:241 — mistralrs_paged_attn::cuda::backend::flashinfer::flashinfer_decode has cyclomatic complexity 54 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • mistralrs_paged_attn::metal::backend::paged_prefill::metal_paged_prefill (cyclomatic 42) mistralrs-paged-attn/src/metal/backend/paged_prefill.rs:434 — mistralrs_paged_attn::metal::backend::paged_prefill::metal_paged_prefill has cyclomatic complexity 42 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_paged_attn::cuda::backend::cache::copy_blocks (cyclomatic 41) mistralrs-paged-attn/src/cuda/backend/cache.rs:26 — mistralrs_paged_attn::cuda::backend::cache::copy_blocks has cyclomatic complexity 41 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_paged_attn::cuda::backend::gather_kv::gather_kv_cache (cyclomatic 38) mistralrs-paged-attn/src/cuda/backend/gather_kv.rs:54 — mistralrs_paged_attn::cuda::backend::gather_kv::gather_kv_cache has cyclomatic complexity 38 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • mistralrs_paged_attn::cuda::backend::mla::flashinfer_mla_decode (cyclomatic 35) mistralrs-paged-attn/src/cuda/backend/mla.rs:227 — mistralrs_paged_attn::cuda::backend::mla::flashinfer_mla_decode has cyclomatic complexity 35 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • mistralrs_paged_attn::cuda::backend::flashinfer::reshape_and_cache_flashinfer (cyclomatic 28) mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:71 — mistralrs_paged_attn::cuda::backend::flashinfer::reshape_and_cache_flashinfer has cyclomatic complexity 28 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • mistralrs_paged_attn::cuda::backend::flashinfer::gather_kv_cache_flashinfer (cyclomatic 28) mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:550 — mistralrs_paged_attn::cuda::backend::flashinfer::gather_kv_cache_flashinfer has cyclomatic complexity 28 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • mistralrs_paged_attn::cuda::backend::paged_attention::update_cache (cyclomatic 26) mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:538 — mistralrs_paged_attn::cuda::backend::paged_attention::update_cache has cyclomatic complexity 26 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • mistralrs_paged_attn::metal::backend::paged_attention::reshape_and_cache (cyclomatic 26) mistralrs-paged-attn/src/metal/backend/paged_attention.rs:767 — mistralrs_paged_attn::metal::backend::paged_attention::reshape_and_cache has cyclomatic complexity 26 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • mistralrs_paged_attn::cuda::backend::mla::concat_and_cache_mla (cyclomatic 21) mistralrs-paged-attn/src/cuda/backend/mla.rs:10 — mistralrs_paged_attn::cuda::backend::mla::concat_and_cache_mla has cyclomatic complexity 21 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • mistralrs_paged_attn::metal::backend::gather_kv::gather_kv_cache (cyclomatic 21) mistralrs-paged-attn/src/metal/backend/gather_kv.rs:9 — mistralrs_paged_attn::metal::backend::gather_kv::gather_kv_cache has cyclomatic complexity 21 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • mistralrs_paged_attn::cuda::backend::fa3::fa3_prepare_paged_metadata (cyclomatic 19) mistralrs-paged-attn/src/cuda/backend/fa3.rs:108 — mistralrs_paged_attn::cuda::backend::fa3::fa3_prepare_paged_metadata has cyclomatic complexity 19 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • mistralrs_paged_attn::cuda::backend::mla::gather_mla_cache (cyclomatic 19) mistralrs-paged-attn/src/cuda/backend/mla.rs:643 — mistralrs_paged_attn::cuda::backend::mla::gather_mla_cache has cyclomatic complexity 19 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • mistralrs_paged_attn::metal::backend::cache::swap_blocks (cyclomatic 16) mistralrs-paged-attn/src/metal/backend/cache.rs:112 — mistralrs_paged_attn::metal::backend::cache::swap_blocks has cyclomatic complexity 16 (threshold 15). Of this number, 15 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · mistralrs_cli · ×14
  • mistralrs_cli::commands::run::interactive::print_agentic_progress (cyclomatic 38) mistralrs-cli/src/commands/run/interactive.rs:1111 — mistralrs_cli::commands::run::interactive::print_agentic_progress has cyclomatic complexity 38 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
  • mistralrs_cli::commands::bench::run_bench (cyclomatic 36) mistralrs-cli/src/commands/bench.rs:80 — mistralrs_cli::commands::bench::run_bench has cyclomatic complexity 36 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_cli::commands::run::interactive::multimodal_interactive_mode (cyclomatic 33) mistralrs-cli/src/commands/run/interactive.rs:1529 — mistralrs_cli::commands::run::interactive::multimodal_interactive_mode has cyclomatic complexity 33 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_cli::commands::doctor::run_doctor (cyclomatic 30) mistralrs-cli/src/commands/doctor.rs:6 — mistralrs_cli::commands::doctor::run_doctor has cyclomatic complexity 30 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_cli::commands::run::interactive::stream_assistant_response (cyclomatic 29) mistralrs-cli/src/commands/run/interactive.rs:1415 — mistralrs_cli::commands::run::interactive::stream_assistant_response has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_cli::commands::serve::apply_quant_resolution (cyclomatic 26) mistralrs-cli/src/commands/serve.rs:978 — mistralrs_cli::commands::serve::apply_quant_resolution has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_cli::commands::tune::run_tune (cyclomatic 24) mistralrs-cli/src/commands/tune.rs:14 — mistralrs_cli::commands::tune::run_tune has cyclomatic complexity 24 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • mistralrs_cli::commands::run::interactive::text_interactive_mode (cyclomatic 17) mistralrs-cli/src/commands/run/interactive.rs:869 — mistralrs_cli::commands::run::interactive::text_interactive_mode has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_cli::commands::serve::convert_to_model_selected (cyclomatic 17) mistralrs-cli/src/commands/serve.rs:296 — mistralrs_cli::commands::serve::convert_to_model_selected has cyclomatic complexity 17 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • mistralrs_cli::commands::quantize::resolve_gguf_source (cyclomatic 16) mistralrs-cli/src/commands/quantize.rs:105 — mistralrs_cli::commands::quantize::resolve_gguf_source has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_cli::commands::quantize::run_quantize (cyclomatic 16) mistralrs-cli/src/commands/quantize.rs:238 — mistralrs_cli::commands::quantize::run_quantize has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_cli::commands::run::interactive::oneshot_multimodal (cyclomatic 16) mistralrs-cli/src/commands/run/interactive.rs:338 — mistralrs_cli::commands::run::interactive::oneshot_multimodal has cyclomatic complexity 16 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • mistralrs_cli::commands::run::interactive::agent_approval_callback (cyclomatic 16) mistralrs-cli/src/commands/run/interactive.rs:1321 — mistralrs_cli::commands::run::interactive::agent_approval_callback has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_cli::ui::handlers::api::validate_text_upload (cyclomatic 16) mistralrs-cli/src/ui/handlers/api.rs:101 — mistralrs_cli::ui::handlers::api::validate_text_upload has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D29 · Static Analysis (SAST) · REDACTED · ×14
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Edited copy of a member (23 corresponding lines) · ×14
  • Edited copy of a member (23 corresponding lines) mistralrs-core/src/tools/parsers/gemma4.rs:286 — mistralrs-core/src/tools/parsers/gemma4.rs:286-326 | mistralrs-core/src/tools/parsers/gemma4.rs:329-360 — These two members are one piece of code written twice and then edited apart: 23 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (23 corresponding lines) REDACTED:431 — REDACTED:431-453 | REDACTED:776-799 — These two members are one piece of code written twice and then edited apart: 23 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (23 corresponding lines) mistralrs-core/src/kv_cache/hybrid_cache.rs:179 — mistralrs-core/src/kv_cache/hybrid_cache.rs:179-210 | mistralrs-core/src/kv_cache/hybrid_cache.rs:343-365 — These two members are one piece of code written twice and then edited apart: 23 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (23 corresponding lines) mistralrs-core/src/models/mixtral.rs:281 — mistralrs-core/src/models/mixtral.rs:281-303 | mistralrs-core/src/vision_models/llama4/text.rs:589-617 — These two members are one piece of code written twice and then edited apart: 23 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (23 corresponding lines) mistralrs-core/src/gdn/layer.rs:136 — mistralrs-core/src/gdn/layer.rs:136-158 | mistralrs-core/src/gdn/layer.rs:160-183 — These two members are one piece of code written twice and then edited apart: 23 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (23 corresponding lines) mistralrs-core/src/ops.rs:2756 — mistralrs-core/src/ops.rs:2756-2783 | mistralrs-core/src/ops.rs:2807-2829 — These two members are one piece of code written twice and then edited apart: 23 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (23 corresponding lines) mistralrs-quant/src/utils/ops.rs:2404 — mistralrs-quant/src/utils/ops.rs:2404-2426 | mistralrs-quant/src/utils/ops.rs:2574-2597 — These two members are one piece of code written twice and then edited apart: 23 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (23 corresponding lines) mistralrs-core/src/lib.rs:2607 — mistralrs-core/src/lib.rs:2607-2631 | mistralrs-core/src/lib.rs:2634-2656 — These two members are one piece of code written twice and then edited apart: 23 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (23 corresponding lines) mistralrs-core/src/models/lfm2.rs:229 — mistralrs-core/src/models/lfm2.rs:229-251 | mistralrs-core/src/models/lfm3.rs:330-365 — These two members are one piece of code written twice and then edited apart: 23 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (23 corresponding lines) mistralrs-core/src/xlora_models/gemma.rs:374 — mistralrs-core/src/xlora_models/gemma.rs:374-396 | mistralrs-core/src/xlora_models/starcoder2.rs:359-381 — These two members are one piece of code written twice and then edited apart: 23 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (23 corresponding lines) mistralrs-server-core/src/openai.rs:57 — mistralrs-server-core/src/openai.rs:57-79 | mistralrs-server-core/src/openai.rs:238-260 — These two members are one piece of code written twice and then edited apart: 23 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (23 corresponding lines) mistralrs-quant/src/bitsandbytes/mod.rs:203 — mistralrs-quant/src/bitsandbytes/mod.rs:203-227 | mistralrs-quant/src/mxfp4/mod.rs:63-85 — These two members are one piece of code written twice and then edited apart: 23 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (23 corresponding lines) mistralrs-core/src/vision_models/qwen3_5/text.rs:1271 — mistralrs-core/src/vision_models/qwen3_5/text.rs:1271-1293 | mistralrs-core/src/vision_models/qwen4_exp/text.rs:549-577 — These two members are one piece of code written twice and then edited apart: 23 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (23 corresponding lines) examples/python/code_execution_approval.py:47 — examples/python/code_execution_approval.py:47-69 | examples/python/shell_skills.py:62-90 — These two members are one piece of code written twice and then edited apart: 23 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Duplicated block (12 lines × 3) · ×14
  • Duplicated block (12 lines × 3) mistralrs-core/src/cuda/gdn.rs:2359 — mistralrs-core/src/cuda/gdn.rs:2359-2370 | mistralrs-core/src/cuda/gdn.rs:2673-2684 | mistralrs-core/src/cuda/gdn.rs:2972-2983 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (12 lines × 3) mistralrs-core/src/layers.rs:1158 — mistralrs-core/src/layers.rs:1158-1169 | mistralrs-core/src/layers.rs:1248-1259 | mistralrs-core/src/layers.rs:1517-1528 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/layers.rs:1158` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (12 lines × 3) mistralrs-core/src/models/deepseek2.rs:457 — mistralrs-core/src/models/deepseek2.rs:457-468 | mistralrs-core/src/models/deepseek3.rs:458-469 | mistralrs-core/src/models/glm4_moe_lite.rs:422-433 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:457` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 3) mistralrs-core/src/models/granite.rs:1487 — mistralrs-core/src/models/granite.rs:1487-1498 | mistralrs-core/src/models/granite.rs:1773-1784 | mistralrs-core/src/vision_models/llama4/text.rs:696-707 — before extracting anything, compare `mistralrs-core/src/models/granite.rs` and `mistralrs-core/src/vision_models/llama4/text.rs` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 151 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/granite.rs:1487` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 3) mistralrs-core/src/models/llama.rs:220 — mistralrs-core/src/models/llama.rs:220-231 | mistralrs-core/src/models/smollm3.rs:237-248 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:193-204 — before extracting anything, compare `mistralrs-core/src/models/llama.rs` and `mistralrs-core/src/models/smollm3.rs` as WHOLE FILES: this scan already matched 47 separate duplicated blocks between them, totalling at least 727 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/llama.rs:220` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 3) mistralrs-core/src/ops.rs:5597 — mistralrs-core/src/ops.rs:5597-5608 | mistralrs-core/src/ops.rs:6026-6037 | mistralrs-core/src/ops.rs:6362-6373 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/ops.rs:5609` calls `is_some_and`, `dtype` and `mistralrs-core/src/ops.rs:6374` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12 lines × 3) mistralrs-core/src/pipeline/loaders/lfm3.rs:243 — mistralrs-core/src/pipeline/loaders/lfm3.rs:243-254 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5135-5146 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:7161-7172 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/lfm3.rs` and `mistralrs-core/src/pipeline/loaders/normal_loaders.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (12 lines × 3) mistralrs-core/src/vision_models/gemma4/mod.rs:539 — mistralrs-core/src/vision_models/gemma4/mod.rs:539-550 | mistralrs-core/src/vision_models/gemma4/mod.rs:662-673 | mistralrs-core/src/vision_models/gemma4/mod.rs:852-863 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma4/mod.rs:539` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 3) mistralrs-core/src/vision_models/grid_processor.rs:1846 — mistralrs-core/src/vision_models/grid_processor.rs:1846-1857 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:986-997 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1551-1562 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:1846` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 3) mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:336 — mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:336-347 | mistralrs-core/src/vision_models/mllama/text.rs:280-291 | mistralrs-core/src/vision_models/mllama/text.rs:639-650 — before extracting anything, compare `mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs` and `mistralrs-core/src/vision_models/mllama/text.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 45 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:336` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (12 lines × 3) mistralrs-quant/src/moe/cuda.rs:231 — mistralrs-quant/src/moe/cuda.rs:231-242 | mistralrs-quant/src/moe/cuda.rs:267-278 | mistralrs-quant/src/moe/cuda.rs:307-318 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/moe/cuda.rs:231` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 3) mistralrs/src/model_builder_trait.rs:869 — mistralrs/src/model_builder_trait.rs:869-880 | mistralrs/src/model_builder_trait.rs:1232-1243 | mistralrs/src/model_builder_trait.rs:1648-1659 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs/src/model_builder_trait.rs:869` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs/src/model_builder_trait.rs:866` calls `clone` and `mistralrs/src/model_builder_trait.rs:1231` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12 lines × 3) mistralrs-quant/src/cutile/fp8_gemm.rs:144 — mistralrs-quant/src/cutile/fp8_gemm.rs:144-155 | mistralrs-quant/src/cutile/fp8_w8a16.rs:211-222 | mistralrs-quant/src/cutile/fp8_w8a8.rs:216-227 — before extracting anything, compare `mistralrs-quant/src/cutile/fp8_gemm.rs` and `mistralrs-quant/src/cutile/fp8_w8a16.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 40 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (12 lines × 3) mistralrs-core/src/speech_models/dia/model.rs:330 — mistralrs-core/src/speech_models/dia/model.rs:330-341 | mistralrs-core/src/speech_models/dia/model.rs:589-600 | mistralrs-core/src/speech_models/dia/model.rs:602-613 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
D4 · Code Duplication · Edited copy of a member (7 corresponding lines) · ×13
  • Edited copy of a member (7 corresponding lines) mistralrs-core/src/engine/agentic_loop.rs:208 — mistralrs-core/src/engine/agentic_loop.rs:208-214 | mistralrs-core/src/engine/agentic_loop.rs:239-245 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (7 corresponding lines) mistralrs-core/src/layers.rs:657 — mistralrs-core/src/layers.rs:657-663 | mistralrs-core/src/vision_models/gemma4/mtp.rs:417-424 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (7 corresponding lines) mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:311 — mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:311-317 | mistralrs-core/src/vision_models/qwen2vl/vision.rs:283-289 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (7 corresponding lines) mistralrs-core/src/diffusion_models/t5/mod.rs:151 — mistralrs-core/src/diffusion_models/t5/mod.rs:151-160 | mistralrs-core/src/vision_models/muse_glimmer/vision.rs:17-23 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (7 corresponding lines) mistralrs-core/src/kv_cache/hybrid_cache.rs:802 — mistralrs-core/src/kv_cache/hybrid_cache.rs:802-808 | mistralrs-core/src/kv_cache/hybrid_cache.rs:849-856 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (7 corresponding lines) mistralrs-mcp/src/tools.rs:79 — mistralrs-mcp/src/tools.rs:79-85 | mistralrs-mcp/src/tools.rs:106-112 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (7 corresponding lines) REDACTED:752 — REDACTED:752-760 | mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:125-131 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (7 corresponding lines) mistralrs-core/src/gguf/qwen4exp.rs:555 — mistralrs-core/src/gguf/qwen4exp.rs:555-562 | mistralrs-core/src/gguf/lfm3_vl_config.rs:250-256 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (7 corresponding lines) mistralrs-core/src/paged_attention/scheduler.rs:1487 — mistralrs-core/src/paged_attention/scheduler.rs:1487-1497 | mistralrs-core/src/scheduler/default_scheduler.rs:364-370 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (7 corresponding lines) mistralrs-core/src/kv_cache/rotating_cache.rs:74 — mistralrs-core/src/kv_cache/rotating_cache.rs:74-80 | mistralrs-core/src/kv_cache/single_cache.rs:50-56 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (7 corresponding lines) mistralrs-core/src/lib.rs:2267 — mistralrs-core/src/lib.rs:2267-2273 | mistralrs-pyo3/src/util.rs:97-103 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (7 corresponding lines) mistralrs-quant/src/cutile/fp8_w8a16.rs:153 — mistralrs-quant/src/cutile/fp8_w8a16.rs:153-159 | mistralrs-quant/src/cutile/fp8_w8a8.rs:102-108 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (7 corresponding lines) mistralrs-core/src/cuda/hyper_connection.rs:170 — mistralrs-core/src/cuda/hyper_connection.rs:170-176 | mistralrs-core/src/cuda/qwen4_exp.rs:228-234 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Duplicated block (16 lines × 3) · ×13
  • Duplicated block (16 lines × 3) mistralrs-core/src/model_loader.rs:199 — mistralrs-core/src/model_loader.rs:199-214 | mistralrs-core/src/model_loader.rs:224-239 | mistralrs-core/src/model_loader.rs:248-263 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/model_loader.rs:199` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 3) mistralrs-core/src/models/phi3.rs:195 — mistralrs-core/src/models/phi3.rs:195-210 | mistralrs-core/src/vision_models/phi3/mod.rs:286-301 | mistralrs-core/src/vision_models/phi4/mod.rs:155-170 — before extracting anything, compare `mistralrs-core/src/models/phi3.rs` and `mistralrs-core/src/vision_models/phi3/mod.rs` as WHOLE FILES: this scan already matched 50 separate duplicated blocks between them, totalling at least 638 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/phi3.rs:195` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 3) mistralrs-core/src/models/phi3.rs:481 — mistralrs-core/src/models/phi3.rs:481-496 | mistralrs-core/src/vision_models/phi3/mod.rs:1262-1277 | mistralrs-core/src/vision_models/phi4/mod.rs:377-392 — before extracting anything, compare `mistralrs-core/src/models/phi3.rs` and `mistralrs-core/src/vision_models/phi3/mod.rs` as WHOLE FILES: this scan already matched 50 separate duplicated blocks between them, totalling at least 638 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/phi3.rs:481` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (16 lines × 3) mistralrs-core/src/ops.rs:5836 — mistralrs-core/src/ops.rs:5836-5851 | mistralrs-core/src/ops.rs:6273-6288 | mistralrs-core/src/ops.rs:6599-6614 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (16 lines × 3) mistralrs-core/src/pipeline/embedding.rs:485 — mistralrs-core/src/pipeline/embedding.rs:485-500 | mistralrs-core/src/pipeline/multimodal.rs:1055-1070 | mistralrs-core/src/pipeline/normal.rs:1058-1073 — before extracting anything, compare `mistralrs-core/src/pipeline/embedding.rs` and `mistralrs-core/src/pipeline/multimodal.rs` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 178 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/embedding.rs:485` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 3) mistralrs-core/src/vision_models/grid_processor.rs:1081 — mistralrs-core/src/vision_models/grid_processor.rs:1081-1096 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:298-313 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:864-879 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:1081` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 3) mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:213 — mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:213-228 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:214-229 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:320-335 — `mistralrs-core/src/vision_models/qwen3_5_moe/text.rs` and `mistralrs-core/src/vision_models/qwen3_vl/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 18 separate duplicated blocks between them, totalling at least 207 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:213` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/vision_models/qwen3_vl/text.rs:231` calls `contiguous` and `mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:231` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (16 lines × 3) mistralrs-core/src/xlora_models/mistral.rs:523 — mistralrs-core/src/xlora_models/mistral.rs:523-538 | mistralrs-core/src/xlora_models/mixtral.rs:653-668 | mistralrs-core/src/xlora_models/starcoder2.rs:506-521 — before extracting anything, compare `mistralrs-core/src/xlora_models/mistral.rs` and `mistralrs-core/src/xlora_models/mixtral.rs` as WHOLE FILES: this scan already matched 53 separate duplicated blocks between them, totalling at least 787 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/mistral.rs:523` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/xlora_models/mistral.rs:539` calls `dtype` and `mistralrs-core/src/xlora_models/starcoder2.rs:522` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (16 lines × 3) mistralrs-core/src/xlora_models/quantized_llama.rs:429 — mistralrs-core/src/xlora_models/quantized_llama.rs:429-444 | mistralrs-core/src/xlora_models/quantized_llama.rs:731-746 | mistralrs-core/src/xlora_models/quantized_phi3.rs:393-408 — before extracting anything, compare `mistralrs-core/src/xlora_models/quantized_llama.rs` and `mistralrs-core/src/xlora_models/quantized_phi3.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 219 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/quantized_llama.rs:429` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 3) mistralrs-quant/src/utils/ops.rs:2837 — mistralrs-quant/src/utils/ops.rs:2837-2852 | mistralrs-quant/src/utils/ops.rs:2864-2879 | mistralrs-quant/src/utils/ops.rs:2891-2906 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/utils/ops.rs:2837` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 3) mistralrs/src/model.rs:317 — mistralrs/src/model.rs:317-332 | mistralrs/src/model.rs:387-402 | mistralrs/src/model.rs:475-490 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs/src/model.rs:317` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 3) mistralrs/src/model_builder_trait.rs:783 — mistralrs/src/model_builder_trait.rs:783-798 | mistralrs/src/model_builder_trait.rs:936-951 | mistralrs/src/model_builder_trait.rs:1560-1575 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs/src/model_builder_trait.rs:783` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 3) mistralrs-quant/src/gguf/fast_mmq.rs:909 — mistralrs-quant/src/gguf/fast_mmq.rs:909-924 | mistralrs-quant/src/gguf/fast_mmq.rs:1110-1125 | mistralrs-quant/src/gguf/fast_mmq.rs:1378-1393 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
D4 · Code Duplication · Duplicated block (7 lines × 4) · ×13
  • Duplicated block (7 lines × 4) mistralrs-core/src/ops.rs:4473 — mistralrs-core/src/ops.rs:4473-4479 | mistralrs-core/src/ops.rs:5433-5439 | mistralrs-core/src/ops.rs:5705-5711 | mistralrs-core/src/ops.rs:6128-6134 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:4473` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/ops.rs:5431` calls `contiguous` and `mistralrs-core/src/ops.rs:4470` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 4) mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:530 — mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:530-536 | mistralrs-core/src/vision_models/qwen2vl/text.rs:532-538 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:517-523 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:638-644 — `mistralrs-core/src/vision_models/qwen2_5_vl/text.rs` and `mistralrs-core/src/vision_models/qwen2vl/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 42 separate duplicated blocks between them, totalling at least 716 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:538` calls `clone` and `mistralrs-core/src/vision_models/qwen3_vl/text.rs:524` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 4) mistralrs-core/src/vision_models/qwen3_5/text.rs:1467 — mistralrs-core/src/vision_models/qwen3_5/text.rs:1467-1473 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:838-844 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:570-576 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:691-697 — `mistralrs-core/src/vision_models/qwen3_5/text.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 26 separate duplicated blocks between them, totalling at least 469 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_5/text.rs:1467` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 4) mistralrs-core/src/vision_models/qwen3_5/text.rs:1719 — mistralrs-core/src/vision_models/qwen3_5/text.rs:1719-1725 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:943-949 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:559-565 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:680-686 — `mistralrs-core/src/vision_models/qwen3_5/text.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 26 separate duplicated blocks between them, totalling at least 469 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (7 lines × 4) mistralrs-quant/src/blockwise_fp8/ops.rs:1069 — mistralrs-quant/src/blockwise_fp8/ops.rs:1069-1075 | mistralrs-quant/src/blockwise_fp8/ops.rs:1248-1254 | mistralrs-quant/src/mxfp4/ops.rs:67-73 | mistralrs-quant/src/mxfp4/ops.rs:416-422 — `mistralrs-quant/src/blockwise_fp8/ops.rs` and `mistralrs-quant/src/mxfp4/ops.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 8 separate duplicated blocks between them, totalling at least 59 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-quant/src/mxfp4/ops.rs:423` calls `storage_and_layout` and `mistralrs-quant/src/blockwise_fp8/ops.rs:1077` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 4) mistralrs-quant/src/mxfp4/ops.rs:95 — mistralrs-quant/src/mxfp4/ops.rs:95-101 | mistralrs-quant/src/mxfp4/ops.rs:156-162 | mistralrs-quant/src/mxfp4/ops.rs:450-456 | mistralrs-quant/src/mxfp4/ops.rs:518-524 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/mxfp4/ops.rs:95` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-quant/src/mxfp4/ops.rs:102` calls `layout` and `mistralrs-quant/src/mxfp4/ops.rs:457` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 4) mistralrs-core/src/models/gemma2.rs:573 — mistralrs-core/src/models/gemma2.rs:573-579 | mistralrs-core/src/models/qwen2.rs:601-607 | mistralrs-core/src/vision_models/gemma3/text.rs:743-749 | mistralrs-core/src/xlora_models/gemma2.rs:642-648 — before extracting anything, compare `mistralrs-core/src/models/gemma2.rs` and `mistralrs-core/src/models/qwen2.rs` as WHOLE FILES: this scan already matched 38 separate duplicated blocks between them, totalling at least 475 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma2.rs:573` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 4) mistralrs-core/src/vision_models/qwen3_5/mod.rs:184 — mistralrs-core/src/vision_models/qwen3_5/mod.rs:184-190 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:167-173 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:690-696 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:136-142 — `mistralrs-core/src/vision_models/qwen3_5/mod.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 24 separate duplicated blocks between them, totalling at least 425 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (7 lines × 4) mistralrs-core/src/models/phi3.rs:559 — mistralrs-core/src/models/phi3.rs:559-565 | mistralrs-core/src/models/phi3_5_moe.rs:632-638 | mistralrs-core/src/vision_models/phi3/mod.rs:1361-1367 | mistralrs-core/src/vision_models/phi4/mod.rs:523-529 — before extracting anything, compare `mistralrs-core/src/models/phi3.rs` and `mistralrs-core/src/models/phi3_5_moe.rs` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 343 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/phi3.rs:559` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 4) mistralrs-core/src/models/granite.rs:658 — mistralrs-core/src/models/granite.rs:658-666 | mistralrs-core/src/models/lfm2.rs:599-606 | mistralrs-core/src/models/qwen3_next.rs:548-556 | mistralrs-core/src/vision_models/qwen3_5/packed_gdn.rs:29-35 — before extracting anything, compare `mistralrs-core/src/models/granite.rs` and `mistralrs-core/src/models/lfm2.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 79 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/granite.rs:658` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (7 lines × 4) mistralrs-paged-attn/src/metal/backend/gather_kv.rs:97 — mistralrs-paged-attn/src/metal/backend/gather_kv.rs:97-103 | mistralrs-paged-attn/src/metal/backend/gather_kv.rs:107-113 | mistralrs-paged-attn/src/metal/backend/paged_attention.rs:789-797 | mistralrs-paged-attn/src/metal/backend/paged_attention.rs:801-809 — before extracting anything, compare `mistralrs-paged-attn/src/metal/backend/gather_kv.rs` and `mistralrs-paged-attn/src/metal/backend/paged_attention.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 32 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/metal/backend/gather_kv.rs:97` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 4) mistralrs-core/src/ops.rs:2186 — mistralrs-core/src/ops.rs:2186-2192 | mistralrs-core/src/ops.rs:2194-2200 | mistralrs-core/src/ops.rs:3926-3933 | mistralrs-core/src/ops.rs:4053-4060 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:2186` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 4) mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:223 — mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:223-229 | mistralrs-core/src/vision_models/llama4/inputs_processor.rs:227-233 | mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:182-188 | mistralrs-core/src/vision_models/phi3/phi3_inputs_processor.rs:138-144 — before extracting anything, compare `mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs` and `mistralrs-core/src/vision_models/llama4/inputs_processor.rs` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 152 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:223` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D6 · Cohesion (LCOM4) · Low cohesion · ×13
  • Low cohesion: GgufModelBuilder (LCOM4 38) mistralrs/src/gguf.rs:12 — GgufModelBuilder's methods fall into 38 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 38 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: EmbeddingModelBuilder (LCOM4 19) mistralrs/src/embedding_model.rs:15 — EmbeddingModelBuilder's methods fall into 19 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 19 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: RequestBuilder (LCOM4 19) mistralrs/src/messages.rs:571 — RequestBuilder's methods fall into 19 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 19 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: ResponseResource (LCOM4 18) mistralrs-server-core/src/responses_types/resource.rs:144 — ResponseResource's methods fall into 18 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 18 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: ModelBuilder (LCOM4 9) mistralrs/src/auto_model.rs:43 — ModelBuilder's methods fall into 9 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 9 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: TextModelBuilder (LCOM4 9) mistralrs/src/text_model.rs:18 — TextModelBuilder's methods fall into 9 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 9 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: MultimodalModelBuilder (LCOM4 8) mistralrs/src/multimodal_model.rs:18 — MultimodalModelBuilder's methods fall into 8 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 8 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: SpeechModelBuilder (LCOM4 8) mistralrs/src/speech_model.rs:7 — SpeechModelBuilder's methods fall into 8 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 8 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: DiffusionModelBuilder (LCOM4 7) mistralrs/src/diffusion_model.rs:7 — DiffusionModelBuilder's methods fall into 7 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 7 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: GgufArchSpec (LCOM4 5) mistralrs-core/src/gguf/arch_registry.rs:62 — GgufArchSpec's methods fall into 5 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 5 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: QuantizeOntoGuard (LCOM4 5) mistralrs-quant/src/lib.rs:1550 — QuantizeOntoGuard's methods fall into 5 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 5 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: MistralRs (LCOM4 4) mistralrs-core/src/lib.rs:462 — MistralRs's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: ChatTemplate (LCOM4 4) mistralrs-core/src/pipeline/chat_template.rs:72 — ChatTemplate's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
D31 · IaC & Container Security · Medium IaC · ×12
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Members sharing a duplicated core (5 members, 50+ identical tokens) · ×12
  • Members sharing a duplicated core (5 members, 50+ identical tokens) mistralrs-core/src/gguf/base_model.rs:138 — mistralrs-core/src/gguf/base_model.rs:138-151 | mistralrs-core/src/gguf/multimodal_binding_utils.rs:108-124 | mistralrs-core/src/gguf/normal_bindings.rs:950-963 | mistralrs-core/src/gguf/qwen_multimodal_bindings.rs:302-318 | mistralrs-quant/src/gguf/archive.rs:1382-1398 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) mistralrs-core/src/gguf/gemma3_bindings.rs:172 — mistralrs-core/src/gguf/gemma3_bindings.rs:172-215 | mistralrs-core/src/gguf/idefics3_bindings.rs:41-84 | mistralrs-core/src/gguf/lfm2_vl_bindings.rs:69-119 | mistralrs-core/src/gguf/llama4_bindings.rs:170-242 | mistralrs-core/src/gguf/muse_glimmer_bindings.rs:114-154 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) mistralrs-core/src/ops.rs:2125 — mistralrs-core/src/ops.rs:2125-2275 | mistralrs-core/src/ops.rs:3870-3990 | mistralrs-core/src/ops.rs:3997-4114 | mistralrs-flash-attn/src/flash.rs:34-224 | mistralrs-flash-attn/src/flash.rs:482-832 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1390 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1390-1507 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3170-3242 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3519-3584 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3865-3966 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4637-4711 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2744 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2744-2775 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6721-6753 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7163-7195 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7640-7668 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:8162-8190 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2781 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2781-2810 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6759-6788 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7201-7230 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7674-7701 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:8196-8223 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4243 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4243-4312 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6797-6886 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7239-7328 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7710-7796 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:8232-8318 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) mistralrs-core/src/vision_models/diffusion_gemma/mod.rs:257 — mistralrs-core/src/vision_models/diffusion_gemma/mod.rs:257-299 | mistralrs-core/src/vision_models/gemma3/mod.rs:118-193 | mistralrs-core/src/vision_models/gemma4/mod.rs:360-891 | mistralrs-core/src/vision_models/lfm2_vl/mod.rs:193-230 | mistralrs-core/src/vision_models/mistral3/mod.rs:238-335 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) REDACTED:509 — REDACTED:509-518 | REDACTED:864-873 | mistralrs-core/src/vision_models/idefics3/vision.rs:305-314 | mistralrs-core/src/vision_models/lfm2_vl/vision.rs:239-246 | mistralrs-core/src/vision_models/siglip.rs:316-325 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) mistralrs-quant/src/cutile/fp8_gemm.rs:466 — mistralrs-quant/src/cutile/fp8_gemm.rs:466-495 | mistralrs-quant/src/cutile/fp8_w8a16.rs:616-648 | mistralrs-quant/src/cutile/fp8_w8a8.rs:684-739 | mistralrs-quant/src/cutile/fused_moe.rs:790-847 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:706-764 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) mistralrs-quant/src/hqq/hqq_op.rs:36 — mistralrs-quant/src/hqq/hqq_op.rs:36-58 | mistralrs-quant/src/hqq/hqq_op.rs:143-167 | mistralrs-quant/src/hqq/hqq_op.rs:256-280 | mistralrs-quant/src/hqq/hqq_op.rs:373-397 | mistralrs-quant/src/hqq/hqq_op.rs:492-516 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) mistralrs-quant/src/metal_kernels/mod.rs:1580 — mistralrs-quant/src/metal_kernels/mod.rs:1580-1622 | mistralrs-quant/src/metal_kernels/mod.rs:1650-1701 | mistralrs-quant/src/metal_kernels/mod.rs:2808-3032 | mistralrs-quant/src/metal_kernels/mod.rs:4759-4799 | mistralrs-quant/src/metal_kernels/mod.rs:4830-4870 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D4 · Code Duplication · Edited copy of a member (16 corresponding lines) · ×12
  • Edited copy of a member (16 corresponding lines) mistralrs-core/src/vision_models/gemma3n/audio.rs:561 — mistralrs-core/src/vision_models/gemma3n/audio.rs:561-585 | mistralrs-core/src/vision_models/gemma4/audio.rs:626-641 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (16 corresponding lines) mistralrs-core/src/paged_attention/layers/paged_attention.rs:471 — mistralrs-core/src/paged_attention/layers/paged_attention.rs:471-486 | mistralrs-core/src/vision_models/mllama/text.rs:403-421 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (16 corresponding lines) mistralrs-core/src/attention/backends/cpu/avx.rs:250 — mistralrs-core/src/attention/backends/cpu/avx.rs:250-267 | mistralrs-core/src/attention/backends/cpu/avx.rs:703-718 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (16 corresponding lines) mistralrs-core/src/vision_models/lfm3_omni/audio.rs:328 — mistralrs-core/src/vision_models/lfm3_omni/audio.rs:328-343 | mistralrs-core/src/vision_models/lfm3_omni/generation.rs:347-362 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (16 corresponding lines) mistralrs-core/src/gguf/normal_config.rs:2580 — mistralrs-core/src/gguf/normal_config.rs:2580-2600 | mistralrs-core/src/gguf/normal_config.rs:2602-2617 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (16 corresponding lines) mistralrs-core/src/pipeline/ggml.rs:137 — mistralrs-core/src/pipeline/ggml.rs:137-152 | mistralrs-core/src/pipeline/gguf.rs:346-362 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (16 corresponding lines) mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:266 — mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:266-281 | mistralrs-core/src/vision_models/llama4/inputs_processor.rs:303-318 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (16 corresponding lines) mistralrs-core/src/gdn/layer.rs:643 — mistralrs-core/src/gdn/layer.rs:643-658 | mistralrs-core/src/gdn/layer.rs:665-687 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (16 corresponding lines) mistralrs-quant/src/f8q8/mod.rs:176 — mistralrs-quant/src/f8q8/mod.rs:176-195 | mistralrs-quant/src/gguf/mod.rs:185-200 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (16 corresponding lines) mistralrs-core/src/vision_models/qwen3_5/text.rs:1150 — mistralrs-core/src/vision_models/qwen3_5/text.rs:1150-1165 | mistralrs-core/src/vision_models/qwen4_exp/text.rs:694-709 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (16 corresponding lines) mistralrs-core/src/pipeline/multimodal.rs:3254 — mistralrs-core/src/pipeline/multimodal.rs:3254-3269 | mistralrs-core/src/pipeline/normal.rs:2801-2816 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (16 corresponding lines) scripts/production_soak.py:6934 — scripts/production_soak.py:6934-6949 | scripts/production_soak.py:6960-6975 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Duplicated block (6 lines × 4) · ×12
  • Duplicated block (6 lines × 4) mistralrs-core/src/cuda/gdn.rs:1984 — mistralrs-core/src/cuda/gdn.rs:1984-1989 | mistralrs-core/src/cuda/gdn.rs:1991-1996 | mistralrs-core/src/cuda/gdn.rs:6215-6220 | mistralrs-core/src/cuda/moe.rs:53-58 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/gdn.rs:1984` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 4) mistralrs-core/src/vision_models/gemma4/mod.rs:394 — mistralrs-core/src/vision_models/gemma4/mod.rs:394-399 | REDACTED:232-237 | mistralrs-core/src/vision_models/llava/llava_next.rs:290-295 | mistralrs-core/src/vision_models/mistral3/mod.rs:261-266 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma4/mod.rs:394` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 4) mistralrs-core/src/vision_models/grid_processor.rs:1869 — mistralrs-core/src/vision_models/grid_processor.rs:1869-1874 | mistralrs-core/src/vision_models/grid_processor.rs:1918-1923 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:1008-1013 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1573-1578 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:1869` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 4) mistralrs-quant/src/blockwise_fp8/mma.rs:147 — mistralrs-quant/src/blockwise_fp8/mma.rs:147-152 | mistralrs-quant/src/blockwise_fp8/ops.rs:881-886 | mistralrs-quant/src/blockwise_fp8/ops.rs:1679-1684 | mistralrs-quant/src/cutile/nvfp4_glu.rs:468-473 — there are 4 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/blockwise_fp8/mma.rs:147` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 4) mistralrs-core/src/models/deepseek2.rs:520 — mistralrs-core/src/models/deepseek2.rs:520-525 | mistralrs-core/src/models/deepseek3.rs:533-538 | mistralrs-core/src/models/glm4_moe.rs:453-458 | mistralrs-core/src/models/glm4_moe_lite.rs:551-556 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (6 lines × 4) mistralrs-paged-attn/src/cuda/backend/cache.rs:138 — mistralrs-paged-attn/src/cuda/backend/cache.rs:138-143 | mistralrs-paged-attn/src/cuda/backend/cache.rs:145-150 | mistralrs-paged-attn/src/cuda/backend/cache.rs:152-157 | mistralrs-paged-attn/src/cuda/backend/cache.rs:159-164 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (6 lines × 4) mistralrs-quant/src/cutile/fp8_gemm.rs:69 — mistralrs-quant/src/cutile/fp8_gemm.rs:69-74 | mistralrs-quant/src/cutile/fp8_w8a16.rs:57-62 | mistralrs-quant/src/cutile/fp8_w8a16.rs:105-110 | mistralrs-quant/src/cutile/fp8_w8a8.rs:59-64 — before extracting anything, compare `mistralrs-quant/src/cutile/fp8_gemm.rs` and `mistralrs-quant/src/cutile/fp8_w8a16.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 40 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cutile/fp8_gemm.rs:69` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 4) REDACTED:408 — REDACTED:408-415 | mistralrs-core/src/vision_models/idefics3/vision.rs:220-227 | mistralrs-core/src/vision_models/lfm2_vl/vision.rs:169-174 | mistralrs-core/src/vision_models/siglip.rs:224-231 — before extracting anything, compare `REDACTED` and `mistralrs-core/src/vision_models/idefics3/vision.rs` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 221 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (6 lines × 4) mistralrs-cli/src/ui/handlers/api.rs:211 — mistralrs-cli/src/ui/handlers/api.rs:211-216 | mistralrs-cli/src/ui/handlers/api.rs:263-268 | mistralrs-cli/src/ui/handlers/api.rs:315-320 | mistralrs-cli/src/ui/handlers/api.rs:371-376 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-cli/src/ui/handlers/api.rs:211` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 4) mistralrs-quant/src/blockwise_fp8/mod.rs:577 — mistralrs-quant/src/blockwise_fp8/mod.rs:577-582 | mistralrs-quant/src/blockwise_fp8/mod.rs:623-628 | mistralrs-quant/src/blockwise_fp8/mod.rs:915-920 | mistralrs-quant/src/lib.rs:1752-1757 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/blockwise_fp8/mod.rs:577` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 4) mistralrs-quant/src/utils/ops.rs:160 — mistralrs-quant/src/utils/ops.rs:160-165 | mistralrs-quant/src/utils/ops.rs:606-611 | mistralrs-quant/src/utils/ops.rs:760-765 | mistralrs-quant/src/utils/ops.rs:1523-1528 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (6 lines × 4) mistralrs-quant/src/hqq/hqq_op.rs:119 — mistralrs-quant/src/hqq/hqq_op.rs:119-124 | mistralrs-quant/src/hqq/hqq_op.rs:230-235 | mistralrs-quant/src/hqq/hqq_op.rs:343-348 | mistralrs-quant/src/hqq/hqq_op.rs:460-465 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/hqq/hqq_op.rs:119` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D2 · Cognitive Complexity · TextModel · ×11
  • TextModel::forward_embeds_scaled (cognitive 66) mistralrs-core/src/vision_models/gemma4/text.rs:2107 — TextModel::forward_embeds_scaled has cognitive complexity 66 (threshold 15). Drivers by points: if/else 33 (46 pts), boolean chains 10, match/switch 6 (9 pts), loops 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • TextModel::forward_embeds (cognitive 34) mistralrs-core/src/vision_models/gemma3/text.rs:599 — TextModel::forward_embeds has cognitive complexity 34 (threshold 15). Drivers by points: if/else 11 (15 pts), match/switch 6 (10 pts), boolean chains 8, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • TextModel::create_anymoe_layers (cognitive 27) mistralrs-core/src/vision_models/gemma3/text.rs:919 — TextModel::create_anymoe_layers has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (19 pts), loops 4 (5 pts), match/switch 1 (3 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • TextModel::new (cognitive 27) mistralrs-core/src/vision_models/gemma4/text.rs:1618 — TextModel::new has cognitive complexity 27 (threshold 15). Drivers by points: if/else 17 (21 pts), loops 3 (4 pts), boolean chains 1, match/switch 1 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • TextModel::new (cognitive 26) mistralrs-core/src/vision_models/gemma3n/text.rs:1310 — TextModel::new has cognitive complexity 26 (threshold 15). Drivers by points: if/else 16 (22 pts), loops 3, match/switch 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • TextModel::forward_embeds (cognitive 25) mistralrs-core/src/vision_models/gemma3n/text.rs:1743 — TextModel::forward_embeds has cognitive complexity 25 (threshold 15). Drivers by points: if/else 15 (22 pts), loops 3 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • TextModel::create_anymoe_layers (cognitive 23) mistralrs-core/src/vision_models/muse_glimmer/text.rs:675 — TextModel::create_anymoe_layers has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (16 pts), loops 3 (4 pts), match/switch 1 (3 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • TextModel::apply_image_bidirectional_mask (cognitive 18) mistralrs-core/src/vision_models/gemma4/text.rs:2443 — TextModel::apply_image_bidirectional_mask has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 3 (4 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • TextModel::residual_tensors (cognitive 17) mistralrs-core/src/vision_models/gemma4/text.rs:2578 — TextModel::residual_tensors has cognitive complexity 17 (threshold 15). Drivers by points: if/else 12 (16 pts), loops 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • TextModel::apply_image_bidirectional_mask (cognitive 16) mistralrs-core/src/vision_models/gemma3/text.rs:772 — TextModel::apply_image_bidirectional_mask has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (10 pts), loops 3 (4 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • TextModel::forward_embeds (cognitive 16) mistralrs-core/src/vision_models/llama4/text.rs:912 — TextModel::forward_embeds has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (13 pts), boolean chains 2, loops 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D4 · Code Duplication · Edited copy of a member (20 corresponding lines) · ×11
  • Edited copy of a member (20 corresponding lines) mistralrs-core/src/layers.rs:3070 — mistralrs-core/src/layers.rs:3070-3089 | mistralrs-core/src/layers.rs:3203-3222 — These two members are one piece of code written twice and then edited apart: 20 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (20 corresponding lines) mistralrs-core/src/cuda/speculative_rejection.rs:731 — mistralrs-core/src/cuda/speculative_rejection.rs:731-750 | mistralrs-core/src/cuda/speculative_rejection.rs:768-787 — These two members are one piece of code written twice and then edited apart: 20 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (20 corresponding lines) mistralrs-core/src/vision_models/qwen3_5/text.rs:1718 — mistralrs-core/src/vision_models/qwen3_5/text.rs:1718-1737 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:942-961 — These two members are one piece of code written twice and then edited apart: 20 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (20 corresponding lines) mistralrs-core/src/vision_models/phi3/mod.rs:1371 — mistralrs-core/src/vision_models/phi3/mod.rs:1371-1390 | mistralrs-core/src/vision_models/phi4/mod.rs:633-652 — These two members are one piece of code written twice and then edited apart: 20 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (20 corresponding lines) mistralrs-core/src/diffusion_models/clip/text.rs:97 — mistralrs-core/src/diffusion_models/clip/text.rs:97-116 | mistralrs-core/src/vision_models/clip.rs:134-153 — These two members are one piece of code written twice and then edited apart: 20 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (20 corresponding lines) mistralrs-quant/src/f8q8/mod.rs:237 — mistralrs-quant/src/f8q8/mod.rs:237-256 | mistralrs-quant/src/gguf/mod.rs:316-336 — These two members are one piece of code written twice and then edited apart: 20 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (20 corresponding lines) mistralrs-quant/src/routed_gemv/cuda.rs:506 — mistralrs-quant/src/routed_gemv/cuda.rs:506-525 | mistralrs-quant/src/routed_gemv/cuda.rs:533-553 — These two members are one piece of code written twice and then edited apart: 20 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (20 corresponding lines) mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:232 — mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:232-251 | mistralrs-core/src/vision_models/qwen2vl/vision.rs:203-223 — These two members are one piece of code written twice and then edited apart: 20 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (20 corresponding lines) mistralrs-core/src/gguf/normal_config.rs:503 — mistralrs-core/src/gguf/normal_config.rs:503-527 | mistralrs-core/src/gguf/normal_config.rs:532-551 — These two members are one piece of code written twice and then edited apart: 20 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (20 corresponding lines) mistralrs-core/src/pipeline/multimodal.rs:2814 — mistralrs-core/src/pipeline/multimodal.rs:2814-2833 | mistralrs-core/src/pipeline/normal.rs:2426-2445 — These two members are one piece of code written twice and then edited apart: 20 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (20 corresponding lines) mistralrs-core/src/lib.rs:652 — mistralrs-core/src/lib.rs:652-672 | mistralrs/src/gguf.rs:183-202 — These two members are one piece of code written twice and then edited apart: 20 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Duplicated block (14 lines × 3) · ×11
  • Duplicated block (14 lines × 3) mistralrs-core/src/cuda/gdn.rs:4993 — mistralrs-core/src/cuda/gdn.rs:4993-5006 | mistralrs-core/src/cuda/gdn.rs:5242-5255 | mistralrs-core/src/cuda/gdn.rs:5499-5512 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/gdn.rs:4993` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/cuda/gdn.rs:5513` calls `is_contiguous` and `mistralrs-core/src/cuda/gdn.rs:5007` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14 lines × 3) mistralrs-core/src/cuda/gdn.rs:5404 — mistralrs-core/src/cuda/gdn.rs:5404-5417 | mistralrs-core/src/cuda/gdn.rs:5580-5593 | mistralrs-core/src/cuda/gdn.rs:5850-5863 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/gdn.rs:5404` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (14 lines × 3) mistralrs-core/src/models/deepseek2.rs:473 — mistralrs-core/src/models/deepseek2.rs:473-486 | mistralrs-core/src/models/deepseek3.rs:474-487 | mistralrs-core/src/models/glm4_moe_lite.rs:438-451 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:473` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 3) mistralrs-core/src/models/gemma.rs:404 — mistralrs-core/src/models/gemma.rs:404-417 | mistralrs-core/src/models/gemma2.rs:477-490 | mistralrs-core/src/vision_models/gemma3/text.rs:517-530 — before extracting anything, compare `mistralrs-core/src/models/gemma.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 707 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma.rs:404` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (14 lines × 3) mistralrs-core/src/models/hunyuan_v1_dense.rs:157 — mistralrs-core/src/models/hunyuan_v1_dense.rs:157-170 | mistralrs-core/src/models/qwen3.rs:158-171 | mistralrs-core/src/models/qwen3_moe.rs:161-174 — before extracting anything, compare `mistralrs-core/src/models/hunyuan_v1_dense.rs` and `mistralrs-core/src/models/qwen3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 731 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/hunyuan_v1_dense.rs:157` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 3) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7609 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7609-7622 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:8125-8138 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:8766-8779 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7609` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:8139` calls `checked_add`, `context` and `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:8780` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14 lines × 3) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3264 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3264-3277 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3597-3610 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4824-4837 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3264` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 3) mistralrs-core/src/vision_models/llava/llava_next.rs:444 — mistralrs-core/src/vision_models/llava/llava_next.rs:444-457 | mistralrs-core/src/vision_models/mistral3/mod.rs:309-322 | mistralrs-core/src/vision_models/phi3/mod.rs:1106-1119 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
  • Duplicated block (14 lines × 3) mistralrs-quant/src/lora/dynamic/moe_cuda.rs:852 — mistralrs-quant/src/lora/dynamic/moe_cuda.rs:852-865 | mistralrs-quant/src/lora/dynamic/moe_cuda.rs:875-888 | mistralrs-quant/src/lora/dynamic/moe_cuda.rs:898-911 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/lora/dynamic/moe_cuda.rs:852` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 3) mistralrs-core/src/pipeline/loaders/lfm3.rs:172 — mistralrs-core/src/pipeline/loaders/lfm3.rs:172-185 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:10540-10554 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:7081-7094 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/lfm3.rs` and `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 35 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (14 lines × 3) mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:291 — mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:291-304 | mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:327-340 | mistralrs-core/src/vision_models/phi3/phi3_inputs_processor.rs:300-313 — before extracting anything, compare `mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs` and `mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 222 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:291` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (10–11 lines × 2) · ×11
  • Duplicated block (10–11 lines × 2) mistralrs-core/src/gguf/lfm2_vl_bindings.rs:39 — mistralrs-core/src/gguf/lfm2_vl_bindings.rs:39-49 | mistralrs-core/src/gguf/lfm3_vl_bindings.rs:48-57 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (10–11 lines × 2) mistralrs-core/src/gguf/multimodal_binding_utils.rs:84 — mistralrs-core/src/gguf/multimodal_binding_utils.rs:84-94 | mistralrs-core/src/gguf/qwen_multimodal_bindings.rs:259-268 — before extracting anything, compare `mistralrs-core/src/gguf/multimodal_binding_utils.rs` and `mistralrs-core/src/gguf/qwen_multimodal_bindings.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 40 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (10–11 lines × 2) mistralrs-core/src/mla/forward.rs:190 — mistralrs-core/src/mla/forward.rs:190-200 | mistralrs-core/src/mla/forward.rs:387-396 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (10–11 lines × 2) mistralrs-core/src/models/glm4.rs:342 — mistralrs-core/src/models/glm4.rs:342-352 | mistralrs-core/src/vision_models/gemma4/text.rs:993-1002 — before extracting anything, compare `mistralrs-core/src/models/glm4.rs` and `mistralrs-core/src/vision_models/gemma4/text.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 52 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/glm4.rs:342` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (10–11 lines × 2) mistralrs-core/src/models/phi3.rs:421 — mistralrs-core/src/models/phi3.rs:421-430 | mistralrs-core/src/vision_models/gemma3/text.rs:447-457 — before extracting anything, compare `mistralrs-core/src/models/phi3.rs` and `mistralrs-core/src/vision_models/gemma3/text.rs` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 199 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/phi3.rs:421` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/vision_models/gemma3/text.rs:444` calls `sqrt` and `mistralrs-core/src/models/phi3.rs:417` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10–11 lines × 2) mistralrs-core/src/models/qwen3_next.rs:280 — mistralrs-core/src/models/qwen3_next.rs:280-290 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:196-205 — before extracting anything, compare `mistralrs-core/src/models/qwen3_next.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/text.rs` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 461 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/qwen3_next.rs:280` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10–11 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:896 — mistralrs-core/src/pipeline/multimodal.rs:896-906 | mistralrs-core/src/pipeline/normal.rs:902-911 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:896` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (10–11 lines × 2) mistralrs-core/src/speculative/dflash.rs:3337 — mistralrs-core/src/speculative/dflash.rs:3337-3347 | mistralrs-core/src/speculative/dflash.rs:3559-3568 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10–11 lines × 2) mistralrs-core/src/vision_models/voxtral/encoder.rs:80 — mistralrs-core/src/vision_models/voxtral/encoder.rs:80-90 | mistralrs-core/src/vision_models/voxtral/mod.rs:127-136 — before extracting anything, compare `mistralrs-core/src/vision_models/voxtral/encoder.rs` and `mistralrs-core/src/vision_models/voxtral/mod.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 36 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/voxtral/encoder.rs:80` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10–11 lines × 2) mistralrs-quant/src/afq/mod.rs:302 — mistralrs-quant/src/afq/mod.rs:302-312 | mistralrs-quant/src/gguf/mod.rs:578-587 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/afq/mod.rs:302` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10–11 lines × 2) mistralrs/src/gguf_lora_model.rs:71 — mistralrs/src/gguf_lora_model.rs:71-80 | mistralrs/src/gguf_xlora_model.rs:80-90 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs/src/gguf_lora_model.rs:71` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Edited copy of a member (29 corresponding lines) · ×10
  • Edited copy of a member (29 corresponding lines) mistralrs-core/src/cuda/speculative_rejection.rs:831 — mistralrs-core/src/cuda/speculative_rejection.rs:831-859 | mistralrs-core/src/cuda/speculative_rejection.rs:866-895 — These two members are one piece of code written twice and then edited apart: 29 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (29 corresponding lines) mistralrs-core/src/tools/parsers/atem.rs:286 — mistralrs-core/src/tools/parsers/atem.rs:286-314 | mistralrs-core/src/tools/parsers/atem.rs:334-363 — These two members are one piece of code written twice and then edited apart: 29 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (29 corresponding lines) mistralrs-quant/src/blockwise_fp8/deepgemm.rs:203 — mistralrs-quant/src/blockwise_fp8/deepgemm.rs:203-233 | mistralrs-quant/src/blockwise_fp8/ops.rs:1365-1393 — These two members are one piece of code written twice and then edited apart: 29 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (29 corresponding lines) mistralrs-quant/src/cublaslt/mod.rs:145 — mistralrs-quant/src/cublaslt/mod.rs:145-176 | mistralrs-quant/src/cublaslt/mod.rs:201-229 — These two members are one piece of code written twice and then edited apart: 29 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (29 corresponding lines) mistralrs-core/src/vision_models/gemma3n/multimodal_embedding.rs:32 — mistralrs-core/src/vision_models/gemma3n/multimodal_embedding.rs:32-84 | mistralrs-core/src/vision_models/gemma4/vision.rs:493-521 — These two members are one piece of code written twice and then edited apart: 29 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (29 corresponding lines) mistralrs-core/src/xlora_models/phi2.rs:57 — mistralrs-core/src/xlora_models/phi2.rs:57-85 | mistralrs-core/src/xlora_models/starcoder2.rs:49-78 — These two members are one piece of code written twice and then edited apart: 29 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (29 corresponding lines) mistralrs-core/src/vision_models/gemma3n/audio.rs:1034 — mistralrs-core/src/vision_models/gemma3n/audio.rs:1034-1062 | mistralrs-core/src/vision_models/gemma3n/audio.rs:1092-1125 — These two members are one piece of code written twice and then edited apart: 29 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (29 corresponding lines) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2081 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2081-2111 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6202-6230 — These two members are one piece of code written twice and then edited apart: 29 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (29 corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1706 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1706-1736 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1742-1770 — These two members are one piece of code written twice and then edited apart: 29 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (29 corresponding lines) mistralrs-core/src/vision_models/mllama/text.rs:39 — mistralrs-core/src/vision_models/mllama/text.rs:39-67 | mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:85-113 — These two members are one piece of code written twice and then edited apart: 29 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Duplicated block (26 lines × 2) · ×10
  • Duplicated block (26 lines × 2) mistralrs-core/src/attention/backends/cpu/neon.rs:331 — mistralrs-core/src/attention/backends/cpu/neon.rs:331-356 | mistralrs-core/src/attention/backends/cpu/neon.rs:571-596 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/attention/backends/cpu/neon.rs:331` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `b` to `&[half::f16]` in one and `&[half::bf16]` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (26 lines × 2) mistralrs-core/src/cuda/speculative_rejection.rs:834 — mistralrs-core/src/cuda/speculative_rejection.rs:834-859 | mistralrs-core/src/cuda/speculative_rejection.rs:870-895 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/speculative_rejection.rs:834` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (26 lines × 2) mistralrs-core/src/layers.rs:1143 — mistralrs-core/src/layers.rs:1143-1168 | mistralrs-core/src/layers.rs:1233-1258 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/layers.rs:1143` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (26 lines × 2) mistralrs-core/src/models/deepseek2.rs:923 — mistralrs-core/src/models/deepseek2.rs:923-948 | mistralrs-core/src/models/deepseek3.rs:986-1011 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:923` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (26 lines × 2) mistralrs-core/src/models/phi3.rs:250 — mistralrs-core/src/models/phi3.rs:250-275 | mistralrs-core/src/vision_models/phi3/mod.rs:341-366 — before extracting anything, compare `mistralrs-core/src/models/phi3.rs` and `mistralrs-core/src/vision_models/phi3/mod.rs` as WHOLE FILES: this scan already matched 50 separate duplicated blocks between them, totalling at least 638 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (26 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:1278 — mistralrs-core/src/pipeline/multimodal.rs:1278-1303 | mistralrs-core/src/pipeline/normal.rs:1354-1379 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:1278` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (26 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:2787 — mistralrs-core/src/pipeline/multimodal.rs:2787-2812 | mistralrs-core/src/pipeline/normal.rs:2351-2376 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (26 lines × 2) mistralrs-core/src/models/llama.rs:492 — mistralrs-core/src/models/llama.rs:492-517 | mistralrs-core/src/models/smollm3.rs:511-536 — before extracting anything, compare `mistralrs-core/src/models/llama.rs` and `mistralrs-core/src/models/smollm3.rs` as WHOLE FILES: this scan already matched 47 separate duplicated blocks between them, totalling at least 727 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (26 lines × 2) mistralrs-quant/src/cutile/nvfp4_glu.rs:118 — mistralrs-quant/src/cutile/nvfp4_glu.rs:118-143 | mistralrs-quant/src/cutile/nvfp4_matmul.rs:35-60 — before extracting anything, compare `mistralrs-quant/src/cutile/nvfp4_glu.rs` and `mistralrs-quant/src/cutile/nvfp4_matmul.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 70 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (26 lines × 2) scripts/production_soak.py:10440 — scripts/production_soak.py:10440-10465 | scripts/production_soak.py:10851-10876 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `scripts/production_soak.py:10440` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (18 lines × 3) · ×10
  • Duplicated block (18 lines × 3) mistralrs-core/src/models/gemma.rs:417 — mistralrs-core/src/models/gemma.rs:417-434 | mistralrs-core/src/models/gemma2.rs:490-507 | mistralrs-core/src/models/starcoder2.rs:481-498 — before extracting anything, compare `mistralrs-core/src/models/gemma.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 707 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma.rs:417` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 3) mistralrs-core/src/models/phi2.rs:677 — mistralrs-core/src/models/phi2.rs:677-694 | mistralrs-core/src/models/starcoder2.rs:668-685 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:685-702 — before extracting anything, compare `mistralrs-core/src/models/phi2.rs` and `mistralrs-core/src/models/starcoder2.rs` as WHOLE FILES: this scan already matched 31 separate duplicated blocks between them, totalling at least 357 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/phi2.rs:677` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 3) mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:848 — mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:848-865 | mistralrs-core/src/vision_models/gemma3n/inputs_processor.rs:766-783 | mistralrs-core/src/vision_models/mistral3/inputs_processor.rs:757-774 — `mistralrs-core/src/vision_models/gemma3/inputs_processor.rs` and `mistralrs-core/src/vision_models/gemma3n/inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 4 separate duplicated blocks between them, totalling at least 75 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:848` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 3) mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:756 — mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:756-773 | mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:977-994 | mistralrs-core/src/vision_models/mllama/inputs_processor.rs:1039-1056 — before extracting anything, compare `mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs` and `mistralrs-core/src/vision_models/idefics3/inputs_processor.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 120 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:756` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 3) mistralrs-core/src/vision_models/muse_glimmer/text.rs:350 — mistralrs-core/src/vision_models/muse_glimmer/text.rs:350-367 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:320-337 | mistralrs-core/src/vision_models/qwen2vl/text.rs:321-338 — `mistralrs-core/src/vision_models/muse_glimmer/text.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 10 separate duplicated blocks between them, totalling at least 145 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/muse_glimmer/text.rs:350` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `rotary_emb` to `Option<Arc<RotaryEmbedding>>` in one and `Arc<Qwen2_5VLRotaryEmbedding>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (18 lines × 3) mistralrs-core/src/xlora_models/gemma.rs:107 — mistralrs-core/src/xlora_models/gemma.rs:107-124 | mistralrs-core/src/xlora_models/gemma2.rs:101-118 | mistralrs-core/src/xlora_models/mistral.rs:100-117 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/gemma2.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 498 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (18 lines × 3) mistralrs-core/src/xlora_models/gemma.rs:499 — mistralrs-core/src/xlora_models/gemma.rs:499-516 | mistralrs-core/src/xlora_models/gemma2.rs:529-546 | mistralrs-core/src/xlora_models/mistral.rs:495-512 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/gemma2.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 498 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma.rs:499` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 3) mistralrs-paged-attn/src/cuda/backend/mla.rs:773 — mistralrs-paged-attn/src/cuda/backend/mla.rs:773-790 | mistralrs-paged-attn/src/cuda/backend/mla.rs:811-828 | mistralrs-paged-attn/src/cuda/backend/mla.rs:849-866 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/cuda/backend/mla.rs:773` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 3) mistralrs-quant/src/metal_kernels/mod.rs:527 — mistralrs-quant/src/metal_kernels/mod.rs:527-544 | mistralrs-quant/src/metal_kernels/mod.rs:573-590 | mistralrs-quant/src/metal_kernels/mod.rs:619-636 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/metal_kernels/mod.rs:527` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 3) mistralrs/src/messages.rs:615 — mistralrs/src/messages.rs:615-632 | mistralrs/src/messages.rs:650-667 | mistralrs/src/messages.rs:692-709 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
D4 · Code Duplication · Duplicated block (12–13 lines × 2) · ×10
  • Duplicated block (12–13 lines × 2) mistralrs-cli/src/commands/run/interactive.rs:2049 — mistralrs-cli/src/commands/run/interactive.rs:2049-2060 | mistralrs/src/model.rs:738-750 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-cli/src/commands/run/interactive.rs:2049` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12–13 lines × 2) mistralrs-code-exec/src/shell.rs:208 — mistralrs-code-exec/src/shell.rs:208-220 | mistralrs-code-exec/src/shell.rs:270-281 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-code-exec/src/shell.rs:208` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12–13 lines × 2) mistralrs-core/src/gguf/normal_config.rs:1801 — mistralrs-core/src/gguf/normal_config.rs:1801-1812 | mistralrs-core/src/gguf/normal_config.rs:1871-1883 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/gguf/normal_config.rs:1801` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/gguf/normal_config.rs:1869` calls `into`, `has_tensor_marker` and `mistralrs-core/src/gguf/normal_config.rs:1801` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12–13 lines × 2) mistralrs-core/src/mla/forward.rs:241 — mistralrs-core/src/mla/forward.rs:241-253 | mistralrs-core/src/mla/forward.rs:397-408 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (12–13 lines × 2) mistralrs-core/src/pipeline/inputs_processor.rs:1318 — mistralrs-core/src/pipeline/inputs_processor.rs:1318-1329 | mistralrs-core/src/pipeline/inputs_processor.rs:1356-1368 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/inputs_processor.rs:1356` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12–13 lines × 2) mistralrs-core/src/utils/gguf_metadata.rs:416 — mistralrs-core/src/utils/gguf_metadata.rs:416-427 | mistralrs-core/src/utils/gguf_metadata.rs:641-653 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/utils/gguf_metadata.rs:416` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (12–13 lines × 2) mistralrs-quant/src/afq/ops.rs:2141 — mistralrs-quant/src/afq/ops.rs:2141-2152 | mistralrs-quant/src/afq/ops.rs:2655-2667 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/afq/ops.rs:2141` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12–13 lines × 2) mistralrs-quant/src/cutile/fused_moe.rs:580 — mistralrs-quant/src/cutile/fused_moe.rs:580-592 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:1024-1035 — before extracting anything, compare `mistralrs-quant/src/cutile/fused_moe.rs` and `mistralrs-quant/src/cutile/fused_moe_fp8.rs` as WHOLE FILES: this scan already matched 24 separate duplicated blocks between them, totalling at least 298 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cutile/fused_moe.rs:580` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12–13 lines × 2) mistralrs-quant/src/cutile/nvfp4_gemv.rs:342 — mistralrs-quant/src/cutile/nvfp4_gemv.rs:342-354 | mistralrs-quant/src/cutile/nvfp4_matmul.rs:1199-1210 — before extracting anything, compare `mistralrs-quant/src/cutile/nvfp4_gemv.rs` and `mistralrs-quant/src/cutile/nvfp4_matmul.rs` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 98 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cutile/nvfp4_gemv.rs:342` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12–13 lines × 2) mistralrs-code-exec/src/lib.rs:312 — mistralrs-code-exec/src/lib.rs:312-324 | mistralrs-code-exec/src/shell.rs:335-346 — before extracting anything, compare `mistralrs-code-exec/src/lib.rs` and `mistralrs-code-exec/src/shell.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 64 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-code-exec/src/lib.rs:312` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (11–12 lines × 2) · ×10
  • Duplicated block (11–12 lines × 2) mistralrs-cli/src/commands/config.rs:120 — mistralrs-cli/src/commands/config.rs:120-130 | mistralrs-cli/src/commands/serve.rs:137-148 — before extracting anything, compare `mistralrs-cli/src/commands/config.rs` and `mistralrs-cli/src/commands/serve.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 60 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-cli/src/commands/serve.rs:149` calls `with_agent_permission`, `into`, `with_approval_broker` and `mistralrs-cli/src/commands/config.rs:131` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (11–12 lines × 2) mistralrs-core/src/models/lfm2.rs:1076 — mistralrs-core/src/models/lfm2.rs:1076-1086 | mistralrs-core/src/models/lfm3.rs:983-994 — before extracting anything, compare `mistralrs-core/src/models/lfm2.rs` and `mistralrs-core/src/models/lfm3.rs` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 402 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/lfm2.rs:1076` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (11–12 lines × 2) mistralrs-core/src/vision_models/gemma3n/audio_processing.rs:68 — mistralrs-core/src/vision_models/gemma3n/audio_processing.rs:68-78 | mistralrs-core/src/vision_models/gemma4/audio_processing.rs:190-201 — `mistralrs-core/src/vision_models/gemma3n/audio_processing.rs` and `mistralrs-core/src/vision_models/gemma4/audio_processing.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 43 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (11–12 lines × 2) mistralrs-core/src/vision_models/qwen3_5/speculative.rs:172 — mistralrs-core/src/vision_models/qwen3_5/speculative.rs:172-182 | mistralrs-core/src/vision_models/qwen3_5/speculative.rs:622-633 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_5/speculative.rs:622` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. Note first that the copies are not typed on the same thing: the declarations holding them bind `config` to `crate::speculative::MtpConfig` in one and `SpeculativeConfig` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (11–12 lines × 2) mistralrs-core/src/xlora_models/classifier.rs:55 — mistralrs-core/src/xlora_models/classifier.rs:55-65 | mistralrs-core/src/xlora_models/classifier.rs:68-79 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/classifier.rs:68` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (11–12 lines × 2) mistralrs-paged-attn/src/metal/backend/paged_attention.rs:589 — mistralrs-paged-attn/src/metal/backend/paged_attention.rs:589-599 | mistralrs-paged-attn/src/metal/backend/paged_attention.rs:649-660 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/metal/backend/paged_attention.rs:589` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (11–12 lines × 2) mistralrs-quant/src/distributed/layers.rs:1455 — mistralrs-quant/src/distributed/layers.rs:1455-1465 | mistralrs-quant/src/distributed/layers.rs:1685-1696 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/distributed/layers.rs:1455` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (11–12 lines × 2) mistralrs-quant/src/utils/ops.rs:2405 — mistralrs-quant/src/utils/ops.rs:2405-2416 | mistralrs-quant/src/utils/ops.rs:2575-2585 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (11–12 lines × 2) mistralrs-server-core/src/mistralrs_for_server_builder.rs:778 — mistralrs-server-core/src/mistralrs_for_server_builder.rs:778-789 | mistralrs-server-core/src/mistralrs_for_server_builder.rs:980-990 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-server-core/src/mistralrs_for_server_builder.rs:778` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11–12 lines × 2) mistralrs-core/src/vision_models/gemma3n/audio.rs:592 — mistralrs-core/src/vision_models/gemma3n/audio.rs:592-603 | mistralrs-core/src/vision_models/gemma4/audio.rs:649-659 — `mistralrs-core/src/vision_models/gemma3n/audio.rs` and `mistralrs-core/src/vision_models/gemma4/audio.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 20 separate duplicated blocks between them, totalling at least 352 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3n/audio.rs:592` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (10 lines × 4) · ×10
  • Duplicated block (10 lines × 4) mistralrs-core/src/embedding_models/qwen3_embedding.rs:138 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:138-147 | mistralrs-core/src/models/flint.rs:279-288 | mistralrs-core/src/models/qwen3.rs:149-158 | mistralrs-core/src/models/qwen3_moe.rs:152-161 — before extracting anything, compare `mistralrs-core/src/embedding_models/qwen3_embedding.rs` and `mistralrs-core/src/models/flint.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 68 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (10 lines × 4) mistralrs-core/src/ops.rs:5721 — mistralrs-core/src/ops.rs:5721-5730 | mistralrs-core/src/ops.rs:5933-5942 | mistralrs-core/src/ops.rs:6144-6153 | mistralrs-core/src/ops.rs:6462-6471 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (10 lines × 4) mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:71 — mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:71-80 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:345-354 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:10394-10403 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:200-209 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/embedding_loaders.rs` and `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 180 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (10 lines × 4) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:731 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:731-740 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1866-1875 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2558-2567 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4384-4393 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/normal_loaders.rs:731` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 4) mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:479 — mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:479-488 | mistralrs-core/src/vision_models/qwen2vl/mod.rs:635-644 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:1090-1099 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:534-543 — `mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs` and `mistralrs-core/src/vision_models/qwen2vl/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 16 separate duplicated blocks between them, totalling at least 396 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:479` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 4) mistralrs-quant/src/cutile/fused_moe.rs:269 — mistralrs-quant/src/cutile/fused_moe.rs:269-278 | mistralrs-quant/src/cutile/fused_moe.rs:280-289 | mistralrs-quant/src/cutile/fused_moe.rs:291-300 | mistralrs-quant/src/cutile/fused_moe.rs:302-311 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (10 lines × 4) mistralrs-quant/src/cutile/fused_moe.rs:314 — mistralrs-quant/src/cutile/fused_moe.rs:314-323 | mistralrs-quant/src/cutile/fused_moe.rs:325-334 | mistralrs-quant/src/cutile/fused_moe.rs:336-345 | mistralrs-quant/src/cutile/fused_moe.rs:347-356 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (10 lines × 4) mistralrs-quant/src/distributed/layers.rs:464 — mistralrs-quant/src/distributed/layers.rs:464-473 | mistralrs-quant/src/distributed/layers.rs:838-847 | mistralrs-quant/src/distributed/layers.rs:1425-1434 | mistralrs-quant/src/distributed/layers.rs:1641-1650 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/distributed/layers.rs:464` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-quant/src/distributed/layers.rs:1637` calls `is_some` and `mistralrs-quant/src/distributed/layers.rs:1424` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10 lines × 4) mistralrs-quant/src/gguf/packed_affine.rs:703 — mistralrs-quant/src/gguf/packed_affine.rs:703-712 | mistralrs-quant/src/gguf/packed_affine.rs:716-725 | mistralrs-quant/src/gguf/packed_affine.rs:729-738 | mistralrs-quant/src/gguf/packed_affine.rs:742-751 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/gguf/packed_affine.rs:703` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 4) mistralrs-quant/src/mxfp4/ops.rs:138 — mistralrs-quant/src/mxfp4/ops.rs:138-147 | mistralrs-quant/src/mxfp4/ops.rs:199-208 | mistralrs-quant/src/mxfp4/ops.rs:500-509 | mistralrs-quant/src/mxfp4/ops.rs:568-577 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/mxfp4/ops.rs:138` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (9 lines × 4) · ×10
  • Duplicated block (9 lines × 4) mistralrs-cli/src/ui/handlers/api.rs:176 — mistralrs-cli/src/ui/handlers/api.rs:176-184 | mistralrs-cli/src/ui/handlers/api.rs:228-236 | mistralrs-cli/src/ui/handlers/api.rs:280-288 | mistralrs-cli/src/ui/handlers/api.rs:332-340 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-cli/src/ui/handlers/api.rs:176` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (9 lines × 4) mistralrs-core/src/gdn/weights.rs:225 — mistralrs-core/src/gdn/weights.rs:225-233 | mistralrs-core/src/gdn/weights.rs:254-262 | mistralrs-core/src/gdn/weights.rs:295-303 | mistralrs-core/src/layers.rs:3666-3674 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/gdn/weights.rs:225` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (9 lines × 4) mistralrs-core/src/models/lfm2.rs:500 — mistralrs-core/src/models/lfm2.rs:500-508 | mistralrs-core/src/models/qwen3.rs:212-220 | mistralrs-core/src/models/qwen3_moe.rs:215-223 | mistralrs-core/src/models/qwen3_next.rs:298-306 — before extracting anything, compare `mistralrs-core/src/models/lfm2.rs` and `mistralrs-core/src/models/qwen3.rs` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 129 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/lfm2.rs:500` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 4) mistralrs-core/src/models/llama.rs:166 — mistralrs-core/src/models/llama.rs:166-174 | mistralrs-core/src/models/smollm3.rs:183-191 | mistralrs-core/src/vision_models/llama4/text.rs:332-340 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:140-148 — before extracting anything, compare `mistralrs-core/src/models/llama.rs` and `mistralrs-core/src/models/smollm3.rs` as WHOLE FILES: this scan already matched 47 separate duplicated blocks between them, totalling at least 727 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/llama.rs:166` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 4) mistralrs-core/src/ops.rs:4320 — mistralrs-core/src/ops.rs:4320-4328 | mistralrs-core/src/ops.rs:5726-5734 | mistralrs-core/src/ops.rs:6154-6162 | mistralrs-core/src/ops.rs:6502-6510 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/ops.rs:4319` calls `contiguous` and `mistralrs-core/src/ops.rs:5725` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 4) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2583 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2583-2591 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3293-3301 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3635-3643 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:8417-8425 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2583` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 4) mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:318 — mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:318-326 | mistralrs-core/src/vision_models/qwen2vl/mod.rs:475-483 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:964-972 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:410-418 — `mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs` and `mistralrs-core/src/vision_models/qwen2vl/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 16 separate duplicated blocks between them, totalling at least 396 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:318` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 4) mistralrs-quant/src/blockwise_fp8/deepgemm.rs:517 — mistralrs-quant/src/blockwise_fp8/deepgemm.rs:517-525 | mistralrs-quant/src/blockwise_fp8/deepgemm.rs:601-609 | mistralrs-quant/src/blockwise_fp8/deepgemm.rs:620-628 | mistralrs-quant/src/nvfp4/cutlass.rs:257-265 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart.
  • Duplicated block (9 lines × 4) mistralrs-server-core/src/responses_types/content.rs:236 — mistralrs-server-core/src/responses_types/content.rs:236-244 | mistralrs-server-core/src/responses_types/content.rs:507-515 | mistralrs-server-core/src/responses_types/items.rs:182-190 | mistralrs-server-core/src/responses_types/items.rs:483-491 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-server-core/src/responses_types/content.rs:236` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 4) mistralrs-quant/src/hqq/hqq_op.rs:184 — mistralrs-quant/src/hqq/hqq_op.rs:184-192 | mistralrs-quant/src/hqq/hqq_op.rs:297-305 | mistralrs-quant/src/hqq/hqq_op.rs:414-422 | mistralrs-quant/src/hqq/hqq_op.rs:533-541 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/hqq/hqq_op.rs:184` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (5 lines × 5) · ×10
  • Duplicated block (5 lines × 5) mistralrs-core/src/layers.rs:889 — mistralrs-core/src/layers.rs:889-893 | mistralrs-core/src/layers.rs:2051-2055 | mistralrs-core/src/layers.rs:2225-2229 | mistralrs-core/src/layers.rs:3079-3084 | mistralrs-core/src/layers.rs:3212-3217 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/layers.rs:889` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (5 lines × 5) mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:244 — mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:244-248 | mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:286-290 | mistralrs-core/src/vision_models/qwen2vl/mod.rs:401-405 | mistralrs-core/src/vision_models/qwen2vl/mod.rs:443-447 | mistralrs-core/src/vision_models/qwen4_exp/mod.rs:344-348 — `mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs` and `mistralrs-core/src/vision_models/qwen2vl/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 16 separate duplicated blocks between them, totalling at least 396 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:244` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 5) mistralrs-paged-attn/src/metal/kernels/mod.rs:428 — mistralrs-paged-attn/src/metal/kernels/mod.rs:428-433 | mistralrs-paged-attn/src/metal/kernels/mod.rs:817-822 | mistralrs-paged-attn/src/metal/kernels/mod.rs:896-901 | mistralrs-quant/src/metal_kernels/mod.rs:1741-1745 | mistralrs-quant/src/metal_kernels/mod.rs:5199-5203 — before extracting anything, compare `mistralrs-paged-attn/src/metal/kernels/mod.rs` and `mistralrs-quant/src/metal_kernels/mod.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 44 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-quant/src/metal_kernels/mod.rs:5205` calls `set_output_buffer`, `Some` and `mistralrs-quant/src/metal_kernels/mod.rs:1747` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 5) mistralrs-quant/src/metal_kernels/mod.rs:1365 — mistralrs-quant/src/metal_kernels/mod.rs:1365-1370 | mistralrs-quant/src/metal_kernels/mod.rs:1513-1518 | mistralrs-quant/src/metal_kernels/mod.rs:4771-4776 | mistralrs-quant/src/metal_kernels/mod.rs:4834-4839 | mistralrs-quant/src/metal_kernels/mod.rs:5019-5023 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-quant/src/metal_kernels/mod.rs:1372` calls `set_input_buffer`, `Some`, `set_output_buffer` and `mistralrs-quant/src/metal_kernels/mod.rs:5025` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 5) mistralrs-quant/src/metal_kernels/mod.rs:1606 — mistralrs-quant/src/metal_kernels/mod.rs:1606-1610 | mistralrs-quant/src/metal_kernels/mod.rs:1685-1689 | mistralrs-quant/src/metal_kernels/mod.rs:2945-2950 | mistralrs-quant/src/metal_kernels/mod.rs:2982-2987 | mistralrs-quant/src/metal_kernels/mod.rs:4783-4787 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/metal_kernels/mod.rs:1606` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-quant/src/metal_kernels/mod.rs:4781` calls `set_input_buffer`, `Some` and `mistralrs-quant/src/metal_kernels/mod.rs:1604` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 5) mistralrs-quant/src/utils/ops.rs:47 — mistralrs-quant/src/utils/ops.rs:47-51 | mistralrs-quant/src/utils/ops.rs:56-60 | mistralrs-quant/src/utils/ops.rs:65-69 | mistralrs-quant/src/utils/ops.rs:74-78 | mistralrs-quant/src/utils/ops.rs:83-87 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (5 lines × 5) mistralrs-quant/src/utils/ops.rs:697 — mistralrs-quant/src/utils/ops.rs:697-701 | mistralrs-quant/src/utils/ops.rs:706-710 | mistralrs-quant/src/utils/ops.rs:715-719 | mistralrs-quant/src/utils/ops.rs:724-728 | mistralrs-quant/src/utils/ops.rs:733-737 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (5 lines × 5) mistralrs-core/src/ops.rs:1188 — mistralrs-core/src/ops.rs:1188-1193 | mistralrs-core/src/ops.rs:1406-1411 | mistralrs-core/src/ops.rs:1425-1429 | mistralrs-core/src/ops.rs:2602-2606 | mistralrs-core/src/ops.rs:2990-2994 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (5 lines × 5) mistralrs-core/src/ops.rs:1182 — mistralrs-core/src/ops.rs:1182-1187 | mistralrs-core/src/ops.rs:1202-1207 | mistralrs-core/src/ops.rs:1212-1217 | mistralrs-core/src/ops.rs:1400-1405 | mistralrs-core/src/ops.rs:1420-1424 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (5 lines × 5) REDACTED:513 — REDACTED:513-518 | REDACTED:868-873 | mistralrs-core/src/vision_models/idefics3/vision.rs:309-314 | mistralrs-core/src/vision_models/lfm2_vl/vision.rs:242-246 | mistralrs-core/src/vision_models/siglip.rs:320-325 — before extracting anything, compare `REDACTED` and `mistralrs-core/src/vision_models/idefics3/vision.rs` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 221 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:513` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D1 · Cyclomatic Complexity · mistralrs_server_core · ×9
  • mistralrs_server_core::chat_completion::parse_request (cyclomatic 60) mistralrs-server-core/src/chat_completion.rs:605 — mistralrs_server_core::chat_completion::parse_request has cyclomatic complexity 60 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_server_core::responses::create_response (cyclomatic 36) mistralrs-server-core/src/responses.rs:2046 — mistralrs_server_core::responses::create_response has cyclomatic complexity 36 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_server_core::chat_completion::serialize_agentic_data (cyclomatic 24) mistralrs-server-core/src/chat_completion.rs:147 — mistralrs_server_core::chat_completion::serialize_agentic_data has cyclomatic complexity 24 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • mistralrs_server_core::metrics::observe_http (cyclomatic 22) mistralrs-server-core/src/metrics.rs:214 — mistralrs_server_core::metrics::observe_http has cyclomatic complexity 22 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • mistralrs_server_core::speech_generation::match_response_with_options (cyclomatic 21) mistralrs-server-core/src/speech_generation.rs:373 — mistralrs_server_core::speech_generation::match_response_with_options has cyclomatic complexity 21 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • mistralrs_server_core::responses::convert_input_items_to_messages (cyclomatic 20) mistralrs-server-core/src/responses.rs:130 — mistralrs_server_core::responses::convert_input_items_to_messages has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_server_core::audio_history::decorate_responses (cyclomatic 17) mistralrs-server-core/src/audio_history.rs:334 — mistralrs_server_core::audio_history::decorate_responses has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • mistralrs_server_core::chat_completion::chatcompletions (cyclomatic 16) mistralrs-server-core/src/chat_completion.rs:1188 — mistralrs_server_core::chat_completion::chatcompletions has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • mistralrs_server_core::openai::normalize_openai_tools (cyclomatic 16) mistralrs-server-core/src/openai.rs:1054 — mistralrs_server_core::openai::normalize_openai_tools has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D4 · Code Duplication · Edited copy of a member (6 corresponding lines) · ×9
  • Edited copy of a member (6 corresponding lines) mistralrs-core/src/diffusion_models/t5/mod.rs:30 — mistralrs-core/src/diffusion_models/t5/mod.rs:30-35 | mistralrs-core/src/layers_masker.rs:80-86 — These two members are one piece of code written twice and then edited apart: 6 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (6 corresponding lines) mistralrs-core/src/diffusion_models/t5/mod.rs:183 — mistralrs-core/src/diffusion_models/t5/mod.rs:183-188 | mistralrs-core/src/vision_models/llama4/vision.rs:247-252 — These two members are one piece of code written twice and then edited apart: 6 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (6 corresponding lines) mistralrs-core/src/gguf/multimodal_bindings.rs:665 — mistralrs-core/src/gguf/multimodal_bindings.rs:665-670 | mistralrs-core/src/gguf/qwen4exp.rs:251-256 — These two members are one piece of code written twice and then edited apart: 6 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (6 corresponding lines) mistralrs-core/src/vision_models/gemma4/mod.rs:913 — mistralrs-core/src/vision_models/gemma4/mod.rs:913-933 | mistralrs-quant/src/metal_kernels/mod.rs:3351-3356 — These two members are one piece of code written twice and then edited apart: 6 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (6 corresponding lines) mistralrs-core/src/vision_models/llama4/vision.rs:396 — mistralrs-core/src/vision_models/llama4/vision.rs:396-403 | mistralrs-core/src/vision_models/mllama/vision.rs:267-272 — These two members are one piece of code written twice and then edited apart: 6 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (6 corresponding lines) mistralrs-core/src/vision_models/phi4/inputs_processor.rs:1320 — mistralrs-core/src/vision_models/phi4/inputs_processor.rs:1320-1325 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:373-379 — These two members are one piece of code written twice and then edited apart: 6 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (6 corresponding lines) mistralrs-core/src/gdn/cache.rs:110 — mistralrs-core/src/gdn/cache.rs:110-115 | mistralrs-core/src/kv_cache/hybrid_cache.rs:771-776 — These two members are one piece of code written twice and then edited apart: 6 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (6 corresponding lines) mistralrs-core/src/pipeline/loaders/lfm3_audio.rs:147 — mistralrs-core/src/pipeline/loaders/lfm3_audio.rs:147-152 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9130-9135 — These two members are one piece of code written twice and then edited apart: 6 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (6 corresponding lines) mistralrs-quant/src/blockwise_fp8/mma.rs:72 — mistralrs-quant/src/blockwise_fp8/mma.rs:72-77 | mistralrs-quant/src/utils/mod.rs:48-53 — These two members are one piece of code written twice and then edited apart: 6 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Duplicated block (35 lines × 2) · ×9
  • Duplicated block (35 lines × 2) mistralrs-core/src/embedding_models/embedding_gemma.rs:148 — mistralrs-core/src/embedding_models/embedding_gemma.rs:148-182 | mistralrs-core/src/vision_models/gemma3/text.rs:120-154 — before extracting anything, compare `mistralrs-core/src/embedding_models/embedding_gemma.rs` and `mistralrs-core/src/vision_models/gemma3/text.rs` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 286 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/embedding_gemma.rs:148` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (35 lines × 2) mistralrs-core/src/models/lfm2.rs:408 — mistralrs-core/src/models/lfm2.rs:408-442 | mistralrs-core/src/models/lfm3.rs:402-436 — before extracting anything, compare `mistralrs-core/src/models/lfm2.rs` and `mistralrs-core/src/models/lfm3.rs` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 402 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/lfm2.rs:408` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (35 lines × 2) mistralrs-core/src/paged_attention/cache_engine.rs:318 — mistralrs-core/src/paged_attention/cache_engine.rs:318-352 | mistralrs-core/src/paged_attention/cache_engine.rs:404-438 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/paged_attention/cache_engine.rs:318` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (35 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1780 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1780-1814 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2080-2114 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (35 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9886 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9886-9920 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:10972-11006 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (35 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:910 — mistralrs-core/src/pipeline/multimodal.rs:910-944 | mistralrs-core/src/pipeline/normal.rs:913-947 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:910` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (35 lines × 2) mistralrs-quant/src/utils/ops.rs:875 — mistralrs-quant/src/utils/ops.rs:875-909 | mistralrs-quant/src/utils/ops.rs:982-1016 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/utils/ops.rs:875` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (35 lines × 2) mistralrs-core/src/vision_models/qwen3_vl/text.rs:561 — mistralrs-core/src/vision_models/qwen3_vl/text.rs:561-595 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:682-716 — `mistralrs-core/src/vision_models/qwen3_vl/text.rs` and `mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 45 separate duplicated blocks between them, totalling at least 674 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_vl/text.rs:561` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (35 lines × 2) mistralrs-core/src/xlora_models/quantized_llama.rs:300 — mistralrs-core/src/xlora_models/quantized_llama.rs:300-334 | mistralrs-core/src/xlora_models/quantized_llama.rs:551-585 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (15 lines × 4) · ×9
  • Duplicated block (15 lines × 4) mistralrs-core/src/distributed.rs:204 — mistralrs-core/src/distributed.rs:204-218 | mistralrs-core/src/distributed.rs:250-264 | mistralrs-core/src/distributed.rs:290-304 | mistralrs-core/src/distributed.rs:330-344 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/distributed.rs:204` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 4) mistralrs-core/src/embedding_models/qwen3_embedding.rs:360 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:360-374 | mistralrs-core/src/models/hunyuan_v1_dense.rs:439-453 | mistralrs-core/src/models/hunyuan_v1_moe.rs:933-947 | mistralrs-core/src/models/qwen3.rs:433-447 — before extracting anything, compare `mistralrs-core/src/embedding_models/qwen3_embedding.rs` and `mistralrs-core/src/models/hunyuan_v1_dense.rs` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 119 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/qwen3_embedding.rs:360` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (15 lines × 4) mistralrs-core/src/models/deepseek2.rs:991 — mistralrs-core/src/models/deepseek2.rs:991-1005 | mistralrs-core/src/models/deepseek2.rs:1031-1045 | mistralrs-core/src/models/glm4_moe_lite.rs:1006-1020 | mistralrs-core/src/models/glm4_moe_lite.rs:1049-1063 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/glm4_moe_lite.rs` as WHOLE FILES: this scan already matched 51 separate duplicated blocks between them, totalling at least 816 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:991` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 4) mistralrs-core/src/models/glm4.rs:185 — mistralrs-core/src/models/glm4.rs:185-199 | mistralrs-core/src/models/mixtral.rs:128-142 | mistralrs-core/src/models/phi3_5_moe.rs:155-169 | mistralrs-core/src/models/starcoder2.rs:204-218 — before extracting anything, compare `mistralrs-core/src/models/glm4.rs` and `mistralrs-core/src/models/mixtral.rs` as WHOLE FILES: this scan already matched 31 separate duplicated blocks between them, totalling at least 356 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/glm4.rs:185` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 4) mistralrs-core/src/models/mixtral.rs:482 — mistralrs-core/src/models/mixtral.rs:482-496 | mistralrs-core/src/vision_models/phi3/mod.rs:1276-1291 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:464-478 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:585-599 — before extracting anything, compare `mistralrs-core/src/models/mixtral.rs` and `mistralrs-core/src/vision_models/phi3/mod.rs` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 327 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/mixtral.rs:482` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (15 lines × 4) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6872 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6872-6886 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7314-7328 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7782-7796 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:8304-8318 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6872` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 4) mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:658 — mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:658-672 | mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1631-1645 | mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:678-692 | mistralrs-core/src/vision_models/mistral3/inputs_processor.rs:448-462 — `mistralrs-core/src/vision_models/gemma3/inputs_processor.rs` and `mistralrs-core/src/vision_models/gemma4/inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 6 separate duplicated blocks between them, totalling at least 86 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:658` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (15 lines × 4) mistralrs-core/src/xlora_models/llama.rs:353 — mistralrs-core/src/xlora_models/llama.rs:353-367 | mistralrs-core/src/xlora_models/mistral.rs:333-347 | mistralrs-core/src/xlora_models/mixtral.rs:460-474 | mistralrs-core/src/xlora_models/phi3.rs:298-312 — before extracting anything, compare `mistralrs-core/src/xlora_models/llama.rs` and `mistralrs-core/src/xlora_models/mistral.rs` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 274 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/llama.rs:353` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (15 lines × 4) mistralrs-core/src/xlora_models/mistral.rs:522 — mistralrs-core/src/xlora_models/mistral.rs:522-536 | mistralrs-core/src/xlora_models/mixtral.rs:652-666 | mistralrs-core/src/xlora_models/phi2.rs:496-510 | mistralrs-core/src/xlora_models/phi3.rs:472-486 — before extracting anything, compare `mistralrs-core/src/xlora_models/mistral.rs` and `mistralrs-core/src/xlora_models/mixtral.rs` as WHOLE FILES: this scan already matched 53 separate duplicated blocks between them, totalling at least 787 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/mistral.rs:522` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (7 lines × 5) · ×9
  • Duplicated block (7 lines × 5) mistralrs-core/src/gdn/weights.rs:226 — mistralrs-core/src/gdn/weights.rs:226-232 | mistralrs-core/src/gdn/weights.rs:255-261 | mistralrs-core/src/gdn/weights.rs:296-302 | mistralrs-core/src/layers.rs:3667-3673 | mistralrs-core/src/layers.rs:3729-3735 — there are 5 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 5 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/gdn/weights.rs:226` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 5) mistralrs-core/src/model_loader.rs:449 — mistralrs-core/src/model_loader.rs:449-455 | mistralrs-core/src/model_loader.rs:498-504 | mistralrs-core/src/model_loader.rs:910-916 | mistralrs-core/src/toml_selector.rs:1194-1200 | mistralrs-core/src/toml_selector.rs:1230-1236 — before extracting anything, compare `mistralrs-core/src/model_loader.rs` and `mistralrs-core/src/toml_selector.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 199 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/model_loader.rs:449` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 5) mistralrs-core/src/vision_models/gemma4/mod.rs:392 — mistralrs-core/src/vision_models/gemma4/mod.rs:392-398 | mistralrs-core/src/vision_models/gemma4/mod.rs:568-574 | mistralrs-core/src/vision_models/gemma4/mod.rs:705-711 | REDACTED:230-236 | mistralrs-core/src/vision_models/mistral3/mod.rs:259-265 — there are 5 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 5 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma4/mod.rs:392` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 5) mistralrs-quant/src/hqq/hqq_op.rs:39 — mistralrs-quant/src/hqq/hqq_op.rs:39-45 | mistralrs-quant/src/hqq/hqq_op.rs:148-154 | mistralrs-quant/src/hqq/hqq_op.rs:261-267 | mistralrs-quant/src/hqq/hqq_op.rs:378-384 | mistralrs-quant/src/hqq/hqq_op.rs:497-503 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/hqq/hqq_op.rs:39` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 5) mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:406 — mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:406-412 | mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1049-1056 | mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:446-452 | mistralrs-core/src/vision_models/mistral3/inputs_processor.rs:278-284 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:426-435 — `mistralrs-core/src/vision_models/gemma3/inputs_processor.rs` and `mistralrs-core/src/vision_models/gemma4/inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 6 separate duplicated blocks between them, totalling at least 86 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:406` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (7 lines × 5) mistralrs-core/src/ops.rs:1130 — mistralrs-core/src/ops.rs:1130-1136 | mistralrs-core/src/ops.rs:2189-2195 | mistralrs-core/src/ops.rs:2197-2203 | mistralrs-core/src/ops.rs:3938-3945 | mistralrs-core/src/ops.rs:4065-4072 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:1130` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/ops.rs:2187` calls `F32` and `mistralrs-core/src/ops.rs:1129` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 5) mistralrs-paged-attn/src/metal/backend/gather_kv.rs:94 — mistralrs-paged-attn/src/metal/backend/gather_kv.rs:94-100 | mistralrs-paged-attn/src/metal/backend/gather_kv.rs:104-110 | mistralrs-paged-attn/src/metal/backend/gather_kv.rs:114-120 | mistralrs-paged-attn/src/metal/backend/paged_attention.rs:792-799 | mistralrs-paged-attn/src/metal/backend/paged_attention.rs:804-811 — before extracting anything, compare `mistralrs-paged-attn/src/metal/backend/gather_kv.rs` and `mistralrs-paged-attn/src/metal/backend/paged_attention.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 32 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/metal/backend/gather_kv.rs:94` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 5) mistralrs-core/src/ops.rs:1604 — mistralrs-core/src/ops.rs:1604-1610 | mistralrs-core/src/ops.rs:1846-1852 | mistralrs-core/src/ops.rs:4481-4487 | mistralrs-core/src/ops.rs:4645-4651 | mistralrs-core/src/ops.rs:5441-5447 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:1604` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 5) mistralrs-quant/src/afq/ops.rs:146 — mistralrs-quant/src/afq/ops.rs:146-152 | mistralrs-quant/src/afq/ops.rs:256-262 | mistralrs-quant/src/afq/ops.rs:390-396 | mistralrs-quant/src/afq/ops.rs:821-827 | mistralrs-quant/src/afq/ops.rs:829-835 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/afq/ops.rs:146` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D2 · Cognitive Complexity · Sampler · ×8
  • Sampler::apply_dry_penalty (cognitive 39) mistralrs-core/src/sampler.rs:2040 — Sampler::apply_dry_penalty has cognitive complexity 39 (threshold 15). Drivers by points: if/else 12 (32 pts), loops 3 (7 pts) (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Sampler::apply_freq_pres_rep_penalty (cognitive 25) mistralrs-core/src/sampler.rs:1989 — Sampler::apply_freq_pres_rep_penalty has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (19 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Sampler::sample_topk_on_device_metal (cognitive 24) mistralrs-core/src/sampler.rs:1649 — Sampler::sample_topk_on_device_metal has cognitive complexity 24 (threshold 15). Drivers by points: if/else 10 (15 pts), boolean chains 4, loops 2 (4 pts), match/switch 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Sampler::sample_cuda_topk_probabilities (cognitive 23) mistralrs-core/src/sampler.rs:955 — Sampler::sample_cuda_topk_probabilities has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 2 (6 pts), boolean chains 2 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Sampler::sample_topk_on_device (cognitive 23) mistralrs-core/src/sampler.rs:1470 — Sampler::sample_topk_on_device has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 4, loops 2 (4 pts), match/switch 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Sampler::cuda_batch_sampling_plan (cognitive 18) mistralrs-core/src/sampler.rs:754 — Sampler::cuda_batch_sampling_plan has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (10 pts), boolean chains 7, match/switch 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Sampler::sample_top_kp_min_p (cognitive 17) mistralrs-core/src/sampler.rs:1903 — Sampler::sample_top_kp_min_p has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (11 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Sampler::sample (cognitive 16) mistralrs-core/src/sampler.rs:2132 — Sampler::sample has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (9 pts), boolean chains 3, match/switch 2 (3 pts), loops 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D4 · Code Duplication · Edited copy of a member (5 corresponding lines) · ×8
  • Edited copy of a member (5 corresponding lines) mistralrs-core/src/vision_models/phi3/mod.rs:162 — mistralrs-core/src/vision_models/phi3/mod.rs:162-166 | mistralrs-core/src/vision_models/phi4/image_embedding.rs:71-75 — These two members are one piece of code written twice and then edited apart: 5 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (5 corresponding lines) mistralrs-vision/src/ops.rs:4 — mistralrs-vision/src/ops.rs:4-8 | mistralrs-vision/src/ops.rs:14-20 — These two members are one piece of code written twice and then edited apart: 5 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (5 corresponding lines) mistralrs-core/src/vision_models/voxtral/adapter.rs:25 — mistralrs-core/src/vision_models/voxtral/adapter.rs:25-46 | mistralrs-core/src/vision_models/voxtral/mod.rs:253-257 — These two members are one piece of code written twice and then edited apart: 5 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (5 corresponding lines) releases/v0.9.3/scripts/bench_decode_serving.py:425 — releases/v0.9.3/scripts/bench_decode_serving.py:425-430 | releases/v0.9.3/scripts/merge_results.py:37-41 — These two members are one piece of code written twice and then edited apart: 5 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (5 corresponding lines) mistralrs-quant/src/gguf/weight_source.rs:268 — mistralrs-quant/src/gguf/weight_source.rs:268-272 | mistralrs-quant/src/uqff/mod.rs:431-435 — These two members are one piece of code written twice and then edited apart: 5 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (5 corresponding lines) mistralrs-cli/src/commands/uqff.rs:1054 — mistralrs-cli/src/commands/uqff.rs:1054-1058 | mistralrs-sandbox/src/lib.rs:235-241 — These two members are one piece of code written twice and then edited apart: 5 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (5 corresponding lines) mistralrs-core/src/pipeline/cuda_graph.rs:2303 — mistralrs-core/src/pipeline/cuda_graph.rs:2303-2308 | mistralrs-core/src/speculative/dflash.rs:1662-1666 — These two members are one piece of code written twice and then edited apart: 5 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (5 corresponding lines) mistralrs-core/src/models/qwen3_next.rs:1210 — mistralrs-core/src/models/qwen3_next.rs:1210-1214 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:439-443 — These two members are one piece of code written twice and then edited apart: 5 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Duplicated block (28 lines × 2) · ×8
  • Duplicated block (28 lines × 2) mistralrs-core/src/models/glm4_moe.rs:378 — mistralrs-core/src/models/glm4_moe.rs:378-405 | mistralrs-core/src/models/glm4_moe_lite.rs:471-498 — before extracting anything, compare `mistralrs-core/src/models/glm4_moe.rs` and `mistralrs-core/src/models/glm4_moe_lite.rs` as WHOLE FILES: this scan already matched 44 separate duplicated blocks between them, totalling at least 596 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (28 lines × 2) mistralrs-core/src/moe/experts/mod.rs:140 — mistralrs-core/src/moe/experts/mod.rs:140-167 | mistralrs-core/src/moe/experts/mod.rs:214-241 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/moe/experts/mod.rs:140` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (28 lines × 2) mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:740 — mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:740-767 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3781-3808 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/embedding_loaders.rs` and `mistralrs-core/src/pipeline/loaders/normal_loaders.rs` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 216 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:740` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (28 lines × 2) mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:913 — mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:913-940 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1478-1505 — `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` and `mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 45 separate duplicated blocks between them, totalling at least 1082 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:913` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (28 lines × 2) mistralrs-core/src/vision_models/qwen3_5/mod.rs:408 — mistralrs-core/src/vision_models/qwen3_5/mod.rs:408-435 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:393-420 — `mistralrs-core/src/vision_models/qwen3_5/mod.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 24 separate duplicated blocks between them, totalling at least 425 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_5/mod.rs:408` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (28 lines × 2) mistralrs-core/src/vision_models/qwen3_vl/text.rs:518 — mistralrs-core/src/vision_models/qwen3_vl/text.rs:518-545 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:639-666 — `mistralrs-core/src/vision_models/qwen3_vl/text.rs` and `mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 45 separate duplicated blocks between them, totalling at least 674 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (28 lines × 2) mistralrs-quant/src/cutile/fused_moe.rs:387 — mistralrs-quant/src/cutile/fused_moe.rs:387-414 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:421-448 — before extracting anything, compare `mistralrs-quant/src/cutile/fused_moe.rs` and `mistralrs-quant/src/cutile/fused_moe_fp8.rs` as WHOLE FILES: this scan already matched 24 separate duplicated blocks between them, totalling at least 298 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cutile/fused_moe.rs:387` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (28 lines × 2) mistralrs-core/src/xlora_models/classifier.rs:81 — mistralrs-core/src/xlora_models/classifier.rs:81-108 | mistralrs-core/src/xlora_models/classifier.rs:144-171 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (24 lines × 2) · ×8
  • Duplicated block (24 lines × 2) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1512 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1512-1535 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2896-2919 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1512` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (24 lines × 2) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3082 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3082-3105 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3415-3438 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3082` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (24 lines × 2) mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:221 — mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:221-244 | mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:648-671 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:221` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (24 lines × 2) mistralrs-paged-attn/src/metal/kernels/mod.rs:108 — mistralrs-paged-attn/src/metal/kernels/mod.rs:108-131 | mistralrs-quant/src/metal_kernels/mod.rs:105-128 — before extracting anything, compare `mistralrs-paged-attn/src/metal/kernels/mod.rs` and `mistralrs-quant/src/metal_kernels/mod.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 44 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/metal/kernels/mod.rs:108` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (24 lines × 2) mistralrs-paged-attn/src/metal/kernels/mod.rs:461 — mistralrs-paged-attn/src/metal/kernels/mod.rs:461-484 | mistralrs-paged-attn/src/metal/kernels/mod.rs:856-879 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/metal/kernels/mod.rs:461` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (24 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1093 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1093-1116 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3894-3917 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (24 lines × 2) mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:985 — mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:985-1008 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1550-1573 — `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` and `mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 45 separate duplicated blocks between them, totalling at least 1082 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:985` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (24 lines × 2) mistralrs-paged-attn/src/cuda/backend/fa3.rs:269 — mistralrs-paged-attn/src/cuda/backend/fa3.rs:269-292 | mistralrs-paged-attn/src/cuda/backend/fa3.rs:543-566 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/cuda/backend/fa3.rs:269` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (19 lines × 3) · ×8
  • Duplicated block (19 lines × 3) mistralrs-core/src/layers.rs:2365 — mistralrs-core/src/layers.rs:2365-2383 | mistralrs-core/src/layers.rs:2463-2481 | mistralrs-core/src/layers.rs:2510-2528 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/layers.rs:2365` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (19 lines × 3) mistralrs-core/src/model_loader.rs:745 — mistralrs-core/src/model_loader.rs:745-763 | mistralrs-core/src/model_loader.rs:779-797 | mistralrs-core/src/toml_selector.rs:1055-1073 — before extracting anything, compare `mistralrs-core/src/model_loader.rs` and `mistralrs-core/src/toml_selector.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 199 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/model_loader.rs:745` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (19 lines × 3) mistralrs-core/src/vision_models/gemma4/mod.rs:445 — mistralrs-core/src/vision_models/gemma4/mod.rs:445-463 | mistralrs-core/src/vision_models/gemma4/mod.rs:598-616 | mistralrs-core/src/vision_models/gemma4/mod.rs:758-776 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma4/mod.rs:445` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (19 lines × 3) mistralrs-core/src/vision_models/grid_processor.rs:1406 — mistralrs-core/src/vision_models/grid_processor.rs:1406-1424 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:604-622 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1212-1230 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:1406` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (19 lines × 3) REDACTED:572 — REDACTED:572-590 | mistralrs-core/src/vision_models/idefics3/vision.rs:369-387 | mistralrs-core/src/vision_models/siglip.rs:380-398 — before extracting anything, compare `REDACTED` and `mistralrs-core/src/vision_models/idefics3/vision.rs` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 221 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit. Note first that the copies are not typed on the same thing: the declarations holding them bind `config` to `VisionConfig` in one and `Idefics3VisionConfig` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (19 lines × 3) mistralrs-core/src/vision_models/qwen3_5/mod.rs:137 — mistralrs-core/src/vision_models/qwen3_5/mod.rs:137-155 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:120-138 | mistralrs-core/src/vision_models/qwen4_exp/mod.rs:244-262 — `mistralrs-core/src/vision_models/qwen3_5/mod.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 24 separate duplicated blocks between them, totalling at least 425 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_5/mod.rs:137` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (19 lines × 3) mistralrs-core/src/models/llama.rs:613 — mistralrs-core/src/models/llama.rs:613-631 | mistralrs-core/src/models/smollm3.rs:632-650 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:626-644 — before extracting anything, compare `mistralrs-core/src/models/llama.rs` and `mistralrs-core/src/models/smollm3.rs` as WHOLE FILES: this scan already matched 47 separate duplicated blocks between them, totalling at least 727 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/llama.rs:613` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (19 lines × 3) mistralrs-core/src/layers.rs:1207 — mistralrs-core/src/layers.rs:1207-1225 | mistralrs-core/src/layers.rs:1297-1315 | mistralrs-core/src/layers.rs:1566-1584 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/layers.rs:1207` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `cfg` to `&llama4::TextConfig` in one and `&smollm3::Config` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (13–14 lines × 2) · ×8
  • Duplicated block (13–14 lines × 2) mistralrs-core/src/embedding_models/embedding_gemma.rs:373 — mistralrs-core/src/embedding_models/embedding_gemma.rs:373-386 | mistralrs-core/src/embedding_models/qwen3_embedding.rs:329-341 — before extracting anything, compare `mistralrs-core/src/embedding_models/embedding_gemma.rs` and `mistralrs-core/src/embedding_models/qwen3_embedding.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 40 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/embedding_models/embedding_gemma.rs:387` calls `sqrt` and `mistralrs-core/src/embedding_models/qwen3_embedding.rs:343` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (13–14 lines × 2) mistralrs-core/src/models/quantized_llama.rs:355 — mistralrs-core/src/models/quantized_llama.rs:355-368 | mistralrs-core/src/xlora_models/quantized_llama.rs:795-807 — `mistralrs-core/src/models/quantized_llama.rs` and `mistralrs-core/src/xlora_models/quantized_llama.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 4 separate duplicated blocks between them, totalling at least 58 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/quantized_llama.rs:355` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (13–14 lines × 2) mistralrs-core/src/moe/experts/backends.rs:920 — mistralrs-core/src/moe/experts/backends.rs:920-933 | mistralrs-core/src/moe/experts/backends.rs:995-1007 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/moe/experts/backends.rs:920` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13–14 lines × 2) mistralrs-core/src/sampler.rs:1235 — mistralrs-core/src/sampler.rs:1235-1247 | mistralrs-core/src/sampler.rs:1943-1956 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (13–14 lines × 2) mistralrs-core/src/vision_models/gemma3/text.rs:143 — mistralrs-core/src/vision_models/gemma3/text.rs:143-156 | mistralrs-core/src/vision_models/gemma3n/text.rs:385-397 — `mistralrs-core/src/vision_models/gemma3/text.rs` and `mistralrs-core/src/vision_models/gemma3n/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 16 separate duplicated blocks between them, totalling at least 214 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3/text.rs:143` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/vision_models/gemma3n/text.rs:384` calls `kv_shared_layer_index`, `Ok` and `mistralrs-core/src/vision_models/gemma3/text.rs:143` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (13–14 lines × 2) mistralrs-quant/src/distributed/layers.rs:562 — mistralrs-quant/src/distributed/layers.rs:562-575 | mistralrs-quant/src/distributed/layers.rs:963-975 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/distributed/layers.rs:562` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13–14 lines × 2) mistralrs-quant/src/mxfp4/ops.rs:473 — mistralrs-quant/src/mxfp4/ops.rs:473-485 | mistralrs-quant/src/mxfp4/ops.rs:490-503 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/mxfp4/ops.rs:473` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (13–14 lines × 2) mistralrs-quant/src/mxfp4/ops.rs:541 — mistralrs-quant/src/mxfp4/ops.rs:541-553 | mistralrs-quant/src/mxfp4/ops.rs:558-571 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/mxfp4/ops.rs:541` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (6 lines × 5) · ×8
  • Duplicated block (6 lines × 5) mistralrs-core/src/cuda/gdn.rs:1998 — mistralrs-core/src/cuda/gdn.rs:1998-2003 | mistralrs-core/src/cuda/gdn.rs:2005-2010 | mistralrs-core/src/cuda/gdn.rs:3192-3197 | mistralrs-core/src/cuda/gdn.rs:6222-6227 | mistralrs-core/src/cuda/gdn.rs:6229-6234 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/gdn.rs:1998` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 5) mistralrs-core/src/metal/gdn.rs:204 — mistralrs-core/src/metal/gdn.rs:204-209 | mistralrs-core/src/metal/gdn.rs:319-324 | mistralrs-core/src/metal/gdn.rs:792-797 | mistralrs-core/src/metal/gdn.rs:980-985 | mistralrs-core/src/metal/ssm.rs:182-187 — before extracting anything, compare `mistralrs-core/src/metal/gdn.rs` and `mistralrs-core/src/metal/ssm.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 68 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (6 lines × 5) mistralrs-core/src/ops.rs:4472 — mistralrs-core/src/ops.rs:4472-4477 | mistralrs-core/src/ops.rs:4758-4763 | mistralrs-core/src/ops.rs:5432-5437 | mistralrs-core/src/ops.rs:5704-5709 | mistralrs-core/src/ops.rs:6127-6132 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/ops.rs:5431` calls `contiguous` and `mistralrs-core/src/ops.rs:4470` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (6 lines × 5) mistralrs-pyo3/src/lib.rs:759 — mistralrs-pyo3/src/lib.rs:759-764 | mistralrs-pyo3/src/lib.rs:795-800 | mistralrs-pyo3/src/lib.rs:826-831 | mistralrs-pyo3/src/lib.rs:874-879 | mistralrs-pyo3/src/lib.rs:1155-1160 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-pyo3/src/lib.rs:759` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-pyo3/src/lib.rs:758` calls `unwrap_or`, `default` and `mistralrs-pyo3/src/lib.rs:794` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (6 lines × 5) mistralrs-quant/src/hqq/mod.rs:381 — mistralrs-quant/src/hqq/mod.rs:381-386 | mistralrs-quant/src/hqq/mod.rs:396-401 | mistralrs-quant/src/hqq/mod.rs:470-475 | mistralrs-quant/src/hqq/mod.rs:534-539 | mistralrs-quant/src/hqq/mod.rs:557-562 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (6 lines × 5) mistralrs-quant/src/metal_kernels/mod.rs:1594 — mistralrs-quant/src/metal_kernels/mod.rs:1594-1600 | mistralrs-quant/src/metal_kernels/mod.rs:1670-1676 | mistralrs-quant/src/metal_kernels/mod.rs:1739-1744 | mistralrs-quant/src/metal_kernels/mod.rs:2720-2727 | mistralrs-quant/src/metal_kernels/mod.rs:2856-2862 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-quant/src/metal_kernels/mod.rs:2852` calls `type_to_name` and `mistralrs-quant/src/metal_kernels/mod.rs:1591` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (6 lines × 5) mistralrs-core/src/layers.rs:881 — mistralrs-core/src/layers.rs:881-886 | mistralrs-core/src/layers.rs:2217-2222 | mistralrs-core/src/layers.rs:2368-2373 | mistralrs-core/src/layers.rs:2466-2471 | mistralrs-core/src/layers.rs:2513-2518 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Note first that the copies are not typed on the same thing: the declarations holding them bind `cfg` to `&PhiRopeConfig` in one and `&Phi4MMConfig` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (6 lines × 5) mistralrs-core/src/models/flint.rs:535 — mistralrs-core/src/models/flint.rs:535-540 | mistralrs-core/src/models/lfm2.rs:283-288 | mistralrs-core/src/models/qwen3_moe.rs:364-369 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:317-322 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:103-108 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/lfm2.rs` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 104 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Edited copy of a member (26 corresponding lines) · ×7
  • Edited copy of a member (26 corresponding lines) mistralrs-core/src/models/flint.rs:981 — mistralrs-core/src/models/flint.rs:981-1017 | mistralrs-core/src/models/hunyuan_v1_moe.rs:1067-1092 — These two members are one piece of code written twice and then edited apart: 26 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (26 corresponding lines) mistralrs-core/src/attention/backends/cpu/neon.rs:366 — mistralrs-core/src/attention/backends/cpu/neon.rs:366-391 | mistralrs-core/src/attention/backends/cpu/neon.rs:605-630 — These two members are one piece of code written twice and then edited apart: 26 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (26 corresponding lines) mistralrs-core/src/cuda/hyper_connection.rs:299 — mistralrs-core/src/cuda/hyper_connection.rs:299-324 | mistralrs-core/src/cuda/hyper_connection.rs:326-354 — These two members are one piece of code written twice and then edited apart: 26 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (26 corresponding lines) mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:362 — mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:362-391 | mistralrs-core/src/vision_models/qwen2vl/vision.rs:330-355 — These two members are one piece of code written twice and then edited apart: 26 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (26 corresponding lines) mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:343 — mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:343-368 | mistralrs-core/src/vision_models/llama4/inputs_processor.rs:189-220 — These two members are one piece of code written twice and then edited apart: 26 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (26 corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2353 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2353-2385 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2391-2416 — These two members are one piece of code written twice and then edited apart: 26 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (26 corresponding lines) mistralrs-core/src/attention/backends/cpu/neon.rs:395 — mistralrs-core/src/attention/backends/cpu/neon.rs:395-420 | mistralrs-core/src/attention/backends/cpu/neon.rs:632-657 — These two members are one piece of code written twice and then edited apart: 26 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (22 corresponding lines) · ×7
  • Edited copy of a member (22 corresponding lines) mistralrs-core/src/pipeline/hf.rs:330 — mistralrs-core/src/pipeline/hf.rs:330-351 | mistralrs-quant/src/uqff/report.rs:871-893 — These two members are one piece of code written twice and then edited apart: 22 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (22 corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7877 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7877-7898 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9041-9064 — These two members are one piece of code written twice and then edited apart: 22 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (22 corresponding lines) mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:515 — mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:515-536 | mistralrs-paged-attn/src/metal/backend/paged_attention.rs:735-756 — These two members are one piece of code written twice and then edited apart: 22 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (22 corresponding lines) mistralrs-core/src/ops.rs:2856 — mistralrs-core/src/ops.rs:2856-2877 | mistralrs-core/src/ops.rs:3360-3382 — These two members are one piece of code written twice and then edited apart: 22 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (22 corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9603 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9603-9627 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:10836-10857 — These two members are one piece of code written twice and then edited apart: 22 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (22 corresponding lines) mistralrs-code-exec/src/tools.rs:374 — mistralrs-code-exec/src/tools.rs:374-398 | mistralrs-code-exec/src/tools.rs:400-421 — These two members are one piece of code written twice and then edited apart: 22 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (22 corresponding lines) mistralrs-server-core/src/metrics.rs:620 — mistralrs-server-core/src/metrics.rs:620-643 | mistralrs-server-core/src/metrics.rs:645-666 — These two members are one piece of code written twice and then edited apart: 22 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Duplicated block (39 lines × 2) · ×7
  • Duplicated block (39 lines × 2) mistralrs-core/src/models/phi3.rs:426 — mistralrs-core/src/models/phi3.rs:426-464 | mistralrs-core/src/models/phi3_5_moe.rs:495-533 — before extracting anything, compare `mistralrs-core/src/models/phi3.rs` and `mistralrs-core/src/models/phi3_5_moe.rs` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 343 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/phi3.rs:426` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/models/phi3.rs:423` calls `then`, `set_nm_device`, `pp` and `mistralrs-core/src/models/phi3_5_moe.rs:494` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (39 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:826 — mistralrs-core/src/pipeline/multimodal.rs:826-864 | mistralrs-core/src/pipeline/normal.rs:832-870 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:826` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (39 lines × 2) mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:550 — mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:550-588 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1158-1196 — `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` and `mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 45 separate duplicated blocks between them, totalling at least 1082 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:550` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (39 lines × 2) mistralrs-core/src/vision_models/qwen3_5/text.rs:980 — mistralrs-core/src/vision_models/qwen3_5/text.rs:980-1018 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:692-730 — `mistralrs-core/src/vision_models/qwen3_5/text.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 26 separate duplicated blocks between them, totalling at least 469 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_5/text.rs:980` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:691` calls `clone` and `mistralrs-core/src/vision_models/qwen3_5/text.rs:979` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (39 lines × 2) mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:394 — mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:394-432 | mistralrs-core/src/vision_models/qwen2vl/vision.rs:358-396 — `mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs` and `mistralrs-core/src/vision_models/qwen2vl/vision.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 15 separate duplicated blocks between them, totalling at least 182 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (39 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:1044 — mistralrs-core/src/pipeline/multimodal.rs:1044-1082 | mistralrs-core/src/pipeline/normal.rs:1047-1085 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:1044` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/pipeline/normal.rs:1087` calls `is_adapted_and`, `is_x_lora` and `mistralrs-core/src/pipeline/multimodal.rs:1084` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (39 lines × 2) mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:171 — mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:171-209 | mistralrs-core/src/vision_models/qwen2vl/vision.rs:142-180 — `mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs` and `mistralrs-core/src/vision_models/qwen2vl/vision.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 15 separate duplicated blocks between them, totalling at least 182 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (32 lines × 2) · ×7
  • Duplicated block (32 lines × 2) mistralrs-core/src/layers.rs:1648 — mistralrs-core/src/layers.rs:1648-1679 | mistralrs-core/src/layers.rs:1959-1990 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/layers.rs:1648` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (32 lines × 2) mistralrs-core/src/model_loader.rs:703 — mistralrs-core/src/model_loader.rs:703-734 | mistralrs-core/src/toml_selector.rs:980-1011 — before extracting anything, compare `mistralrs-core/src/model_loader.rs` and `mistralrs-core/src/toml_selector.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 199 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (32 lines × 2) mistralrs-core/src/models/phi3.rs:98 — mistralrs-core/src/models/phi3.rs:98-129 | mistralrs-core/src/vision_models/phi3/mod.rs:189-220 — before extracting anything, compare `mistralrs-core/src/models/phi3.rs` and `mistralrs-core/src/vision_models/phi3/mod.rs` as WHOLE FILES: this scan already matched 50 separate duplicated blocks between them, totalling at least 638 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/phi3.rs:98` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (32 lines × 2) mistralrs-core/src/ops.rs:1639 — mistralrs-core/src/ops.rs:1639-1670 | mistralrs-core/src/ops.rs:1902-1933 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (32 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:3214 — mistralrs-core/src/pipeline/multimodal.rs:3214-3245 | mistralrs-core/src/pipeline/normal.rs:2761-2792 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (32 lines × 2) mistralrs-core/src/speculative/hybrid_state.rs:429 — mistralrs-core/src/speculative/hybrid_state.rs:429-460 | mistralrs-core/src/speculative/hybrid_state.rs:493-524 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/speculative/hybrid_state.rs:429` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (32 lines × 2) mistralrs-core/src/vision_models/gemma4/audio.rs:271 — mistralrs-core/src/vision_models/gemma4/audio.rs:271-302 | mistralrs-core/src/vision_models/gemma4/vision.rs:102-133 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (29 lines × 2) · ×7
  • Duplicated block (29 lines × 2) mistralrs-core/src/models/gemma.rs:200 — mistralrs-core/src/models/gemma.rs:200-228 | mistralrs-core/src/models/phi2.rs:296-324 — before extracting anything, compare `mistralrs-core/src/models/gemma.rs` and `mistralrs-core/src/models/phi2.rs` as WHOLE FILES: this scan already matched 36 separate duplicated blocks between them, totalling at least 418 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma.rs:200` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (29 lines × 2) mistralrs-core/src/models/qwen3_moe.rs:369 — mistralrs-core/src/models/qwen3_moe.rs:369-397 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:108-136 — before extracting anything, compare `mistralrs-core/src/models/qwen3_moe.rs` and `mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs` as WHOLE FILES: this scan already matched 29 separate duplicated blocks between them, totalling at least 331 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/qwen3_moe.rs:369` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (29 lines × 2) mistralrs-core/src/paged_attention/cache_engine.rs:466 — mistralrs-core/src/paged_attention/cache_engine.rs:466-494 | mistralrs-core/src/paged_attention/cache_engine.rs:504-532 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/paged_attention/cache_engine.rs:466` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (29 lines × 2) mistralrs-core/src/paged_attention/layers/paged_attention.rs:1710 — mistralrs-core/src/paged_attention/layers/paged_attention.rs:1710-1738 | mistralrs-core/src/paged_attention/layers/paged_attention.rs:1848-1876 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/paged_attention/layers/paged_attention.rs:1710` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (29 lines × 2) mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:332 — mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:332-360 | mistralrs-paged-attn/src/cuda/backend/mla.rs:341-369 — before extracting anything, compare `mistralrs-paged-attn/src/cuda/backend/flashinfer.rs` and `mistralrs-paged-attn/src/cuda/backend/mla.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 50 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:332` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (29 lines × 2) mistralrs-quant/src/lib.rs:2632 — mistralrs-quant/src/lib.rs:2632-2660 | mistralrs-quant/src/lib.rs:2698-2726 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/lib.rs:2632` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (29 lines × 2) mistralrs-core/src/vision_models/phi3/mod.rs:561 — mistralrs-core/src/vision_models/phi3/mod.rs:561-589 | mistralrs-core/src/vision_models/phi4/image_embedding.rs:184-212 — before extracting anything, compare `mistralrs-core/src/vision_models/phi3/mod.rs` and `mistralrs-core/src/vision_models/phi4/image_embedding.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 98 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/phi3/mod.rs:561` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (12–14 lines × 2) · ×7
  • Duplicated block (12–14 lines × 2) mistralrs-core/src/engine/add_request.rs:818 — mistralrs-core/src/engine/add_request.rs:818-829 | mistralrs-core/src/engine/add_request.rs:834-847 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (12–14 lines × 2) mistralrs-core/src/vision_models/lfm3_d1/mod.rs:190 — mistralrs-core/src/vision_models/lfm3_d1/mod.rs:190-201 | mistralrs-core/src/vision_models/lfm3_omni/mod.rs:399-412 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/lfm3_d1/mod.rs:190` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12–14 lines × 2) mistralrs-paged-attn/src/metal/kernels/mod.rs:531 — mistralrs-paged-attn/src/metal/kernels/mod.rs:531-542 | mistralrs-paged-attn/src/metal/kernels/mod.rs:671-684 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/metal/kernels/mod.rs:531` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (12–14 lines × 2) mistralrs-quant/src/distributed/layers.rs:503 — mistralrs-quant/src/distributed/layers.rs:503-514 | mistralrs-quant/src/distributed/layers.rs:598-611 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/distributed/layers.rs:598` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (12–14 lines × 2) mistralrs-quant/src/distributed/layers.rs:876 — mistralrs-quant/src/distributed/layers.rs:876-889 | mistralrs-quant/src/distributed/layers.rs:996-1007 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/distributed/layers.rs:876` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (12–14 lines × 2) mistralrs-quant/src/routed_moe/cuda.rs:213 — mistralrs-quant/src/routed_moe/cuda.rs:213-224 | mistralrs-quant/src/routed_moe/cuda.rs:283-296 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (12–14 lines × 2) mistralrs-core/src/ops.rs:464 — mistralrs-core/src/ops.rs:464-477 | mistralrs-core/src/ops.rs:481-492 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:481` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (9 lines × 5) · ×7
  • Duplicated block (9 lines × 5) mistralrs-core/src/embedding_models/qwen3_embedding.rs:413 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:413-421 | mistralrs-core/src/models/glm4.rs:556-564 | mistralrs-core/src/models/mistral.rs:557-565 | mistralrs-core/src/models/qwen3.rs:515-523 | mistralrs-core/src/models/qwen3_moe.rs:695-703 — before extracting anything, compare `mistralrs-core/src/embedding_models/qwen3_embedding.rs` and `mistralrs-core/src/models/glm4.rs` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 137 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/qwen3_embedding.rs:413` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 5) mistralrs-core/src/models/llama.rs:382 — mistralrs-core/src/models/llama.rs:382-390 | mistralrs-core/src/models/mistral.rs:436-444 | mistralrs-core/src/models/phi3.rs:428-436 | mistralrs-core/src/models/phi3_5_moe.rs:497-505 | mistralrs-core/src/models/smollm3.rs:398-406 — before extracting anything, compare `mistralrs-core/src/models/llama.rs` and `mistralrs-core/src/models/mistral.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 397 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/llama.rs:382` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/models/mistral.rs:435` calls `head_dim` and `mistralrs-core/src/models/phi3.rs:427` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 5) mistralrs-core/src/models/qwen3_moe.rs:408 — mistralrs-core/src/models/qwen3_moe.rs:408-416 | mistralrs-core/src/models/qwen3_next.rs:479-487 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:383-391 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:147-155 | mistralrs-core/src/vision_models/qwen4_exp/text.rs:156-164 — before extracting anything, compare `mistralrs-core/src/models/qwen3_moe.rs` and `mistralrs-core/src/models/qwen3_next.rs` as WHOLE FILES: this scan already matched 27 separate duplicated blocks between them, totalling at least 332 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/qwen3_moe.rs:408` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 5) mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:219 — mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:219-227 | mistralrs-core/src/vision_models/qwen2vl/text.rs:220-228 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:211-219 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:212-220 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:318-326 — `mistralrs-core/src/vision_models/qwen2_5_vl/text.rs` and `mistralrs-core/src/vision_models/qwen2vl/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 42 separate duplicated blocks between them, totalling at least 716 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:219` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 5) mistralrs-core/src/vision_models/qwen3_5/text.rs:870 — mistralrs-core/src/vision_models/qwen3_5/text.rs:870-878 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:566-574 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:401-409 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:521-529 | mistralrs-core/src/vision_models/qwen4_exp/text.rs:271-279 — `mistralrs-core/src/vision_models/qwen3_5/text.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 26 separate duplicated blocks between them, totalling at least 469 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (9 lines × 5) mistralrs-quant/src/utils/ops.rs:292 — mistralrs-quant/src/utils/ops.rs:292-300 | mistralrs-quant/src/utils/ops.rs:306-314 | mistralrs-quant/src/utils/ops.rs:320-328 | mistralrs-quant/src/utils/ops.rs:334-342 | mistralrs-quant/src/utils/ops.rs:348-356 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (9 lines × 5) mistralrs-core/src/models/granite.rs:2221 — mistralrs-core/src/models/granite.rs:2221-2229 | mistralrs-core/src/models/lfm2.rs:1211-1219 | mistralrs-core/src/models/lfm3.rs:1211-1219 | mistralrs-core/src/models/qwen3_next.rs:1012-1020 | mistralrs-core/src/vision_models/qwen3_5/packed_gdn.rs:95-103 — before extracting anything, compare `mistralrs-core/src/models/granite.rs` and `mistralrs-core/src/models/lfm2.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 79 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/granite.rs:2221` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/models/granite.rs:2218` calls `dims3`, `packed_mamba_query_ranges` and `mistralrs-core/src/models/lfm3.rs:1209` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (5 lines × 4) · ×7
  • Duplicated block (5 lines × 4) REDACTED:513 — REDACTED:513-518 | mistralrs-core/src/vision_models/idefics3/vision.rs:309-314 | mistralrs-core/src/vision_models/lfm2_vl/vision.rs:242-246 | mistralrs-core/src/vision_models/siglip.rs:320-325 — before extracting anything, compare `REDACTED` and `mistralrs-core/src/vision_models/idefics3/vision.rs` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 221 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:513` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 4) mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:67 — mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:67-71 | mistralrs-quant/src/gguf/cuda.rs:123-127 | mistralrs-quant/src/gguf/fast_mmq.rs:395-399 | mistralrs-quant/src/gguf/fast_mmvq.rs:128-132 — before extracting anything, compare `mistralrs-quant/src/gguf/fast_mmq.rs` and `mistralrs-quant/src/gguf/fast_mmvq.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 62 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:67` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `dev` to `&candle::cuda_backend::CudaDevice` in one and `&CudaDevice` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (5 lines × 4) mistralrs-core/src/vision_models/gemma4/vision.rs:56 — mistralrs-core/src/vision_models/gemma4/vision.rs:56-60 | mistralrs-core/src/vision_models/gemma4/vision.rs:62-66 | mistralrs-core/src/vision_models/gemma4/vision.rs:68-72 | mistralrs-core/src/vision_models/gemma4/vision.rs:73-77 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma4/vision.rs:56` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/vision_models/gemma4/vision.rs:56` calls `ok` and `mistralrs-core/src/vision_models/gemma4/vision.rs:73` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 4) mistralrs-quant/src/cutile/fused_moe.rs:481 — mistralrs-quant/src/cutile/fused_moe.rs:481-486 | mistralrs-quant/src/moe/cuda.rs:236-240 | mistralrs-quant/src/moe/cuda.rs:272-276 | mistralrs-quant/src/moe/cuda.rs:312-316 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart.
  • Duplicated block (5 lines × 4) mistralrs-paged-attn/src/cuda/backend/flash_attn_sinks.rs:225 — mistralrs-paged-attn/src/cuda/backend/flash_attn_sinks.rs:225-229 | mistralrs-paged-attn/src/cuda/backend/flash_attn_sinks.rs:234-238 | mistralrs-quant/src/gptq/marlin_backend.rs:66-70 | mistralrs-quant/src/gptq/marlin_backend.rs:258-262 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart.
  • Duplicated block (5 lines × 4) mistralrs-quant/src/blockwise_fp8/deepgemm.rs:446 — mistralrs-quant/src/blockwise_fp8/deepgemm.rs:446-450 | mistralrs-quant/src/blockwise_fp8/ops.rs:1780-1784 | mistralrs-quant/src/cutile/fp8_w8a16.rs:419-423 | mistralrs-quant/src/cutile/fp8_w8a8.rs:481-485 — before extracting anything, compare `mistralrs-quant/src/blockwise_fp8/deepgemm.rs` and `mistralrs-quant/src/blockwise_fp8/ops.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 65 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/blockwise_fp8/deepgemm.rs:446` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-quant/src/cutile/fp8_w8a8.rs:480` calls `device`, `same_device` and `mistralrs-quant/src/blockwise_fp8/deepgemm.rs:445` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 4) mistralrs-quant/src/cutile/fused_moe.rs:475 — mistralrs-quant/src/cutile/fused_moe.rs:475-479 | mistralrs-quant/src/moe/cuda.rs:235-239 | mistralrs-quant/src/moe/cuda.rs:271-275 | mistralrs-quant/src/moe/cuda.rs:311-315 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-quant/src/moe/cuda.rs:233` calls `cu_stream` and `mistralrs-quant/src/cutile/fused_moe.rs:473` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D2 · Cognitive Complexity · Attention · ×6
  • Attention::forward (cognitive 53) mistralrs-core/src/vision_models/gemma4/text.rs:507 — Attention::forward has cognitive complexity 53 (threshold 15). Drivers by points: if/else 33 (46 pts), match/switch 3 (6 pts), boolean chains 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Attention::forward (cognitive 30) mistralrs-core/src/vision_models/gemma3n/text.rs:434 — Attention::forward has cognitive complexity 30 (threshold 15). Drivers by points: if/else 18 (24 pts), match/switch 3 (6 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Attention::forward (cognitive 27) mistralrs-core/src/models/deepseek2.rs:287 — Attention::forward has cognitive complexity 27 (threshold 15). Drivers by points: if/else 12 (18 pts), match/switch 2 (7 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Attention::forward (cognitive 27) mistralrs-core/src/models/deepseek3.rs:288 — Attention::forward has cognitive complexity 27 (threshold 15). Drivers by points: if/else 12 (18 pts), match/switch 2 (7 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Attention::forward (cognitive 27) mistralrs-core/src/models/glm4_moe_lite.rs:248 — Attention::forward has cognitive complexity 27 (threshold 15). Drivers by points: if/else 12 (18 pts), match/switch 2 (7 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Attention::new (cognitive 20) mistralrs-core/src/vision_models/gemma4/text.rs:313 — Attention::new has cognitive complexity 20 (threshold 15). Drivers by points: if/else 12 (16 pts), boolean chains 2, match/switch 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D35 · Change Coupling · Change coupling · ×6
  • Change coupling: embedding.rs ↔ multimodal.rs mistralrs-core/src/pipeline/embedding.rs:1 — `mistralrs-core/src/pipeline/embedding.rs` and `mistralrs-core/src/pipeline/multimodal.rs` change together 88% of the time (14 of the 16 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency between them. They sit in the same directory, but in this ecosystem each file is its own module — a sibling reference still needs an import — so the missing import edge is real: the coupling runs through shared behaviour, not a declared dependency. If they duplicate structure, extract the common part into one unit; otherwise the coupling is hidden and worth breaking. You can check this without leaving the row: of the 14 shared commits counted here, the most recent 3 are `86f39271` feat(fp8): support ModelOpt and compressed-tensors checkpoints with c…; `d1ffbe7e` fix(qwen3.5): better support for hybrid models and auto device map (#…; `b7956205` feat(uqff): no dummy run for uqff generation pass (#2316) — run `git show` on any of them.
  • Change coupling: embedding.rs ↔ normal.rs mistralrs-core/src/pipeline/embedding.rs:1 — `mistralrs-core/src/pipeline/embedding.rs` and `mistralrs-core/src/pipeline/normal.rs` change together 81% of the time (13 of the 16 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency between them. They sit in the same directory, but in this ecosystem each file is its own module — a sibling reference still needs an import — so the missing import edge is real: the coupling runs through shared behaviour, not a declared dependency. If they duplicate structure, extract the common part into one unit; otherwise the coupling is hidden and worth breaking. You can check this without leaving the row: of the 13 shared commits counted here, the most recent 3 are `86f39271` feat(fp8): support ModelOpt and compressed-tensors checkpoints with c…; `d1ffbe7e` fix(qwen3.5): better support for hybrid models and auto device map (#…; `b7956205` feat(uqff): no dummy run for uqff generation pass (#2316) — run `git show` on any of them.
  • Change coupling: REDACTED ↔ REDACTED mistralrs-quant/src/fp8/mod.rs:1 — `mistralrs-quant/src/fp8/mod.rs` and `mistralrs-quant/src/gguf/mod.rs` change together 76% of the time (13 of the 17 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 13 shared commits counted here, the most recent 3 are `aed0b295` feat(quant): add isq executor and planning (#2283); `392a7567` feat(uqff): support ser/de for unquant layers, handle afq fallback (#…; `bdaf6eec` Add new quant method: F8Q8 (#1883) — run `git show` on any of them.
  • Change coupling: model_selected.rs ↔ toml_selector.rs mistralrs-core/src/model_selected.rs:1 — `mistralrs-core/src/model_selected.rs` and `mistralrs-core/src/toml_selector.rs` change together 69% of the time (11 of the 16 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency between them. They sit in the same directory, but in this ecosystem each file is its own module — a sibling reference still needs an import — so the missing import edge is real: the coupling runs through shared behaviour, not a declared dependency. If they duplicate structure, extract the common part into one unit; otherwise the coupling is hidden and worth breaking. You can check this without leaving the row: of the 11 shared commits counted here, the most recent 3 are `3fb22c84` feat(quant): support isq/uqff/imatrix machinery for broader model cla…; `6927a4f2` Parallel + I/O pipelined ISQ (#1870); `fd2456cd` Support sharding for UQFF (#1276) — run `git show` on any of them.
  • Change coupling: REDACTED ↔ config.rs mistralrs-core/src/pipeline/mod.rs:1 — `mistralrs-core/src/pipeline/mod.rs` and `mistralrs-core/src/xlora_models/config.rs` change together 58% of the time (7 of the 12 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 7 shared commits counted here, the most recent 3 are `91eb3816` Xlora sanity check; `512b485d` Use the ordering; `978c5b67` Make xlora variant untagged — run `git show` on any of them.
  • Change coupling: layers.rs ↔ REDACTED mistralrs-quant/src/distributed/layers.rs:1 — `mistralrs-quant/src/distributed/layers.rs` and `mistralrs-quant/src/fp8/mod.rs` change together 53% of the time (9 of the 17 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 9 shared commits counted here, the most recent 3 are `aed0b295` feat(quant): add isq executor and planning (#2283); `392a7567` feat(uqff): support ser/de for unquant layers, handle afq fallback (#…; `bdaf6eec` Add new quant method: F8Q8 (#1883) — run `git show` on any of them.
D4 · Code Duplication · Edited copy of a member (32 corresponding lines) · ×6
  • Edited copy of a member (32 corresponding lines) mistralrs-pyo3/src/lib.rs:1291 — mistralrs-pyo3/src/lib.rs:1291-1576 | mistralrs-server-core/src/mistralrs_for_server_builder.rs:1364-1400 — These two members are one piece of code written twice and then edited apart: 32 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (32 corresponding lines) mistralrs-core/src/attention/backends/cpu/avx.rs:33 — mistralrs-core/src/attention/backends/cpu/avx.rs:33-64 | mistralrs-core/src/attention/backends/cpu/avx.rs:276-323 — These two members are one piece of code written twice and then edited apart: 32 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (32 corresponding lines) mistralrs-quant/src/cutile/fused_moe.rs:669 — mistralrs-quant/src/cutile/fused_moe.rs:669-702 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:584-615 — These two members are one piece of code written twice and then edited apart: 32 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (32 corresponding lines) REDACTED:653 — REDACTED:653-684 | mistralrs-core/src/vision_models/siglip.rs:484-522 — These two members are one piece of code written twice and then edited apart: 32 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (32 corresponding lines) mistralrs-core/src/vision_models/qwen2_5_vl/config.rs:100 — mistralrs-core/src/vision_models/qwen2_5_vl/config.rs:100-131 | mistralrs-core/src/vision_models/qwen2vl/config.rs:74-105 — These two members are one piece of code written twice and then edited apart: 32 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (32 corresponding lines) mistralrs-quant/src/lora/dynamic/expert.rs:592 — mistralrs-quant/src/lora/dynamic/expert.rs:592-623 | mistralrs-quant/src/lora/dynamic/expert.rs:631-664 — These two members are one piece of code written twice and then edited apart: 32 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (39 corresponding lines) · ×6
  • Edited copy of a member (39 corresponding lines) mistralrs-core/src/models/granite.rs:1455 — mistralrs-core/src/models/granite.rs:1455-1501 | mistralrs-core/src/models/granite.rs:1745-1787 — These two members are one piece of code written twice and then edited apart: 39 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (39 corresponding lines) mistralrs-core/src/models/deepseek2.rs:981 — mistralrs-core/src/models/deepseek2.rs:981-1019 | mistralrs-core/src/models/deepseek3.rs:1044-1083 — These two members are one piece of code written twice and then edited apart: 39 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (39 corresponding lines) mistralrs-core/src/pipeline/loaders/lfm3.rs:196 — mistralrs-core/src/pipeline/loaders/lfm3.rs:196-234 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:7105-7152 — These two members are one piece of code written twice and then edited apart: 39 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (39 corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4945 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4945-4986 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4992-5030 — These two members are one piece of code written twice and then edited apart: 39 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (39 corresponding lines) mistralrs-vision/src/pad.rs:26 — mistralrs-vision/src/pad.rs:26-69 | mistralrs-vision/src/pad.rs:71-109 — These two members are one piece of code written twice and then edited apart: 39 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (39 corresponding lines) mistralrs-core/src/gguf/gemma3_bindings.rs:129 — mistralrs-core/src/gguf/gemma3_bindings.rs:129-167 | mistralrs-core/src/gguf/gemma3n_bindings.rs:231-280 — These two members are one piece of code written twice and then edited apart: 39 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (35 corresponding lines) · ×6
  • Edited copy of a member (35 corresponding lines) mistralrs-quant/src/metal_kernels/mod.rs:3378 — mistralrs-quant/src/metal_kernels/mod.rs:3378-3416 | mistralrs-quant/src/metal_kernels/mod.rs:3506-3544 — These two members are one piece of code written twice and then edited apart: 35 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (35 corresponding lines) mistralrs-core/src/vision_models/gemma3n/mod.rs:205 — mistralrs-core/src/vision_models/gemma3n/mod.rs:205-250 | mistralrs-core/src/vision_models/gemma3n/mod.rs:297-331 — These two members are one piece of code written twice and then edited apart: 35 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (35 corresponding lines) mistralrs-quant/src/afq/mod.rs:589 — mistralrs-quant/src/afq/mod.rs:589-623 | mistralrs-quant/src/afq/mod.rs:632-672 — These two members are one piece of code written twice and then edited apart: 35 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (35 corresponding lines) mistralrs-paged-attn/src/metal/kernels/mod.rs:97 — mistralrs-paged-attn/src/metal/kernels/mod.rs:97-131 | mistralrs-quant/src/metal_kernels/mod.rs:94-129 — These two members are one piece of code written twice and then edited apart: 35 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (35 corresponding lines) mistralrs-core/src/models/qwen3_moe.rs:363 — mistralrs-core/src/models/qwen3_moe.rs:363-397 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:102-136 — These two members are one piece of code written twice and then edited apart: 35 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (35 corresponding lines) mistralrs-core/src/models/mixtral.rs:324 — mistralrs-core/src/models/mixtral.rs:324-359 | mistralrs-core/src/models/phi3_5_moe.rs:400-434 — These two members are one piece of code written twice and then edited apart: 35 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (36 corresponding lines) · ×6
  • Edited copy of a member (36 corresponding lines) mistralrs-core/src/embedding_models/embedding_gemma.rs:207 — mistralrs-core/src/embedding_models/embedding_gemma.rs:207-251 | mistralrs-core/src/embedding_models/qwen3_embedding.rs:180-215 — These two members are one piece of code written twice and then edited apart: 36 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (36 corresponding lines) mistralrs-core/src/metal/gdn.rs:47 — mistralrs-core/src/metal/gdn.rs:47-82 | mistralrs-core/src/metal/ssm.rs:37-72 — These two members are one piece of code written twice and then edited apart: 36 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (36 corresponding lines) mistralrs-quant/src/rotary/mod.rs:16 — mistralrs-quant/src/rotary/mod.rs:16-51 | mistralrs-quant/src/rotary/mod.rs:217-267 — These two members are one piece of code written twice and then edited apart: 36 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (36 corresponding lines) mistralrs-core/src/vision_models/llama4/vision.rs:163 — mistralrs-core/src/vision_models/llama4/vision.rs:163-211 | mistralrs-core/src/vision_models/mllama/vision.rs:195-230 — These two members are one piece of code written twice and then edited apart: 36 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (36 corresponding lines) mistralrs-core/src/vision_models/voxtral/encoder.rs:36 — mistralrs-core/src/vision_models/voxtral/encoder.rs:36-71 | mistralrs-core/src/vision_models/voxtral/mod.rs:63-117 — These two members are one piece of code written twice and then edited apart: 36 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (36 corresponding lines) mistralrs-core/src/pipeline/ggml.rs:538 — mistralrs-core/src/pipeline/ggml.rs:538-573 | mistralrs-core/src/pipeline/gguf.rs:1576-1619 — These two members are one piece of code written twice and then edited apart: 36 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (33 corresponding lines) · ×6
  • Edited copy of a member (33 corresponding lines) mistralrs-core/src/vision_models/qwen3_vl/text.rs:516 — mistralrs-core/src/vision_models/qwen3_vl/text.rs:516-548 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:637-669 — These two members are one piece of code written twice and then edited apart: 33 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (33 corresponding lines) mistralrs-core/src/models/lfm2.rs:1309 — mistralrs-core/src/models/lfm2.rs:1309-1341 | mistralrs-core/src/models/lfm3.rs:1323-1356 — These two members are one piece of code written twice and then edited apart: 33 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (33 corresponding lines) mistralrs-core/src/gguf/normal_registry.rs:83 — mistralrs-core/src/gguf/normal_registry.rs:83-117 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:386-418 — These two members are one piece of code written twice and then edited apart: 33 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (33 corresponding lines) mistralrs-core/src/gguf/normal_config.rs:1220 — mistralrs-core/src/gguf/normal_config.rs:1220-1252 | mistralrs-core/src/gguf/normal_config.rs:1324-1363 — These two members are one piece of code written twice and then edited apart: 33 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (33 corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9565 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9565-9597 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:10794-10830 — These two members are one piece of code written twice and then edited apart: 33 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (33 corresponding lines) mistralrs-quant/src/afq/mod.rs:159 — mistralrs-quant/src/afq/mod.rs:159-191 | mistralrs-quant/src/blockwise_fp8/mod.rs:481-514 — These two members are one piece of code written twice and then edited apart: 33 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (30 corresponding lines) · ×6
  • Edited copy of a member (30 corresponding lines) mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:528 — mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:528-557 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:537-569 — These two members are one piece of code written twice and then edited apart: 30 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (30 corresponding lines) mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:60 — mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:60-89 | mistralrs-core/src/vision_models/qwen2vl/mod.rs:83-112 — These two members are one piece of code written twice and then edited apart: 30 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (30 corresponding lines) mistralrs-quant/src/utils/ops.rs:2918 — mistralrs-quant/src/utils/ops.rs:2918-2947 | mistralrs-quant/src/utils/ops.rs:3398-3428 — These two members are one piece of code written twice and then edited apart: 30 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (30 corresponding lines) mistralrs-core/src/kv_cache/mod.rs:1092 — mistralrs-core/src/kv_cache/mod.rs:1092-1124 | mistralrs-core/src/kv_cache/mod.rs:1131-1160 — These two members are one piece of code written twice and then edited apart: 30 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (30 corresponding lines) mistralrs-core/src/pipeline/prompt_chunks.rs:52 — mistralrs-core/src/pipeline/prompt_chunks.rs:52-81 | mistralrs-core/src/pipeline/prompt_chunks.rs:87-118 — These two members are one piece of code written twice and then edited apart: 30 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (30 corresponding lines) mistralrs-quant/src/metal_kernels/mod.rs:3255 — mistralrs-quant/src/metal_kernels/mod.rs:3255-3287 | mistralrs-quant/src/metal_kernels/mod.rs:3300-3329 — These two members are one piece of code written twice and then edited apart: 30 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (24 corresponding lines) · ×6
  • Edited copy of a member (24 corresponding lines) mistralrs-core/src/vision_models/gemma3n/text.rs:1264 — mistralrs-core/src/vision_models/gemma3n/text.rs:1264-1287 | mistralrs-core/src/vision_models/gemma4/text.rs:1577-1604 — These two members are one piece of code written twice and then edited apart: 24 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (24 corresponding lines) mistralrs-core/src/utils/memory_usage.rs:246 — mistralrs-core/src/utils/memory_usage.rs:246-276 | mistralrs-core/src/utils/memory_usage.rs:338-361 — These two members are one piece of code written twice and then edited apart: 24 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (24 corresponding lines) mistralrs-core/src/models/phi2.rs:367 — mistralrs-core/src/models/phi2.rs:367-390 | mistralrs-core/src/models/starcoder2.rs:330-359 — These two members are one piece of code written twice and then edited apart: 24 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (24 corresponding lines) mistralrs-core/src/utils/progress.rs:87 — mistralrs-core/src/utils/progress.rs:87-110 | mistralrs-core/src/utils/progress.rs:184-207 — These two members are one piece of code written twice and then edited apart: 24 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (24 corresponding lines) mistralrs-core/src/vision_models/lfm2_vl/mod.rs:35 — mistralrs-core/src/vision_models/lfm2_vl/mod.rs:35-58 | mistralrs-core/src/vision_models/lfm3_vl/mod.rs:48-73 — These two members are one piece of code written twice and then edited apart: 24 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (24 corresponding lines) mistralrs-core/src/utils/model_config.rs:218 — mistralrs-core/src/utils/model_config.rs:218-241 | mistralrs-core/src/utils/model_config.rs:245-269 — These two members are one piece of code written twice and then edited apart: 24 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (4 corresponding lines) · ×6
  • Edited copy of a member (4 corresponding lines) mistralrs-paged-attn/src/cuda/backend/mod.rs:80 — mistralrs-paged-attn/src/cuda/backend/mod.rs:80-83 | mistralrs-quant/src/utils/mod.rs:68-71 — These two members are one piece of code written twice and then edited apart: 4 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (4 corresponding lines) mistralrs-core/src/topology/mod.rs:232 — mistralrs-core/src/topology/mod.rs:232-238 | mistralrs-core/src/utils/unvarbuilder.rs:203-206 — These two members are one piece of code written twice and then edited apart: 4 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (4 corresponding lines) mistralrs-core/src/models/phi2.rs:110 — mistralrs-core/src/models/phi2.rs:110-113 | mistralrs-core/src/models/starcoder2.rs:90-95 — These two members are one piece of code written twice and then edited apart: 4 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (4 corresponding lines) mistralrs-core/src/diffusion_models/clip/text.rs:190 — mistralrs-core/src/diffusion_models/clip/text.rs:190-193 | mistralrs-core/src/vision_models/clip.rs:221-224 — These two members are one piece of code written twice and then edited apart: 4 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (4 corresponding lines) mistralrs-core/src/layers.rs:262 — mistralrs-core/src/layers.rs:262-265 | mistralrs-core/src/vision_models/gemma4/mtp.rs:909-912 — These two members are one piece of code written twice and then edited apart: 4 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (4 corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:921 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:921-924 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1832-1836 — These two members are one piece of code written twice and then edited apart: 4 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Duplicated block (18–19 lines × 2) · ×6
  • Duplicated block (18–19 lines × 2) mistralrs-core/src/models/mixtral.rs:480 — mistralrs-core/src/models/mixtral.rs:480-497 | mistralrs-core/src/vision_models/phi3/mod.rs:1274-1292 — before extracting anything, compare `mistralrs-core/src/models/mixtral.rs` and `mistralrs-core/src/vision_models/phi3/mod.rs` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 327 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/mixtral.rs:480` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18–19 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7607 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7607-7624 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:8123-8141 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7607` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (18–19 lines × 2) mistralrs-quant/src/afq/ops.rs:857 — mistralrs-quant/src/afq/ops.rs:857-874 | mistralrs-quant/src/afq/ops.rs:983-1001 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/afq/ops.rs:857` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18–19 lines × 2) mistralrs-quant/src/lora/dynamic/loader/expert.rs:322 — mistralrs-quant/src/lora/dynamic/loader/expert.rs:322-339 | mistralrs-quant/src/lora/dynamic/loader/expert.rs:349-367 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/lora/dynamic/loader/expert.rs:322` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18–19 lines × 2) mistralrs-quant/src/rotary/mod.rs:108 — mistralrs-quant/src/rotary/mod.rs:108-125 | mistralrs-quant/src/rotary/mod.rs:382-400 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/rotary/mod.rs:108` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18–19 lines × 2) mistralrs/src/model_builder_trait.rs:1257 — mistralrs/src/model_builder_trait.rs:1257-1275 | mistralrs/src/model_builder_trait.rs:1324-1341 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs/src/model_builder_trait.rs:1257` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `builder` to `crate::DiffusionModelBuilder` in one and `crate::SpeechModelBuilder` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs/src/model_builder_trait.rs:1344` calls `clone` and `mistralrs/src/model_builder_trait.rs:1278` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (17–18 lines × 2) · ×6
  • Duplicated block (17–18 lines × 2) mistralrs-core/src/engine/agentic_loop.rs:1507 — mistralrs-core/src/engine/agentic_loop.rs:1507-1523 | mistralrs-core/src/engine/agentic_loop.rs:1574-1591 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/engine/agentic_loop.rs:1507` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (17–18 lines × 2) mistralrs-core/src/models/llama.rs:403 — mistralrs-core/src/models/llama.rs:403-420 | mistralrs-core/src/models/smollm3.rs:419-435 — before extracting anything, compare `mistralrs-core/src/models/llama.rs` and `mistralrs-core/src/models/smollm3.rs` as WHOLE FILES: this scan already matched 47 separate duplicated blocks between them, totalling at least 727 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/llama.rs:403` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (17–18 lines × 2) mistralrs-core/src/models/qwen3_next.rs:673 — mistralrs-core/src/models/qwen3_next.rs:673-689 | mistralrs-core/src/vision_models/qwen3_5/packed_gdn.rs:158-175 — before extracting anything, compare `mistralrs-core/src/models/qwen3_next.rs` and `mistralrs-core/src/vision_models/qwen3_5/packed_gdn.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 64 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/qwen3_next.rs:673` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (17–18 lines × 2) mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1235 — mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1235-1252 | mistralrs-core/src/vision_models/mistral3/inputs_processor.rs:297-313 — `mistralrs-core/src/vision_models/gemma4/inputs_processor.rs` and `mistralrs-core/src/vision_models/mistral3/inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 9 separate duplicated blocks between them, totalling at least 132 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1235` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (17–18 lines × 2) mistralrs-core/src/sampler.rs:1486 — mistralrs-core/src/sampler.rs:1486-1503 | mistralrs-core/src/sampler.rs:1656-1672 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (17–18 lines × 2) mistralrs-core/src/vision_models/gemma4/mod.rs:377 — mistralrs-core/src/vision_models/gemma4/mod.rs:377-393 | mistralrs-core/src/vision_models/gemma4/mod.rs:689-706 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma4/mod.rs:377` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (15–16 lines × 2) · ×6
  • Duplicated block (15–16 lines × 2) mistralrs-core/src/attention/backends/metal_flash_attn.rs:127 — mistralrs-core/src/attention/backends/metal_flash_attn.rs:127-142 | mistralrs-core/src/attention/backends/metal_flash_attn.rs:270-284 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/attention/backends/metal_flash_attn.rs:127` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15–16 lines × 2) mistralrs-core/src/gguf/normal_config.rs:1480 — mistralrs-core/src/gguf/normal_config.rs:1480-1494 | mistralrs-core/src/gguf/normal_config.rs:1577-1592 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/gguf/normal_config.rs:1480` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/gguf/normal_config.rs:1495` calls `insert`, `into` and `mistralrs-core/src/gguf/normal_config.rs:1592` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (15–16 lines × 2) mistralrs-core/src/models/gpt_oss.rs:908 — mistralrs-core/src/models/gpt_oss.rs:908-923 | mistralrs-core/src/vision_models/muse_glimmer/text.rs:586-600 — before extracting anything, compare `mistralrs-core/src/models/gpt_oss.rs` and `mistralrs-core/src/vision_models/muse_glimmer/text.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 97 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gpt_oss.rs:908` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15–16 lines × 2) mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:334 — mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:334-349 | mistralrs-core/src/vision_models/qwen4_exp/text.rs:114-128 — `mistralrs-core/src/vision_models/qwen3_5_moe/text.rs` and `mistralrs-core/src/vision_models/qwen4_exp/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 34 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:334` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (15–16 lines × 2) mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:351 — mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:351-365 | mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:404-419 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:351` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15–16 lines × 2) mistralrs-server-core/src/responses.rs:2364 — mistralrs-server-core/src/responses.rs:2364-2379 | mistralrs-server-core/src/responses.rs:2440-2454 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-server-core/src/responses.rs:2364` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-server-core/src/responses.rs:2437` calls `request_cancel`, `mark_cancelled` and `mistralrs-server-core/src/responses.rs:2363` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (14 lines × 4) · ×6
  • Duplicated block (14 lines × 4) mistralrs-cli/src/commands/run/interactive.rs:991 — mistralrs-cli/src/commands/run/interactive.rs:991-1004 | mistralrs-cli/src/commands/run/interactive.rs:1779-1792 | mistralrs-cli/src/commands/run/interactive.rs:1946-1959 | mistralrs-cli/src/commands/run/interactive.rs:2069-2082 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-cli/src/commands/run/interactive.rs:991` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 4) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2832 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2832-2845 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4256-4269 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5052-5065 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5463-5476 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2832` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (14 lines × 4) mistralrs-core/src/xlora_models/gemma.rs:195 — mistralrs-core/src/xlora_models/gemma.rs:195-208 | mistralrs-core/src/xlora_models/mistral.rs:184-197 | mistralrs-core/src/xlora_models/mixtral.rs:97-110 | mistralrs-core/src/xlora_models/phi3.rs:76-89 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/mistral.rs` as WHOLE FILES: this scan already matched 37 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma.rs:195` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (14 lines × 4) mistralrs-quant/src/distributed/layers.rs:476 — mistralrs-quant/src/distributed/layers.rs:476-489 | mistralrs-quant/src/distributed/layers.rs:850-863 | mistralrs-quant/src/distributed/layers.rs:1437-1450 | mistralrs-quant/src/distributed/layers.rs:1653-1666 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/distributed/layers.rs:476` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (14 lines × 4) mistralrs-core/src/models/phi3.rs:147 — mistralrs-core/src/models/phi3.rs:147-160 | mistralrs-core/src/vision_models/phi3/mod.rs:239-252 | mistralrs-core/src/vision_models/phi4/mod.rs:108-121 | mistralrs-core/src/xlora_models/phi3.rs:122-135 — before extracting anything, compare `mistralrs-core/src/models/phi3.rs` and `mistralrs-core/src/vision_models/phi3/mod.rs` as WHOLE FILES: this scan already matched 50 separate duplicated blocks between them, totalling at least 638 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/phi3.rs:147` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 4) mistralrs-core/src/models/granite.rs:2224 — mistralrs-core/src/models/granite.rs:2224-2237 | mistralrs-core/src/models/lfm2.rs:1214-1227 | mistralrs-core/src/models/lfm3.rs:1214-1227 | mistralrs-core/src/models/qwen3_next.rs:1015-1028 — before extracting anything, compare `mistralrs-core/src/models/granite.rs` and `mistralrs-core/src/models/lfm2.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 79 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/granite.rs:2224` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/models/qwen3_next.rs:1032` calls `Paged`, `seqlen_offsets` and `mistralrs-core/src/models/lfm2.rs:1231` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (12 lines × 5) · ×6
  • Duplicated block (12 lines × 5) mistralrs-core/src/embedding_models/qwen3_embedding.rs:103 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:103-114 | mistralrs-core/src/models/glm4.rs:136-147 | mistralrs-core/src/models/glm4_moe.rs:188-199 | mistralrs-core/src/models/qwen3.rs:114-125 | mistralrs-core/src/models/qwen3_moe.rs:117-128 — before extracting anything, compare `mistralrs-core/src/embedding_models/qwen3_embedding.rs` and `mistralrs-core/src/models/glm4.rs` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 137 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/qwen3_embedding.rs:103` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (12 lines × 5) mistralrs-core/src/embedding_models/qwen3_embedding.rs:125 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:125-136 | mistralrs-core/src/models/glm4.rs:158-169 | mistralrs-core/src/models/glm4_moe.rs:210-221 | mistralrs-core/src/models/qwen3.rs:136-147 | mistralrs-core/src/models/qwen3_moe.rs:139-150 — before extracting anything, compare `mistralrs-core/src/embedding_models/qwen3_embedding.rs` and `mistralrs-core/src/models/glm4.rs` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 137 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/qwen3_embedding.rs:125` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (12 lines × 5) mistralrs-core/src/embedding_models/qwen3_embedding.rs:145 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:145-156 | mistralrs-core/src/models/qwen3.rs:156-167 | mistralrs-core/src/models/qwen3_moe.rs:159-170 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:156-167 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:262-273 — `mistralrs-core/src/embedding_models/qwen3_embedding.rs` and `mistralrs-core/src/models/qwen3.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 26 separate duplicated blocks between them, totalling at least 364 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/qwen3_embedding.rs:145` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (12 lines × 5) mistralrs-core/src/models/flint.rs:537 — mistralrs-core/src/models/flint.rs:537-548 | mistralrs-core/src/models/qwen3_moe.rs:366-377 | mistralrs-core/src/models/qwen3_next.rs:413-424 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:319-330 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:105-116 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/qwen3_moe.rs` as WHOLE FILES: this scan already matched 43 separate duplicated blocks between them, totalling at least 479 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (12 lines × 5) mistralrs-core/src/xlora_models/gemma.rs:601 — mistralrs-core/src/xlora_models/gemma.rs:601-612 | mistralrs-core/src/xlora_models/mistral.rs:597-608 | mistralrs-core/src/xlora_models/mixtral.rs:727-738 | mistralrs-core/src/xlora_models/phi2.rs:567-578 | mistralrs-core/src/xlora_models/starcoder2.rs:582-593 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/mistral.rs` as WHOLE FILES: this scan already matched 37 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma.rs:601` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/xlora_models/gemma.rs:600` calls `sqrt` and `mistralrs-core/src/xlora_models/mistral.rs:596` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12 lines × 5) mistralrs-quant/src/metal_kernels/mod.rs:480 — mistralrs-quant/src/metal_kernels/mod.rs:480-491 | mistralrs-quant/src/metal_kernels/mod.rs:518-529 | mistralrs-quant/src/metal_kernels/mod.rs:564-575 | mistralrs-quant/src/metal_kernels/mod.rs:610-621 | mistralrs-quant/src/metal_kernels/mod.rs:655-666 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/metal_kernels/mod.rs:480` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (12 lines × 4) · ×6
  • Duplicated block (12 lines × 4) mistralrs-core/src/model_loader.rs:752 — mistralrs-core/src/model_loader.rs:752-763 | mistralrs-core/src/model_loader.rs:786-797 | mistralrs-core/src/toml_selector.rs:1028-1039 | mistralrs-core/src/toml_selector.rs:1062-1073 — before extracting anything, compare `mistralrs-core/src/model_loader.rs` and `mistralrs-core/src/toml_selector.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 199 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/model_loader.rs:752` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 4) mistralrs-core/src/models/flint.rs:867 — mistralrs-core/src/models/flint.rs:867-879 | mistralrs-core/src/models/glm4.rs:534-545 | mistralrs-core/src/models/qwen3.rs:493-504 | mistralrs-core/src/models/qwen3_moe.rs:673-684 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/glm4.rs` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 240 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/flint.rs:867` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (12 lines × 4) mistralrs-core/src/vision_models/qwen3_5/mod.rs:97 — mistralrs-core/src/vision_models/qwen3_5/mod.rs:97-108 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:85-96 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:637-648 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:83-94 — `mistralrs-core/src/vision_models/qwen3_5/mod.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 24 separate duplicated blocks between them, totalling at least 425 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_5/mod.rs:97` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (12 lines × 4) mistralrs-core/src/xlora_models/gemma.rs:379 — mistralrs-core/src/xlora_models/gemma.rs:379-390 | mistralrs-core/src/xlora_models/mistral.rs:375-386 | mistralrs-core/src/xlora_models/phi3.rs:341-353 | mistralrs-core/src/xlora_models/starcoder2.rs:364-375 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/mistral.rs` as WHOLE FILES: this scan already matched 37 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma.rs:379` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/xlora_models/gemma.rs:391` calls `clone` and `mistralrs-core/src/xlora_models/mistral.rs:387` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12 lines × 4) mistralrs-quant/src/blockwise_fp8/ops.rs:1110 — mistralrs-quant/src/blockwise_fp8/ops.rs:1110-1121 | mistralrs-quant/src/blockwise_fp8/ops.rs:1145-1156 | mistralrs-quant/src/blockwise_fp8/ops.rs:1299-1310 | mistralrs-quant/src/blockwise_fp8/ops.rs:1338-1349 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/blockwise_fp8/ops.rs:1110` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (12 lines × 4) mistralrs/src/model_builder_trait.rs:854 — mistralrs/src/model_builder_trait.rs:854-865 | mistralrs/src/model_builder_trait.rs:1014-1025 | mistralrs/src/model_builder_trait.rs:1217-1228 | mistralrs/src/model_builder_trait.rs:1633-1644 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs/src/model_builder_trait.rs:854` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs/src/model_builder_trait.rs:1013` calls `Some` and `mistralrs/src/model_builder_trait.rs:853` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (11 lines × 4) · ×6
  • Duplicated block (11 lines × 4) mistralrs-cli/src/commands/run/interactive.rs:894 — mistralrs-cli/src/commands/run/interactive.rs:894-904 | mistralrs-cli/src/commands/run/interactive.rs:1576-1586 | mistralrs-cli/src/commands/run/interactive.rs:1884-1894 | mistralrs-cli/src/commands/run/interactive.rs:2008-2018 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-cli/src/commands/run/interactive.rs:894` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-cli/src/commands/run/interactive.rs:893` calls `format_sampling_params` and `mistralrs-cli/src/commands/run/interactive.rs:1883` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (11 lines × 4) mistralrs-core/src/models/deepseek2.rs:780 — mistralrs-core/src/models/deepseek2.rs:780-790 | mistralrs-core/src/models/deepseek3.rs:843-853 | mistralrs-core/src/models/glm4_moe.rs:680-690 | mistralrs-core/src/models/glm4_moe_lite.rs:790-800 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (11 lines × 4) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4785 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4785-4795 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:8419-8429 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1075-1085 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6654-6664 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` and `mistralrs-core/src/pipeline/loaders/normal_loaders.rs` as WHOLE FILES: this scan already matched 34 separate duplicated blocks between them, totalling at least 445 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (11 lines × 4) mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:228 — mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:228-238 | mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:270-280 | mistralrs-core/src/vision_models/qwen2vl/mod.rs:385-395 | mistralrs-core/src/vision_models/qwen2vl/mod.rs:427-437 — `mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs` and `mistralrs-core/src/vision_models/qwen2vl/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 16 separate duplicated blocks between them, totalling at least 396 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:228` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 4) mistralrs-core/src/vision_models/qwen3_vl/mod.rs:737 — mistralrs-core/src/vision_models/qwen3_vl/mod.rs:737-747 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:812-822 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:183-193 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:258-268 — `mistralrs-core/src/vision_models/qwen3_vl/mod.rs` and `mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 25 separate duplicated blocks between them, totalling at least 658 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_vl/mod.rs:737` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 4) mistralrs-core/src/xlora_models/gemma2.rs:648 — mistralrs-core/src/xlora_models/gemma2.rs:648-658 | mistralrs-core/src/xlora_models/phi2.rs:571-581 | mistralrs-core/src/xlora_models/quantized_llama.rs:805-815 | mistralrs-core/src/xlora_models/quantized_phi3.rs:473-483 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma2.rs` and `mistralrs-core/src/xlora_models/phi2.rs` as WHOLE FILES: this scan already matched 22 separate duplicated blocks between them, totalling at least 304 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma2.rs:648` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/xlora_models/gemma2.rs:647` calls `get`, `device` and `mistralrs-core/src/xlora_models/phi2.rs:570` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (8–9 lines × 2) · ×6
  • Duplicated block (8–9 lines × 2) mistralrs-core/src/attention/backends/cpu/avx.rs:644 — mistralrs-core/src/attention/backends/cpu/avx.rs:644-652 | mistralrs-core/src/attention/backends/cpu/avx.rs:787-794 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/attention/backends/cpu/avx.rs:644` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8–9 lines × 2) mistralrs-core/src/models/gpt_oss.rs:358 — mistralrs-core/src/models/gpt_oss.rs:358-365 | mistralrs-core/src/models/gpt_oss.rs:396-404 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (8–9 lines × 2) mistralrs-core/src/vision_models/grid_processor.rs:1853 — mistralrs-core/src/vision_models/grid_processor.rs:1853-1860 | mistralrs-core/src/vision_models/grid_processor.rs:1896-1904 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:1853` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8–9 lines × 2) mistralrs-core/src/xlora_models/classifier.rs:177 — mistralrs-core/src/xlora_models/classifier.rs:177-184 | mistralrs-core/src/xlora_models/classifier.rs:187-195 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/classifier.rs:177` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (8–9 lines × 2) mistralrs-core/src/xlora_models/quantized_llama.rs:792 — mistralrs-core/src/xlora_models/quantized_llama.rs:792-799 | mistralrs-core/src/xlora_models/quantized_phi3.rs:460-468 — before extracting anything, compare `mistralrs-core/src/xlora_models/quantized_llama.rs` and `mistralrs-core/src/xlora_models/quantized_phi3.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 219 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/quantized_llama.rs:792` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8–9 lines × 2) mistralrs-quant/src/metal_kernels/mod.rs:1403 — mistralrs-quant/src/metal_kernels/mod.rs:1403-1411 | mistralrs-quant/src/metal_kernels/mod.rs:1434-1441 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/metal_kernels/mod.rs:1403` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-quant/src/metal_kernels/mod.rs:1432` calls `set_input_buffer`, `Some`, `set_param` and `mistralrs-quant/src/metal_kernels/mod.rs:1403` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (6–7 lines × 2) · ×6
  • Duplicated block (6–7 lines × 2) mistralrs-cli/src/commands/bench.rs:157 — mistralrs-cli/src/commands/bench.rs:157-163 | mistralrs-cli/src/commands/run/mod.rs:127-132 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (6–7 lines × 2) mistralrs-core/src/cuda/gdn.rs:6076 — mistralrs-core/src/cuda/gdn.rs:6076-6081 | mistralrs-core/src/cuda/gdn.rs:6090-6096 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (6–7 lines × 2) mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:310 — mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:310-316 | mistralrs-core/src/vision_models/phi3/phi3_inputs_processor.rs:379-384 — `mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs` and `mistralrs-core/src/vision_models/phi3/phi3_inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 8 separate duplicated blocks between them, totalling at least 172 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:310` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/vision_models/phi3/phi3_inputs_processor.rs:385` calls `count_prefix_cached_mm_items` and `mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:316` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (6–7 lines × 2) mistralrs-quant/src/blockwise_fp8/ops.rs:1275 — mistralrs-quant/src/blockwise_fp8/ops.rs:1275-1281 | mistralrs-quant/src/mxfp4/ops.rs:446-451 — `mistralrs-quant/src/blockwise_fp8/ops.rs` and `mistralrs-quant/src/mxfp4/ops.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 8 separate duplicated blocks between them, totalling at least 59 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/blockwise_fp8/ops.rs:1275` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6–7 lines × 2) mistralrs-quant/src/blockwise_fp8/ops.rs:1314 — mistralrs-quant/src/blockwise_fp8/ops.rs:1314-1320 | mistralrs-quant/src/mxfp4/ops.rs:514-519 — `mistralrs-quant/src/blockwise_fp8/ops.rs` and `mistralrs-quant/src/mxfp4/ops.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 8 separate duplicated blocks between them, totalling at least 59 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/blockwise_fp8/ops.rs:1314` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6–7 lines × 2) mistralrs-core/src/pipeline/chat_template.rs:386 — mistralrs-core/src/pipeline/chat_template.rs:386-391 | mistralrs-core/src/pipeline/chat_template.rs:396-402 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/chat_template.rs:396` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D2 · Cognitive Complexity · Engine · ×5
  • Engine::run (cognitive 511) mistralrs-core/src/engine/mod.rs:1157 — Engine::run has cognitive complexity 511 (threshold 15). Drivers by points: if/else 112 (370 pts), loops 19 (71 pts), match/switch 10 (42 pts), boolean chains 28 (nesting depth added 342). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • Engine::add_request (cognitive 253) mistralrs-core/src/engine/add_request.rs:156 — Engine::add_request has cognitive complexity 253 (threshold 15). Drivers by points: if/else 90 (180 pts), match/switch 22 (46 pts), boolean chains 19, loops 4 (8 pts) (nesting depth added 118). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Engine::new (cognitive 28) mistralrs-core/src/engine/mod.rs:553 — Engine::new has cognitive complexity 28 (threshold 15). Drivers by points: if/else 12 (16 pts), boolean chains 7, match/switch 4 (5 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Engine::handle_request (cognitive 19) mistralrs-core/src/engine/add_request.rs:78 — Engine::handle_request has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (11 pts), boolean chains 5, match/switch 2 (3 pts) (nesting depth added 6). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • Engine::free_finished_scheduler_sequences (cognitive 16) mistralrs-core/src/engine/mod.rs:800 — Engine::free_finished_scheduler_sequences has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 1 (3 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · PagedAttention · ×5
  • PagedAttention::try_prefix_gather_prefill (cognitive 77) mistralrs-core/src/paged_attention/layers/paged_attention.rs:1412 — PagedAttention::try_prefix_gather_prefill has cognitive complexity 77 (threshold 15). Drivers by points: if/else 40 (58 pts), boolean chains 14, match/switch 4 (5 pts) (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • PagedAttention::try_metal_prefill (cognitive 56) mistralrs-core/src/paged_attention/layers/paged_attention.rs:1142 — PagedAttention::try_metal_prefill has cognitive complexity 56 (threshold 15). Drivers by points: if/else 34 (40 pts), boolean chains 9, loops 2 (5 pts), match/switch 2 (nesting depth added 9). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • PagedAttention::cuda_fwd_t (cognitive 42) mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:112 — PagedAttention::cuda_fwd_t has cognitive complexity 42 (threshold 15). Drivers by points: if/else 22 (23 pts), match/switch 11 (16 pts), boolean chains 3 (nesting depth added 6). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • PagedAttention::metal_fwd (cognitive 41) mistralrs-paged-attn/src/metal/backend/paged_attention.rs:321 — PagedAttention::metal_fwd has cognitive complexity 41 (threshold 15). Drivers by points: if/else 19 (22 pts), match/switch 10 (14 pts), boolean chains 5 (nesting depth added 7). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • PagedAttention::run_standard_paged_decode (cognitive 20) mistralrs-core/src/paged_attention/layers/paged_attention.rs:2584 — PagedAttention::run_standard_paged_decode has cognitive complexity 20 (threshold 15). Drivers by points: if/else 14 (19 pts), boolean chains 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DFlashDraftModel · ×5
  • DFlashDraftModel::prepare_ctx_batch (cognitive 24) mistralrs-core/src/speculative/dflash.rs:2999 — DFlashDraftModel::prepare_ctx_batch has cognitive complexity 24 (threshold 15). Drivers by points: if/else 10 (13 pts), loops 4 (11 pts) (nesting depth added 10). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • DFlashDraftModel::geometry_mask (cognitive 22) mistralrs-core/src/speculative/dflash.rs:3808 — DFlashDraftModel::geometry_mask has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (19 pts), loops 2 (3 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • DFlashDraftModel::precapture_cuda_graphs (cognitive 19) mistralrs-core/src/speculative/dflash.rs:2459 — DFlashDraftModel::precapture_cuda_graphs has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (11 pts), boolean chains 4, loops 2 (3 pts), match/switch 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • DFlashDraftModel::draft_hidden_batch (cognitive 18) mistralrs-core/src/speculative/dflash.rs:3257 — DFlashDraftModel::draft_hidden_batch has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (12 pts), loops 5 (6 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • DFlashDraftModel::run_draft_layers (cognitive 18) mistralrs-core/src/speculative/dflash.rs:3378 — DFlashDraftModel::run_draft_layers has cognitive complexity 18 (threshold 15). Drivers by points: match/switch 6 (10 pts), if/else 4 (7 pts), loops 1 (nesting depth added 7). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D30 · Dependency Vulnerabilities · Medium advisory (unmaintained) · ×5
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D30 · Dependency Vulnerabilities · Medium vulnerability · ×5
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Edited copy of a member (38 corresponding lines) · ×5
  • Edited copy of a member (38 corresponding lines) mistralrs-quant/src/metal_kernels/mod.rs:3442 — mistralrs-quant/src/metal_kernels/mod.rs:3442-3483 | mistralrs-quant/src/metal_kernels/mod.rs:3571-3612 — These two members are one piece of code written twice and then edited apart: 38 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (38 corresponding lines) mistralrs-core/src/diffusion_models/t5/mod.rs:495 — mistralrs-core/src/diffusion_models/t5/mod.rs:495-532 | mistralrs-core/src/diffusion_models/t5/mod.rs:569-606 — These two members are one piece of code written twice and then edited apart: 38 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (38 corresponding lines) mistralrs-core/src/ops.rs:885 — mistralrs-core/src/ops.rs:885-924 | mistralrs-core/src/ops.rs:969-1006 — These two members are one piece of code written twice and then edited apart: 38 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (38 corresponding lines) mistralrs-pyo3/src/util.rs:519 — mistralrs-pyo3/src/util.rs:519-556 | mistralrs-server-core/src/video.rs:339-382 — These two members are one piece of code written twice and then edited apart: 38 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (38 corresponding lines) mistralrs-core/src/models/phi3.rs:97 — mistralrs-core/src/models/phi3.rs:97-134 | mistralrs-core/src/vision_models/phi3/mod.rs:188-225 — These two members are one piece of code written twice and then edited apart: 38 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (37 corresponding lines) · ×5
  • Edited copy of a member (37 corresponding lines) mistralrs-quant/src/gguf/fast_mmvq.rs:242 — mistralrs-quant/src/gguf/fast_mmvq.rs:242-278 | mistralrs-quant/src/gguf/fast_mmvq.rs:284-320 — These two members are one piece of code written twice and then edited apart: 37 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (37 corresponding lines) mistralrs-core/src/diffusion_models/clip/text.rs:124 — mistralrs-core/src/diffusion_models/clip/text.rs:124-166 | mistralrs-core/src/vision_models/clip.rs:161-197 — These two members are one piece of code written twice and then edited apart: 37 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (37 corresponding lines) mistralrs-core/src/layers.rs:1643 — mistralrs-core/src/layers.rs:1643-1679 | mistralrs-core/src/layers.rs:1954-1990 — These two members are one piece of code written twice and then edited apart: 37 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (37 corresponding lines) mistralrs-core/src/sampler.rs:865 — mistralrs-core/src/sampler.rs:865-901 | mistralrs-core/src/sampler.rs:910-952 — These two members are one piece of code written twice and then edited apart: 37 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (37 corresponding lines) mistralrs-core/src/models/glm4.rs:319 — mistralrs-core/src/models/glm4.rs:319-369 | mistralrs-core/src/models/hunyuan_v1_dense.rs:293-329 — These two members are one piece of code written twice and then edited apart: 37 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (34 corresponding lines) · ×5
  • Edited copy of a member (34 corresponding lines) mistralrs-core/src/vision_models/gemma3n/audio_processing.rs:263 — mistralrs-core/src/vision_models/gemma3n/audio_processing.rs:263-311 | mistralrs-core/src/vision_models/gemma4/audio_processing.rs:384-417 — These two members are one piece of code written twice and then edited apart: 34 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (34 corresponding lines) mistralrs-core/src/speech_models/dia/audio.rs:23 — mistralrs-core/src/speech_models/dia/audio.rs:23-59 | mistralrs-core/src/speech_models/dia/audio.rs:130-163 — These two members are one piece of code written twice and then edited apart: 34 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (34 corresponding lines) mistralrs-quant/src/mxfp8/cuda.rs:84 — mistralrs-quant/src/mxfp8/cuda.rs:84-117 | mistralrs-quant/src/mxfp8/cuda.rs:169-206 — These two members are one piece of code written twice and then edited apart: 34 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (34 corresponding lines) mistralrs/src/lora_model.rs:60 — mistralrs/src/lora_model.rs:60-93 | mistralrs/src/xlora_model.rs:40-78 — These two members are one piece of code written twice and then edited apart: 34 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (34 corresponding lines) mistralrs-quant/src/mxfp4/mod.rs:478 — mistralrs-quant/src/mxfp4/mod.rs:478-511 | mistralrs-quant/src/mxfp4/mod.rs:520-553 — These two members are one piece of code written twice and then edited apart: 34 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (50 corresponding lines) · ×5
  • Edited copy of a member (50 corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9877 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9877-9935 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:10966-11015 — These two members are one piece of code written twice and then edited apart: 50 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (50 corresponding lines) mistralrs-quant/src/cutile/fused_moe.rs:982 — mistralrs-quant/src/cutile/fused_moe.rs:982-1031 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:1056-1115 — These two members are one piece of code written twice and then edited apart: 50 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (50 corresponding lines) mistralrs-core/src/vision_models/llava/llava15.rs:182 — mistralrs-core/src/vision_models/llava/llava15.rs:182-231 | mistralrs-core/src/vision_models/llava/llava_next.rs:142-195 — These two members are one piece of code written twice and then edited apart: 50 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (50 corresponding lines) mistralrs-server-core/src/image_generation.rs:56 — mistralrs-server-core/src/image_generation.rs:56-109 | mistralrs-server-core/src/speech_generation.rs:190-239 — These two members are one piece of code written twice and then edited apart: 50 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (50 corresponding lines) mistralrs-core/src/layers.rs:3657 — mistralrs-core/src/layers.rs:3657-3710 | mistralrs-core/src/layers.rs:3720-3769 — These two members are one piece of code written twice and then edited apart: 50 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (27 corresponding lines) · ×5
  • Edited copy of a member (27 corresponding lines) mistralrs-quant/src/distributed/mod.rs:401 — mistralrs-quant/src/distributed/mod.rs:401-431 | mistralrs-quant/src/distributed/mod.rs:466-492 — These two members are one piece of code written twice and then edited apart: 27 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (27 corresponding lines) mistralrs-core/src/cuda/qwen4_exp.rs:438 — mistralrs-core/src/cuda/qwen4_exp.rs:438-465 | mistralrs-core/src/cuda/qwen4_exp.rs:479-505 — These two members are one piece of code written twice and then edited apart: 27 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (27 corresponding lines) mistralrs-quant/src/lora/dynamic/loader/expert.rs:311 — mistralrs-quant/src/lora/dynamic/loader/expert.rs:311-339 | mistralrs-quant/src/lora/dynamic/loader/expert.rs:341-367 — These two members are one piece of code written twice and then edited apart: 27 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (27 corresponding lines) mistralrs-quant/src/afq/mod.rs:691 — mistralrs-quant/src/afq/mod.rs:691-717 | mistralrs-quant/src/fp8/mod.rs:351-380 — These two members are one piece of code written twice and then edited apart: 27 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (27 corresponding lines) mistralrs-core/src/paged_attention/block_hash.rs:237 — mistralrs-core/src/paged_attention/block_hash.rs:237-263 | mistralrs-core/src/paged_attention/block_hash.rs:276-307 — These two members are one piece of code written twice and then edited apart: 27 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 11+ corresponding lines) · ×5
  • Edited copies of one member (3 members, 11+ corresponding lines) mistralrs-quant/src/cutile/fp8_gemm.rs:181 — mistralrs-quant/src/cutile/fp8_gemm.rs:181-192 | mistralrs-quant/src/cutile/fp8_w8a16.rs:259-270 | mistralrs-quant/src/cutile/fp8_w8a8.rs:264-274 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 11 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 11+ corresponding lines) mistralrs-quant/src/blockwise_fp8/mod.rs:735 — mistralrs-quant/src/blockwise_fp8/mod.rs:735-751 | mistralrs-quant/src/mxfp4/mod.rs:155-165 | mistralrs-quant/src/mxfp8/mod.rs:259-269 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 11 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 11+ corresponding lines) mistralrs-core/src/sequence.rs:2034 — mistralrs-core/src/sequence.rs:2034-2044 | mistralrs-core/src/sequence.rs:2074-2084 | mistralrs-core/src/sequence.rs:2121-2131 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 11 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 11+ corresponding lines) mistralrs-quant/src/fp8/mod.rs:29 — mistralrs-quant/src/fp8/mod.rs:29-48 | mistralrs-quant/src/mxfp4/mod.rs:39-49 | mistralrs-quant/src/unquantized/mod.rs:55-65 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 11 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 11+ corresponding lines) mistralrs-core/src/models/phi3.rs:61 — mistralrs-core/src/models/phi3.rs:61-71 | mistralrs-core/src/models/phi3_5_moe.rs:63-73 | mistralrs-core/src/vision_models/phi3/mod.rs:97-107 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 11 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 15+ corresponding lines) · ×5
  • Edited copies of one member (3 members, 15+ corresponding lines) mistralrs-sandbox/src/linux/namespaces.rs:81 — mistralrs-sandbox/src/linux/namespaces.rs:81-95 | mistralrs-sandbox/src/linux/namespaces.rs:110-128 | mistralrs-sandbox/src/linux/seccomp.rs:93-111 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 15 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 15+ corresponding lines) mistralrs-core/src/models/qwen3_next.rs:606 — mistralrs-core/src/models/qwen3_next.rs:606-620 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:436-457 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:465-483 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 15 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 15+ corresponding lines) mistralrs-core/src/lib.rs:952 — mistralrs-core/src/lib.rs:952-967 | mistralrs-core/src/lib.rs:991-1006 | mistralrs-core/src/lib.rs:1061-1075 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 15 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 15+ corresponding lines) mistralrs-core/src/diffusion_models/clip/text.rs:284 — mistralrs-core/src/diffusion_models/clip/text.rs:284-298 | mistralrs-core/src/layers_masker.rs:131-151 | mistralrs-core/src/layers_masker.rs:297-313 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 15 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 15+ corresponding lines) mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:321 — mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:321-335 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:367-383 | mistralrs-core/src/vision_models/mllama/text.rs:317-331 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 15 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Duplicated block (40 lines × 2) · ×5
  • Duplicated block (40 lines × 2) mistralrs-cli/src/commands/config.rs:162 — mistralrs-cli/src/commands/config.rs:162-201 | mistralrs-cli/src/commands/serve.rs:182-221 — before extracting anything, compare `mistralrs-cli/src/commands/config.rs` and `mistralrs-cli/src/commands/serve.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 60 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-cli/src/commands/config.rs:162` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (40 lines × 2) mistralrs-core/src/models/phi3.rs:685 — mistralrs-core/src/models/phi3.rs:685-724 | mistralrs-core/src/vision_models/phi3/mod.rs:1520-1559 — before extracting anything, compare `mistralrs-core/src/models/phi3.rs` and `mistralrs-core/src/vision_models/phi3/mod.rs` as WHOLE FILES: this scan already matched 50 separate duplicated blocks between them, totalling at least 638 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/phi3.rs:685` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (40 lines × 2) mistralrs-core/src/vision_models/qwen3_vl/text.rs:392 — mistralrs-core/src/vision_models/qwen3_vl/text.rs:392-431 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:512-551 — `mistralrs-core/src/vision_models/qwen3_vl/text.rs` and `mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 45 separate duplicated blocks between them, totalling at least 674 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (40 lines × 2) mistralrs-macros/src/lib.rs:266 — mistralrs-macros/src/lib.rs:266-305 | mistralrs-macros/src/lib.rs:329-368 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-macros/src/lib.rs:266` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (40 lines × 2) mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:337 — mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:337-376 | mistralrs-core/src/vision_models/qwen2vl/mod.rs:493-532 — `mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs` and `mistralrs-core/src/vision_models/qwen2vl/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 16 separate duplicated blocks between them, totalling at least 396 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:337` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (21 lines × 3) · ×5
  • Duplicated block (21 lines × 3) mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:65 — mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:65-85 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:339-359 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:194-214 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/embedding_loaders.rs` and `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 180 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (21 lines × 3) mistralrs-core/src/vision_models/grid_processor.rs:1195 — mistralrs-core/src/vision_models/grid_processor.rs:1195-1215 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:405-425 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:970-990 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:1195` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (21 lines × 3) mistralrs-core/src/vision_models/qwen3_5/mod.rs:383 — mistralrs-core/src/vision_models/qwen3_5/mod.rs:383-403 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:368-388 | mistralrs-core/src/vision_models/qwen4_exp/mod.rs:363-383 — `mistralrs-core/src/vision_models/qwen3_5/mod.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 24 separate duplicated blocks between them, totalling at least 425 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_5/mod.rs:383` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (21 lines × 3) mistralrs-quant/src/gguf/fast_mmvq.rs:474 — mistralrs-quant/src/gguf/fast_mmvq.rs:474-494 | mistralrs-quant/src/gguf/fast_mmvq.rs:516-536 | mistralrs-quant/src/gguf/fast_mmvq.rs:558-578 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/gguf/fast_mmvq.rs:474` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (21 lines × 3) mistralrs-core/src/models/deepseek2.rs:1054 — mistralrs-core/src/models/deepseek2.rs:1054-1074 | mistralrs-core/src/models/deepseek3.rs:1119-1139 | mistralrs-core/src/models/glm4_moe_lite.rs:1073-1093 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:1054` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/models/deepseek2.rs:1051` calls `Plain`, `pp`, `add` and `mistralrs-core/src/models/glm4_moe_lite.rs:1072` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (20 lines × 3) · ×5
  • Duplicated block (20 lines × 3) mistralrs-core/src/models/phi3.rs:115 — mistralrs-core/src/models/phi3.rs:115-134 | mistralrs-core/src/vision_models/phi3/mod.rs:206-225 | mistralrs-core/src/vision_models/phi4/mod.rs:76-95 — before extracting anything, compare `mistralrs-core/src/models/phi3.rs` and `mistralrs-core/src/vision_models/phi3/mod.rs` as WHOLE FILES: this scan already matched 50 separate duplicated blocks between them, totalling at least 638 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/phi3.rs:115` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (20 lines × 3) mistralrs-core/src/pipeline/embedding.rs:651 — mistralrs-core/src/pipeline/embedding.rs:651-670 | mistralrs-core/src/pipeline/multimodal.rs:1426-1445 | mistralrs-core/src/pipeline/normal.rs:1469-1488 — before extracting anything, compare `mistralrs-core/src/pipeline/embedding.rs` and `mistralrs-core/src/pipeline/multimodal.rs` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 178 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/embedding.rs:651` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (20 lines × 3) mistralrs-core/src/vision_models/grid_processor.rs:204 — mistralrs-core/src/vision_models/grid_processor.rs:204-223 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:92-111 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:193-212 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (20 lines × 3) mistralrs-quant/src/utils/ops.rs:268 — mistralrs-quant/src/utils/ops.rs:268-287 | mistralrs-quant/src/utils/ops.rs:372-391 | mistralrs-quant/src/utils/ops.rs:585-604 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (20 lines × 3) mistralrs/src/model_builder_trait.rs:1287 — mistralrs/src/model_builder_trait.rs:1287-1306 | mistralrs/src/model_builder_trait.rs:1354-1373 | mistralrs/src/model_builder_trait.rs:1452-1471 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs/src/model_builder_trait.rs:1287` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `builder` to `crate::DiffusionModelBuilder` in one and `crate::SpeechModelBuilder` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (16–17 lines × 2) · ×5
  • Duplicated block (16–17 lines × 2) mistralrs-core/src/models/gemma2.rs:545 — mistralrs-core/src/models/gemma2.rs:545-561 | mistralrs-core/src/models/qwen2.rs:575-590 — before extracting anything, compare `mistralrs-core/src/models/gemma2.rs` and `mistralrs-core/src/models/qwen2.rs` as WHOLE FILES: this scan already matched 38 separate duplicated blocks between them, totalling at least 475 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma2.rs:545` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16–17 lines × 2) mistralrs-core/src/models/gpt_oss.rs:819 — mistralrs-core/src/models/gpt_oss.rs:819-835 | mistralrs-core/src/models/phi3.rs:489-504 — before extracting anything, compare `mistralrs-core/src/models/gpt_oss.rs` and `mistralrs-core/src/models/phi3.rs` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 162 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (16–17 lines × 2) mistralrs-core/src/vision_models/gemma3n/text.rs:1721 — mistralrs-core/src/vision_models/gemma3n/text.rs:1721-1736 | mistralrs-core/src/vision_models/gemma4/text.rs:2049-2065 — `mistralrs-core/src/vision_models/gemma3n/text.rs` and `mistralrs-core/src/vision_models/gemma4/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 7 separate duplicated blocks between them, totalling at least 70 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3n/text.rs:1721` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (16–17 lines × 2) mistralrs-core/src/xlora_models/gemma.rs:528 — mistralrs-core/src/xlora_models/gemma.rs:528-544 | mistralrs-core/src/xlora_models/phi3.rs:473-488 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/phi3.rs` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 233 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma.rs:528` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (16–17 lines × 2) mistralrs-quant/src/rotary/mod.rs:583 — mistralrs-quant/src/rotary/mod.rs:583-598 | mistralrs-quant/src/rotary/mod.rs:690-706 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/rotary/mod.rs:583` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-quant/src/rotary/mod.rs:689` calls `check_qk_shape` and `mistralrs-quant/src/rotary/mod.rs:582` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (13 lines × 4) · ×5
  • Duplicated block (13 lines × 4) mistralrs-core/src/models/gemma.rs:416 — mistralrs-core/src/models/gemma.rs:416-428 | mistralrs-core/src/models/gemma2.rs:489-501 | mistralrs-core/src/models/starcoder2.rs:480-492 | mistralrs-core/src/vision_models/muse_glimmer/text.rs:513-525 — before extracting anything, compare `mistralrs-core/src/models/gemma.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 707 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma.rs:416` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (13 lines × 4) mistralrs-core/src/models/glm4_moe.rs:881 — mistralrs-core/src/models/glm4_moe.rs:881-893 | mistralrs-core/src/models/glm4_moe.rs:926-938 | mistralrs-core/src/models/glm4_moe_lite.rs:1015-1027 | mistralrs-core/src/models/glm4_moe_lite.rs:1058-1070 — before extracting anything, compare `mistralrs-core/src/models/glm4_moe.rs` and `mistralrs-core/src/models/glm4_moe_lite.rs` as WHOLE FILES: this scan already matched 44 separate duplicated blocks between them, totalling at least 596 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (13 lines × 4) mistralrs-quant/src/hqq/mod.rs:159 — mistralrs-quant/src/hqq/mod.rs:159-171 | mistralrs-quant/src/hqq/mod.rs:242-254 | mistralrs-quant/src/hqq/mod.rs:336-348 | mistralrs-quant/src/hqq/mod.rs:485-497 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/hqq/mod.rs:159` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 4) mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:1144 — mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:1144-1156 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:1173-1185 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1709-1721 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1738-1750 — `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` and `mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 45 separate duplicated blocks between them, totalling at least 1082 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:1144` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (13 lines × 4) mistralrs-quant/src/cutile/qsa.rs:422 — mistralrs-quant/src/cutile/qsa.rs:422-434 | mistralrs-quant/src/cutile/qsa.rs:440-452 | mistralrs-quant/src/cutile/qsa_decode.rs:235-247 | mistralrs-quant/src/cutile/qsa_decode.rs:253-265 — before extracting anything, compare `mistralrs-quant/src/cutile/qsa.rs` and `mistralrs-quant/src/cutile/qsa_decode.rs` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 134 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (12–13 lines × 3) · ×5
  • Duplicated block (12–13 lines × 3) mistralrs-core/src/models/flint.rs:867 — mistralrs-core/src/models/flint.rs:867-879 | mistralrs-core/src/models/qwen3.rs:493-504 | mistralrs-core/src/models/qwen3_moe.rs:673-684 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/qwen3.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 396 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/flint.rs:867` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (12–13 lines × 3) mistralrs-core/src/sampler.rs:966 — mistralrs-core/src/sampler.rs:966-977 | mistralrs-core/src/sampler.rs:1515-1527 | mistralrs-core/src/sampler.rs:1683-1694 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/sampler.rs:966` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/sampler.rs:1513` calls `clone` and `mistralrs-core/src/sampler.rs:1681` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12–13 lines × 3) mistralrs-core/src/sampler.rs:1179 — mistralrs-core/src/sampler.rs:1179-1191 | mistralrs-core/src/sampler.rs:1259-1271 | mistralrs-core/src/sampler.rs:1729-1740 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/sampler.rs:1179` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12–13 lines × 3) mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:288 — mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:288-300 | mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:525-537 | mistralrs-core/src/vision_models/phi3/phi3_inputs_processor.rs:457-468 — before extracting anything, compare `mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs` and `mistralrs-core/src/vision_models/phi3/phi3_inputs_processor.rs` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 288 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:288` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12–13 lines × 3) REDACTED:20 — REDACTED:20-31 | REDACTED:84-96 | REDACTED:20-31 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (10 lines × 7) · ×5
  • Duplicated block (10 lines × 7) mistralrs-core/src/embedding_models/embedding_gemma.rs:292 — mistralrs-core/src/embedding_models/embedding_gemma.rs:292-301 | mistralrs-core/src/models/gemma.rs:286-295 | mistralrs-core/src/models/gemma2.rs:337-346 | mistralrs-core/src/models/qwen3_next.rs:868-877 | mistralrs-core/src/vision_models/gemma3/text.rs:345-354 | mistralrs-core/src/xlora_models/gemma.rs:345-354 | mistralrs-core/src/xlora_models/gemma2.rs:354-363 — `mistralrs-core/src/embedding_models/embedding_gemma.rs` and `mistralrs-core/src/models/gemma.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 9 separate duplicated blocks between them, totalling at least 133 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (10 lines × 7) mistralrs-core/src/models/gemma.rs:391 — mistralrs-core/src/models/gemma.rs:391-400 | mistralrs-core/src/models/gemma2.rs:464-473 | mistralrs-core/src/models/qwen3_next.rs:832-841 | mistralrs-core/src/vision_models/gemma3/text.rs:503-512 | mistralrs-core/src/vision_models/gemma3n/text.rs:1443-1452 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:436-445 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:556-565 — before extracting anything, compare `mistralrs-core/src/models/gemma.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 707 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (10 lines × 7) mistralrs-core/src/pipeline/multimodal.rs:1161 — mistralrs-core/src/pipeline/multimodal.rs:1161-1170 | mistralrs-core/src/pipeline/multimodal.rs:1218-1227 | mistralrs-core/src/pipeline/multimodal.rs:1270-1279 | mistralrs-core/src/pipeline/normal.rs:1160-1169 | mistralrs-core/src/pipeline/normal.rs:1213-1222 | mistralrs-core/src/pipeline/normal.rs:1270-1279 | mistralrs-core/src/pipeline/normal.rs:1346-1355 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:1161` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 7) mistralrs-core/src/xlora_models/gemma.rs:605 — mistralrs-core/src/xlora_models/gemma.rs:605-615 | mistralrs-core/src/xlora_models/mistral.rs:601-611 | mistralrs-core/src/xlora_models/mixtral.rs:731-741 | mistralrs-core/src/xlora_models/phi2.rs:571-580 | mistralrs-core/src/xlora_models/quantized_llama.rs:805-814 | mistralrs-core/src/xlora_models/quantized_phi3.rs:473-482 | mistralrs-core/src/xlora_models/starcoder2.rs:586-596 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/mistral.rs` as WHOLE FILES: this scan already matched 37 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma.rs:605` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (10 lines × 7) mistralrs-quant/src/cutile/mxfp8_gemm.rs:539 — mistralrs-quant/src/cutile/mxfp8_gemm.rs:539-548 | mistralrs-quant/src/cutile/nvfp4_gemv.rs:323-332 | mistralrs-quant/src/cutile/nvfp4_matmul.rs:650-659 | mistralrs-quant/src/cutile/nvfp4_matmul.rs:694-703 | mistralrs-quant/src/cutile/nvfp4_matmul.rs:1152-1161 | mistralrs-quant/src/nvfp4/decode.rs:124-133 | mistralrs-quant/src/nvfp4/portable.rs:313-322 — before extracting anything, compare `mistralrs-quant/src/cutile/mxfp8_gemm.rs` and `mistralrs-quant/src/cutile/nvfp4_matmul.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 34 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (9–10 lines × 2) · ×5
  • Duplicated block (9–10 lines × 2) mistralrs-core/src/pipeline/chat_template.rs:612 — mistralrs-core/src/pipeline/chat_template.rs:612-621 | mistralrs-core/src/pipeline/chat_template.rs:645-653 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/chat_template.rs:612` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9–10 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1137 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1137-1145 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1947-1956 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` and `mistralrs-core/src/pipeline/loaders/normal_loaders.rs` as WHOLE FILES: this scan already matched 34 separate duplicated blocks between them, totalling at least 445 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1137` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (9–10 lines × 2) mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:458 — mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:458-466 | mistralrs-core/src/vision_models/mistral3/inputs_processor.rs:289-298 — `mistralrs-core/src/vision_models/idefics3/inputs_processor.rs` and `mistralrs-core/src/vision_models/mistral3/inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 13 separate duplicated blocks between them, totalling at least 194 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:458` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9–10 lines × 2) mistralrs/src/anymoe.rs:141 — mistralrs/src/anymoe.rs:141-150 | mistralrs/src/model_builder_trait.rs:1083-1091 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs/src/anymoe.rs:141` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9–10 lines × 2) mistralrs/src/model.rs:439 — mistralrs/src/model.rs:439-447 | mistralrs/src/model.rs:524-533 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs/src/model.rs:439` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (7 lines × 6) · ×5
  • Duplicated block (7 lines × 6) mistralrs-core/src/cuda/rounded_rope.rs:68 — mistralrs-core/src/cuda/rounded_rope.rs:68-74 | mistralrs-quant/src/cutile/fp8_w8a8.rs:522-528 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:905-911 | mistralrs-quant/src/cutile/mxfp8_gemm.rs:524-530 | mistralrs-quant/src/cutile/nvfp4_gemv.rs:305-311 | mistralrs-quant/src/nvfp4/portable.rs:302-308 — before extracting anything, compare `mistralrs-quant/src/cutile/fp8_w8a8.rs` and `mistralrs-quant/src/cutile/fused_moe_fp8.rs` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 83 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/rounded_rope.rs:68` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-quant/src/cutile/nvfp4_gemv.rs:302` calls `storage_and_layout` and `mistralrs-quant/src/cutile/fp8_w8a8.rs:519` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 6) mistralrs-core/src/xlora_models/gemma.rs:489 — mistralrs-core/src/xlora_models/gemma.rs:489-495 | mistralrs-core/src/xlora_models/gemma2.rs:519-525 | mistralrs-core/src/xlora_models/mistral.rs:485-491 | mistralrs-core/src/xlora_models/mixtral.rs:616-622 | mistralrs-core/src/xlora_models/phi2.rs:471-477 | mistralrs-core/src/xlora_models/starcoder2.rs:473-479 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/gemma2.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 498 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma.rs:489` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 6) mistralrs-quant/src/cutile/fp8_gemm.rs:340 — mistralrs-quant/src/cutile/fp8_gemm.rs:340-346 | mistralrs-quant/src/cutile/fp8_w8a8.rs:524-530 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:907-913 | mistralrs-quant/src/cutile/mxfp8_gemm.rs:526-532 | mistralrs-quant/src/cutile/nvfp4_matmul.rs:641-647 | mistralrs-quant/src/nvfp4/portable.rs:304-310 — before extracting anything, compare `mistralrs-quant/src/cutile/fp8_gemm.rs` and `mistralrs-quant/src/cutile/fp8_w8a8.rs` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 88 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cutile/fp8_gemm.rs:340` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 6) mistralrs-core/src/vision_models/grid_processor.rs:2079 — mistralrs-core/src/vision_models/grid_processor.rs:2079-2085 | mistralrs-core/src/vision_models/grid_processor.rs:2139-2145 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:1144-1150 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:1173-1179 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1709-1715 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1738-1744 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:2079` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (7 lines × 6) mistralrs-quant/src/bitsandbytes/op.rs:421 — mistralrs-quant/src/bitsandbytes/op.rs:421-427 | mistralrs-quant/src/hqq/hqq_op.rs:73-79 | mistralrs-quant/src/hqq/hqq_op.rs:184-190 | mistralrs-quant/src/hqq/hqq_op.rs:297-303 | mistralrs-quant/src/hqq/hqq_op.rs:414-420 | mistralrs-quant/src/hqq/hqq_op.rs:533-539 — there are 6 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 6 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/bitsandbytes/op.rs:421` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D5 · Coupling · Off the main sequence · ×5
  • Off the main sequence: mistralrs-audio — mistralrs-audio: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 1 project(s), so it's rigid to change.
  • Off the main sequence: mistralrs-flash-attn — mistralrs-flash-attn: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 1 project(s), so it's rigid to change.
  • Off the main sequence: mistralrs-metal-compile — mistralrs-metal-compile: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 3 project(s), so it's rigid to change.
  • Off the main sequence: mistralrs-mcp — mistralrs-mcp: abstractness 0.06, instability 0.00, distance 0.94 — zone of pain — concrete and depended on by 3 project(s), so it's rigid to change.
  • Off the main sequence: mistralrs-sandbox — mistralrs-sandbox: abstractness 0.14, instability 0.00, distance 0.86 — zone of pain — concrete and depended on by 3 project(s), so it's rigid to change.
P7 · Outbound HTTP resilience · Outbound HTTP without resilience · ×5
  • Outbound HTTP without resilience mistralrs-core/src/engine/tool_dispatch.rs:461 — `reqwest::blocking::Client::new(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
  • Outbound HTTP without resilience mistralrs-core/src/pipeline/amoe.rs:647 — `reqwest::blocking::get(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
  • Outbound HTTP without resilience mistralrs-pyo3/src/util.rs:219 — `reqwest::blocking::get(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
  • Outbound HTTP without resilience mistralrs-pyo3/src/util.rs:272 — `reqwest::blocking::get(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
  • Outbound HTTP without resilience mistralrs-pyo3/src/util.rs:332 — `reqwest::blocking::get(` makes an outbound HTTP call, and nothing bounds it: no timeout, deadline, retry or circuit breaker is set for it here, and the client has no process-wide default. A slow or failing dependency will hold this service's request, thread or connection until the call gives up on its own — or never, for a client with no default timeout.
X2 · Cancellation propagation · Async function without AbortSignal · ×5
  • Async function without AbortSignal: get mistralrs-cli/webui/src/lib/services/api.ts:24 — `get` awaits `fetch(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `fetch(url, { signal })`.
  • Async function without AbortSignal: post mistralrs-cli/webui/src/lib/services/api.ts:30 — `post` awaits `fetch(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `fetch(url, { signal })`.
  • Async function without AbortSignal: postVoid mistralrs-cli/webui/src/lib/services/api.ts:40 — `postVoid` awaits `fetch(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `fetch(url, { signal })`.
  • Async function without AbortSignal: uploadFile mistralrs-cli/webui/src/lib/services/api.ts:131 — `uploadFile` awaits `fetch(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `fetch(url, { signal })`.
  • Async function without AbortSignal: resolveAgentApproval mistralrs-cli/webui/src/lib/services/streaming.ts:185 — `resolveAgentApproval` awaits `fetch(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `fetch(url, { signal })`.
D1 · Cyclomatic Complexity · Engine · ×4
  • Engine::run (cyclomatic 147) mistralrs-core/src/engine/mod.rs:1157 — Engine::run has cyclomatic complexity 147 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • Engine::add_request (cyclomatic 125) mistralrs-core/src/engine/add_request.rs:156 — Engine::add_request has cyclomatic complexity 125 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • Engine::new (cyclomatic 21) mistralrs-core/src/engine/mod.rs:553 — Engine::new has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • Engine::handle_request (cyclomatic 19) mistralrs-core/src/engine/add_request.rs:78 — Engine::handle_request has cyclomatic complexity 19 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
D1 · Cyclomatic Complexity · PagedAttention · ×4
  • PagedAttention::try_prefix_gather_prefill (cyclomatic 51) mistralrs-core/src/paged_attention/layers/paged_attention.rs:1412 — PagedAttention::try_prefix_gather_prefill has cyclomatic complexity 51 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • PagedAttention::try_metal_prefill (cyclomatic 40) mistralrs-core/src/paged_attention/layers/paged_attention.rs:1142 — PagedAttention::try_metal_prefill has cyclomatic complexity 40 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • PagedAttention::cuda_fwd_t (cyclomatic 38) mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:112 — PagedAttention::cuda_fwd_t has cyclomatic complexity 38 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • PagedAttention::metal_fwd (cyclomatic 35) mistralrs-paged-attn/src/metal/backend/paged_attention.rs:321 — PagedAttention::metal_fwd has cyclomatic complexity 35 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · Model · ×4
  • Model::prepare_inputs_labels_for_multimodal (cyclomatic 32) mistralrs-core/src/vision_models/llava/llava_next.rs:224 — Model::prepare_inputs_labels_for_multimodal has cyclomatic complexity 32 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • Model::forward_hidden (cyclomatic 20) mistralrs-core/src/models/lfm3.rs:1170 — Model::forward_hidden has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • Model::forward (cyclomatic 18) mistralrs-core/src/models/qwen3_next.rs:964 — Model::forward has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • Model::forward_embeds (cyclomatic 16) mistralrs-core/src/models/lfm2.rs:1172 — Model::forward_embeds has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MultimodalPipeline · ×4
  • MultimodalPipeline::try_cuda_decode_graph_forward (cyclomatic 29) mistralrs-core/src/pipeline/multimodal.rs:2129 — MultimodalPipeline::try_cuda_decode_graph_forward has cyclomatic complexity 29 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • MultimodalPipeline::precapture_cuda_decode_graphs_impl (cyclomatic 21) mistralrs-core/src/pipeline/multimodal.rs:2360 — MultimodalPipeline::precapture_cuda_decode_graphs_impl has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: MultimodalLoaderBuilder::build_inner (cyclomatic 29) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
  • MultimodalPipeline::capture_cuda_decode_graph_step (cyclomatic 17) mistralrs-core/src/pipeline/multimodal.rs:2549 — MultimodalPipeline::capture_cuda_decode_graph_step has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This is NOT this file's highest cyclomatic complexity: MultimodalLoaderBuilder::build_inner (cyclomatic 29) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
  • MultimodalPipeline::forward_step (cyclomatic 16) mistralrs-core/src/pipeline/multimodal.rs:2933 — MultimodalPipeline::forward_step has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: MultimodalLoaderBuilder::build_inner (cyclomatic 29) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · BlockwiseFP8Linear · ×4
  • BlockwiseFP8Linear::forward_raw (cyclomatic 24) mistralrs-quant/src/blockwise_fp8/mod.rs:554 — BlockwiseFP8Linear::forward_raw has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • BlockwiseFP8Linear::apply_isq (cyclomatic 24) mistralrs-quant/src/blockwise_fp8/mod.rs:1074 — BlockwiseFP8Linear::apply_isq has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • BlockwiseFP8Linear::prepare_provider (cyclomatic 17) mistralrs-quant/src/blockwise_fp8/mod.rs:117 — BlockwiseFP8Linear::prepare_provider has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • BlockwiseFP8Linear::forward_packed_glu (cyclomatic 16) mistralrs-quant/src/blockwise_fp8/mod.rs:288 — BlockwiseFP8Linear::forward_packed_glu has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D17 · Explicit Debt · FixmeComment · ×4
  • FixmeComment mistralrs-core/src/sampler.rs:248 — // FIXME: This is a hack. See https://github.com/LostRuins/koboldcpp/pull/982
  • FixmeComment mistralrs-core/src/pipeline/diffusion.rs:172 — // FIXME(EricLBuehler): we know this is only for caching, so its OK. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment mistralrs-core/src/pipeline/embedding.rs:723 — // FIXME(EricLBuehler): we know this is only for caching, so its OK. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment mistralrs-core/src/pipeline/speech.rs:272 — // FIXME(EricLBuehler): we know this is only for caching, so its OK. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
D2 · Cognitive Complexity · Phi4MMInputsProcessor · ×4
  • Phi4MMInputsProcessor::process_image_batch (cognitive 47) mistralrs-core/src/vision_models/phi4/inputs_processor.rs:754 — Phi4MMInputsProcessor::process_image_batch has cognitive complexity 47 (threshold 15). Drivers by points: if/else 17 (40 pts), loops 2 (3 pts), boolean chains 2, match/switch 1 (2 pts) (nesting depth added 25). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Phi4MMInputsProcessor::process_audio_batch (cognitive 20) mistralrs-core/src/vision_models/phi4/inputs_processor.rs:950 — Phi4MMInputsProcessor::process_audio_batch has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (17 pts), loops 2 (3 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Phi4MMInputsProcessor::process_inputs (cognitive 17) mistralrs-core/src/vision_models/phi4/inputs_processor.rs:329 — Phi4MMInputsProcessor::process_inputs has cognitive complexity 17 (threshold 15). Drivers by points: if/else 11 (12 pts), boolean chains 3, match/switch 2 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • Phi4MMInputsProcessor::prepare_prompt_plans (cognitive 16) mistralrs-core/src/vision_models/phi4/inputs_processor.rs:576 — Phi4MMInputsProcessor::prepare_prompt_plans has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (12 pts), boolean chains 3, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BlockwiseFP8Linear · ×4
  • BlockwiseFP8Linear::forward_raw (cognitive 41) mistralrs-quant/src/blockwise_fp8/mod.rs:554 — BlockwiseFP8Linear::forward_raw has cognitive complexity 41 (threshold 15). Drivers by points: if/else 20 (33 pts), boolean chains 4, match/switch 2 (4 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • BlockwiseFP8Linear::apply_isq (cognitive 30) mistralrs-quant/src/blockwise_fp8/mod.rs:1074 — BlockwiseFP8Linear::apply_isq has cognitive complexity 30 (threshold 15). Drivers by points: if/else 15 (25 pts), match/switch 3 (5 pts) (nesting depth added 12). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • BlockwiseFP8Linear::prepare_provider (cognitive 21) mistralrs-quant/src/blockwise_fp8/mod.rs:117 — BlockwiseFP8Linear::prepare_provider has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (15 pts), boolean chains 3, match/switch 2 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • BlockwiseFP8Linear::forward_packed_glu (cognitive 20) mistralrs-quant/src/blockwise_fp8/mod.rs:288 — BlockwiseFP8Linear::forward_packed_glu has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (14 pts), boolean chains 3, match/switch 2 (3 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Nvfp4Layer · ×4
  • Nvfp4Layer::from_normalized_parts (cognitive 41) mistralrs-quant/src/nvfp4/mod.rs:201 — Nvfp4Layer::from_normalized_parts has cognitive complexity 41 (threshold 15). Drivers by points: if/else 25 (30 pts), boolean chains 9, loops 1, match/switch 1 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • Nvfp4Layer::load_shape (cognitive 34) mistralrs-quant/src/nvfp4/mod.rs:387 — Nvfp4Layer::load_shape has cognitive complexity 34 (threshold 15). Drivers by points: if/else 16 (21 pts), match/switch 5 (7 pts), boolean chains 5, loops 1 (nesting depth added 7). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • Nvfp4Layer::gather_forward_raw (cognitive 23) mistralrs-quant/src/nvfp4/mod.rs:985 — Nvfp4Layer::gather_forward_raw has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 6, match/switch 2 (3 pts), loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Nvfp4Layer::reference_forward (cognitive 17) mistralrs-quant/src/nvfp4/mod.rs:793 — Nvfp4Layer::reference_forward has cognitive complexity 17 (threshold 15). Drivers by points: loops 3 (8 pts), if/else 4 (7 pts), match/switch 2 (nesting depth added 8). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · MultimodalPipeline · ×4
  • MultimodalPipeline::try_cuda_decode_graph_forward (cognitive 34) mistralrs-core/src/pipeline/multimodal.rs:2129 — MultimodalPipeline::try_cuda_decode_graph_forward has cognitive complexity 34 (threshold 15). Drivers by points: if/else 23 (28 pts), boolean chains 6 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • MultimodalPipeline::precapture_cuda_decode_graphs_impl (cognitive 29) mistralrs-core/src/pipeline/multimodal.rs:2360 — MultimodalPipeline::precapture_cuda_decode_graphs_impl has cognitive complexity 29 (threshold 15). Drivers by points: if/else 17 (24 pts), loops 3, boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • MultimodalPipeline::capture_cuda_decode_graph_step (cognitive 22) mistralrs-core/src/pipeline/multimodal.rs:2549 — MultimodalPipeline::capture_cuda_decode_graph_step has cognitive complexity 22 (threshold 15). Drivers by points: if/else 14, match/switch 3 (6 pts), boolean chains 2 (nesting depth added 3). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • MultimodalPipeline::forward_step (cognitive 17) mistralrs-core/src/pipeline/multimodal.rs:2933 — MultimodalPipeline::forward_step has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (11 pts), boolean chains 3, match/switch 2 (3 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D4 · Code Duplication · Edited copy of a member (46 corresponding lines) · ×4
  • Edited copy of a member (46 corresponding lines) mistralrs-core/src/models/gemma2.rs:538 — mistralrs-core/src/models/gemma2.rs:538-596 | mistralrs-core/src/models/qwen2.rs:572-617 — These two members are one piece of code written twice and then edited apart: 46 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (46 corresponding lines) mistralrs-core/src/flashinfer/metadata.rs:105 — mistralrs-core/src/flashinfer/metadata.rs:105-167 | mistralrs-core/src/speculative/paged_rows.rs:272-317 — These two members are one piece of code written twice and then edited apart: 46 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (46 corresponding lines) mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:235 — mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:235-280 | mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:500-545 — These two members are one piece of code written twice and then edited apart: 46 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (46 corresponding lines) mistralrs-core/src/vision_models/llama4/vision.rs:116 — mistralrs-core/src/vision_models/llama4/vision.rs:116-161 | mistralrs-core/src/vision_models/mllama/vision.rs:147-192 — These two members are one piece of code written twice and then edited apart: 46 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (28 corresponding lines) · ×4
  • Edited copy of a member (28 corresponding lines) mistralrs-quant/src/gguf/cuda.rs:84 — mistralrs-quant/src/gguf/cuda.rs:84-112 | mistralrs-quant/src/gguf/cuda.rs:151-178 — These two members are one piece of code written twice and then edited apart: 28 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (28 corresponding lines) mistralrs-quant/src/cutile/fp8_w8a16.rs:294 — mistralrs-quant/src/cutile/fp8_w8a16.rs:294-327 | mistralrs-quant/src/cutile/fp8_w8a8.rs:293-320 — These two members are one piece of code written twice and then edited apart: 28 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (28 corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9444 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9444-9474 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:10701-10728 — These two members are one piece of code written twice and then edited apart: 28 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (28 corresponding lines) examples/python/code_execution.py:28 — examples/python/code_execution.py:28-55 | examples/python/shell.py:23-50 — These two members are one piece of code written twice and then edited apart: 28 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (31 corresponding lines) · ×4
  • Edited copy of a member (31 corresponding lines) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1724 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1724-1754 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2630-2663 — These two members are one piece of code written twice and then edited apart: 31 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (31 corresponding lines) mistralrs-quant/src/scalar_fp8/ops.rs:133 — mistralrs-quant/src/scalar_fp8/ops.rs:133-163 | mistralrs-quant/src/scalar_fp8/ops.rs:292-322 — These two members are one piece of code written twice and then edited apart: 31 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (31 corresponding lines) mistralrs-core/src/pipeline/amoe.rs:116 — mistralrs-core/src/pipeline/amoe.rs:116-147 | mistralrs-core/src/pipeline/amoe.rs:159-189 — These two members are one piece of code written twice and then edited apart: 31 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (31 corresponding lines) mistralrs-core/src/lib.rs:2181 — mistralrs-core/src/lib.rs:2181-2211 | mistralrs-core/src/lib.rs:2969-3005 — These two members are one piece of code written twice and then edited apart: 31 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (25 corresponding lines) · ×4
  • Edited copy of a member (25 corresponding lines) mistralrs-core/src/pipeline/multimodal.rs:2089 — mistralrs-core/src/pipeline/multimodal.rs:2089-2113 | mistralrs-core/src/pipeline/normal.rs:2381-2410 — These two members are one piece of code written twice and then edited apart: 25 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (25 corresponding lines) mistralrs-core/src/attention/backends/cpu/neon.rs:255 — mistralrs-core/src/attention/backends/cpu/neon.rs:255-279 | mistralrs-core/src/attention/backends/cpu/neon.rs:498-524 — These two members are one piece of code written twice and then edited apart: 25 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (25 corresponding lines) mistralrs-core/src/models/phi2.rs:79 — mistralrs-core/src/models/phi2.rs:79-104 | mistralrs-core/src/models/starcoder2.rs:60-84 — These two members are one piece of code written twice and then edited apart: 25 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (25 corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2014 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2014-2040 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2046-2070 — These two members are one piece of code written twice and then edited apart: 25 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 14+ corresponding lines) · ×4
  • Edited copies of one member (3 members, 14+ corresponding lines) mistralrs-core/src/models/granite.rs:1413 — mistralrs-core/src/models/granite.rs:1413-1426 | mistralrs-core/src/models/granite.rs:1433-1446 | mistralrs-core/src/models/granite.rs:1715-1733 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 14 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 14+ corresponding lines) mistralrs-quant/src/embedding/storage.rs:983 — mistralrs-quant/src/embedding/storage.rs:983-996 | mistralrs-quant/src/gguf/archive.rs:672-689 | mistralrs-quant/src/safetensors.rs:24-37 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 14 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 14+ corresponding lines) mistralrs-core/src/engine/agentic_loop.rs:931 — mistralrs-core/src/engine/agentic_loop.rs:931-948 | mistralrs-core/src/engine/agentic_loop.rs:955-969 | mistralrs-core/src/engine/agentic_loop.rs:1091-1104 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 14 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 14+ corresponding lines) mistralrs-server-core/src/responses.rs:77 — mistralrs-server-core/src/responses.rs:77-94 | mistralrs-server-core/src/responses_types/items.rs:25-38 | mistralrs-server-core/src/responses_types/items.rs:879-892 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 14 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Duplicated block (42 lines × 2) · ×4
  • Duplicated block (42 lines × 2) mistralrs-core/src/embedding_models/embedding_gemma.rs:404 — mistralrs-core/src/embedding_models/embedding_gemma.rs:404-445 | mistralrs-core/src/vision_models/gemma3/text.rs:463-504 — before extracting anything, compare `mistralrs-core/src/embedding_models/embedding_gemma.rs` and `mistralrs-core/src/vision_models/gemma3/text.rs` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 286 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/embedding_gemma.rs:404` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (42 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:1092 — mistralrs-core/src/pipeline/multimodal.rs:1092-1133 | mistralrs-core/src/pipeline/normal.rs:1118-1159 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:1092` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (42 lines × 2) mistralrs-core/src/vision_models/qwen3_vl/text.rs:459 — mistralrs-core/src/vision_models/qwen3_vl/text.rs:459-500 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:580-621 — `mistralrs-core/src/vision_models/qwen3_vl/text.rs` and `mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 45 separate duplicated blocks between them, totalling at least 674 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_vl/text.rs:459` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (42 lines × 2) mistralrs-core/src/xlora_models/quantized_llama.rs:398 — mistralrs-core/src/xlora_models/quantized_llama.rs:398-439 | mistralrs-core/src/xlora_models/quantized_llama.rs:700-741 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/quantized_llama.rs:398` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (39–40 lines × 2) · ×4
  • Duplicated block (39–40 lines × 2) mistralrs-core/src/lib.rs:1269 — mistralrs-core/src/lib.rs:1269-1307 | mistralrs-core/src/lib.rs:1312-1351 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (39–40 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:2232 — mistralrs-core/src/pipeline/multimodal.rs:2232-2271 | mistralrs-core/src/pipeline/normal.rs:1975-2013 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:2232` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/pipeline/multimodal.rs:2272` calls `as_ref` and `mistralrs-core/src/pipeline/normal.rs:2014` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (39–40 lines × 2) mistralrs-pyo3/src/lib.rs:255 — mistralrs-pyo3/src/lib.rs:255-293 | mistralrs-server-core/src/chat_completion.rs:979-1018 — before extracting anything, compare `mistralrs-pyo3/src/lib.rs` and `mistralrs-server-core/src/chat_completion.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 89 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-pyo3/src/lib.rs:255` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (39–40 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:2306 — mistralrs-core/src/pipeline/multimodal.rs:2306-2345 | mistralrs-core/src/pipeline/normal.rs:2041-2079 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:2306` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (37 lines × 2) · ×4
  • Duplicated block (37 lines × 2) mistralrs-core/src/xlora_models/gemma2.rs:154 — mistralrs-core/src/xlora_models/gemma2.rs:154-190 | mistralrs-core/src/xlora_models/starcoder2.rs:133-169 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma2.rs` and `mistralrs-core/src/xlora_models/starcoder2.rs` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 400 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma2.rs:154` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (37 lines × 2) mistralrs-flash-attn/src/flash.rs:94 — mistralrs-flash-attn/src/flash.rs:94-130 | mistralrs-flash-attn/src/flash.rs:661-697 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (37 lines × 2) mistralrs-server-core/src/embeddings.rs:123 — mistralrs-server-core/src/embeddings.rs:123-159 | mistralrs-server-core/src/embeddings.rs:166-202 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-server-core/src/embeddings.rs:123` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (37 lines × 2) mistralrs-core/src/lora/loralinear.rs:211 — mistralrs-core/src/lora/loralinear.rs:211-247 | mistralrs-core/src/lora/qloralinear.rs:260-296 — before extracting anything, compare `mistralrs-core/src/lora/loralinear.rs` and `mistralrs-core/src/lora/qloralinear.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 151 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/lora/loralinear.rs:211` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (36 lines × 2) · ×4
  • Duplicated block (36 lines × 2) mistralrs-core/src/pipeline/mod.rs:2396 — mistralrs-core/src/pipeline/mod.rs:2396-2431 | mistralrs-core/src/pipeline/mod.rs:2993-3028 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (36 lines × 2) mistralrs-core/src/vision_models/grid_processor.rs:796 — mistralrs-core/src/vision_models/grid_processor.rs:796-831 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:519-554 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 51 separate duplicated blocks between them, totalling at least 1008 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:796` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (36 lines × 2) mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:247 — mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:247-282 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:813-848 — `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` and `mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 45 separate duplicated blocks between them, totalling at least 1082 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:247` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (36 lines × 2) mistralrs-core/src/vision_models/phi3/mod.rs:1239 — mistralrs-core/src/vision_models/phi3/mod.rs:1239-1274 | mistralrs-core/src/vision_models/phi4/mod.rs:354-389 — `mistralrs-core/src/vision_models/phi3/mod.rs` and `mistralrs-core/src/vision_models/phi4/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 48 separate duplicated blocks between them, totalling at least 586 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/phi3/mod.rs:1239` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (34 lines × 2) · ×4
  • Duplicated block (34 lines × 2) mistralrs-core/src/lora/mod.rs:163 — mistralrs-core/src/lora/mod.rs:163-196 | mistralrs-core/src/lora/mod.rs:215-248 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/lora/mod.rs:163` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (34 lines × 2) mistralrs-core/src/ops.rs:660 — mistralrs-core/src/ops.rs:660-693 | mistralrs-core/src/ops.rs:807-840 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (34 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:685 — mistralrs-core/src/pipeline/multimodal.rs:685-718 | mistralrs-core/src/pipeline/normal.rs:723-756 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:685` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (34 lines × 2) mistralrs-core/src/pipeline/normal.rs:1177 — mistralrs-core/src/pipeline/normal.rs:1177-1210 | mistralrs-core/src/pipeline/normal.rs:1305-1338 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/normal.rs:1177` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (33 lines × 2) · ×4
  • Duplicated block (33 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:1352 — mistralrs-core/src/pipeline/multimodal.rs:1352-1384 | mistralrs-core/src/pipeline/normal.rs:1414-1446 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/pipeline/normal.rs:1412` calls `or_else`, `from_model_config` and `mistralrs-core/src/pipeline/multimodal.rs:1351` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (33 lines × 2) mistralrs-core/src/vision_models/gemma3n/vision.rs:950 — mistralrs-core/src/vision_models/gemma3n/vision.rs:950-982 | mistralrs-core/src/vision_models/gemma3n/vision.rs:994-1026 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3n/vision.rs:950` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (33 lines × 2) mistralrs-quant/src/safetensors.rs:828 — mistralrs-quant/src/safetensors.rs:828-860 | mistralrs-quant/src/safetensors.rs:894-926 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/safetensors.rs:828` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (33 lines × 2) mistralrs-quant/src/utils/ops.rs:1131 — mistralrs-quant/src/utils/ops.rs:1131-1163 | mistralrs-quant/src/utils/ops.rs:1203-1235 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (31 lines × 2) · ×4
  • Duplicated block (31 lines × 2) mistralrs-core/src/model_metadata.rs:420 — mistralrs-core/src/model_metadata.rs:420-450 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:282-312 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (31 lines × 2) mistralrs-core/src/models/deepseek2.rs:555 — mistralrs-core/src/models/deepseek2.rs:555-585 | mistralrs-core/src/models/deepseek3.rs:605-635 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:555` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (31 lines × 2) mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:98 — mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:98-128 | mistralrs-core/src/vision_models/qwen2vl/mod.rs:121-151 — `mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs` and `mistralrs-core/src/vision_models/qwen2vl/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 16 separate duplicated blocks between them, totalling at least 396 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:98` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (31 lines × 2) mistralrs-quant/src/cutile/nvfp4_glu.rs:146 — mistralrs-quant/src/cutile/nvfp4_glu.rs:146-176 | mistralrs-quant/src/cutile/nvfp4_matmul.rs:66-96 — before extracting anything, compare `mistralrs-quant/src/cutile/nvfp4_glu.rs` and `mistralrs-quant/src/cutile/nvfp4_matmul.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 70 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cutile/nvfp4_glu.rs:146` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-quant/src/cutile/nvfp4_matmul.rs:65` calls `exti` and `mistralrs-quant/src/cutile/nvfp4_glu.rs:145` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (30 lines × 2) · ×4
  • Duplicated block (30 lines × 2) mistralrs-core/src/models/deepseek2.rs:732 — mistralrs-core/src/models/deepseek2.rs:732-761 | mistralrs-core/src/models/deepseek3.rs:795-824 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:732` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (30 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4952 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4952-4981 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4998-5027 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4952` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (30 lines × 2) mistralrs-core/src/vision_models/gemma3n/audio.rs:476 — mistralrs-core/src/vision_models/gemma3n/audio.rs:476-505 | mistralrs-core/src/vision_models/gemma4/audio.rs:549-578 — `mistralrs-core/src/vision_models/gemma3n/audio.rs` and `mistralrs-core/src/vision_models/gemma4/audio.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 20 separate duplicated blocks between them, totalling at least 352 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (30 lines × 2) mistralrs-pyo3/src/lib.rs:1877 — mistralrs-pyo3/src/lib.rs:1877-1906 | mistralrs-pyo3/src/lib.rs:2367-2396 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-pyo3/src/lib.rs:1877` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (27 lines × 2) · ×4
  • Duplicated block (27 lines × 2) mistralrs-core/src/distributed.rs:189 — mistralrs-core/src/distributed.rs:189-215 | mistralrs-core/src/distributed.rs:235-261 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/distributed.rs:189` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (27 lines × 2) mistralrs-core/src/vision_models/llava/llava15.rs:91 — mistralrs-core/src/vision_models/llava/llava15.rs:91-117 | mistralrs-core/src/vision_models/llava/llava_next.rs:50-76 — before extracting anything, compare `mistralrs-core/src/vision_models/llava/llava15.rs` and `mistralrs-core/src/vision_models/llava/llava_next.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 109 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (27 lines × 2) mistralrs-core/src/xlora_models/gemma.rs:326 — mistralrs-core/src/xlora_models/gemma.rs:326-352 | mistralrs-core/src/xlora_models/gemma2.rs:335-361 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/gemma2.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 498 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma.rs:326` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (27 lines × 2) mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:531 — mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:531-557 | mistralrs-core/src/vision_models/qwen2vl/text.rs:533-559 — `mistralrs-core/src/vision_models/qwen2_5_vl/text.rs` and `mistralrs-core/src/vision_models/qwen2vl/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 42 separate duplicated blocks between them, totalling at least 716 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:531` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (25 lines × 3) · ×4
  • Duplicated block (25 lines × 3) mistralrs-core/src/models/deepseek2.rs:295 — mistralrs-core/src/models/deepseek2.rs:295-319 | mistralrs-core/src/models/deepseek3.rs:296-320 | mistralrs-core/src/models/glm4_moe_lite.rs:256-280 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (25 lines × 3) REDACTED:301 — REDACTED:301-325 | mistralrs-core/src/vision_models/idefics3/vision.rs:113-137 | mistralrs-core/src/vision_models/siglip.rs:104-128 — before extracting anything, compare `REDACTED` and `mistralrs-core/src/vision_models/idefics3/vision.rs` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 221 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit. Note first that the copies are not typed on the same thing: the declarations holding them bind `config` to `&VisionConfig` in one and `&Idefics3VisionConfig` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (25 lines × 3) mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:334 — mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:334-358 | mistralrs-core/src/vision_models/qwen2vl/text.rs:335-359 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:316-340 — `mistralrs-core/src/vision_models/qwen2_5_vl/text.rs` and `mistralrs-core/src/vision_models/qwen2vl/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 42 separate duplicated blocks between them, totalling at least 716 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:334` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:333` calls `set_device`, `pp` and `mistralrs-core/src/vision_models/qwen3_vl/text.rs:315` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (25 lines × 3) examples/python/shell_skills.py:18 — examples/python/shell_skills.py:18-42 | REDACTED:25-52 | examples/server/skills.py:29-53 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:25` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (20–21 lines × 2) · ×4
  • Duplicated block (20–21 lines × 2) mistralrs-core/src/models/glm4_moe.rs:429 — mistralrs-core/src/models/glm4_moe.rs:429-448 | mistralrs-core/src/models/glm4_moe_lite.rs:525-545 — before extracting anything, compare `mistralrs-core/src/models/glm4_moe.rs` and `mistralrs-core/src/models/glm4_moe_lite.rs` as WHOLE FILES: this scan already matched 44 separate duplicated blocks between them, totalling at least 596 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit. Note first that the copies are not typed on the same thing: the declarations holding them bind `cfg` to `&Glm4MoeConfig` in one and `&Glm4MoeLiteConfig` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (20–21 lines × 2) mistralrs-core/src/paged_attention/block_hash.rs:243 — mistralrs-core/src/paged_attention/block_hash.rs:243-263 | mistralrs-core/src/paged_attention/block_hash.rs:288-307 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/paged_attention/block_hash.rs:243` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (20–21 lines × 2) mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:396 — mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:396-415 | mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:530-550 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:396` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (20–21 lines × 2) mistralrs-quant/src/blockwise_fp8/ops.rs:588 — mistralrs-quant/src/blockwise_fp8/ops.rs:588-607 | mistralrs-quant/src/blockwise_fp8/ops.rs:735-755 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/blockwise_fp8/ops.rs:588` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (20 lines × 4) · ×4
  • Duplicated block (20 lines × 4) mistralrs-cli/src/ui/handlers/api.rs:186 — mistralrs-cli/src/ui/handlers/api.rs:186-205 | mistralrs-cli/src/ui/handlers/api.rs:238-257 | mistralrs-cli/src/ui/handlers/api.rs:290-309 | mistralrs-cli/src/ui/handlers/api.rs:342-361 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-cli/src/ui/handlers/api.rs:186` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (20 lines × 4) mistralrs-core/src/models/deepseek2.rs:719 — mistralrs-core/src/models/deepseek2.rs:719-738 | mistralrs-core/src/models/deepseek3.rs:782-801 | mistralrs-core/src/models/glm4_moe.rs:619-638 | mistralrs-core/src/models/glm4_moe_lite.rs:728-747 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (20 lines × 4) mistralrs-core/src/models/gemma.rs:391 — mistralrs-core/src/models/gemma.rs:391-410 | mistralrs-core/src/models/gemma2.rs:464-483 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:436-455 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:556-575 — before extracting anything, compare `mistralrs-core/src/models/gemma.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 707 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma.rs:391` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:576` calls `clone` and `mistralrs-core/src/models/gemma.rs:411` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (20 lines × 4) mistralrs-core/src/models/phi2.rs:710 — mistralrs-core/src/models/phi2.rs:710-729 | mistralrs-core/src/models/phi3.rs:705-724 | mistralrs-core/src/models/starcoder2.rs:701-720 | mistralrs-core/src/vision_models/phi3/mod.rs:1540-1559 — before extracting anything, compare `mistralrs-core/src/models/phi2.rs` and `mistralrs-core/src/models/phi3.rs` as WHOLE FILES: this scan already matched 22 separate duplicated blocks between them, totalling at least 237 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/phi2.rs:710` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (19–20 lines × 2) · ×4
  • Duplicated block (19–20 lines × 2) mistralrs-core/src/cuda/gdn.rs:4255 — mistralrs-core/src/cuda/gdn.rs:4255-4273 | mistralrs-core/src/cuda/gdn.rs:4715-4734 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/gdn.rs:4715` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (19–20 lines × 2) mistralrs-core/src/models/phi3.rs:499 — mistralrs-core/src/models/phi3.rs:499-517 | mistralrs-core/src/vision_models/phi3/mod.rs:1280-1299 — before extracting anything, compare `mistralrs-core/src/models/phi3.rs` and `mistralrs-core/src/vision_models/phi3/mod.rs` as WHOLE FILES: this scan already matched 50 separate duplicated blocks between them, totalling at least 638 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/phi3.rs:499` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (19–20 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:1549 — mistralrs-core/src/pipeline/multimodal.rs:1549-1568 | mistralrs-core/src/pipeline/normal.rs:245-263 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:1549` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (19–20 lines × 2) mistralrs-quant/src/cutile/fp8_w8a16.rs:653 — mistralrs-quant/src/cutile/fp8_w8a16.rs:653-671 | mistralrs-quant/src/cutile/fp8_w8a8.rs:744-763 — before extracting anything, compare `mistralrs-quant/src/cutile/fp8_w8a16.rs` and `mistralrs-quant/src/cutile/fp8_w8a8.rs` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 212 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cutile/fp8_w8a16.rs:653` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (16 lines × 5) · ×4
  • Duplicated block (16 lines × 5) mistralrs-core/src/models/gemma.rs:143 — mistralrs-core/src/models/gemma.rs:143-158 | mistralrs-core/src/models/glm4_moe.rs:248-263 | mistralrs-core/src/models/hunyuan_v1_dense.rs:167-182 | mistralrs-core/src/models/hunyuan_v1_moe.rs:350-365 | mistralrs-core/src/models/lfm2.rs:457-472 — before extracting anything, compare `mistralrs-core/src/models/gemma.rs` and `mistralrs-core/src/models/glm4_moe.rs` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 228 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma.rs:143` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 5) mistralrs-core/src/models/gemma.rs:348 — mistralrs-core/src/models/gemma.rs:348-363 | mistralrs-core/src/models/gemma2.rs:421-436 | mistralrs-core/src/models/phi2.rs:432-447 | mistralrs-core/src/models/phi3_5_moe.rs:481-496 | mistralrs-core/src/models/starcoder2.rs:406-421 — before extracting anything, compare `mistralrs-core/src/models/gemma.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 707 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma.rs:348` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/models/starcoder2.rs:422` calls `pp` and `mistralrs-core/src/models/gemma.rs:364` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (16 lines × 5) mistralrs-core/src/models/qwen2.rs:215 — mistralrs-core/src/models/qwen2.rs:215-230 | mistralrs-core/src/models/qwen3.rs:168-183 | mistralrs-core/src/models/qwen3_moe.rs:171-186 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:172-187 | mistralrs-core/src/vision_models/qwen2vl/text.rs:173-188 — before extracting anything, compare `mistralrs-core/src/models/qwen2.rs` and `mistralrs-core/src/models/qwen3.rs` as WHOLE FILES: this scan already matched 44 separate duplicated blocks between them, totalling at least 576 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/qwen2.rs:215` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 5) mistralrs/src/model_builder_trait.rs:544 — mistralrs/src/model_builder_trait.rs:544-559 | mistralrs/src/model_builder_trait.rs:621-636 | mistralrs/src/model_builder_trait.rs:771-786 | mistralrs/src/model_builder_trait.rs:1094-1109 | mistralrs/src/model_builder_trait.rs:1548-1563 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs/src/model_builder_trait.rs:544` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs/src/model_builder_trait.rs:543` calls `clone` and `mistralrs/src/model_builder_trait.rs:620` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (14–16 lines × 2) · ×4
  • Duplicated block (14–16 lines × 2) mistralrs-core/src/ops.rs:2028 — mistralrs-core/src/ops.rs:2028-2041 | mistralrs-core/src/ops.rs:2159-2174 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:2159` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14–16 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9776 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9776-9791 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:10935-10948 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9776` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (14–16 lines × 2) mistralrs-core/src/pipeline/mod.rs:2434 — mistralrs-core/src/pipeline/mod.rs:2434-2449 | mistralrs-core/src/pipeline/mod.rs:3100-3113 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/mod.rs:2434` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (14–16 lines × 2) mistralrs-quant/src/blockwise_fp8/deepgemm.rs:207 — mistralrs-quant/src/blockwise_fp8/deepgemm.rs:207-222 | mistralrs-quant/src/blockwise_fp8/ops.rs:1369-1382 — before extracting anything, compare `mistralrs-quant/src/blockwise_fp8/deepgemm.rs` and `mistralrs-quant/src/blockwise_fp8/ops.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 65 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (13–15 lines × 2) · ×4
  • Duplicated block (13–15 lines × 2) mistralrs-core/src/models/deepseek2.rs:1007 — mistralrs-core/src/models/deepseek2.rs:1007-1019 | mistralrs-core/src/models/deepseek3.rs:1069-1083 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:1007` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13–15 lines × 2) mistralrs-core/src/vision_models/gemma3n/audio.rs:545 — mistralrs-core/src/vision_models/gemma3n/audio.rs:545-559 | mistralrs-core/src/vision_models/gemma4/audio.rs:612-624 — `mistralrs-core/src/vision_models/gemma3n/audio.rs` and `mistralrs-core/src/vision_models/gemma4/audio.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 20 separate duplicated blocks between them, totalling at least 352 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (13–15 lines × 2) mistralrs-paged-attn/src/metal/backend/gather_kv.rs:93 — mistralrs-paged-attn/src/metal/backend/gather_kv.rs:93-105 | mistralrs-paged-attn/src/metal/backend/paged_attention.rs:803-817 — before extracting anything, compare `mistralrs-paged-attn/src/metal/backend/gather_kv.rs` and `mistralrs-paged-attn/src/metal/backend/paged_attention.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 32 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/metal/backend/gather_kv.rs:93` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13–15 lines × 2) mistralrs-quant/src/cutile/fused_moe.rs:535 — mistralrs-quant/src/cutile/fused_moe.rs:535-549 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:979-991 — before extracting anything, compare `mistralrs-quant/src/cutile/fused_moe.rs` and `mistralrs-quant/src/cutile/fused_moe_fp8.rs` as WHOLE FILES: this scan already matched 24 separate duplicated blocks between them, totalling at least 298 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cutile/fused_moe.rs:535` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (14–15 lines × 2) · ×4
  • Duplicated block (14–15 lines × 2) mistralrs-core/src/models/gemma2.rs:380 — mistralrs-core/src/models/gemma2.rs:380-393 | mistralrs-core/src/vision_models/gemma3/text.rs:390-404 — before extracting anything, compare `mistralrs-core/src/models/gemma2.rs` and `mistralrs-core/src/vision_models/gemma3/text.rs` as WHOLE FILES: this scan already matched 34 separate duplicated blocks between them, totalling at least 411 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma2.rs:380` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14–15 lines × 2) mistralrs-core/src/models/mixtral.rs:286 — mistralrs-core/src/models/mixtral.rs:286-299 | mistralrs-core/src/xlora_models/mixtral.rs:363-377 — `mistralrs-core/src/models/mixtral.rs` and `mistralrs-core/src/xlora_models/mixtral.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 12 separate duplicated blocks between them, totalling at least 134 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/mixtral.rs:363` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14–15 lines × 2) mistralrs-core/src/models/phi2.rs:259 — mistralrs-core/src/models/phi2.rs:259-272 | mistralrs-core/src/xlora_models/phi2.rs:236-250 — `mistralrs-core/src/models/phi2.rs` and `mistralrs-core/src/xlora_models/phi2.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 7 separate duplicated blocks between them, totalling at least 85 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/phi2.rs:259` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14–15 lines × 2) mistralrs-quant/src/blockwise_fp8/ops.rs:1057 — mistralrs-quant/src/blockwise_fp8/ops.rs:1057-1071 | mistralrs-quant/src/blockwise_fp8/ops.rs:1236-1249 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/blockwise_fp8/ops.rs:1057` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-quant/src/blockwise_fp8/ops.rs:1250` calls `layout` and `mistralrs-quant/src/blockwise_fp8/ops.rs:1073` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (14 lines × 5) · ×4
  • Duplicated block (14 lines × 5) mistralrs-core/src/embedding_models/qwen3_embedding.rs:366 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:366-379 | mistralrs-core/src/models/glm4.rs:480-493 | mistralrs-core/src/models/hunyuan_v1_dense.rs:445-458 | mistralrs-core/src/models/hunyuan_v1_moe.rs:939-952 | mistralrs-core/src/models/qwen3.rs:439-452 — before extracting anything, compare `mistralrs-core/src/embedding_models/qwen3_embedding.rs` and `mistralrs-core/src/models/glm4.rs` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 137 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/qwen3_embedding.rs:366` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 5) mistralrs-core/src/models/deepseek2.rs:886 — mistralrs-core/src/models/deepseek2.rs:886-899 | mistralrs-core/src/models/deepseek3.rs:949-962 | mistralrs-core/src/models/glm4_moe.rs:785-798 | mistralrs-core/src/models/glm4_moe_lite.rs:896-909 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:565-578 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:886` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 5) mistralrs-core/src/xlora_models/gemma.rs:491 — mistralrs-core/src/xlora_models/gemma.rs:491-504 | mistralrs-core/src/xlora_models/gemma2.rs:521-534 | mistralrs-core/src/xlora_models/mistral.rs:487-500 | mistralrs-core/src/xlora_models/mixtral.rs:618-631 | mistralrs-core/src/xlora_models/starcoder2.rs:475-488 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/gemma2.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 498 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma.rs:491` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/xlora_models/starcoder2.rs:490` calls `get_mut`, `unwrap`, `merge_weights` and `mistralrs-core/src/xlora_models/gemma.rs:506` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14 lines × 5) mistralrs-core/src/xlora_models/gemma.rs:606 — mistralrs-core/src/xlora_models/gemma.rs:606-619 | mistralrs-core/src/xlora_models/mistral.rs:602-615 | mistralrs-core/src/xlora_models/mixtral.rs:732-745 | mistralrs-core/src/xlora_models/phi3.rs:555-568 | mistralrs-core/src/xlora_models/starcoder2.rs:587-600 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/mistral.rs` as WHOLE FILES: this scan already matched 37 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma.rs:606` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (11–13 lines × 2) · ×4
  • Duplicated block (11–13 lines × 2) mistralrs-core/src/models/flint.rs:776 — mistralrs-core/src/models/flint.rs:776-786 | mistralrs-core/src/models/qwen3_next.rs:730-742 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/qwen3_next.rs` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 229 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (11–13 lines × 2) mistralrs-core/src/pipeline/inputs_processor.rs:1014 — mistralrs-core/src/pipeline/inputs_processor.rs:1014-1026 | mistralrs-core/src/pipeline/inputs_processor.rs:1685-1695 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/inputs_processor.rs:1014` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (11–13 lines × 2) mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1138 — mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1138-1150 | mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1391-1401 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1138` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11–13 lines × 2) mistralrs-quant/src/distributed/layers.rs:728 — mistralrs-quant/src/distributed/layers.rs:728-740 | mistralrs-quant/src/distributed/layers.rs:1310-1320 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/distributed/layers.rs:728` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (12 lines × 6) · ×4
  • Duplicated block (12 lines × 6) mistralrs-core/src/embedding_models/qwen3_embedding.rs:101 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:101-112 | mistralrs-core/src/models/qwen3.rs:112-123 | mistralrs-core/src/models/qwen3_moe.rs:115-126 | mistralrs-core/src/vision_models/llama4/text.rs:338-349 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:113-124 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:219-230 — `mistralrs-core/src/embedding_models/qwen3_embedding.rs` and `mistralrs-core/src/models/qwen3.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 26 separate duplicated blocks between them, totalling at least 364 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/qwen3_embedding.rs:101` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (12 lines × 6) mistralrs-core/src/embedding_models/qwen3_embedding.rs:371 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:371-382 | mistralrs-core/src/models/glm4.rs:485-496 | mistralrs-core/src/models/hunyuan_v1_dense.rs:450-461 | mistralrs-core/src/models/hunyuan_v1_moe.rs:944-955 | mistralrs-core/src/models/qwen2.rs:476-487 | mistralrs-core/src/models/qwen3.rs:444-455 — before extracting anything, compare `mistralrs-core/src/embedding_models/qwen3_embedding.rs` and `mistralrs-core/src/models/glm4.rs` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 137 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/qwen3_embedding.rs:371` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (12 lines × 6) mistralrs-core/src/models/gemma.rs:391 — mistralrs-core/src/models/gemma.rs:391-402 | mistralrs-core/src/models/gemma2.rs:464-475 | mistralrs-core/src/vision_models/gemma3/text.rs:503-514 | mistralrs-core/src/vision_models/gemma3n/text.rs:1443-1454 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:436-447 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:556-567 — before extracting anything, compare `mistralrs-core/src/models/gemma.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 707 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma.rs:391` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 6) mistralrs-core/src/vision_models/grid_processor.rs:1007 — mistralrs-core/src/vision_models/grid_processor.rs:1007-1018 | mistralrs-core/src/vision_models/grid_processor.rs:1316-1327 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:230-241 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:520-531 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:796-807 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1128-1139 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:1007` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (9 lines × 10) · ×4
  • Duplicated block (9 lines × 10) mistralrs-core/src/layers.rs:1192 — mistralrs-core/src/layers.rs:1192-1200 | mistralrs-core/src/layers.rs:1215-1223 | mistralrs-core/src/layers.rs:1282-1290 | mistralrs-core/src/layers.rs:1305-1313 | mistralrs-core/src/layers.rs:1382-1390 | mistralrs-core/src/layers.rs:1551-1559 | mistralrs-core/src/layers.rs:1574-1582 | mistralrs-core/src/layers.rs:2379-2387 | mistralrs-core/src/layers.rs:2477-2485 | mistralrs-core/src/layers.rs:2524-2532 — all 10 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/layers.rs:1192` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 10) mistralrs-core/src/models/deepseek2.rs:959 — mistralrs-core/src/models/deepseek2.rs:959-968 | mistralrs-core/src/models/deepseek3.rs:1022-1031 | mistralrs-core/src/models/gemma.rs:472-481 | mistralrs-core/src/models/glm4_moe.rs:838-846 | mistralrs-core/src/models/glm4_moe_lite.rs:975-983 | mistralrs-core/src/models/granite.rs:2252-2261 | mistralrs-core/src/models/llama.rs:498-507 | mistralrs-core/src/models/phi2.rs:551-560 | mistralrs-core/src/models/smollm3.rs:517-526 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:539-548 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:959` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note first that the copies are not typed on the same thing: the declarations holding them bind `ctx` to `&mut ModelForwardContext<'_>` in one and `&mut crate::pipeline::ModelForwardContext<'_>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (9 lines × 10) mistralrs-core/src/models/flint.rs:742 — mistralrs-core/src/models/flint.rs:742-750 | mistralrs-core/src/models/gemma.rs:314-322 | mistralrs-core/src/models/hunyuan_v1_dense.rs:341-349 | mistralrs-core/src/models/hunyuan_v1_moe.rs:831-839 | mistralrs-core/src/models/mistral.rs:362-370 | mistralrs-core/src/models/phi3.rs:375-383 | mistralrs-core/src/models/qwen3.rs:350-358 | mistralrs-core/src/models/qwen3_moe.rs:524-532 | mistralrs-core/src/vision_models/phi3/mod.rs:466-474 | mistralrs-core/src/vision_models/phi4/mod.rs:296-304 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/gemma.rs` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 152 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/flint.rs:742` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 10) mistralrs-paged-attn/src/cuda/backend/fa3.rs:460 — mistralrs-paged-attn/src/cuda/backend/fa3.rs:460-468 | mistralrs-quant/src/cutile/fp8_gemm.rs:356-364 | mistralrs-quant/src/cutile/fp8_w8a8.rs:540-548 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:923-931 | mistralrs-quant/src/cutile/mxfp8_gemm.rs:541-549 | mistralrs-quant/src/cutile/nvfp4_gemv.rs:325-333 | mistralrs-quant/src/cutile/nvfp4_matmul.rs:652-660 | mistralrs-quant/src/cutile/nvfp4_matmul.rs:1154-1162 | mistralrs-quant/src/nvfp4/decode.rs:126-134 | mistralrs-quant/src/nvfp4/portable.rs:315-323 — before extracting anything, compare `mistralrs-paged-attn/src/cuda/backend/fa3.rs` and `mistralrs-quant/src/cutile/nvfp4_gemv.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 31 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/cuda/backend/fa3.rs:460` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (5 lines × 8) · ×4
  • Duplicated block (5 lines × 8) mistralrs-core/src/models/flint.rs:597 — mistralrs-core/src/models/flint.rs:597-601 | mistralrs-core/src/models/gpt_oss.rs:517-521 | mistralrs-core/src/models/lfm2.rs:330-334 | mistralrs-core/src/models/phi3_5_moe.rs:366-370 | mistralrs-core/src/models/qwen3_moe.rs:403-407 | mistralrs-core/src/models/qwen3_next.rs:474-478 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:378-382 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:142-146 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/gpt_oss.rs` as WHOLE FILES: this scan already matched 24 separate duplicated blocks between them, totalling at least 268 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (5 lines × 8) mistralrs-core/src/ops.rs:1124 — mistralrs-core/src/ops.rs:1124-1128 | mistralrs-core/src/ops.rs:1353-1357 | mistralrs-core/src/ops.rs:1598-1602 | mistralrs-core/src/ops.rs:1840-1844 | mistralrs-core/src/ops.rs:2047-2051 | mistralrs-core/src/ops.rs:2180-2184 | mistralrs-core/src/ops.rs:3920-3924 | mistralrs-core/src/ops.rs:4047-4051 — all 8 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:1124` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 8) mistralrs-core/src/vision_models/qwen3_5/mod.rs:215 — mistralrs-core/src/vision_models/qwen3_5/mod.rs:215-220 | mistralrs-core/src/vision_models/qwen3_5/mod.rs:277-281 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:198-203 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:260-264 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:726-731 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:802-806 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:172-177 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:248-252 — `mistralrs-core/src/vision_models/qwen3_5/mod.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 24 separate duplicated blocks between them, totalling at least 425 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_5/mod.rs:215` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 8) mistralrs-paged-attn/src/cuda/backend/fa3.rs:187 — mistralrs-paged-attn/src/cuda/backend/fa3.rs:187-192 | mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:316-321 | mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:608-613 | mistralrs-paged-attn/src/cuda/backend/mla.rs:34-39 | mistralrs-paged-attn/src/cuda/backend/mla.rs:321-326 | mistralrs-paged-attn/src/cuda/backend/mla.rs:684-689 | mistralrs-quant/src/blockwise_fp8/mma.rs:189-194 | mistralrs-quant/src/rotary/mod.rs:697-701 — before extracting anything, compare `mistralrs-paged-attn/src/cuda/backend/flashinfer.rs` and `mistralrs-paged-attn/src/cuda/backend/mla.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 50 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/cuda/backend/fa3.rs:187` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (5 lines × 6) · ×4
  • Duplicated block (5 lines × 6) mistralrs-core/src/embedding_models/qwen3_embedding.rs:452 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:452-457 | mistralrs-core/src/xlora_models/mistral.rs:595-599 | mistralrs-core/src/xlora_models/mixtral.rs:725-729 | mistralrs-core/src/xlora_models/phi2.rs:565-569 | mistralrs-core/src/xlora_models/phi3.rs:546-551 | mistralrs-core/src/xlora_models/starcoder2.rs:579-584 — before extracting anything, compare `mistralrs-core/src/embedding_models/qwen3_embedding.rs` and `mistralrs-core/src/xlora_models/mistral.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 81 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/qwen3_embedding.rs:452` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 6) mistralrs-quant/src/distributed/mod.rs:562 — mistralrs-quant/src/distributed/mod.rs:562-566 | mistralrs-quant/src/distributed/mod.rs:593-597 | mistralrs-quant/src/distributed/mod.rs:624-628 | mistralrs-quant/src/distributed/mod.rs:711-715 | mistralrs-quant/src/distributed/mod.rs:742-746 | mistralrs-quant/src/distributed/mod.rs:773-777 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/distributed/mod.rs:562` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 6) mistralrs-quant/src/utils/ops.rs:2027 — mistralrs-quant/src/utils/ops.rs:2027-2032 | mistralrs-quant/src/utils/ops.rs:2056-2061 | mistralrs-quant/src/utils/ops.rs:2085-2090 | mistralrs-quant/src/utils/ops.rs:2831-2835 | mistralrs-quant/src/utils/ops.rs:2858-2862 | mistralrs-quant/src/utils/ops.rs:2885-2889 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/utils/ops.rs:2027` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 6) mistralrs-core/src/ops.rs:1177 — mistralrs-core/src/ops.rs:1177-1182 | mistralrs-core/src/ops.rs:1197-1202 | mistralrs-core/src/ops.rs:1207-1212 | mistralrs-core/src/ops.rs:1217-1221 | mistralrs-core/src/ops.rs:1395-1400 | mistralrs-core/src/ops.rs:1415-1419 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:1177` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/ops.rs:1221` calls `device_ptr`, `add`, `start_offset` and `mistralrs-core/src/ops.rs:1182` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D1 · Cyclomatic Complexity · TextModel · ×3
  • TextModel::forward_embeds_scaled (cyclomatic 39) mistralrs-core/src/vision_models/gemma4/text.rs:2107 — TextModel::forward_embeds_scaled has cyclomatic complexity 39 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • TextModel::forward_embeds (cyclomatic 22) mistralrs-core/src/vision_models/gemma3/text.rs:599 — TextModel::forward_embeds has cyclomatic complexity 22 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
  • TextModel::new (cyclomatic 17) mistralrs-core/src/vision_models/gemma4/text.rs:1618 — TextModel::new has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · Nvfp4Layer · ×3
  • Nvfp4Layer::from_normalized_parts (cyclomatic 34) mistralrs-quant/src/nvfp4/mod.rs:201 — Nvfp4Layer::from_normalized_parts has cyclomatic complexity 34 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • Nvfp4Layer::load_shape (cyclomatic 24) mistralrs-quant/src/nvfp4/mod.rs:387 — Nvfp4Layer::load_shape has cyclomatic complexity 24 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • Nvfp4Layer::gather_forward_raw (cyclomatic 21) mistralrs-quant/src/nvfp4/mod.rs:985 — Nvfp4Layer::gather_forward_raw has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · TextConfig · ×3
  • TextConfig::validate (cyclomatic 26) mistralrs-core/src/vision_models/qwen3_5_moe/config.rs:71 — TextConfig::validate has cyclomatic complexity 26 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • TextConfig::validate (cyclomatic 24) mistralrs-core/src/vision_models/qwen3_5/config.rs:266 — TextConfig::validate has cyclomatic complexity 24 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • TextConfig::validate (cyclomatic 21) mistralrs-core/src/vision_models/qwen4_exp/config.rs:194 — TextConfig::validate has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · ImageEmbedding · ×3
  • ImageEmbedding::forward (cognitive 136) mistralrs-core/src/vision_models/phi3/mod.rs:697 — ImageEmbedding::forward has cognitive complexity 136 (threshold 15). Drivers by points: if/else 37 (96 pts), loops 8 (26 pts), match/switch 4 (8 pts), boolean chains 6 (nesting depth added 81). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • ImageEmbedding::forward (cognitive 74) mistralrs-core/src/vision_models/phi4/image_embedding.rs:465 — ImageEmbedding::forward has cognitive complexity 74 (threshold 15). Drivers by points: if/else 16 (44 pts), loops 3 (15 pts), match/switch 3 (13 pts), boolean chains 2 (nesting depth added 50). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • ImageEmbedding::new (cognitive 17) mistralrs-core/src/vision_models/phi4/image_embedding.rs:124 — ImageEmbedding::new has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (14 pts), match/switch 3 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GridImageProcessor · ×3
  • GridImageProcessor::process_inputs (cognitive 129) mistralrs-core/src/vision_models/grid_processor.rs:1139 — GridImageProcessor::process_inputs has cognitive complexity 129 (threshold 15). Drivers by points: if/else 53 (102 pts), loops 8 (17 pts), boolean chains 9, match/switch 1 (nesting depth added 58). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • GridImageProcessor::prepare_for_paged_prompt_planning (cognitive 61) mistralrs-core/src/vision_models/grid_processor.rs:884 — GridImageProcessor::prepare_for_paged_prompt_planning has cognitive complexity 61 (threshold 15). Drivers by points: if/else 26 (51 pts), loops 6 (8 pts), boolean chains 2 (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • GridImageProcessor::preprocess_inner (cognitive 18) mistralrs-core/src/vision_models/grid_processor.rs:1926 — GridImageProcessor::preprocess_inner has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (11 pts), loops 2 (3 pts), match/switch 1 (3 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · PagedAttentionScheduler · ×3
  • PagedAttentionScheduler::schedule (cognitive 113) mistralrs-core/src/paged_attention/scheduler.rs:930 — PagedAttentionScheduler::schedule has cognitive complexity 113 (threshold 15). Drivers by points: if/else 41 (88 pts), loops 7 (12 pts), boolean chains 8, match/switch 2 (5 pts) (nesting depth added 55). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • PagedAttentionScheduler::select_prompt_batch (cognitive 28) mistralrs-core/src/paged_attention/scheduler.rs:327 — PagedAttentionScheduler::select_prompt_batch has cognitive complexity 28 (threshold 15). Drivers by points: if/else 12 (15 pts), boolean chains 12, loops 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • PagedAttentionScheduler::bucket_and_preempt_sequences (cognitive 18) mistralrs-core/src/paged_attention/scheduler.rs:786 — PagedAttentionScheduler::bucket_and_preempt_sequences has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (11 pts), loops 3, boolean chains 2, match/switch 1 (2 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Idefics3ImageProcessor · ×3
  • Idefics3ImageProcessor::process_inputs (cognitive 64) mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:422 — Idefics3ImageProcessor::process_inputs has cognitive complexity 64 (threshold 15). Drivers by points: if/else 31 (57 pts), loops 2 (6 pts), boolean chains 1 (nesting depth added 30). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Idefics3ImageProcessor::preprocess (cognitive 20) mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:890 — Idefics3ImageProcessor::preprocess has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (13 pts), loops 5 (7 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Idefics3ImageProcessor::planned_image_grids (cognitive 17) mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:274 — Idefics3ImageProcessor::planned_image_grids has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (12 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AudioProcessor · ×3
  • AudioProcessor::extract_spectrogram (cognitive 32) mistralrs-core/src/vision_models/gemma4/audio_processing.rs:237 — AudioProcessor::extract_spectrogram has cognitive complexity 32 (threshold 15). Drivers by points: if/else 8 (18 pts), loops 5 (14 pts) (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • AudioProcessor::normalize_mel_spectrogram (cognitive 21) mistralrs-core/src/vision_models/gemma3n/audio_processing.rs:313 — AudioProcessor::normalize_mel_spectrogram has cognitive complexity 21 (threshold 15). Drivers by points: if/else 4 (10 pts), loops 4 (10 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • AudioProcessor::create_mel_filterbank (cognitive 18) mistralrs-core/src/vision_models/gemma3n/audio_processing.rs:258 — AudioProcessor::create_mel_filterbank has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (12 pts), loops 3 (4 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · NormalCacheManager · ×3
  • NormalCacheManager::set_none_cache (cognitive 27) mistralrs-core/src/kv_cache/mod.rs:731 — NormalCacheManager::set_none_cache has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (17 pts), loops 4 (6 pts), match/switch 2 (4 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • NormalCacheManager::clone_in_cache (cognitive 25) mistralrs-core/src/kv_cache/mod.rs:486 — NormalCacheManager::clone_in_cache has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (16 pts), match/switch 3 (5 pts), loops 3 (4 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • NormalCacheManager::clone_out_cache (cognitive 24) mistralrs-core/src/kv_cache/mod.rs:634 — NormalCacheManager::clone_out_cache has cognitive complexity 24 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 3 (6 pts), match/switch 2 (5 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TextConfig · ×3
  • TextConfig::validate (cognitive 26) mistralrs-core/src/vision_models/qwen3_5_moe/config.rs:71 — TextConfig::validate has cognitive complexity 26 (threshold 15). Drivers by points: if/else 15 (16 pts), boolean chains 10 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • TextConfig::validate (cognitive 24) mistralrs-core/src/vision_models/qwen3_5/config.rs:266 — TextConfig::validate has cognitive complexity 24 (threshold 15). Drivers by points: if/else 14 (15 pts), boolean chains 9 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • TextConfig::validate (cognitive 22) mistralrs-core/src/vision_models/qwen4_exp/config.rs:194 — TextConfig::validate has cognitive complexity 22 (threshold 15). Drivers by points: if/else 13 (15 pts), boolean chains 7 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · NormalPipeline · ×3
  • NormalPipeline::try_cuda_decode_graph_forward (cognitive 23) mistralrs-core/src/pipeline/normal.rs:1886 — NormalPipeline::try_cuda_decode_graph_forward has cognitive complexity 23 (threshold 15). Drivers by points: if/else 19 (20 pts), boolean chains 3 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • NormalPipeline::forward_step (cognitive 19) mistralrs-core/src/pipeline/normal.rs:2540 — NormalPipeline::forward_step has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (13 pts), match/switch 3 (5 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • NormalPipeline::precapture_cuda_decode_graphs_impl (cognitive 18) mistralrs-core/src/pipeline/normal.rs:2088 — NormalPipeline::precapture_cuda_decode_graphs_impl has cognitive complexity 18 (threshold 15). Drivers by points: if/else 11 (16 pts), boolean chains 1, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D30 · Dependency Vulnerabilities · Medium advisory (unsound) · ×3
  • REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Near-duplicate member family (5 members, 31 shared lines) · ×3
  • Near-duplicate member family (5 members, 31 shared lines) mistralrs-core/src/models/gemma.rs:346 — mistralrs-core/src/models/gemma.rs:346-456 | mistralrs-core/src/models/gemma2.rs:419-532 | mistralrs-core/src/models/phi2.rs:430-540 | mistralrs-core/src/models/phi3_5_moe.rs:479-605 | mistralrs-core/src/models/starcoder2.rs:404-521 — These 5 members are variants of one another: a block of 31 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Near-duplicate member family (5 members, 31 shared lines) mistralrs-core/src/models/gemma.rs:346 — mistralrs-core/src/models/gemma.rs:346-456 | mistralrs-core/src/models/gemma2.rs:419-532 | mistralrs-core/src/models/glm4.rs:439-564 | mistralrs-core/src/models/mixtral.rs:405-520 | mistralrs-core/src/models/qwen3.rs:402-523 — These 5 members are variants of one another: a block of 31 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Near-duplicate member family (5 members, 31 shared lines) mistralrs-core/src/models/glm4.rs:439 — mistralrs-core/src/models/glm4.rs:439-564 | mistralrs-core/src/models/mixtral.rs:405-520 | mistralrs-core/src/models/qwen2.rs:432-549 | mistralrs-core/src/models/qwen3.rs:402-523 | mistralrs-core/src/models/qwen3_moe.rs:576-703 — These 5 members are variants of one another: a block of 31 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D4 · Code Duplication · Near-duplicate member family (5 members, 28 shared lines) · ×3
  • Near-duplicate member family (5 members, 28 shared lines) mistralrs-core/src/embedding_models/qwen3_embedding.rs:328 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:328-421 | mistralrs-core/src/models/glm4.rs:439-564 | mistralrs-core/src/models/hunyuan_v1_dense.rs:392-522 | mistralrs-core/src/models/hunyuan_v1_moe.rs:882-1016 | mistralrs-core/src/models/qwen3.rs:402-523 — These 5 members are variants of one another: a block of 28 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Near-duplicate member family (5 members, 28 shared lines) mistralrs-core/src/models/gemma.rs:346 — mistralrs-core/src/models/gemma.rs:346-456 | mistralrs-core/src/models/gemma2.rs:419-532 | mistralrs-core/src/models/mixtral.rs:405-520 | mistralrs-core/src/models/qwen2.rs:432-549 | mistralrs-core/src/models/starcoder2.rs:404-521 — These 5 members are variants of one another: a block of 28 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Near-duplicate member family (5 members, 28 shared lines) mistralrs-core/src/models/mixtral.rs:405 — mistralrs-core/src/models/mixtral.rs:405-520 | mistralrs-core/src/models/phi3.rs:407-532 | mistralrs-core/src/models/qwen2.rs:432-549 | mistralrs-core/src/vision_models/phi3/mod.rs:1209-1317 | mistralrs-core/src/vision_models/phi4/mod.rs:330-438 — These 5 members are variants of one another: a block of 28 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D4 · Code Duplication · Near-duplicate member pair (32 shared lines) · ×3
  • Near-duplicate member pair (32 shared lines) mistralrs-quant/src/distributed/mod.rs:550 — mistralrs-quant/src/distributed/mod.rs:550-659 | mistralrs-quant/src/distributed/mod.rs:696-808 — These two members are variants of one another: 32 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
  • Near-duplicate member pair (32 shared lines) mistralrs-core/src/models/qwen3_next.rs:628 — mistralrs-core/src/models/qwen3_next.rs:628-701 | mistralrs-core/src/vision_models/qwen3_5/packed_gdn.rs:122-176 — These two members are variants of one another: 32 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
  • Near-duplicate member pair (32 shared lines) mistralrs-quant/src/utils/ops.rs:2001 — mistralrs-quant/src/utils/ops.rs:2001-2111 | mistralrs-quant/src/utils/ops.rs:2798-2909 — These two members are variants of one another: 32 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Members sharing a duplicated core (7 members, 50+ identical tokens) · ×3
  • Members sharing a duplicated core (7 members, 50+ identical tokens) mistralrs-core/src/models/flint.rs:471 — mistralrs-core/src/models/flint.rs:471-505 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:219-252 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:42-76 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:46-79 | mistralrs-core/src/vision_models/qwen2vl/text.rs:47-80 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:34-67 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:40-74 — These 7 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 7 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 7 times.
  • Members sharing a duplicated core (7 members, 50+ identical tokens) mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:414 — mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:414-458 | mistralrs-core/src/vision_models/qwen2vl/mod.rs:570-614 | mistralrs-core/src/vision_models/qwen3_5/mod.rs:455-499 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:463-507 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:1025-1069 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:469-513 | mistralrs-core/src/vision_models/qwen4_exp/mod.rs:440-484 — These 7 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 7 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 7 times.
  • Members sharing a duplicated core (7 members, 50+ identical tokens) mistralrs-quant/src/cutile/fused_moe.rs:58 — mistralrs-quant/src/cutile/fused_moe.rs:58-414 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:73-448 | mistralrs-quant/src/cutile/gdn_prefill.rs:234-435 | mistralrs-quant/src/cutile/qsa.rs:49-258 | mistralrs-quant/src/cutile/qsa.rs:281-545 | mistralrs-quant/src/cutile/qsa_decode.rs:59-397 | mistralrs-quant/src/cutile/routed_lora.rs:99-489 — These 7 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 7 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 7 times.
D4 · Code Duplication · Members sharing a duplicated core (6 members, 50+ identical tokens) · ×3
  • Members sharing a duplicated core (6 members, 50+ identical tokens) mistralrs-core/src/pipeline/diffusion.rs:99 — mistralrs-core/src/pipeline/diffusion.rs:99-192 | mistralrs-core/src/pipeline/embedding.rs:218-747 | mistralrs-core/src/pipeline/gguf.rs:1236-1473 | mistralrs-core/src/pipeline/multimodal.rs:535-1720 | mistralrs-core/src/pipeline/normal.rs:668-1593 | mistralrs-core/src/pipeline/speech.rs:202-295 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Members sharing a duplicated core (6 members, 50+ identical tokens) mistralrs-quant/src/bitsandbytes/op.rs:417 — mistralrs-quant/src/bitsandbytes/op.rs:417-494 | mistralrs-quant/src/hqq/hqq_op.rs:68-106 | mistralrs-quant/src/hqq/hqq_op.rs:177-217 | mistralrs-quant/src/hqq/hqq_op.rs:290-330 | mistralrs-quant/src/hqq/hqq_op.rs:407-447 | mistralrs-quant/src/hqq/hqq_op.rs:526-566 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Members sharing a duplicated core (6 members, 50+ identical tokens) mistralrs/src/model_builder_trait.rs:530 — mistralrs/src/model_builder_trait.rs:530-603 | mistralrs/src/model_builder_trait.rs:608-682 | mistralrs/src/model_builder_trait.rs:734-880 | mistralrs/src/model_builder_trait.rs:886-1040 | mistralrs/src/model_builder_trait.rs:1046-1243 | mistralrs/src/model_builder_trait.rs:1478-1659 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
D4 · Code Duplication · Edited copy of a member (60 corresponding lines) · ×3
  • Edited copy of a member (60 corresponding lines) mistralrs-quant/src/lib.rs:2631 — mistralrs-quant/src/lib.rs:2631-2690 | mistralrs-quant/src/lib.rs:2697-2757 — These two members are one piece of code written twice and then edited apart: 60 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (60 corresponding lines) mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:645 — mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:645-704 | mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:663-734 — These two members are one piece of code written twice and then edited apart: 60 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (60 corresponding lines) mistralrs-quant/src/distributed/layers.rs:1082 — mistralrs-quant/src/distributed/layers.rs:1082-1141 | mistralrs-quant/src/distributed/layers.rs:1495-1557 — These two members are one piece of code written twice and then edited apart: 60 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (41 corresponding lines) · ×3
  • Edited copy of a member (41 corresponding lines) mistralrs-core/src/lora/mod.rs:156 — mistralrs-core/src/lora/mod.rs:156-196 | mistralrs-core/src/lora/mod.rs:208-248 — These two members are one piece of code written twice and then edited apart: 41 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (41 corresponding lines) mistralrs-core/src/vision_models/qwen3_5/speculative.rs:598 — mistralrs-core/src/vision_models/qwen3_5/speculative.rs:598-641 | mistralrs-core/src/vision_models/qwen4_exp/speculative.rs:102-142 — These two members are one piece of code written twice and then edited apart: 41 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (41 corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6894 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6894-6934 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3981-4021 — These two members are one piece of code written twice and then edited apart: 41 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (40 corresponding lines) · ×3
  • Edited copy of a member (40 corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7595 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7595-7634 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:8111-8156 — These two members are one piece of code written twice and then edited apart: 40 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (40 corresponding lines) mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:728 — mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:728-767 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3769-3808 — These two members are one piece of code written twice and then edited apart: 40 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (40 corresponding lines) mistralrs-quant/src/lora/dynamic/registry.rs:328 — mistralrs-quant/src/lora/dynamic/registry.rs:328-367 | mistralrs-quant/src/lora/dynamic/registry.rs:375-415 — These two members are one piece of code written twice and then edited apart: 40 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 30+ corresponding lines) · ×3
  • Edited copies of one member (3 members, 30+ corresponding lines) mistralrs-core/src/pipeline/embedding.rs:177 — mistralrs-core/src/pipeline/embedding.rs:177-206 | mistralrs-core/src/pipeline/multimodal.rs:487-523 | mistralrs-core/src/pipeline/normal.rs:621-656 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 30 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 30+ corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1135 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1135-1164 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3974-4003 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1944-1975 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 30 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 30+ corresponding lines) mistralrs-core/src/models/gpt_oss.rs:637 — mistralrs-core/src/models/gpt_oss.rs:637-672 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:328-357 | mistralrs-core/src/vision_models/mllama/text.rs:271-308 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 30 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 17+ corresponding lines) · ×3
  • Edited copies of one member (3 members, 17+ corresponding lines) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3261 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3261-3277 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3594-3610 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4821-4837 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 17 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 17+ corresponding lines) mistralrs-core/src/vision_models/grid_processor.rs:861 — mistralrs-core/src/vision_models/grid_processor.rs:861-877 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:36-52 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:584-600 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 17 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 17+ corresponding lines) mistralrs-core/src/ops.rs:3092 — mistralrs-core/src/ops.rs:3092-3108 | mistralrs-core/src/ops.rs:3114-3130 | mistralrs-core/src/ops.rs:3137-3153 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 17 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 13+ corresponding lines) · ×3
  • Edited copies of one member (3 members, 13+ corresponding lines) mistralrs-core/src/models/glm4.rs:379 — mistralrs-core/src/models/glm4.rs:379-395 | mistralrs-core/src/vision_models/gemma4/vision.rs:530-546 | mistralrs-core/src/vision_models/muse_glimmer/text.rs:398-410 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 13 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 13+ corresponding lines) mistralrs-core/src/sequence.rs:416 — mistralrs-core/src/sequence.rs:416-428 | mistralrs-core/src/sequence.rs:454-466 | mistralrs-core/src/sequence.rs:498-510 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 13 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 13+ corresponding lines) mistralrs-core/src/reasoning_parsers/harmony.rs:330 — mistralrs-core/src/reasoning_parsers/harmony.rs:330-342 | mistralrs-core/src/reasoning_parsers/tag_based.rs:329-341 | mistralrs-core/src/reasoning_parsers/tag_based.rs:346-358 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 13 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 12+ corresponding lines) · ×3
  • Edited copies of one member (3 members, 12+ corresponding lines) mistralrs-core/src/lib.rs:2486 — mistralrs-core/src/lib.rs:2486-2497 | mistralrs-core/src/lib.rs:2499-2511 | mistralrs-core/src/lib.rs:2513-2524 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 12 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 12+ corresponding lines) mistralrs-quant/src/utils/log.rs:12 — mistralrs-quant/src/utils/log.rs:12-23 | mistralrs-quant/src/utils/log.rs:25-36 | mistralrs-quant/src/utils/log.rs:38-49 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 12 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 12+ corresponding lines) REDACTED:1384 — REDACTED:1384-1399 | mistralrs-core/src/vision_models/llama4/mod.rs:275-287 | mistralrs-core/src/vision_models/mllama/mod.rs:402-413 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 12 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 8+ corresponding lines) · ×3
  • Edited copies of one member (3 members, 8+ corresponding lines) mistralrs-paged-attn/src/cuda/backend/flash_attn_sinks.rs:134 — mistralrs-paged-attn/src/cuda/backend/flash_attn_sinks.rs:134-141 | mistralrs-paged-attn/src/cuda/backend/flash_attn_sinks.rs:303-310 | mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:437-444 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 8 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 8+ corresponding lines) mistralrs-core/src/models/glm4_moe.rs:407 — mistralrs-core/src/models/glm4_moe.rs:407-414 | mistralrs-core/src/models/glm4_moe_lite.rs:500-507 | mistralrs-core/src/vision_models/gemma3n/text.rs:270-280 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 8 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 8+ corresponding lines) mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:157 — mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:157-164 | mistralrs-core/src/vision_models/qwen2vl/vision.rs:128-135 | mistralrs-core/src/vision_models/qwen3_vl/vision.rs:171-178 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 8 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 6+ corresponding lines) · ×3
  • Edited copies of one member (3 members, 6+ corresponding lines) mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:156 — mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:156-161 | mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:159-164 | mistralrs-core/src/vision_models/muse_glimmer/inputs_processor.rs:200-205 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 6 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 6+ corresponding lines) mistralrs-core/src/flashinfer/mod.rs:325 — mistralrs-core/src/flashinfer/mod.rs:325-330 | mistralrs-core/src/pipeline/loaders/activation_memory.rs:121-126 | mistralrs-core/src/pipeline/loaders/qwen_vision_memory.rs:29-34 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 6 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 6+ corresponding lines) mistralrs-core/src/pipeline/loaders/activation_memory.rs:114 — mistralrs-core/src/pipeline/loaders/activation_memory.rs:114-119 | mistralrs-core/src/pipeline/loaders/qwen_vision_memory.rs:22-27 | mistralrs-paged-attn/src/metal/backend/paged_prefill.rs:378-383 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 6 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copy of a member (3 corresponding lines) · ×3
  • Edited copy of a member (3 corresponding lines) mistralrs-core/src/ops.rs:2471 — mistralrs-core/src/ops.rs:2471-2473 | mistralrs-core/src/pipeline/cuda_graph.rs:1356-1358 — These two members are one piece of code written twice and then edited apart: 3 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (3 corresponding lines) REDACTED:78 — REDACTED:78-80 | examples/server/skills.py:74-76 — These two members are one piece of code written twice and then edited apart: 3 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (3 corresponding lines) examples/python/tool_call.py:36 — examples/python/tool_call.py:36-38 | examples/server/tool_calling.py:36-38 — These two members are one piece of code written twice and then edited apart: 3 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Duplicated block (54 lines × 2) · ×3
  • Duplicated block (54 lines × 2) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3008 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3008-3061 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3341-3394 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3008` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (54 lines × 2) REDACTED:1181 — REDACTED:1181-1234 | REDACTED:146-199 — `REDACTED` and `REDACTED` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 4 separate duplicated blocks between them, totalling at least 87 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (54 lines × 2) mistralrs-core/src/xlora_models/mistral.rs:151 — mistralrs-core/src/xlora_models/mistral.rs:151-204 | mistralrs-core/src/xlora_models/mixtral.rs:64-117 — before extracting anything, compare `mistralrs-core/src/xlora_models/mistral.rs` and `mistralrs-core/src/xlora_models/mixtral.rs` as WHOLE FILES: this scan already matched 53 separate duplicated blocks between them, totalling at least 787 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/mistral.rs:151` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (50 lines × 2) · ×3
  • Duplicated block (50 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:969 — mistralrs-core/src/pipeline/multimodal.rs:969-1018 | mistralrs-core/src/pipeline/normal.rs:972-1021 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:969` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (50 lines × 2) mistralrs-core/src/xlora_models/quantized_llama.rs:859 — mistralrs-core/src/xlora_models/quantized_llama.rs:859-908 | mistralrs-core/src/xlora_models/quantized_phi3.rs:524-573 — before extracting anything, compare `mistralrs-core/src/xlora_models/quantized_llama.rs` and `mistralrs-core/src/xlora_models/quantized_phi3.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 219 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/quantized_llama.rs:859` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (50 lines × 2) mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:1148 — mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:1148-1197 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1713-1762 — `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` and `mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 45 separate duplicated blocks between them, totalling at least 1082 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:1148` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (43–44 lines × 2) · ×3
  • Duplicated block (43–44 lines × 2) mistralrs-core/src/models/qwen3_next.rs:195 — mistralrs-core/src/models/qwen3_next.rs:195-238 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:100-142 — before extracting anything, compare `mistralrs-core/src/models/qwen3_next.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/text.rs` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 461 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (43–44 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:2996 — mistralrs-core/src/pipeline/multimodal.rs:2996-3038 | mistralrs-core/src/pipeline/normal.rs:2595-2638 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:2996` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (43–44 lines × 2) scripts/production_soak.py:13670 — scripts/production_soak.py:13670-13712 | scripts/production_soak.py:13828-13871 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `scripts/production_soak.py:13714` calls `ValueError` and `scripts/production_soak.py:13872` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (43 lines × 2) · ×3
  • Duplicated block (43 lines × 2) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4588 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4588-4630 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4905-4947 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4588` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (43 lines × 2) mistralrs-quant/src/metal_kernels/mod.rs:1795 — mistralrs-quant/src/metal_kernels/mod.rs:1795-1837 | mistralrs-quant/src/metal_kernels/mod.rs:1860-1902 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/metal_kernels/mod.rs:1795` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (43 lines × 2) mistralrs-core/src/vision_models/phi3/mod.rs:269 — mistralrs-core/src/vision_models/phi3/mod.rs:269-311 | mistralrs-core/src/vision_models/phi4/mod.rs:138-180 — `mistralrs-core/src/vision_models/phi3/mod.rs` and `mistralrs-core/src/vision_models/phi4/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 48 separate duplicated blocks between them, totalling at least 586 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/phi3/mod.rs:269` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (38 lines × 2) · ×3
  • Duplicated block (38 lines × 2) mistralrs-core/src/models/granite.rs:1464 — mistralrs-core/src/models/granite.rs:1464-1501 | mistralrs-core/src/models/granite.rs:1750-1787 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/granite.rs:1464` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (38 lines × 2) mistralrs-core/src/vision_models/gemma4/mod.rs:487 — mistralrs-core/src/vision_models/gemma4/mod.rs:487-524 | mistralrs-core/src/vision_models/gemma4/mod.rs:800-837 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma4/mod.rs:487` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (38 lines × 2) mistralrs-vision/src/pad.rs:32 — mistralrs-vision/src/pad.rs:32-69 | mistralrs-vision/src/pad.rs:72-109 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-vision/src/pad.rs:32` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (35 lines × 3) · ×3
  • Duplicated block (35 lines × 3) mistralrs-core/src/models/deepseek2.rs:394 — mistralrs-core/src/models/deepseek2.rs:394-428 | mistralrs-core/src/models/deepseek3.rs:395-429 | mistralrs-core/src/models/glm4_moe_lite.rs:359-393 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:394` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/models/deepseek2.rs:391` calls `seqlen_offsets`, `flash_params` and `mistralrs-core/src/models/glm4_moe_lite.rs:358` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (35 lines × 3) mistralrs-core/src/models/flint.rs:243 — mistralrs-core/src/models/flint.rs:243-277 | mistralrs-core/src/models/hunyuan_v1_dense.rs:113-147 | mistralrs-core/src/models/hunyuan_v1_moe.rs:290-324 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/hunyuan_v1_dense.rs` as WHOLE FILES: this scan already matched 34 separate duplicated blocks between them, totalling at least 419 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (35 lines × 3) mistralrs-core/src/vision_models/grid_processor.rs:1154 — mistralrs-core/src/vision_models/grid_processor.rs:1154-1188 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:367-401 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:933-967 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:1154` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (30–31 lines × 2) · ×3
  • Duplicated block (30–31 lines × 2) mistralrs-core/src/models/qwen3_next.rs:438 — mistralrs-core/src/models/qwen3_next.rs:438-468 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:343-372 — before extracting anything, compare `mistralrs-core/src/models/qwen3_next.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/text.rs` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 461 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/qwen3_next.rs:438` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (30–31 lines × 2) mistralrs-core/src/models/qwen3_next.rs:1082 — mistralrs-core/src/models/qwen3_next.rs:1082-1112 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:884-913 — before extracting anything, compare `mistralrs-core/src/models/qwen3_next.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/text.rs` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 461 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/qwen3_next.rs:1082` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (30–31 lines × 2) mistralrs-pyo3/src/lib.rs:1393 — mistralrs-pyo3/src/lib.rs:1393-1423 | mistralrs-server-core/src/mistralrs_for_server_builder.rs:1367-1396 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
D4 · Code Duplication · Duplicated block (29–30 lines × 2) · ×3
  • Duplicated block (29–30 lines × 2) mistralrs-core/src/sampler.rs:1518 — mistralrs-core/src/sampler.rs:1518-1547 | mistralrs-core/src/sampler.rs:1686-1714 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/sampler.rs:1518` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (29–30 lines × 2) mistralrs-quant/src/cutile/fused_moe.rs:163 — mistralrs-quant/src/cutile/fused_moe.rs:163-192 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:169-197 — before extracting anything, compare `mistralrs-quant/src/cutile/fused_moe.rs` and `mistralrs-quant/src/cutile/fused_moe_fp8.rs` as WHOLE FILES: this scan already matched 24 separate duplicated blocks between them, totalling at least 298 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cutile/fused_moe.rs:163` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (29–30 lines × 2) mistralrs-quant/src/metal_kernels/mod.rs:4311 — mistralrs-quant/src/metal_kernels/mod.rs:4311-4340 | mistralrs-quant/src/metal_kernels/mod.rs:5064-5092 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (24–26 lines × 2) · ×3
  • Duplicated block (24–26 lines × 2) mistralrs-core/src/models/qwen3_next.rs:482 — mistralrs-core/src/models/qwen3_next.rs:482-507 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:386-409 — before extracting anything, compare `mistralrs-core/src/models/qwen3_next.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/text.rs` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 461 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/qwen3_next.rs:482` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (24–26 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:2138 — mistralrs-core/src/pipeline/multimodal.rs:2138-2163 | mistralrs-core/src/pipeline/normal.rs:1894-1917 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:2138` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (24–26 lines × 2) mistralrs-quant/src/gguf/fast_mmq.rs:1005 — mistralrs-quant/src/gguf/fast_mmq.rs:1005-1028 | mistralrs-quant/src/gguf/fast_mmq.rs:1168-1193 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/gguf/fast_mmq.rs:1005` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (23–24 lines × 2) · ×3
  • Duplicated block (23–24 lines × 2) mistralrs-core/src/lora/loralinear.rs:182 — mistralrs-core/src/lora/loralinear.rs:182-205 | mistralrs-core/src/lora/qloralinear.rs:233-255 — before extracting anything, compare `mistralrs-core/src/lora/loralinear.rs` and `mistralrs-core/src/lora/qloralinear.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 151 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/lora/loralinear.rs:182` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (23–24 lines × 2) mistralrs/src/anymoe.rs:118 — mistralrs/src/anymoe.rs:118-140 | mistralrs/src/model_builder_trait.rs:1058-1081 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs/src/anymoe.rs:118` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (23–24 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:2398 — mistralrs-core/src/pipeline/multimodal.rs:2398-2421 | mistralrs-core/src/pipeline/normal.rs:2106-2128 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/pipeline/normal.rs:2129` calls `device_mapper` and `mistralrs-core/src/pipeline/multimodal.rs:2421` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (21–22 lines × 2) · ×3
  • Duplicated block (21–22 lines × 2) mistralrs-core/src/ops.rs:634 — mistralrs-core/src/ops.rs:634-655 | mistralrs-core/src/ops.rs:790-810 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:634` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (21–22 lines × 2) mistralrs-quant/src/metal_kernels/mod.rs:3462 — mistralrs-quant/src/metal_kernels/mod.rs:3462-3483 | mistralrs-quant/src/metal_kernels/mod.rs:3592-3612 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/metal_kernels/mod.rs:3462` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (21–22 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:757 — mistralrs-core/src/pipeline/multimodal.rs:757-778 | mistralrs-core/src/pipeline/normal.rs:767-787 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:757` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (19 lines × 4) · ×3
  • Duplicated block (19 lines × 4) mistralrs-core/src/embedding_models/embedding_gemma.rs:295 — mistralrs-core/src/embedding_models/embedding_gemma.rs:295-313 | mistralrs-core/src/models/gemma2.rs:340-358 | mistralrs-core/src/vision_models/gemma3/text.rs:348-366 | mistralrs-core/src/xlora_models/gemma2.rs:357-375 — before extracting anything, compare `mistralrs-core/src/embedding_models/embedding_gemma.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 175 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/embedding_gemma.rs:295` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (19 lines × 4) mistralrs-core/src/vision_models/qwen3_5/mod.rs:400 — mistralrs-core/src/vision_models/qwen3_5/mod.rs:400-418 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:385-403 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:415-433 | mistralrs-core/src/vision_models/qwen4_exp/mod.rs:380-398 — `mistralrs-core/src/vision_models/qwen3_5/mod.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 24 separate duplicated blocks between them, totalling at least 425 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_5/mod.rs:400` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (19 lines × 4) mistralrs-quant/src/metal_kernels/mod.rs:3123 — mistralrs-quant/src/metal_kernels/mod.rs:3123-3141 | mistralrs-quant/src/metal_kernels/mod.rs:3156-3174 | mistralrs-quant/src/metal_kernels/mod.rs:3189-3207 | mistralrs-quant/src/metal_kernels/mod.rs:3222-3240 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/metal_kernels/mod.rs:3123` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (18–19 lines × 3) · ×3
  • Duplicated block (18–19 lines × 3) mistralrs-core/src/embedding_models/embedding_gemma.rs:414 — mistralrs-core/src/embedding_models/embedding_gemma.rs:414-431 | mistralrs-core/src/vision_models/gemma3/text.rs:473-490 | mistralrs-core/src/vision_models/gemma3n/text.rs:1401-1419 — before extracting anything, compare `mistralrs-core/src/embedding_models/embedding_gemma.rs` and `mistralrs-core/src/vision_models/gemma3/text.rs` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 286 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/embedding_gemma.rs:414` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18–19 lines × 3) mistralrs-core/src/xlora_models/mistral.rs:445 — mistralrs-core/src/xlora_models/mistral.rs:445-462 | mistralrs-core/src/xlora_models/mixtral.rs:575-593 | mistralrs-core/src/xlora_models/starcoder2.rs:434-451 — before extracting anything, compare `mistralrs-core/src/xlora_models/mistral.rs` and `mistralrs-core/src/xlora_models/mixtral.rs` as WHOLE FILES: this scan already matched 53 separate duplicated blocks between them, totalling at least 787 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/mistral.rs:445` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18–19 lines × 3) mistralrs-pyo3/src/util.rs:202 — mistralrs-pyo3/src/util.rs:202-219 | mistralrs-pyo3/src/util.rs:256-274 | mistralrs-pyo3/src/util.rs:316-334 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-pyo3/src/util.rs:202` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (17 lines × 6) · ×3
  • Duplicated block (17 lines × 6) mistralrs-core/src/embedding_models/qwen3_embedding.rs:242 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:242-258 | mistralrs-core/src/models/llama.rs:276-292 | mistralrs-core/src/models/mistral.rs:323-339 | mistralrs-core/src/models/qwen2.rs:355-371 | mistralrs-core/src/models/qwen3.rs:311-327 | mistralrs-core/src/models/smollm3.rs:292-308 — before extracting anything, compare `mistralrs-core/src/embedding_models/qwen3_embedding.rs` and `mistralrs-core/src/models/llama.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 61 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/qwen3_embedding.rs:242` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/models/mistral.rs:322` calls `set_device`, `pp` and `mistralrs-core/src/models/llama.rs:275` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (17 lines × 6) mistralrs-paged-attn/src/cuda/backend/mla.rs:455 — mistralrs-paged-attn/src/cuda/backend/mla.rs:455-471 | mistralrs-paged-attn/src/cuda/backend/mla.rs:514-530 | mistralrs-paged-attn/src/cuda/backend/mla.rs:573-589 | mistralrs-paged-attn/src/cuda/backend/mla.rs:772-788 | mistralrs-paged-attn/src/cuda/backend/mla.rs:810-826 | mistralrs-paged-attn/src/cuda/backend/mla.rs:848-864 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/cuda/backend/mla.rs:455` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-paged-attn/src/cuda/backend/mla.rs:454` calls `slice_ptr`, `start_offset` and `mistralrs-paged-attn/src/cuda/backend/mla.rs:771` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (17 lines × 6) mistralrs-quant/src/afq/ops.rs:2270 — mistralrs-quant/src/afq/ops.rs:2270-2286 | mistralrs-quant/src/afq/ops.rs:2418-2434 | mistralrs-quant/src/afq/ops.rs:2566-2582 | mistralrs-quant/src/afq/ops.rs:2815-2831 | mistralrs-quant/src/afq/ops.rs:2995-3011 | mistralrs-quant/src/afq/ops.rs:3178-3194 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/afq/ops.rs:2270` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (16 lines × 4) · ×3
  • Duplicated block (16 lines × 4) mistralrs-core/src/models/gemma.rs:365 — mistralrs-core/src/models/gemma.rs:365-380 | mistralrs-core/src/models/gemma2.rs:438-453 | mistralrs-core/src/xlora_models/gemma.rs:445-460 | mistralrs-core/src/xlora_models/gemma2.rs:476-491 — before extracting anything, compare `mistralrs-core/src/models/gemma.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 707 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/xlora_models/gemma.rs:442` calls `with_capacity`, `pp` and `mistralrs-core/src/models/gemma.rs:363` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (16 lines × 4) mistralrs-core/src/pipeline/multimodal.rs:1181 — mistralrs-core/src/pipeline/multimodal.rs:1181-1196 | mistralrs-core/src/pipeline/multimodal.rs:1290-1305 | mistralrs-core/src/pipeline/normal.rs:1233-1248 | mistralrs-core/src/pipeline/normal.rs:1366-1381 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:1181` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 4) mistralrs-quant/src/hqq/hqq_op.rs:152 — mistralrs-quant/src/hqq/hqq_op.rs:152-167 | mistralrs-quant/src/hqq/hqq_op.rs:265-280 | mistralrs-quant/src/hqq/hqq_op.rs:382-397 | mistralrs-quant/src/hqq/hqq_op.rs:501-516 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/hqq/hqq_op.rs:152` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (15–16 lines × 4) · ×3
  • Duplicated block (15–16 lines × 4) mistralrs-core/src/vision_models/qwen3_5/mod.rs:196 — mistralrs-core/src/vision_models/qwen3_5/mod.rs:196-211 | mistralrs-core/src/vision_models/qwen3_5/mod.rs:259-273 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:179-194 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:242-256 — `mistralrs-core/src/vision_models/qwen3_5/mod.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 24 separate duplicated blocks between them, totalling at least 425 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_5/mod.rs:196` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15–16 lines × 4) mistralrs-core/src/vision_models/qwen3_vl/mod.rs:703 — mistralrs-core/src/vision_models/qwen3_vl/mod.rs:703-718 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:780-794 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:149-164 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:226-240 — `mistralrs-core/src/vision_models/qwen3_vl/mod.rs` and `mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 25 separate duplicated blocks between them, totalling at least 658 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_vl/mod.rs:703` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15–16 lines × 4) mistralrs-core/src/vision_models/qwen3_vl/mod.rs:720 — mistralrs-core/src/vision_models/qwen3_vl/mod.rs:720-735 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:796-810 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:166-181 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:242-256 — `mistralrs-core/src/vision_models/qwen3_vl/mod.rs` and `mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 25 separate duplicated blocks between them, totalling at least 658 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_vl/mod.rs:720` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (13–16 lines × 2) · ×3
  • Duplicated block (13–16 lines × 2) mistralrs-core/src/vision_models/gemma3n/audio_processing.rs:280 — mistralrs-core/src/vision_models/gemma3n/audio_processing.rs:280-295 | mistralrs-core/src/vision_models/gemma4/audio_processing.rs:395-407 — `mistralrs-core/src/vision_models/gemma3n/audio_processing.rs` and `mistralrs-core/src/vision_models/gemma4/audio_processing.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 43 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3n/audio_processing.rs:280` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13–16 lines × 2) mistralrs-core/src/vision_models/qwen3_5/text.rs:1545 — mistralrs-core/src/vision_models/qwen3_5/text.rs:1545-1560 | mistralrs-core/src/vision_models/qwen4_exp/text.rs:1007-1019 — `mistralrs-core/src/vision_models/qwen3_5/text.rs` and `mistralrs-core/src/vision_models/qwen4_exp/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 7 separate duplicated blocks between them, totalling at least 83 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_5/text.rs:1545` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (13–16 lines × 2) mistralrs-server-core/src/mistralrs_for_server_builder.rs:845 — mistralrs-server-core/src/mistralrs_for_server_builder.rs:845-860 | mistralrs-server-core/src/mistralrs_for_server_builder.rs:1069-1081 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-server-core/src/mistralrs_for_server_builder.rs:845` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (14–15 lines × 4) · ×3
  • Duplicated block (14–15 lines × 4) mistralrs-core/src/models/deepseek2.rs:624 — mistralrs-core/src/models/deepseek2.rs:624-638 | mistralrs-core/src/models/deepseek3.rs:687-701 | mistralrs-core/src/models/glm4_moe.rs:529-542 | mistralrs-core/src/models/glm4_moe_lite.rs:633-647 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:624` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (14–15 lines × 4) mistralrs-core/src/vision_models/qwen3_5/mod.rs:213 — mistralrs-core/src/vision_models/qwen3_5/mod.rs:213-227 | mistralrs-core/src/vision_models/qwen3_5/mod.rs:275-288 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:196-210 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:258-271 — `mistralrs-core/src/vision_models/qwen3_5/mod.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 24 separate duplicated blocks between them, totalling at least 425 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_5/mod.rs:213` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14–15 lines × 4) mistralrs-core/src/xlora_models/gemma.rs:375 — mistralrs-core/src/xlora_models/gemma.rs:375-388 | mistralrs-core/src/xlora_models/mistral.rs:371-384 | mistralrs-core/src/xlora_models/mixtral.rs:498-512 | mistralrs-core/src/xlora_models/starcoder2.rs:360-373 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/mistral.rs` as WHOLE FILES: this scan already matched 37 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/xlora_models/gemma.rs:391` calls `clone` and `mistralrs-core/src/xlora_models/mistral.rs:387` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (13 lines × 11) · ×3
  • Duplicated block (13 lines × 11) mistralrs-core/src/models/flint.rs:718 — mistralrs-core/src/models/flint.rs:718-730 | mistralrs-core/src/models/gpt_oss.rs:659-672 | mistralrs-core/src/models/hunyuan_v1_moe.rs:807-819 | mistralrs-core/src/models/mixtral.rs:347-359 | mistralrs-core/src/models/qwen3_moe.rs:500-512 | mistralrs-core/src/vision_models/phi4/mod.rs:271-284 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:449-461 | mistralrs-core/src/xlora_models/llama.rs:365-377 | mistralrs-core/src/xlora_models/mistral.rs:345-357 | mistralrs-core/src/xlora_models/mixtral.rs:472-484 | mistralrs-core/src/xlora_models/phi3.rs:310-322 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/gpt_oss.rs` as WHOLE FILES: this scan already matched 24 separate duplicated blocks between them, totalling at least 268 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/flint.rs:718` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 11) mistralrs-core/src/models/flint.rs:846 — mistralrs-core/src/models/flint.rs:846-858 | mistralrs-core/src/models/glm4.rs:513-525 | mistralrs-core/src/models/hunyuan_v1_dense.rs:478-490 | mistralrs-core/src/models/hunyuan_v1_moe.rs:972-984 | mistralrs-core/src/models/mistral.rs:519-531 | mistralrs-core/src/models/mixtral.rs:474-486 | mistralrs-core/src/models/qwen2.rs:505-517 | mistralrs-core/src/models/qwen3.rs:472-484 | mistralrs-core/src/models/qwen3_moe.rs:652-664 | mistralrs-core/src/vision_models/phi3/mod.rs:1268-1280 | mistralrs-core/src/vision_models/phi4/mod.rs:383-395 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/glm4.rs` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 240 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/flint.rs:846` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/models/qwen3_moe.rs:650` calls `clone` and `mistralrs-core/src/models/glm4.rs:511` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (13 lines × 11) mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:397 — mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:397-409 | mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1040-1052 | mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:437-449 | mistralrs-core/src/vision_models/llama4/inputs_processor.rs:407-419 | mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:288-300 | mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:324-336 | mistralrs-core/src/vision_models/minicpmo/inputs_processor.rs:312-324 | mistralrs-core/src/vision_models/mistral3/inputs_processor.rs:269-281 | mistralrs-core/src/vision_models/mllama/inputs_processor.rs:335-347 | mistralrs-core/src/vision_models/phi3/phi3_inputs_processor.rs:297-309 | mistralrs-core/src/vision_models/voxtral/inputs_processor.rs:210-222 — `mistralrs-core/src/vision_models/gemma3/inputs_processor.rs` and `mistralrs-core/src/vision_models/gemma4/inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 6 separate duplicated blocks between them, totalling at least 86 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (13 lines × 7) · ×3
  • Duplicated block (13 lines × 7) mistralrs-core/src/embedding_models/qwen3_embedding.rs:257 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:257-269 | mistralrs-core/src/models/hunyuan_v1_dense.rs:317-329 | mistralrs-core/src/models/mistral.rs:338-350 | mistralrs-core/src/models/phi3.rs:351-363 | mistralrs-core/src/models/qwen2.rs:370-382 | mistralrs-core/src/models/qwen3.rs:326-338 | mistralrs-core/src/vision_models/phi3/mod.rs:442-454 — before extracting anything, compare `mistralrs-core/src/embedding_models/qwen3_embedding.rs` and `mistralrs-core/src/models/hunyuan_v1_dense.rs` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 119 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/qwen3_embedding.rs:257` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 7) mistralrs-core/src/models/glm4_moe.rs:239 — mistralrs-core/src/models/glm4_moe.rs:239-252 | mistralrs-core/src/models/hunyuan_v1_dense.rs:158-171 | mistralrs-core/src/models/hunyuan_v1_moe.rs:341-354 | mistralrs-core/src/models/qwen3.rs:159-172 | mistralrs-core/src/models/qwen3_moe.rs:162-175 | mistralrs-core/src/models/qwen3_next.rs:243-255 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:158-170 — before extracting anything, compare `mistralrs-core/src/models/glm4_moe.rs` and `mistralrs-core/src/models/hunyuan_v1_dense.rs` as WHOLE FILES: this scan already matched 24 separate duplicated blocks between them, totalling at least 260 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/glm4_moe.rs:239` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (13 lines × 7) mistralrs-core/src/xlora_models/gemma.rs:577 — mistralrs-core/src/xlora_models/gemma.rs:577-589 | mistralrs-core/src/xlora_models/gemma2.rs:613-625 | mistralrs-core/src/xlora_models/mistral.rs:571-583 | mistralrs-core/src/xlora_models/mixtral.rs:701-713 | mistralrs-core/src/xlora_models/phi2.rs:547-559 | mistralrs-core/src/xlora_models/phi3.rs:525-537 | mistralrs-core/src/xlora_models/starcoder2.rs:558-570 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/gemma2.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 498 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/xlora_models/gemma.rs:592` calls `embedding_forward`, `into` and `mistralrs-core/src/xlora_models/gemma2.rs:626` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (13 lines × 6) · ×3
  • Duplicated block (13 lines × 6) mistralrs-core/src/models/deepseek2.rs:989 — mistralrs-core/src/models/deepseek2.rs:989-1001 | mistralrs-core/src/models/deepseek2.rs:1029-1041 | mistralrs-core/src/models/deepseek3.rs:1052-1064 | mistralrs-core/src/models/deepseek3.rs:1093-1105 | mistralrs-core/src/models/glm4_moe_lite.rs:1004-1016 | mistralrs-core/src/models/glm4_moe_lite.rs:1047-1059 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:989` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 6) mistralrs-core/src/pipeline/multimodal.rs:1185 — mistralrs-core/src/pipeline/multimodal.rs:1185-1197 | mistralrs-core/src/pipeline/multimodal.rs:1235-1247 | mistralrs-core/src/pipeline/multimodal.rs:1294-1306 | mistralrs-core/src/pipeline/normal.rs:1237-1249 | mistralrs-core/src/pipeline/normal.rs:1287-1299 | mistralrs-core/src/pipeline/normal.rs:1370-1382 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (13 lines × 6) mistralrs-paged-attn/src/cuda/backend/fa3.rs:495 — mistralrs-paged-attn/src/cuda/backend/fa3.rs:495-507 | mistralrs-quant/src/cutile/gdn_prefill.rs:712-724 | mistralrs-quant/src/cutile/nvfp4_gemv.rs:330-342 | mistralrs-quant/src/cutile/nvfp4_matmul.rs:657-669 | mistralrs-quant/src/cutile/nvfp4_matmul.rs:1159-1171 | mistralrs-quant/src/nvfp4/decode.rs:131-143 — before extracting anything, compare `mistralrs-paged-attn/src/cuda/backend/fa3.rs` and `mistralrs-quant/src/cutile/nvfp4_gemv.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 31 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/cuda/backend/fa3.rs:495` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (11 lines × 6) · ×3
  • Duplicated block (11 lines × 6) mistralrs-core/src/embedding_models/qwen3_embedding.rs:103 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:103-113 | mistralrs-core/src/models/glm4.rs:136-146 | mistralrs-core/src/models/glm4_moe.rs:188-198 | mistralrs-core/src/models/gpt_oss.rs:171-181 | mistralrs-core/src/models/qwen3.rs:114-124 | mistralrs-core/src/models/qwen3_moe.rs:117-127 — before extracting anything, compare `mistralrs-core/src/embedding_models/qwen3_embedding.rs` and `mistralrs-core/src/models/glm4.rs` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 137 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/qwen3_embedding.rs:103` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (11 lines × 6) mistralrs-core/src/models/gemma.rs:272 — mistralrs-core/src/models/gemma.rs:272-282 | mistralrs-core/src/models/gemma2.rs:323-333 | mistralrs-core/src/models/mistral.rs:320-330 | mistralrs-core/src/models/qwen2.rs:352-362 | mistralrs-core/src/vision_models/gemma3/text.rs:331-341 | mistralrs-core/src/vision_models/muse_glimmer/text.rs:361-371 — before extracting anything, compare `mistralrs-core/src/models/gemma.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 707 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma.rs:272` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (11 lines × 6) mistralrs/src/model_builder_trait.rs:580 — mistralrs/src/model_builder_trait.rs:580-590 | mistralrs/src/model_builder_trait.rs:659-669 | mistralrs/src/model_builder_trait.rs:802-813 | mistralrs/src/model_builder_trait.rs:957-968 | mistralrs/src/model_builder_trait.rs:1130-1141 | mistralrs/src/model_builder_trait.rs:1579-1590 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs/src/model_builder_trait.rs:580` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (10–11 lines × 3) · ×3
  • Duplicated block (10–11 lines × 3) mistralrs-core/src/models/llama.rs:499 — mistralrs-core/src/models/llama.rs:499-509 | mistralrs-core/src/models/smollm3.rs:518-528 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:541-550 — before extracting anything, compare `mistralrs-core/src/models/llama.rs` and `mistralrs-core/src/models/smollm3.rs` as WHOLE FILES: this scan already matched 47 separate duplicated blocks between them, totalling at least 727 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/llama.rs:499` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (10–11 lines × 3) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1013 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1013-1023 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3804-3814 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4591-4600 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1013` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10–11 lines × 3) mistralrs-core/src/vision_models/muse_glimmer/text.rs:227 — mistralrs-core/src/vision_models/muse_glimmer/text.rs:227-236 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:195-205 | mistralrs-core/src/vision_models/qwen2vl/text.rs:196-206 — `mistralrs-core/src/vision_models/muse_glimmer/text.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 10 separate duplicated blocks between them, totalling at least 145 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (9 lines × 12) · ×3
  • Duplicated block (9 lines × 12) mistralrs-core/src/models/flint.rs:788 — mistralrs-core/src/models/flint.rs:788-796 | mistralrs-core/src/models/glm4.rs:450-458 | mistralrs-core/src/models/granite.rs:1958-1966 | mistralrs-core/src/models/hunyuan_v1_dense.rs:419-427 | mistralrs-core/src/models/hunyuan_v1_moe.rs:913-921 | mistralrs-core/src/models/llama.rs:356-364 | mistralrs-core/src/models/mistral.rs:425-433 | mistralrs-core/src/models/qwen3.rs:413-421 | mistralrs-core/src/models/qwen3_moe.rs:587-595 | mistralrs-core/src/models/qwen3_next.rs:748-756 | mistralrs-core/src/models/smollm3.rs:372-380 | mistralrs-core/src/vision_models/llama4/text.rs:805-813 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/glm4.rs` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 240 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/models/qwen3_next.rs:744` calls `is_empty` and `mistralrs-core/src/models/flint.rs:786` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 12) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1520 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1520-1528 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1827-1835 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2127-2135 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2543-2551 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3255-3263 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3597-3605 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5114-5122 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5545-5553 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:814-822 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1258-1266 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1502-1510 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5795-5803 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` and `mistralrs-core/src/pipeline/loaders/normal_loaders.rs` as WHOLE FILES: this scan already matched 34 separate duplicated blocks between them, totalling at least 445 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5555` calls `moe_layers`, `contains` and `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1530` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 12) mistralrs-quant/src/metal_kernels/mod.rs:285 — mistralrs-quant/src/metal_kernels/mod.rs:285-293 | mistralrs-quant/src/metal_kernels/mod.rs:324-332 | mistralrs-quant/src/metal_kernels/mod.rs:363-371 | mistralrs-quant/src/metal_kernels/mod.rs:402-410 | mistralrs-quant/src/metal_kernels/mod.rs:441-449 | mistralrs-quant/src/metal_kernels/mod.rs:694-702 | mistralrs-quant/src/metal_kernels/mod.rs:741-749 | mistralrs-quant/src/metal_kernels/mod.rs:788-796 | mistralrs-quant/src/metal_kernels/mod.rs:2026-2034 | mistralrs-quant/src/metal_kernels/mod.rs:4897-4905 | mistralrs-quant/src/metal_kernels/mod.rs:4968-4976 | mistralrs-quant/src/metal_kernels/mod.rs:5010-5018 — all 12 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/metal_kernels/mod.rs:285` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-quant/src/metal_kernels/mod.rs:4906` calls `load_pipeline` and `mistralrs-quant/src/metal_kernels/mod.rs:295` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (9 lines × 6) · ×3
  • Duplicated block (9 lines × 6) mistralrs-core/src/embedding_models/embedding_gemma.rs:393 — mistralrs-core/src/embedding_models/embedding_gemma.rs:393-402 | mistralrs-core/src/models/gemma.rs:362-370 | mistralrs-core/src/models/gemma2.rs:435-443 | mistralrs-core/src/vision_models/gemma3/text.rs:452-461 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:408-417 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:528-537 — `mistralrs-core/src/embedding_models/embedding_gemma.rs` and `mistralrs-core/src/models/gemma.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 9 separate duplicated blocks between them, totalling at least 133 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/embedding_gemma.rs:393` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/vision_models/gemma3/text.rs:449` calls `then`, `set_nm_device`, `pp` and `mistralrs-core/src/embedding_models/embedding_gemma.rs:392` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 6) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1558 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1558-1566 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1866-1874 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2166-2174 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5154-5162 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6944-6952 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7408-7416 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1558` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 6) mistralrs-core/src/xlora_models/classifier.rs:55 — mistralrs-core/src/xlora_models/classifier.rs:55-63 | mistralrs-core/src/xlora_models/classifier.rs:68-76 | mistralrs-core/src/xlora_models/classifier.rs:118-126 | mistralrs-core/src/xlora_models/classifier.rs:131-139 | mistralrs-core/src/xlora_models/classifier.rs:210-218 | mistralrs-core/src/xlora_models/classifier.rs:223-231 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/classifier.rs:55` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (8–9 lines × 3) · ×3
  • Duplicated block (8–9 lines × 3) mistralrs-core/src/models/granite.rs:1417 — mistralrs-core/src/models/granite.rs:1417-1424 | mistralrs-core/src/models/granite.rs:1437-1444 | mistralrs-core/src/models/granite.rs:1722-1730 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (8–9 lines × 3) mistralrs-core/src/ops.rs:1161 — mistralrs-core/src/ops.rs:1161-1169 | mistralrs-core/src/ops.rs:1380-1388 | mistralrs-core/src/ops.rs:2967-2974 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:1161` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (8–9 lines × 3) mistralrs/src/model.rs:1006 — mistralrs/src/model.rs:1006-1013 | mistralrs/src/model.rs:1115-1123 | mistralrs/src/model.rs:1148-1155 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs/src/model.rs:1006` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (7–9 lines × 2) · ×3
  • Duplicated block (7–9 lines × 2) mistralrs-core/src/ops.rs:4213 — mistralrs-core/src/ops.rs:4213-4219 | mistralrs-core/src/ops.rs:4841-4849 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:4841` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (7–9 lines × 2) mistralrs-core/src/pipeline/auto.rs:172 — mistralrs-core/src/pipeline/auto.rs:172-178 | mistralrs-core/src/pipeline/auto.rs:188-196 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (7–9 lines × 2) mistralrs-core/src/vision_models/phi4/inputs_processor.rs:928 — mistralrs-core/src/vision_models/phi4/inputs_processor.rs:928-936 | mistralrs-core/src/vision_models/phi4/inputs_processor.rs:1030-1036 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/phi4/inputs_processor.rs:928` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (8 lines × 6) · ×3
  • Duplicated block (8 lines × 6) mistralrs-core/src/cuda/rounded_rope.rs:69 — mistralrs-core/src/cuda/rounded_rope.rs:69-76 | mistralrs-quant/src/cutile/fp8_w8a8.rs:523-530 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:906-913 | mistralrs-quant/src/cutile/mxfp8_gemm.rs:525-532 | mistralrs-quant/src/cutile/nvfp4_matmul.rs:640-647 | mistralrs-quant/src/nvfp4/portable.rs:303-310 — before extracting anything, compare `mistralrs-quant/src/cutile/fp8_w8a8.rs` and `mistralrs-quant/src/cutile/fused_moe_fp8.rs` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 83 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/rounded_rope.rs:69` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 6) mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:536 — mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:536-543 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4735-4742 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1036-1043 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2416-2423 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2887-2894 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6310-6317 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/embedding_loaders.rs` and `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 180 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (8 lines × 6) mistralrs-core/src/xlora_models/gemma.rs:497 — mistralrs-core/src/xlora_models/gemma.rs:497-504 | mistralrs-core/src/xlora_models/gemma2.rs:527-534 | mistralrs-core/src/xlora_models/mistral.rs:493-500 | mistralrs-core/src/xlora_models/mixtral.rs:624-631 | mistralrs-core/src/xlora_models/phi2.rs:479-486 | mistralrs-core/src/xlora_models/starcoder2.rs:481-488 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/gemma2.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 498 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma.rs:497` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/xlora_models/starcoder2.rs:490` calls `get_mut`, `unwrap`, `merge_weights` and `mistralrs-core/src/xlora_models/gemma.rs:506` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (7–8 lines × 4) · ×3
  • Duplicated block (7–8 lines × 4) mistralrs-code-exec/src/lib.rs:464 — mistralrs-code-exec/src/lib.rs:464-471 | mistralrs-code-exec/src/lib.rs:532-539 | mistralrs-code-exec/src/shell.rs:196-202 | mistralrs-code-exec/src/shell.rs:258-264 — before extracting anything, compare `mistralrs-code-exec/src/lib.rs` and `mistralrs-code-exec/src/shell.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 64 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-code-exec/src/lib.rs:464` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7–8 lines × 4) mistralrs-core/src/vision_models/grid_processor.rs:1339 — mistralrs-core/src/vision_models/grid_processor.rs:1339-1346 | mistralrs-core/src/vision_models/muse_glimmer/inputs_processor.rs:844-850 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:543-550 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1151-1158 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:1339` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7–8 lines × 4) mistralrs-core/src/models/llama.rs:523 — mistralrs-core/src/models/llama.rs:523-530 | mistralrs-core/src/models/smollm3.rs:542-549 | mistralrs-core/src/vision_models/llama4/text.rs:1022-1029 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:510-516 — before extracting anything, compare `mistralrs-core/src/models/llama.rs` and `mistralrs-core/src/models/smollm3.rs` as WHOLE FILES: this scan already matched 47 separate duplicated blocks between them, totalling at least 727 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/llama.rs:523` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (7 lines × 13) · ×3
  • Duplicated block (7 lines × 13) mistralrs-core/src/embedding_models/qwen3_embedding.rs:477 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:477-483 | mistralrs-core/src/models/deepseek2.rs:989-996 | mistralrs-core/src/models/deepseek2.rs:1029-1036 | mistralrs-core/src/models/deepseek3.rs:1052-1059 | mistralrs-core/src/models/deepseek3.rs:1093-1100 | mistralrs-core/src/models/flint.rs:989-995 | mistralrs-core/src/models/glm4_moe_lite.rs:1004-1011 | mistralrs-core/src/models/glm4_moe_lite.rs:1047-1054 | mistralrs-core/src/models/hunyuan_v1_dense.rs:581-587 | mistralrs-core/src/models/qwen3.rs:583-589 | mistralrs-core/src/models/qwen3_moe.rs:764-770 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:607-614 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:728-735 — before extracting anything, compare `mistralrs-core/src/embedding_models/qwen3_embedding.rs` and `mistralrs-core/src/models/deepseek2.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 35 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 13) mistralrs-core/src/models/gemma.rs:563 — mistralrs-core/src/models/gemma.rs:563-569 | mistralrs-core/src/models/gemma2.rs:680-686 | mistralrs-core/src/models/glm4.rs:682-688 | mistralrs-core/src/models/hunyuan_v1_dense.rs:650-656 | mistralrs-core/src/models/mistral.rs:691-697 | mistralrs-core/src/models/phi2.rs:639-645 | mistralrs-core/src/models/phi3.rs:634-640 | mistralrs-core/src/models/qwen2.rs:694-700 | mistralrs-core/src/models/qwen3.rs:668-674 | mistralrs-core/src/models/starcoder2.rs:630-636 | mistralrs-core/src/vision_models/gemma3/text.rs:905-911 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:647-653 | mistralrs-core/src/vision_models/phi3/mod.rs:1470-1476 — before extracting anything, compare `mistralrs-core/src/models/gemma.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 707 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 13) mistralrs-core/src/models/gemma.rs:570 — mistralrs-core/src/models/gemma.rs:570-576 | mistralrs-core/src/models/gemma2.rs:687-693 | mistralrs-core/src/models/glm4.rs:689-695 | mistralrs-core/src/models/hunyuan_v1_dense.rs:657-663 | mistralrs-core/src/models/mistral.rs:698-704 | mistralrs-core/src/models/phi2.rs:646-652 | mistralrs-core/src/models/phi3.rs:641-647 | mistralrs-core/src/models/qwen2.rs:701-707 | mistralrs-core/src/models/qwen3.rs:675-681 | mistralrs-core/src/models/starcoder2.rs:637-643 | mistralrs-core/src/vision_models/gemma3/text.rs:912-918 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:654-660 | mistralrs-core/src/vision_models/phi3/mod.rs:1477-1483 — before extracting anything, compare `mistralrs-core/src/models/gemma.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 707 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (6 lines × 9) · ×3
  • Duplicated block (6 lines × 9) mistralrs-core/src/models/gemma.rs:187 — mistralrs-core/src/models/gemma.rs:187-192 | mistralrs-core/src/models/gemma2.rs:228-233 | mistralrs-core/src/models/hunyuan_v1_dense.rs:211-216 | mistralrs-core/src/models/hunyuan_v1_moe.rs:394-399 | mistralrs-core/src/models/llama.rs:95-100 | mistralrs-core/src/models/mixtral.rs:171-176 | mistralrs-core/src/models/phi2.rs:283-288 | mistralrs-core/src/models/qwen2.rs:260-265 | mistralrs-core/src/models/starcoder2.rs:247-252 — before extracting anything, compare `mistralrs-core/src/models/gemma.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 707 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma.rs:187` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/models/hunyuan_v1_dense.rs:218` calls `forward` and `mistralrs-core/src/models/gemma.rs:194` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (6 lines × 9) mistralrs-core/src/vision_models/qwen3_5/mod.rs:226 — mistralrs-core/src/vision_models/qwen3_5/mod.rs:226-231 | mistralrs-core/src/vision_models/qwen3_5/mod.rs:287-292 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:209-214 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:270-275 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:746-751 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:821-826 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:192-197 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:267-272 | mistralrs-core/src/vision_models/qwen4_exp/mod.rs:334-339 — `mistralrs-core/src/vision_models/qwen3_5/mod.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 24 separate duplicated blocks between them, totalling at least 425 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_5/mod.rs:226` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 9) mistralrs-core/src/layers.rs:884 — mistralrs-core/src/layers.rs:884-889 | mistralrs-core/src/layers.rs:942-947 | mistralrs-core/src/layers.rs:959-964 | mistralrs-core/src/layers.rs:2046-2051 | mistralrs-core/src/layers.rs:2220-2225 | mistralrs-core/src/layers.rs:2265-2270 | mistralrs-core/src/layers.rs:2282-2287 | mistralrs-core/src/layers.rs:3074-3079 | mistralrs-core/src/layers.rs:3207-3212 — all 9 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/layers.rs:884` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D1 · Cyclomatic Complexity · Gemma4ImageProcessor · ×2
  • Gemma4ImageProcessor::process_inputs (cyclomatic 81) mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1025 — Gemma4ImageProcessor::process_inputs has cyclomatic complexity 81 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • Gemma4ImageProcessor::prepare_for_paged_prompt_planning (cyclomatic 29) mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:834 — Gemma4ImageProcessor::prepare_for_paged_prompt_planning has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · GridImageProcessor · ×2
  • GridImageProcessor::process_inputs (cyclomatic 58) mistralrs-core/src/vision_models/grid_processor.rs:1139 — GridImageProcessor::process_inputs has cyclomatic complexity 58 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • GridImageProcessor::prepare_for_paged_prompt_planning (cyclomatic 30) mistralrs-core/src/vision_models/grid_processor.rs:884 — GridImageProcessor::prepare_for_paged_prompt_planning has cyclomatic complexity 30 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ImageEmbedding · ×2
  • ImageEmbedding::forward (cyclomatic 54) mistralrs-core/src/vision_models/phi3/mod.rs:697 — ImageEmbedding::forward has cyclomatic complexity 54 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ImageEmbedding::forward (cyclomatic 20) mistralrs-core/src/vision_models/phi4/image_embedding.rs:465 — ImageEmbedding::forward has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Qwen2_5VLImageProcessor · ×2
  • Qwen2_5VLImageProcessor::process_inputs (cyclomatic 52) mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:352 — Qwen2_5VLImageProcessor::process_inputs has cyclomatic complexity 52 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • Qwen2_5VLImageProcessor::prepare_for_paged_prompt_planning (cyclomatic 29) mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:118 — Qwen2_5VLImageProcessor::prepare_for_paged_prompt_planning has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Qwen2VLImageProcessor · ×2
  • Qwen2VLImageProcessor::process_inputs (cyclomatic 52) mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:918 — Qwen2VLImageProcessor::process_inputs has cyclomatic complexity 52 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • Qwen2VLImageProcessor::prepare_for_paged_prompt_planning (cyclomatic 29) mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:684 — Qwen2VLImageProcessor::prepare_for_paged_prompt_planning has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · PagedAttentionScheduler · ×2
  • PagedAttentionScheduler::schedule (cyclomatic 50) mistralrs-core/src/paged_attention/scheduler.rs:930 — PagedAttentionScheduler::schedule has cyclomatic complexity 50 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • PagedAttentionScheduler::select_prompt_batch (cyclomatic 23) mistralrs-core/src/paged_attention/scheduler.rs:327 — PagedAttentionScheduler::select_prompt_batch has cyclomatic complexity 23 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · Qwen3_5Model · ×2
  • Qwen3_5Model::dflash_propose (cyclomatic 34) mistralrs-core/src/vision_models/qwen3_5/speculative.rs:304 — Qwen3_5Model::dflash_propose has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • Qwen3_5Model::forward (cyclomatic 31) mistralrs-core/src/vision_models/qwen3_5/mod.rs:118 — Qwen3_5Model::forward has cyclomatic complexity 31 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Sdpa · ×2
  • Sdpa::run_attention_noflash (cyclomatic 32) mistralrs-core/src/attention/mod.rs:476 — Sdpa::run_attention_noflash has cyclomatic complexity 32 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • Sdpa::run_attention (cyclomatic 26) mistralrs-core/src/attention/mod.rs:320 — Sdpa::run_attention has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · UnquantLinear · ×2
  • UnquantLinear::apply_isq (cyclomatic 29) mistralrs-quant/src/unquantized/mod.rs:423 — UnquantLinear::apply_isq has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • UnquantLinear::forward_raw (cyclomatic 17) mistralrs-quant/src/unquantized/mod.rs:149 — UnquantLinear::forward_raw has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Qwen2VLModel · ×2
  • Qwen2VLModel::forward (cyclomatic 26) mistralrs-core/src/vision_models/qwen2vl/mod.rs:326 — Qwen2VLModel::forward has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • Qwen2VLModel::compute_rope_index (cyclomatic 20) mistralrs-core/src/vision_models/qwen2vl/mod.rs:191 — Qwen2VLModel::compute_rope_index has cyclomatic complexity 20 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D1 · Cyclomatic Complexity · GGUFLoader · ×2
  • GGUFLoader::load_model_from_path (cyclomatic 25) mistralrs-core/src/pipeline/gguf.rs:1227 — GGUFLoader::load_model_from_path has cyclomatic complexity 25 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • GGUFLoader::infer_multimodal_asset_paths (cyclomatic 21) mistralrs-core/src/pipeline/gguf.rs:965 — GGUFLoader::infer_multimodal_asset_paths has cyclomatic complexity 21 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · mistralrs_pyo3 · ×2
  • mistralrs_pyo3::normalize_chat_messages (cyclomatic 25) mistralrs-pyo3/src/lib.rs:78 — mistralrs_pyo3::normalize_chat_messages has cyclomatic complexity 25 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline. This is NOT this file's highest cyclomatic complexity: mistralrs_pyo3::lora_adapter_error_code (cyclomatic 28) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
  • mistralrs_pyo3::parse_which (cyclomatic 21) mistralrs-pyo3/src/lib.rs:715 — mistralrs_pyo3::parse_which has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: mistralrs_pyo3::lora_adapter_error_code (cyclomatic 28) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · Idefics2ImageProcessor · ×2
  • Idefics2ImageProcessor::process_inputs (cyclomatic 23) mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:409 — Idefics2ImageProcessor::process_inputs has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • Idefics2ImageProcessor::preprocess (cyclomatic 16) mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:679 — Idefics2ImageProcessor::preprocess has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · BitWise · ×2
  • BitWise::cuda_fwd (cyclomatic 23) mistralrs-quant/src/utils/ops.rs:365 — BitWise::cuda_fwd has cyclomatic complexity 23 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • BitWise::cpu_fwd (cyclomatic 21) mistralrs-quant/src/utils/ops.rs:261 — BitWise::cpu_fwd has cyclomatic complexity 21 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · Attention · ×2
  • Attention::forward (cyclomatic 22) mistralrs-core/src/vision_models/gemma4/text.rs:507 — Attention::forward has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • Attention::forward (cyclomatic 18) mistralrs-core/src/vision_models/gemma3n/text.rs:434 — Attention::forward has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Sampler · ×2
  • Sampler::sample_topk_on_device (cyclomatic 16) mistralrs-core/src/sampler.rs:1470 — Sampler::sample_topk_on_device has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • Sampler::sample_topk_on_device_metal (cyclomatic 16) mistralrs-core/src/sampler.rs:1649 — Sampler::sample_topk_on_device_metal has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D17 · Explicit Debt · XxxComment · ×2
  • XxxComment mistralrs-quant/src/safetensors.rs:161 — // XXX: We need to specify `T` here, otherwise the compiler will infer u8 because of the following cast — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • XxxComment mistralrs-quant/src/safetensors.rs:192 — // XXX: We need to specify `T` here, otherwise the compiler will infer u8 because of the following cast — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
D2 · Cognitive Complexity · Gemma4ImageProcessor · ×2
  • Gemma4ImageProcessor::process_inputs (cognitive 242) mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1025 — Gemma4ImageProcessor::process_inputs has cognitive complexity 242 (threshold 15). Drivers by points: if/else 88 (188 pts), loops 14 (49 pts), boolean chains 5 (nesting depth added 135). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • Gemma4ImageProcessor::prepare_for_paged_prompt_planning (cognitive 57) mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:834 — Gemma4ImageProcessor::prepare_for_paged_prompt_planning has cognitive complexity 57 (threshold 15). Drivers by points: if/else 22 (47 pts), boolean chains 6, loops 2 (4 pts) (nesting depth added 27). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · Gemma4Model · ×2
  • Gemma4Model::forward_inner (cognitive 139) mistralrs-core/src/vision_models/gemma4/mod.rs:341 — Gemma4Model::forward_inner has cognitive complexity 139 (threshold 15). Drivers by points: if/else 50 (105 pts), loops 9 (30 pts), boolean chains 4 (nesting depth added 76). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • Gemma4Model::speculative_target_hiddens (cognitive 18) mistralrs-core/src/vision_models/gemma4/mod.rs:1213 — Gemma4Model::speculative_target_hiddens has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (13 pts), loops 2 (4 pts), match/switch 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Qwen2_5VLImageProcessor · ×2
  • Qwen2_5VLImageProcessor::process_inputs (cognitive 115) mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:352 — Qwen2_5VLImageProcessor::process_inputs has cognitive complexity 115 (threshold 15). Drivers by points: if/else 48 (93 pts), loops 7 (14 pts), boolean chains 7, match/switch 1 (nesting depth added 52). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Qwen2_5VLImageProcessor::prepare_for_paged_prompt_planning (cognitive 58) mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:118 — Qwen2_5VLImageProcessor::prepare_for_paged_prompt_planning has cognitive complexity 58 (threshold 15). Drivers by points: if/else 24 (48 pts), loops 6 (8 pts), boolean chains 2 (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Qwen2VLImageProcessor · ×2
  • Qwen2VLImageProcessor::process_inputs (cognitive 115) mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:918 — Qwen2VLImageProcessor::process_inputs has cognitive complexity 115 (threshold 15). Drivers by points: if/else 48 (93 pts), loops 7 (14 pts), boolean chains 7, match/switch 1 (nesting depth added 52). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Qwen2VLImageProcessor::prepare_for_paged_prompt_planning (cognitive 58) mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:684 — Qwen2VLImageProcessor::prepare_for_paged_prompt_planning has cognitive complexity 58 (threshold 15). Drivers by points: if/else 24 (48 pts), loops 6 (8 pts), boolean chains 2 (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Gemma3ImageProcessor · ×2
  • Gemma3ImageProcessor::process_inputs (cognitive 83) mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:382 — Gemma3ImageProcessor::process_inputs has cognitive complexity 83 (threshold 15). Drivers by points: if/else 36 (75 pts), loops 2 (6 pts), boolean chains 2 (nesting depth added 43). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • Gemma3ImageProcessor::prepare_for_paged_prompt_planning (cognitive 21) mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:265 — Gemma3ImageProcessor::prepare_for_paged_prompt_planning has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (18 pts), loops 2 (3 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Qwen3_5TextModel · ×2
  • Qwen3_5TextModel::forward_embeds (cognitive 75) mistralrs-core/src/vision_models/qwen3_5/text.rs:1358 — Qwen3_5TextModel::forward_embeds has cognitive complexity 75 (threshold 15). Drivers by points: if/else 29 (47 pts), match/switch 7 (15 pts), boolean chains 12, loops 1 (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Qwen3_5TextModel::new (cognitive 16) mistralrs-core/src/vision_models/qwen3_5/text.rs:804 — Qwen3_5TextModel::new has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (11 pts), match/switch 3 (4 pts), loops 1 (nesting depth added 2). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · Qwen3_5Model · ×2
  • Qwen3_5Model::dflash_propose (cognitive 70) mistralrs-core/src/vision_models/qwen3_5/speculative.rs:304 — Qwen3_5Model::dflash_propose has cognitive complexity 70 (threshold 15). Drivers by points: if/else 22 (41 pts), loops 7 (20 pts), boolean chains 6, match/switch 1 (3 pts) (nesting depth added 34). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Qwen3_5Model::forward (cognitive 58) mistralrs-core/src/vision_models/qwen3_5/mod.rs:118 — Qwen3_5Model::forward has cognitive complexity 58 (threshold 15). Drivers by points: if/else 21 (35 pts), loops 7 (17 pts), match/switch 3 (4 pts), boolean chains 2 (nesting depth added 25). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Qwen2VLModel · ×2
  • Qwen2VLModel::forward (cognitive 69) mistralrs-core/src/vision_models/qwen2vl/mod.rs:326 — Qwen2VLModel::forward has cognitive complexity 69 (threshold 15). Drivers by points: if/else 26 (41 pts), loops 5 (20 pts), match/switch 2 (6 pts), boolean chains 2 (nesting depth added 34). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Qwen2VLModel::compute_rope_index (cognitive 47) mistralrs-core/src/vision_models/qwen2vl/mod.rs:191 — Qwen2VLModel::compute_rope_index has cognitive complexity 47 (threshold 15). Drivers by points: loops 9 (27 pts), if/else 7 (16 pts), boolean chains 3, match/switch 1 (nesting depth added 27). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · mistralrs_pyo3 · ×2
  • mistralrs_pyo3::normalize_chat_messages (cognitive 65) mistralrs-pyo3/src/lib.rs:78 — mistralrs_pyo3::normalize_chat_messages has cognitive complexity 65 (threshold 15). Drivers by points: loops 8 (27 pts), match/switch 7 (25 pts), if/else 4 (11 pts), boolean chains 2 (nesting depth added 44). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • mistralrs_pyo3::util::parse_video_url (cognitive 18) mistralrs-pyo3/src/util.rs:315 — mistralrs_pyo3::util::parse_video_url has cognitive complexity 18 (threshold 15). Drivers by points: if/else 11 (12 pts), boolean chains 4, match/switch 1 (2 pts) (nesting depth added 2). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · MistralRs · ×2
  • MistralRs::init_external_tool_callbacks (cognitive 64) mistralrs-core/src/lib.rs:1378 — MistralRs::init_external_tool_callbacks has cognitive complexity 64 (threshold 15). Drivers by points: if/else 18 (39 pts), match/switch 6 (15 pts), loops 3 (9 pts), boolean chains 1 (nesting depth added 36). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • MistralRs::new (cognitive 18) mistralrs-core/src/lib.rs:1557 — MistralRs::new has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (10 pts), loops 2 (4 pts), boolean chains 2, match/switch 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LLaVAInputProcessor · ×2
  • LLaVAInputProcessor::process_inputs (cognitive 53) mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:273 — LLaVAInputProcessor::process_inputs has cognitive complexity 53 (threshold 15). Drivers by points: if/else 25 (39 pts), loops 6 (12 pts), boolean chains 2 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • LLaVAInputProcessor::prepare_for_paged_prompt_planning (cognitive 21) mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:171 — LLaVAInputProcessor::prepare_for_paged_prompt_planning has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (16 pts), loops 3 (5 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GraniteMoeHybrid · ×2
  • GraniteMoeHybrid::forward (cognitive 51) mistralrs-core/src/models/granite.rs:2180 — GraniteMoeHybrid::forward has cognitive complexity 51 (threshold 15). Drivers by points: if/else 21 (48 pts), match/switch 1 (2 pts), loops 1 (nesting depth added 28). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • GraniteMoeHybrid::new_inner (cognitive 26) mistralrs-core/src/models/granite.rs:1940 — GraniteMoeHybrid::new_inner has cognitive complexity 26 (threshold 15). Drivers by points: if/else 12 (17 pts), match/switch 3 (6 pts), loops 2 (3 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · PrefixCacheManagerV2 · ×2
  • PrefixCacheManagerV2::search_for_matching_cache (cognitive 51) mistralrs-core/src/prefix_cacher.rs:735 — PrefixCacheManagerV2::search_for_matching_cache has cognitive complexity 51 (threshold 15). Drivers by points: if/else 21 (33 pts), match/switch 4 (10 pts), loops 3 (5 pts), boolean chains 3 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • PrefixCacheManagerV2::evict_caches (cognitive 17) mistralrs-core/src/prefix_cacher.rs:437 — PrefixCacheManagerV2::evict_caches has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (12 pts), match/switch 2 (3 pts), loops 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Idefics2ImageProcessor · ×2
  • Idefics2ImageProcessor::process_inputs (cognitive 48) mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:409 — Idefics2ImageProcessor::process_inputs has cognitive complexity 48 (threshold 15). Drivers by points: if/else 24 (41 pts), loops 2 (4 pts), boolean chains 3 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Idefics2ImageProcessor::preprocess (cognitive 24) mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:679 — Idefics2ImageProcessor::preprocess has cognitive complexity 24 (threshold 15). Drivers by points: if/else 10 (17 pts), loops 4 (5 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · HybridCacheManager · ×2
  • HybridCacheManager::clone_in_cache (cognitive 47) mistralrs-core/src/kv_cache/mod.rs:1196 — HybridCacheManager::clone_in_cache has cognitive complexity 47 (threshold 15). Drivers by points: if/else 12 (38 pts), match/switch 1 (5 pts), loops 2 (4 pts) (nesting depth added 32). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • HybridCacheManager::clone_out_cache (cognitive 39) mistralrs-core/src/kv_cache/mod.rs:1285 — HybridCacheManager::clone_out_cache has cognitive complexity 39 (threshold 15). Drivers by points: if/else 6 (21 pts), loops 3 (11 pts), match/switch 1 (6 pts), boolean chains 1 (nesting depth added 28). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LLaVANextInputProcessor · ×2
  • LLaVANextInputProcessor::process_inputs (cognitive 44) mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:309 — LLaVANextInputProcessor::process_inputs has cognitive complexity 44 (threshold 15). Drivers by points: if/else 25 (37 pts), loops 3 (4 pts), boolean chains 3 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • LLaVANextInputProcessor::prepare_for_paged_prompt_planning (cognitive 16) mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:236 — LLaVANextInputProcessor::prepare_for_paged_prompt_planning has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (15 pts), loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Sdpa · ×2
  • Sdpa::run_attention_noflash (cognitive 40) mistralrs-core/src/attention/mod.rs:476 — Sdpa::run_attention_noflash has cognitive complexity 40 (threshold 15). Drivers by points: if/else 14 (22 pts), boolean chains 12, match/switch 3 (6 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Sdpa::run_attention (cognitive 35) mistralrs-core/src/attention/mod.rs:320 — Sdpa::run_attention has cognitive complexity 35 (threshold 15). Drivers by points: if/else 12 (18 pts), boolean chains 12, match/switch 3 (5 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · UnquantLinear · ×2
  • UnquantLinear::apply_isq (cognitive 39) mistralrs-quant/src/unquantized/mod.rs:423 — UnquantLinear::apply_isq has cognitive complexity 39 (threshold 15). Drivers by points: if/else 17 (29 pts), match/switch 4 (8 pts), boolean chains 2 (nesting depth added 16). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • UnquantLinear::forward_raw (cognitive 29) mistralrs-quant/src/unquantized/mod.rs:149 — UnquantLinear::forward_raw has cognitive complexity 29 (threshold 15). Drivers by points: if/else 13 (21 pts), match/switch 4 (7 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RoutedExperts · ×2
  • RoutedExperts::forward_grouped (cognitive 35) mistralrs-quant/src/routed_moe/cuda.rs:275 — RoutedExperts::forward_grouped has cognitive complexity 35 (threshold 15). Drivers by points: if/else 17 (22 pts), match/switch 8 (11 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • RoutedExperts::forward (cognitive 21) mistralrs-quant/src/routed_moe/mod.rs:111 — RoutedExperts::forward has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (18 pts), match/switch 1 (3 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ParsedShard · ×2
  • ParsedShard::finish (cognitive 33) mistralrs-quant/src/gguf/archive.rs:847 — ParsedShard::finish has cognitive complexity 33 (threshold 15). Drivers by points: if/else 10 (25 pts), match/switch 2 (4 pts), boolean chains 3, loops 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ParsedShard::parse (cognitive 16) mistralrs-quant/src/gguf/archive.rs:768 — ParsedShard::parse has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (8 pts), loops 3 (4 pts), match/switch 2 (4 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Lfm2VlImageProcessor · ×2
  • Lfm2VlImageProcessor::patchify (cognitive 30) mistralrs-core/src/vision_models/lfm2_vl/inputs_processor.rs:320 — Lfm2VlImageProcessor::patchify has cognitive complexity 30 (threshold 15). Drivers by points: loops 5 (15 pts), if/else 4 (14 pts), boolean chains 1 (nesting depth added 20). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
  • Lfm2VlImageProcessor::process_inputs (cognitive 23) mistralrs-core/src/vision_models/lfm2_vl/inputs_processor.rs:646 — Lfm2VlImageProcessor::process_inputs has cognitive complexity 23 (threshold 15). Drivers by points: if/else 17 (21 pts), loops 1 (2 pts) (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · PerTensorFP8Linear · ×2
  • PerTensorFP8Linear::apply_isq (cognitive 30) mistralrs-quant/src/pertensor_fp8/mod.rs:642 — PerTensorFP8Linear::apply_isq has cognitive complexity 30 (threshold 15). Drivers by points: if/else 15 (25 pts), match/switch 3 (5 pts) (nesting depth added 12). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • PerTensorFP8Linear::register_cutile (cognitive 17) mistralrs-quant/src/pertensor_fp8/mod.rs:204 — PerTensorFP8Linear::register_cutile has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (15 pts), boolean chains 2 (nesting depth added 9). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · GGUFLoader · ×2
  • GGUFLoader::load_model_from_path (cognitive 29) mistralrs-core/src/pipeline/gguf.rs:1227 — GGUFLoader::load_model_from_path has cognitive complexity 29 (threshold 15). Drivers by points: if/else 17 (20 pts), match/switch 4 (5 pts), boolean chains 3, loops 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • GGUFLoader::infer_multimodal_asset_paths (cognitive 23) mistralrs-core/src/pipeline/gguf.rs:965 — GGUFLoader::infer_multimodal_asset_paths has cognitive complexity 23 (threshold 15). Drivers by points: if/else 12 (14 pts), match/switch 6 (7 pts), boolean chains 2 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · BuiltinMtpProposer · ×2
  • BuiltinMtpProposer::propose (cognitive 28) mistralrs-core/src/speculative/builtin_mtp.rs:216 — BuiltinMtpProposer::propose has cognitive complexity 28 (threshold 15). Drivers by points: if/else 9 (15 pts), loops 6 (9 pts), boolean chains 4 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • BuiltinMtpProposer::prefill (cognitive 18) mistralrs-core/src/speculative/builtin_mtp.rs:373 — BuiltinMtpProposer::prefill has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (14 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MXFP4Layer · ×2
  • MXFP4Layer::gather_forward_dequantize (cognitive 28) mistralrs-quant/src/mxfp4/mod.rs:763 — MXFP4Layer::gather_forward_dequantize has cognitive complexity 28 (threshold 15). Drivers by points: loops 6 (19 pts), if/else 5 (9 pts) (nesting depth added 17). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
  • MXFP4Layer::forward_dequantize (cognitive 19) mistralrs-quant/src/mxfp4/mod.rs:683 — MXFP4Layer::forward_dequantize has cognitive complexity 19 (threshold 15). Drivers by points: loops 5 (13 pts), if/else 6 (nesting depth added 8). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · Llama · ×2
  • Llama::create_anymoe_layers (cognitive 27) mistralrs-core/src/models/llama.rs:604 — Llama::create_anymoe_layers has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (19 pts), loops 4 (5 pts), match/switch 1 (3 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Llama::create_anymoe_layers (cognitive 27) mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:617 — Llama::create_anymoe_layers has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (19 pts), loops 4 (5 pts), match/switch 1 (3 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GgufDeviceMapLoaderInner · ×2
  • GgufDeviceMapLoaderInner::layer_sizes_in_bytes (cognitive 26) mistralrs-core/src/utils/gguf_metadata.rs:401 — GgufDeviceMapLoaderInner::layer_sizes_in_bytes has cognitive complexity 26 (threshold 15). Drivers by points: if/else 11 (18 pts), loops 1 (4 pts), match/switch 2 (4 pts) (nesting depth added 12). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • GgufDeviceMapLoaderInner::non_mapped_size_in_bytes (cognitive 16) mistralrs-core/src/utils/gguf_metadata.rs:303 — GgufDeviceMapLoaderInner::non_mapped_size_in_bytes has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (15 pts), match/switch 1 (nesting depth added 5). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · DecoderLayer · ×2
  • DecoderLayer::forward_post_attn (cognitive 26) mistralrs-core/src/vision_models/gemma4/text.rs:1208 — DecoderLayer::forward_post_attn has cognitive complexity 26 (threshold 15). Drivers by points: if/else 16 (26 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • DecoderLayer::forward_linear (cognitive 16) mistralrs-core/src/models/qwen3_next.rs:622 — DecoderLayer::forward_linear has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (11 pts), loops 1 (3 pts), boolean chains 1, match/switch 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GdnTransitionLayers · ×2
  • GdnTransitionLayers::stage_prefixes (cognitive 24) mistralrs-core/src/speculative/gdn_transitions.rs:285 — GdnTransitionLayers::stage_prefixes has cognitive complexity 24 (threshold 15). Drivers by points: if/else 11 (16 pts), boolean chains 4, loops 3 (4 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • GdnTransitionLayers::apply_pending (cognitive 22) mistralrs-core/src/speculative/gdn_transitions.rs:189 — GdnTransitionLayers::apply_pending has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (13 pts), loops 4 (7 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Gemma3nImageProcessor · ×2
  • Gemma3nImageProcessor::prepare_prompt_plans (cognitive 24) mistralrs-core/src/vision_models/gemma3n/inputs_processor.rs:462 — Gemma3nImageProcessor::prepare_prompt_plans has cognitive complexity 24 (threshold 15). Drivers by points: if/else 12 (17 pts), boolean chains 6, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Gemma3nImageProcessor::process_audio_batch (cognitive 18) mistralrs-core/src/vision_models/gemma3n/inputs_processor.rs:640 — Gemma3nImageProcessor::process_audio_batch has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (11 pts), loops 4 (5 pts), boolean chains 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · QLoraLinear · ×2
  • QLoraLinear::lora_forward (cognitive 21) mistralrs-core/src/lora/qloralinear.rs:213 — QLoraLinear::lora_forward has cognitive complexity 21 (threshold 15). Drivers by points: if/else 12 (17 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • QLoraLinear::new (cognitive 17) mistralrs-core/src/lora/qloralinear.rs:31 — QLoraLinear::new has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (11 pts), loops 3 (4 pts), boolean chains 1, match/switch 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · DiaPipeline · ×2
  • DiaPipeline::generate (cognitive 21) mistralrs-core/src/speech_models/dia/mod.rs:380 — DiaPipeline::generate has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (11 pts), loops 2 (4 pts), match/switch 1 (4 pts), boolean chains 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • DiaPipeline::sample_next_token (cognitive 20) mistralrs-core/src/speech_models/dia/mod.rs:222 — DiaPipeline::sample_next_token has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 3 (6 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ToolCallingMatcher · ×2
  • ToolCallingMatcher::new_with_format (cognitive 20) mistralrs-core/src/tools/mod.rs:115 — ToolCallingMatcher::new_with_format has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (17 pts), loops 1 (2 pts), match/switch 1 (nesting depth added 11). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • ToolCallingMatcher::get_call_with_content (cognitive 19) mistralrs-core/src/tools/mod.rs:234 — ToolCallingMatcher::get_call_with_content has cognitive complexity 19 (threshold 15). Drivers by points: if/else 14 (18 pts), boolean chains 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · HybridCache · ×2
  • HybridCache::allocate_slot (cognitive 19) mistralrs-core/src/kv_cache/hybrid_cache.rs:1972 — HybridCache::allocate_slot has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (12 pts), loops 2 (4 pts), match/switch 2 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • HybridCache::reserve_gdn_deferred_state (cognitive 17) mistralrs-core/src/kv_cache/hybrid_cache.rs:1718 — HybridCache::reserve_gdn_deferred_state has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (15 pts), loops 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D29 · Static Analysis (SAST) · REDACTED · ×2
  • REDACTED
  • REDACTED
D30 · Dependency Vulnerabilities · Medium CVE · ×2
  • REDACTED
  • REDACTED
D4 · Code Duplication · Near-duplicate member family (24 members, 23 shared lines) · ×2
  • Near-duplicate member family (24 members, 23 shared lines) mistralrs-core/src/models/flint.rs:347 — mistralrs-core/src/models/flint.rs:347-454 | mistralrs-core/src/models/gemma.rs:167-249 | mistralrs-core/src/models/gemma2.rs:208-297 | mistralrs-core/src/models/glm4.rs:209-296 | mistralrs-core/src/models/glm4_moe.rs:272-361 | mistralrs-core/src/models/gpt_oss.rs:248-326 | mistralrs-core/src/models/hunyuan_v1_dense.rs:191-272 | mistralrs-core/src/models/hunyuan_v1_moe.rs:374-458 | mistralrs-core/src/models/mistral.rs:206-297 | mistralrs-core/src/models/mixtral.rs:151-233 | mistralrs-core/src/models/phi2.rs:254-347 | mistralrs-core/src/models/phi3.rs:143-236 | mistralrs-core/src/models/phi3_5_moe.rs:178-263 | mistralrs-core/src/models/qwen2.rs:240-327 | mistralrs-core/src/models/qwen3.rs:192-282 | mistralrs-core/src/models/qwen3_moe.rs:195-285 | mistralrs-core/src/models/qwen3_next.rs:272-378 | mistralrs-core/src/models/starcoder2.rs:227-309 | mistralrs-core/src/vision_models/phi3/mod.rs:235-327 | mistralrs-core/src/vision_models/phi4/mod.rs:104-196 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:189-285 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:194-287 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:300-390 | mistralrs-core/src/vision_models/voxtral/mod.rs:126-208 — These 24 members are variants of one another: a block of 23 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 24 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 24 times.
  • Near-duplicate member family (24 members, 23 shared lines) mistralrs-core/src/models/flint.rs:347 — mistralrs-core/src/models/flint.rs:347-454 | mistralrs-core/src/models/gemma.rs:167-249 | mistralrs-core/src/models/gemma2.rs:208-297 | mistralrs-core/src/models/glm4.rs:209-296 | mistralrs-core/src/models/glm4_moe.rs:272-361 | mistralrs-core/src/models/gpt_oss.rs:248-326 | mistralrs-core/src/models/hunyuan_v1_dense.rs:191-272 | mistralrs-core/src/models/hunyuan_v1_moe.rs:374-458 | mistralrs-core/src/models/mistral.rs:206-297 | mistralrs-core/src/models/mixtral.rs:151-233 | mistralrs-core/src/models/phi2.rs:254-347 | mistralrs-core/src/models/phi3.rs:143-236 | mistralrs-core/src/models/phi3_5_moe.rs:178-263 | mistralrs-core/src/models/qwen2.rs:240-327 | mistralrs-core/src/models/qwen3.rs:192-282 | mistralrs-core/src/models/qwen3_moe.rs:195-285 | mistralrs-core/src/models/starcoder2.rs:227-309 | mistralrs-core/src/vision_models/phi3/mod.rs:235-327 | mistralrs-core/src/vision_models/phi4/mod.rs:104-196 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:194-294 | mistralrs-core/src/vision_models/qwen2vl/text.rs:195-295 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:194-287 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:300-390 | mistralrs-core/src/vision_models/voxtral/mod.rs:126-208 — These 24 members are variants of one another: a block of 23 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 24 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 24 times.
D4 · Code Duplication · Near-duplicate member family (6 members, 28 shared lines) · ×2
  • Near-duplicate member family (6 members, 28 shared lines) mistralrs-core/src/models/gemma.rs:346 — mistralrs-core/src/models/gemma.rs:346-456 | mistralrs-core/src/models/gemma2.rs:419-532 | mistralrs-core/src/models/mixtral.rs:405-520 | mistralrs-core/src/models/phi2.rs:430-540 | mistralrs-core/src/models/phi3.rs:407-532 | mistralrs-core/src/models/phi3_5_moe.rs:479-605 — These 6 members are variants of one another: a block of 28 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Near-duplicate member family (6 members, 28 shared lines) mistralrs-core/src/models/glm4.rs:439 — mistralrs-core/src/models/glm4.rs:439-564 | mistralrs-core/src/models/glm4_moe.rs:713-827 | mistralrs-core/src/models/hunyuan_v1_dense.rs:392-522 | mistralrs-core/src/models/hunyuan_v1_moe.rs:882-1016 | mistralrs-core/src/models/qwen3.rs:402-523 | mistralrs-core/src/models/qwen3_moe.rs:576-703 — These 6 members are variants of one another: a block of 28 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
D4 · Code Duplication · Near-duplicate member family (5 members, 27 shared lines) · ×2
  • Near-duplicate member family (5 members, 27 shared lines) mistralrs-core/src/xlora_models/gemma.rs:576 — mistralrs-core/src/xlora_models/gemma.rs:576-619 | mistralrs-core/src/xlora_models/mistral.rs:570-615 | mistralrs-core/src/xlora_models/mixtral.rs:700-745 | mistralrs-core/src/xlora_models/phi3.rs:521-568 | mistralrs-core/src/xlora_models/starcoder2.rs:553-600 — These 5 members are variants of one another: a block of 27 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Near-duplicate member family (5 members, 27 shared lines) mistralrs-core/src/xlora_models/gemma.rs:576 — mistralrs-core/src/xlora_models/gemma.rs:576-619 | mistralrs-core/src/xlora_models/mistral.rs:570-615 | mistralrs-core/src/xlora_models/mixtral.rs:700-745 | mistralrs-core/src/xlora_models/phi2.rs:543-585 | mistralrs-core/src/xlora_models/starcoder2.rs:553-600 — These 5 members are variants of one another: a block of 27 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D4 · Code Duplication · Near-duplicate member family (5 members, 24 shared lines) · ×2
  • Near-duplicate member family (5 members, 24 shared lines) mistralrs-core/src/embedding_models/qwen3_embedding.rs:93 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:93-171 | mistralrs-core/src/models/qwen3.rs:104-183 | mistralrs-core/src/models/qwen3_moe.rs:107-186 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:106-183 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:212-289 — These 5 members are variants of one another: a block of 24 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Near-duplicate member family (5 members, 24 shared lines) mistralrs-core/src/embedding_models/qwen3_embedding.rs:93 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:93-171 | mistralrs-core/src/models/glm4.rs:126-199 | mistralrs-core/src/models/glm4_moe.rs:177-263 | mistralrs-core/src/models/qwen3.rs:104-183 | mistralrs-core/src/models/qwen3_moe.rs:107-186 — These 5 members are variants of one another: a block of 24 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D4 · Code Duplication · Near-duplicate member family (3 members, 25 shared lines) · ×2
  • Near-duplicate member family (3 members, 25 shared lines) mistralrs-core/src/vision_models/grid_processor.rs:2066 — mistralrs-core/src/vision_models/grid_processor.rs:2066-2163 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:1131-1197 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1696-1762 — These 3 members are variants of one another: a block of 25 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
  • Near-duplicate member family (3 members, 25 shared lines) mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:319 — mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:319-358 | mistralrs-core/src/vision_models/qwen2vl/text.rs:320-359 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:308-340 — These 3 members are variants of one another: a block of 25 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
D4 · Code Duplication · Near-duplicate member pair (85 shared lines) · ×2
  • Near-duplicate member pair (85 shared lines) mistralrs-core/src/vision_models/gemma3n/audio.rs:587 — mistralrs-core/src/vision_models/gemma3n/audio.rs:587-844 | mistralrs-core/src/vision_models/gemma4/audio.rs:643-812 — These two members are variants of one another: 85 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
  • Near-duplicate member pair (85 shared lines) mistralrs-core/src/vision_models/phi3/mod.rs:532 — mistralrs-core/src/vision_models/phi3/mod.rs:532-679 | mistralrs-core/src/vision_models/phi4/image_embedding.rs:130-311 — These two members are variants of one another: 85 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (80 shared lines) · ×2
  • Near-duplicate member pair (80 shared lines) mistralrs-core/src/models/lfm2.rs:1177 — mistralrs-core/src/models/lfm2.rs:1177-1307 | mistralrs-core/src/models/lfm3.rs:1175-1321 — These two members are variants of one another: 80 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
  • Near-duplicate member pair (80 shared lines) mistralrs-quant/src/cutile/nvfp4_gemv.rs:62 — mistralrs-quant/src/cutile/nvfp4_gemv.rs:62-148 | mistralrs-quant/src/cutile/nvfp4_gemv.rs:166-252 — These two members are variants of one another: 80 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (73 shared lines) · ×2
  • Near-duplicate member pair (73 shared lines) mistralrs-core/src/models/lfm2.rs:1009 — mistralrs-core/src/models/lfm2.rs:1009-1161 | mistralrs-core/src/models/lfm3.rs:911-1084 — These two members are variants of one another: 73 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
  • Near-duplicate member pair (73 shared lines) mistralrs-core/src/vision_models/gemma3n/audio.rs:292 — mistralrs-core/src/vision_models/gemma3n/audio.rs:292-408 | mistralrs-core/src/vision_models/gemma4/audio.rs:113-203 — These two members are variants of one another: 73 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (65 shared lines) · ×2
  • Near-duplicate member pair (65 shared lines) mistralrs-core/src/ops.rs:2008 — mistralrs-core/src/ops.rs:2008-2118 | mistralrs-core/src/ops.rs:2125-2275 — These two members are variants of one another: 65 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
  • Near-duplicate member pair (65 shared lines) mistralrs-quant/src/cutile/fused_moe.rs:463 — mistralrs-quant/src/cutile/fused_moe.rs:463-592 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:882-1035 — These two members are variants of one another: 65 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (50 shared lines) · ×2
  • Near-duplicate member pair (50 shared lines) mistralrs-core/src/xlora_models/mixtral.rs:354 — mistralrs-core/src/xlora_models/mixtral.rs:354-421 | mistralrs-core/src/xlora_models/quantized_llama.rs:94-168 — These two members are variants of one another: 50 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
  • Near-duplicate member pair (50 shared lines) mistralrs-quant/src/cublaslt/matmul.rs:407 — mistralrs-quant/src/cublaslt/matmul.rs:407-515 | mistralrs-quant/src/cublaslt/matmul.rs:531-612 — These two members are variants of one another: 50 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (47 shared lines) · ×2
  • Near-duplicate member pair (47 shared lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7804 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7804-7870 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:8326-8408 — These two members are variants of one another: 47 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
  • Near-duplicate member pair (47 shared lines) mistralrs-core/src/moe/experts/mod.rs:108 — mistralrs-core/src/moe/experts/mod.rs:108-189 | mistralrs-core/src/moe/experts/mod.rs:200-260 — These two members are variants of one another: 47 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (46 shared lines) · ×2
  • Near-duplicate member pair (46 shared lines) mistralrs-paged-attn/src/metal/kernels/mod.rs:425 — mistralrs-paged-attn/src/metal/kernels/mod.rs:425-484 | mistralrs-paged-attn/src/metal/kernels/mod.rs:814-879 — These two members are variants of one another: 46 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
  • Near-duplicate member pair (46 shared lines) mistralrs-quant/src/cutile/fp8_w8a16.rs:652 — mistralrs-quant/src/cutile/fp8_w8a16.rs:652-727 | mistralrs-quant/src/cutile/fp8_w8a8.rs:743-836 — These two members are variants of one another: 46 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (36 shared lines) · ×2
  • Near-duplicate member pair (36 shared lines) mistralrs-paged-attn/src/cuda/backend/flash_attn_sinks.rs:25 — mistralrs-paged-attn/src/cuda/backend/flash_attn_sinks.rs:25-122 | mistralrs-paged-attn/src/cuda/backend/flash_attn_sinks.rs:164-291 — These two members are variants of one another: 36 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
  • Near-duplicate member pair (36 shared lines) mistralrs-quant/src/blockwise_fp8/ops.rs:778 — mistralrs-quant/src/blockwise_fp8/ops.rs:778-890 | mistralrs-quant/src/blockwise_fp8/ops.rs:893-1001 — These two members are variants of one another: 36 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (35 shared lines) · ×2
  • Near-duplicate member pair (35 shared lines) mistralrs-quant/src/utils/ops.rs:44 — mistralrs-quant/src/utils/ops.rs:44-93 | mistralrs-quant/src/utils/ops.rs:690-743 — These two members are variants of one another: 35 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
  • Near-duplicate member pair (35 shared lines) mistralrs-quant/src/blockwise_fp8/deepgemm.rs:574 — mistralrs-quant/src/blockwise_fp8/deepgemm.rs:574-668 | mistralrs-quant/src/blockwise_fp8/ops.rs:1992-2098 — These two members are variants of one another: 35 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (33 shared lines) · ×2
  • Near-duplicate member pair (33 shared lines) mistralrs-quant/src/distributed/layers.rs:528 — mistralrs-quant/src/distributed/layers.rs:528-614 | mistralrs-quant/src/distributed/layers.rs:919-1010 — These two members are variants of one another: 33 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
  • Near-duplicate member pair (33 shared lines) mistralrs/src/model.rs:384 — mistralrs/src/model.rs:384-454 | mistralrs/src/model.rs:472-541 — These two members are variants of one another: 33 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Members sharing a duplicated core (11 members, 50+ identical tokens) · ×2
  • Members sharing a duplicated core (11 members, 50+ identical tokens) mistralrs-core/src/cuda/dflash_context.rs:263 — mistralrs-core/src/cuda/dflash_context.rs:263-379 | mistralrs-core/src/cuda/speculative_rejection.rs:474-630 | mistralrs-core/src/ops.rs:1045-1271 | mistralrs-core/src/ops.rs:1287-1478 | mistralrs-core/src/ops.rs:1499-1707 | mistralrs-core/src/ops.rs:1712-2002 | mistralrs-core/src/ops.rs:4121-4187 | mistralrs-core/src/ops.rs:4272-4392 | mistralrs-core/src/ops.rs:5596-5898 | mistralrs-core/src/ops.rs:6025-6343 | mistralrs-core/src/ops.rs:6361-6661 — These 11 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 11 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 11 times.
  • Members sharing a duplicated core (11 members, 50+ identical tokens) mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:396 — mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:396-690 | mistralrs-core/src/vision_models/gemma3n/inputs_processor.rs:323-458 | mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:423-670 | mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:436-712 | mistralrs-core/src/vision_models/llama4/inputs_processor.rs:406-613 | mistralrs-core/src/vision_models/mistral3/inputs_processor.rs:268-481 | mistralrs-core/src/vision_models/mllama/inputs_processor.rs:334-663 | mistralrs-core/src/vision_models/muse_glimmer/inputs_processor.rs:918-1102 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:366-973 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:932-1538 | mistralrs-core/src/vision_models/voxtral/inputs_processor.rs:209-363 — These 11 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 11 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 11 times.
D4 · Code Duplication · Members sharing a duplicated core (9 members, 50+ identical tokens) · ×2
  • Members sharing a duplicated core (9 members, 50+ identical tokens) mistralrs-core/src/metal/gdn.rs:161 — mistralrs-core/src/metal/gdn.rs:161-237 | mistralrs-core/src/metal/gdn.rs:272-342 | mistralrs-core/src/metal/gdn.rs:374-431 | mistralrs-core/src/metal/gdn.rs:491-582 | mistralrs-core/src/metal/gdn.rs:586-633 | mistralrs-core/src/metal/gdn.rs:646-698 | mistralrs-core/src/metal/gdn.rs:753-908 | mistralrs-core/src/metal/gdn.rs:937-1002 | mistralrs-core/src/metal/ssm.rs:132-212 — These 9 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 9 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 9 times.
  • Members sharing a duplicated core (9 members, 50+ identical tokens) mistralrs-core/src/models/flint.rs:593 — mistralrs-core/src/models/flint.rs:593-615 | mistralrs-core/src/models/gpt_oss.rs:513-615 | mistralrs-core/src/models/lfm2.rs:327-360 | mistralrs-core/src/models/phi3_5_moe.rs:362-378 | mistralrs-core/src/models/qwen3_moe.rs:399-426 | mistralrs-core/src/models/qwen3_next.rs:470-507 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:374-409 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:138-165 | mistralrs-core/src/vision_models/qwen4_exp/text.rs:152-178 — These 9 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 9 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 9 times.
D4 · Code Duplication · Edited copy of a member (94 corresponding lines) · ×2
  • Edited copy of a member (94 corresponding lines) mistralrs-core/src/kv_cache/mod.rs:1393 — mistralrs-core/src/kv_cache/mod.rs:1393-1486 | mistralrs-core/src/kv_cache/mod.rs:1494-1594 — These two members are one piece of code written twice and then edited apart: 94 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (94 corresponding lines) mistralrs-mcp/src/client.rs:420 — mistralrs-mcp/src/client.rs:420-513 | mistralrs-mcp/src/client.rs:568-668 — These two members are one piece of code written twice and then edited apart: 94 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (79 corresponding lines) · ×2
  • Edited copy of a member (79 corresponding lines) mistralrs-core/src/vision_models/gemma3n/audio.rs:432 — mistralrs-core/src/vision_models/gemma3n/audio.rs:432-538 | mistralrs-core/src/vision_models/gemma4/audio.rs:527-605 — These two members are one piece of code written twice and then edited apart: 79 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (79 corresponding lines) mistralrs-quant/src/utils/ops.rs:855 — mistralrs-quant/src/utils/ops.rs:855-937 | mistralrs-quant/src/utils/ops.rs:962-1040 — These two members are one piece of code written twice and then edited apart: 79 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (55 corresponding lines) · ×2
  • Edited copy of a member (55 corresponding lines) mistralrs-core/src/layers.rs:912 — mistralrs-core/src/layers.rs:912-975 | mistralrs-core/src/layers.rs:2245-2299 — These two members are one piece of code written twice and then edited apart: 55 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (55 corresponding lines) mistralrs-quant/src/cutile/fused_moe.rs:924 — mistralrs-quant/src/cutile/fused_moe.rs:924-978 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:1121-1180 — These two members are one piece of code written twice and then edited apart: 55 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (47 corresponding lines) · ×2
  • Edited copy of a member (47 corresponding lines) mistralrs-quant/src/gguf/cuda.rs:1243 — mistralrs-quant/src/gguf/cuda.rs:1243-1294 | mistralrs-quant/src/gguf/cuda.rs:1308-1354 — These two members are one piece of code written twice and then edited apart: 47 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (47 corresponding lines) mistralrs-core/src/attention/backends/cpu/neon.rs:306 — mistralrs-core/src/attention/backends/cpu/neon.rs:306-356 | mistralrs-core/src/attention/backends/cpu/neon.rs:550-596 — These two members are one piece of code written twice and then edited apart: 47 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (68 corresponding lines) · ×2
  • Edited copy of a member (68 corresponding lines) mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:801 — mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:801-882 | mistralrs-core/src/vision_models/gemma3n/inputs_processor.rs:733-800 — These two members are one piece of code written twice and then edited apart: 68 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (68 corresponding lines) mistralrs-core/src/models/phi3_5_moe.rs:102 — mistralrs-core/src/models/phi3_5_moe.rs:102-169 | mistralrs-core/src/vision_models/muse_glimmer/text.rs:144-219 — These two members are one piece of code written twice and then edited apart: 68 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (48 corresponding lines) · ×2
  • Edited copy of a member (48 corresponding lines) mistralrs-core/src/vision_models/gemma3/text.rs:777 — mistralrs-core/src/vision_models/gemma3/text.rs:777-836 | mistralrs-core/src/vision_models/gemma4/text.rs:2449-2496 — These two members are one piece of code written twice and then edited apart: 48 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (48 corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7525 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7525-7572 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:8000-8062 — These two members are one piece of code written twice and then edited apart: 48 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (49 corresponding lines) · ×2
  • Edited copy of a member (49 corresponding lines) mistralrs-core/src/vision_models/grid_processor.rs:783 — mistralrs-core/src/vision_models/grid_processor.rs:783-831 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:481-554 — These two members are one piece of code written twice and then edited apart: 49 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (49 corresponding lines) mistralrs/src/gguf_lora_model.rs:32 — mistralrs/src/gguf_lora_model.rs:32-80 | mistralrs/src/gguf_xlora_model.rs:40-90 — These two members are one piece of code written twice and then edited apart: 49 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 24+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 24+ corresponding lines) mistralrs-core/src/layers.rs:2364 — mistralrs-core/src/layers.rs:2364-2387 | mistralrs-core/src/layers.rs:2462-2485 | mistralrs-core/src/layers.rs:2509-2532 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 24 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 24+ corresponding lines) mistralrs-core/src/layers.rs:3900 — mistralrs-core/src/layers.rs:3900-3926 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:275-298 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:100-124 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 24 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 20+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 20+ corresponding lines) mistralrs-core/src/layers.rs:877 — mistralrs-core/src/layers.rs:877-900 | mistralrs-core/src/layers.rs:2039-2058 | mistralrs-core/src/layers.rs:2213-2236 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 20 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 20+ corresponding lines) mistralrs-pyo3/src/code_execution.rs:361 — mistralrs-pyo3/src/code_execution.rs:361-380 | mistralrs-pyo3/src/code_execution.rs:384-403 | mistralrs-pyo3/src/code_execution.rs:405-424 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 20 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copy of a member (43 corresponding lines) · ×2
  • Edited copy of a member (43 corresponding lines) mistralrs/src/auto_model.rs:97 — mistralrs/src/auto_model.rs:97-141 | mistralrs/src/text_model.rs:127-169 — These two members are one piece of code written twice and then edited apart: 43 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (43 corresponding lines) mistralrs-code-exec/src/tools.rs:144 — mistralrs-code-exec/src/tools.rs:144-186 | mistralrs-code-exec/src/tools.rs:330-372 — These two members are one piece of code written twice and then edited apart: 43 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 32+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 32+ corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2707 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2707-2738 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3415-3448 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4135-4166 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 32 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 32+ corresponding lines) mistralrs/src/messages.rs:609 — mistralrs/src/messages.rs:609-640 | mistralrs/src/messages.rs:644-675 | mistralrs/src/messages.rs:686-717 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 32 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 21+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 21+ corresponding lines) mistralrs-core/src/lib.rs:857 — mistralrs-core/src/lib.rs:857-880 | mistralrs-core/src/lib.rs:906-928 | mistralrs-core/src/lib.rs:1024-1044 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 21 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 21+ corresponding lines) mistralrs-core/src/vision_models/llama4/vision.rs:374 — mistralrs-core/src/vision_models/llama4/vision.rs:374-394 | mistralrs-core/src/vision_models/muse_glimmer/vision.rs:397-417 | mistralrs-core/src/vision_models/muse_glimmer/vision.rs:489-509 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 21 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 19+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 19+ corresponding lines) mistralrs-paged-attn/src/cuda/backend/gather_kv.rs:14 — mistralrs-paged-attn/src/cuda/backend/gather_kv.rs:14-36 | mistralrs-paged-attn/src/cuda/backend/paged_attention.rs:39-57 | mistralrs-paged-attn/src/metal/backend/mod.rs:50-68 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 19 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 19+ corresponding lines) mistralrs-cli/src/ui/handlers/api.rs:35 — mistralrs-cli/src/ui/handlers/api.rs:35-53 | mistralrs-cli/src/ui/handlers/api.rs:58-76 | mistralrs-cli/src/ui/handlers/api.rs:81-99 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 19 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 18+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 18+ corresponding lines) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1001 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1001-1018 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2381-2398 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2605-2622 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 18 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 18+ corresponding lines) mistralrs-core/src/models/gemma2.rs:375 — mistralrs-core/src/models/gemma2.rs:375-393 | mistralrs-core/src/vision_models/gemma3/text.rs:385-404 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:351-368 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 18 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 8+ corresponding lines) · ×2
  • Edited copies of one member (4 members, 8+ corresponding lines) mistralrs-core/src/vision_models/muse_glimmer/vision.rs:472 — mistralrs-core/src/vision_models/muse_glimmer/vision.rs:472-479 | mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:266-273 | mistralrs-core/src/vision_models/qwen2vl/vision.rs:238-245 | mistralrs-core/src/vision_models/qwen3_vl/vision.rs:302-309 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 8 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
  • Edited copies of one member (4 members, 8+ corresponding lines) REDACTED:611 — REDACTED:611-618 | mistralrs-core/src/vision_models/idefics3/vision.rs:408-415 | mistralrs-core/src/vision_models/mistral3/vision.rs:256-264 | mistralrs-core/src/vision_models/siglip.rs:419-426 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 8 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (5 members, 16+ corresponding lines) · ×2
  • Edited copies of one member (5 members, 16+ corresponding lines) mistralrs-core/src/pipeline/loaders/lfm3.rs:241 — mistralrs-core/src/pipeline/loaders/lfm3.rs:241-261 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:10643-10658 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5132-5149 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6359-6376 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:7159-7175 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 16 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 5 times and the copies will drift further apart.
  • Edited copies of one member (5 members, 16+ corresponding lines) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3708 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3708-3723 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3919-3935 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4168-4184 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4399-4415 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5266-5282 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 16 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 5 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 7+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 7+ corresponding lines) mistralrs-flash-attn/src/flash.rs:252 — mistralrs-flash-attn/src/flash.rs:252-258 | mistralrs-flash-attn/src/flash.rs:860-866 | mistralrs-quant/src/gptq/marlin_backend.rs:191-197 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 7 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 7+ corresponding lines) mistralrs-core/src/vision_models/lfm3_omni/audio.rs:499 — mistralrs-core/src/vision_models/lfm3_omni/audio.rs:499-505 | mistralrs-core/src/vision_models/lfm3_vl/mod.rs:84-90 | mistralrs-core/src/vision_models/mistral3/mod.rs:154-165 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 7 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (5 members, 13+ corresponding lines) · ×2
  • Edited copies of one member (5 members, 13+ corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:979 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:979-991 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1306-1319 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3769-3782 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4925-4939 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9189-9202 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 13 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 5 times and the copies will drift further apart.
  • Edited copies of one member (5 members, 13+ corresponding lines) mistralrs-core/src/lib.rs:2217 — mistralrs-core/src/lib.rs:2217-2229 | mistralrs-core/src/lib.rs:2235-2247 | mistralrs-core/src/lib.rs:2253-2265 | mistralrs-core/src/lib.rs:2527-2541 | mistralrs-core/src/lib.rs:2590-2604 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 13 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 5 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 10+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 10+ corresponding lines) mistralrs-core/src/speculative/dflash.rs:2736 — mistralrs-core/src/speculative/dflash.rs:2736-2745 | mistralrs-core/src/speculative/dflash.rs:2866-2880 | mistralrs-core/src/speculative/dflash.rs:2941-2954 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 10 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 10+ corresponding lines) mistralrs-core/src/ops.rs:6916 — mistralrs-core/src/ops.rs:6916-6925 | mistralrs-core/src/ops.rs:6943-6952 | mistralrs-quant/src/routed_moe/mod.rs:40-49 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 10 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Duplicated block (65 lines × 3) · ×2
  • Duplicated block (65 lines × 3) mistralrs-core/src/embedding_models/qwen3_embedding.rs:94 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:94-158 | mistralrs-core/src/models/qwen3.rs:105-169 | mistralrs-core/src/models/qwen3_moe.rs:108-172 — `mistralrs-core/src/embedding_models/qwen3_embedding.rs` and `mistralrs-core/src/models/qwen3.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 26 separate duplicated blocks between them, totalling at least 364 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/qwen3_embedding.rs:94` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (65 lines × 3) mistralrs-core/src/models/llama.rs:639 — mistralrs-core/src/models/llama.rs:639-703 | mistralrs-core/src/models/smollm3.rs:658-722 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:655-719 — before extracting anything, compare `mistralrs-core/src/models/llama.rs` and `mistralrs-core/src/models/smollm3.rs` as WHOLE FILES: this scan already matched 47 separate duplicated blocks between them, totalling at least 727 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/llama.rs:639` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (48 lines × 3) · ×2
  • Duplicated block (48 lines × 3) mistralrs-core/src/models/qwen2.rs:165 — mistralrs-core/src/models/qwen2.rs:165-212 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:122-169 | mistralrs-core/src/vision_models/qwen2vl/text.rs:123-170 — before extracting anything, compare `mistralrs-core/src/models/qwen2.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/text.rs` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 319 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/qwen2.rs:165` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (48 lines × 3) mistralrs-core/src/vision_models/grid_processor.rs:1646 — mistralrs-core/src/vision_models/grid_processor.rs:1646-1693 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:818-865 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1383-1430 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:1646` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (44 lines × 2) · ×2
  • Duplicated block (44 lines × 2) mistralrs-core/src/lora/loralinear.rs:37 — mistralrs-core/src/lora/loralinear.rs:37-80 | mistralrs-core/src/lora/qloralinear.rs:80-123 — before extracting anything, compare `mistralrs-core/src/lora/loralinear.rs` and `mistralrs-core/src/lora/qloralinear.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 151 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/lora/qloralinear.rs:79` calls `pp`, `clone` and `mistralrs-core/src/lora/loralinear.rs:36` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (44 lines × 2) mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:754 — mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:754-797 | mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:975-1018 — before extracting anything, compare `mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs` and `mistralrs-core/src/vision_models/idefics3/inputs_processor.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 120 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:754` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (36 lines × 3) · ×2
  • Duplicated block (36 lines × 3) mistralrs-core/src/gguf/gemma3_bindings.rs:180 — mistralrs-core/src/gguf/gemma3_bindings.rs:180-215 | mistralrs-core/src/gguf/idefics3_bindings.rs:49-84 | mistralrs-core/src/gguf/lfm2_vl_bindings.rs:84-119 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/gguf/gemma3_bindings.rs:180` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (36 lines × 3) mistralrs-core/src/models/qwen3_next.rs:898 — mistralrs-core/src/models/qwen3_next.rs:898-933 | mistralrs-core/src/vision_models/qwen3_5/text.rs:1009-1044 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:721-756 — before extracting anything, compare `mistralrs-core/src/models/qwen3_next.rs` and `mistralrs-core/src/vision_models/qwen3_5/text.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 176 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/models/qwen3_next.rs:935` calls `get_comm_for`, `world_size` and `mistralrs-core/src/vision_models/qwen3_5/text.rs:1046` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (34–35 lines × 2) · ×2
  • Duplicated block (34–35 lines × 2) mistralrs-core/src/gguf/gemma3_bindings.rs:131 — mistralrs-core/src/gguf/gemma3_bindings.rs:131-165 | mistralrs-core/src/gguf/muse_glimmer_bindings.rs:67-100 — before extracting anything, compare `mistralrs-core/src/gguf/gemma3_bindings.rs` and `mistralrs-core/src/gguf/muse_glimmer_bindings.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 62 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (34–35 lines × 2) mistralrs-quant/src/cutile/fused_moe.rs:59 — mistralrs-quant/src/cutile/fused_moe.rs:59-93 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:74-107 — before extracting anything, compare `mistralrs-quant/src/cutile/fused_moe.rs` and `mistralrs-quant/src/cutile/fused_moe_fp8.rs` as WHOLE FILES: this scan already matched 24 separate duplicated blocks between them, totalling at least 298 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cutile/fused_moe.rs:59` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (30 lines × 4) · ×2
  • Duplicated block (30 lines × 4) mistralrs-core/src/models/deepseek2.rs:884 — mistralrs-core/src/models/deepseek2.rs:884-913 | mistralrs-core/src/models/deepseek3.rs:947-976 | mistralrs-core/src/models/glm4_moe.rs:783-812 | mistralrs-core/src/models/glm4_moe_lite.rs:894-923 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:884` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (30 lines × 4) mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:530 — mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:530-559 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4729-4758 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1030-1059 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2410-2439 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/embedding_loaders.rs` and `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 180 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (29 lines × 3) · ×2
  • Duplicated block (29 lines × 3) mistralrs-core/src/vision_models/grid_processor.rs:2024 — mistralrs-core/src/vision_models/grid_processor.rs:2024-2052 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:1089-1117 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1654-1682 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:2024` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:1086` calls `context` and `mistralrs-core/src/vision_models/grid_processor.rs:2022` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (29 lines × 3) mistralrs-quant/src/gguf/fast_mmvq.rs:923 — mistralrs-quant/src/gguf/fast_mmvq.rs:923-951 | mistralrs-quant/src/gguf/fast_mmvq.rs:962-990 | mistralrs-quant/src/gguf/fast_mmvq.rs:1001-1029 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/gguf/fast_mmvq.rs:923` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (26–29 lines × 2) · ×2
  • Duplicated block (26–29 lines × 2) mistralrs-core/src/gguf/llama4_bindings.rs:51 — mistralrs-core/src/gguf/llama4_bindings.rs:51-76 | mistralrs-core/src/gguf/multimodal_binding_utils.rs:220-248 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (26–29 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7829 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7829-7854 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:8351-8379 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7829` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (27–28 lines × 2) · ×2
  • Duplicated block (27–28 lines × 2) mistralrs-quant/src/cutile/qsa_decode.rs:340 — mistralrs-quant/src/cutile/qsa_decode.rs:340-366 | mistralrs-quant/src/cutile/qsa_decode.rs:369-396 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cutile/qsa_decode.rs:369` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (27–28 lines × 2) mistralrs/src/model_builder_trait.rs:298 — mistralrs/src/model_builder_trait.rs:298-325 | mistralrs/src/model_builder_trait.rs:698-724 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs/src/model_builder_trait.rs:295` calls `with_model_id`, `clone` and `mistralrs/src/model_builder_trait.rs:696` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (27 lines × 3) · ×2
  • Duplicated block (27 lines × 3) mistralrs-core/src/models/qwen3_next.rs:1142 — mistralrs-core/src/models/qwen3_next.rs:1142-1168 | mistralrs-core/src/vision_models/qwen3_5/text.rs:1752-1778 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:972-998 — before extracting anything, compare `mistralrs-core/src/models/qwen3_next.rs` and `mistralrs-core/src/vision_models/qwen3_5/text.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 176 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (27 lines × 3) REDACTED:271 — REDACTED:271-297 | mistralrs-core/src/vision_models/idefics3/vision.rs:83-109 | mistralrs-core/src/vision_models/siglip.rs:74-100 — before extracting anything, compare `REDACTED` and `mistralrs-core/src/vision_models/idefics3/vision.rs` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 221 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/vision_models/siglip.rs:68` calls `pub` and `REDACTED:265` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (22–27 lines × 2) · ×2
  • Duplicated block (22–27 lines × 2) mistralrs-core/src/vision_models/gemma3n/audio.rs:619 — mistralrs-core/src/vision_models/gemma3n/audio.rs:619-645 | mistralrs-core/src/vision_models/gemma4/audio.rs:674-695 — `mistralrs-core/src/vision_models/gemma3n/audio.rs` and `mistralrs-core/src/vision_models/gemma4/audio.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 20 separate duplicated blocks between them, totalling at least 352 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3n/audio.rs:619` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (22–27 lines × 2) mistralrs-quant/src/mxfp4/ops.rs:22 — mistralrs-quant/src/mxfp4/ops.rs:22-43 | mistralrs-quant/src/mxfp4/ops.rs:320-346 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (25–27 lines × 2) · ×2
  • Duplicated block (25–27 lines × 2) mistralrs-core/src/xlora_models/mixtral.rs:397 — mistralrs-core/src/xlora_models/mixtral.rs:397-421 | mistralrs-core/src/xlora_models/quantized_llama.rs:137-163 — before extracting anything, compare `mistralrs-core/src/xlora_models/mixtral.rs` and `mistralrs-core/src/xlora_models/quantized_llama.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 118 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/mixtral.rs:397` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (25–27 lines × 2) mistralrs/src/gguf_lora_model.rs:43 — mistralrs/src/gguf_lora_model.rs:43-69 | mistralrs/src/gguf_xlora_model.rs:50-74 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs/src/gguf_lora_model.rs:43` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (25–26 lines × 2) · ×2
  • Duplicated block (25–26 lines × 2) mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:339 — mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:339-363 | mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:485-510 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:339` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (25–26 lines × 2) mistralrs-quant/src/safetensors.rs:786 — mistralrs-quant/src/safetensors.rs:786-811 | mistralrs-quant/src/safetensors.rs:862-886 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/safetensors.rs:786` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (24–25 lines × 2) · ×2
  • Duplicated block (24–25 lines × 2) mistralrs-code-exec/src/lib.rs:340 — mistralrs-code-exec/src/lib.rs:340-364 | mistralrs-code-exec/src/shell.rs:354-377 — before extracting anything, compare `mistralrs-code-exec/src/lib.rs` and `mistralrs-code-exec/src/shell.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 64 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (24–25 lines × 2) mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:762 — mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:762-785 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1326-1350 — `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` and `mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 45 separate duplicated blocks between them, totalling at least 1082 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:762` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (23 lines × 4) · ×2
  • Duplicated block (23 lines × 4) mistralrs-core/src/models/deepseek2.rs:821 — mistralrs-core/src/models/deepseek2.rs:821-843 | mistralrs-core/src/models/deepseek3.rs:884-906 | mistralrs-core/src/models/glm4_moe.rs:721-743 | mistralrs-core/src/models/glm4_moe_lite.rs:831-853 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:821` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (23 lines × 4) mistralrs-core/src/xlora_models/gemma.rs:322 — mistralrs-core/src/xlora_models/gemma.rs:322-344 | mistralrs-core/src/xlora_models/gemma2.rs:331-353 | mistralrs-core/src/xlora_models/mistral.rs:318-340 | mistralrs-core/src/xlora_models/starcoder2.rs:307-329 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/gemma2.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 498 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (23 lines × 3) · ×2
  • Duplicated block (23 lines × 3) mistralrs-cli/src/commands/run/interactive.rs:528 — mistralrs-cli/src/commands/run/interactive.rs:528-550 | mistralrs-cli/src/commands/run/interactive.rs:1025-1047 | mistralrs-cli/src/commands/run/interactive.rs:1813-1835 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-cli/src/commands/run/interactive.rs:528` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (23 lines × 3) mistralrs-quant/src/metal_kernels/mod.rs:701 — mistralrs-quant/src/metal_kernels/mod.rs:701-723 | mistralrs-quant/src/metal_kernels/mod.rs:748-770 | mistralrs-quant/src/metal_kernels/mod.rs:795-817 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/metal_kernels/mod.rs:701` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (22 lines × 3) · ×2
  • Duplicated block (22 lines × 3) mistralrs-core/src/models/deepseek2.rs:256 — mistralrs-core/src/models/deepseek2.rs:256-277 | mistralrs-core/src/models/deepseek3.rs:257-278 | mistralrs-core/src/models/glm4_moe_lite.rs:217-238 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:256` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (22 lines × 3) mistralrs-core/src/pipeline/inputs_processor.rs:2737 — mistralrs-core/src/pipeline/inputs_processor.rs:2737-2758 | mistralrs-core/src/pipeline/inputs_processor.rs:2781-2802 | mistralrs-core/src/pipeline/inputs_processor.rs:2830-2851 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/inputs_processor.rs:2737` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (19–21 lines × 2) · ×2
  • Duplicated block (19–21 lines × 2) mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1238 — mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1238-1258 | mistralrs-core/src/vision_models/phi4/inputs_processor.rs:864-882 — `mistralrs-core/src/vision_models/gemma4/inputs_processor.rs` and `mistralrs-core/src/vision_models/phi4/inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 46 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1238` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (19–21 lines × 2) mistralrs-core/src/vision_models/phi4/audio_embedding.rs:306 — mistralrs-core/src/vision_models/phi4/audio_embedding.rs:306-324 | mistralrs-core/src/vision_models/phi4/image_embedding.rs:795-815 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
D4 · Code Duplication · Duplicated block (18–20 lines × 2) · ×2
  • Duplicated block (18–20 lines × 2) mistralrs-core/src/layers.rs:3975 — mistralrs-core/src/layers.rs:3975-3994 | mistralrs-core/src/layers.rs:4003-4020 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/layers.rs:3975` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18–20 lines × 2) mistralrs-core/src/utils/progress.rs:88 — mistralrs-core/src/utils/progress.rs:88-107 | mistralrs-core/src/utils/progress.rs:185-202 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (16–20 lines × 2) · ×2
  • Duplicated block (16–20 lines × 2) mistralrs-core/src/vision_models/gemma3n/audio.rs:708 — mistralrs-core/src/vision_models/gemma3n/audio.rs:708-727 | mistralrs-core/src/vision_models/gemma4/audio.rs:734-749 — `mistralrs-core/src/vision_models/gemma3n/audio.rs` and `mistralrs-core/src/vision_models/gemma4/audio.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 20 separate duplicated blocks between them, totalling at least 352 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3n/audio.rs:708` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (16–20 lines × 2) mistralrs-quant/src/afq/ops.rs:141 — mistralrs-quant/src/afq/ops.rs:141-156 | mistralrs-quant/src/afq/ops.rs:385-404 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/afq/ops.rs:141` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (17–18 lines × 3) · ×2
  • Duplicated block (17–18 lines × 3) mistralrs-core/src/models/flint.rs:705 — mistralrs-core/src/models/flint.rs:705-721 | mistralrs-core/src/models/qwen3_moe.rs:487-503 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:435-452 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/qwen3_moe.rs` as WHOLE FILES: this scan already matched 43 separate duplicated blocks between them, totalling at least 479 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/flint.rs:705` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (17–18 lines × 3) mistralrs-core/src/xlora_models/gemma.rs:193 — mistralrs-core/src/xlora_models/gemma.rs:193-210 | mistralrs-core/src/xlora_models/mistral.rs:183-199 | mistralrs-core/src/xlora_models/mixtral.rs:96-112 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/mistral.rs` as WHOLE FILES: this scan already matched 37 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma.rs:193` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (16–18 lines × 2) · ×2
  • Duplicated block (16–18 lines × 2) mistralrs-core/src/models/qwen3_moe.rs:768 — mistralrs-core/src/models/qwen3_moe.rs:768-783 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:732-749 — before extracting anything, compare `mistralrs-core/src/models/qwen3_moe.rs` and `mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs` as WHOLE FILES: this scan already matched 29 separate duplicated blocks between them, totalling at least 331 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/qwen3_moe.rs:768` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16–18 lines × 2) mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:304 — mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:304-319 | mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:442-459 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:304` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (17 lines × 4) · ×2
  • Duplicated block (17 lines × 4) mistralrs-core/src/models/qwen3_moe.rs:405 — mistralrs-core/src/models/qwen3_moe.rs:405-421 | mistralrs-core/src/models/qwen3_next.rs:476-492 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:380-396 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:144-160 — before extracting anything, compare `mistralrs-core/src/models/qwen3_moe.rs` and `mistralrs-core/src/models/qwen3_next.rs` as WHOLE FILES: this scan already matched 27 separate duplicated blocks between them, totalling at least 332 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/qwen3_moe.rs:405` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (17 lines × 4) mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:240 — mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:240-256 | mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:282-298 | mistralrs-core/src/vision_models/qwen2vl/mod.rs:397-413 | mistralrs-core/src/vision_models/qwen2vl/mod.rs:439-455 — `mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs` and `mistralrs-core/src/vision_models/qwen2vl/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 16 separate duplicated blocks between them, totalling at least 396 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:240` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (16–17 lines × 3) · ×2
  • Duplicated block (16–17 lines × 3) mistralrs-core/src/tools/parsers/gemma4.rs:295 — mistralrs-core/src/tools/parsers/gemma4.rs:295-310 | mistralrs-core/src/tools/parsers/gemma4.rs:336-351 | mistralrs-core/src/tools/parsers/gemma4.rs:372-388 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/tools/parsers/gemma4.rs:295` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16–17 lines × 3) mistralrs-core/src/xlora_models/gemma.rs:526 — mistralrs-core/src/xlora_models/gemma.rs:526-542 | mistralrs-core/src/xlora_models/gemma2.rs:556-572 | mistralrs-core/src/xlora_models/starcoder2.rs:504-519 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/gemma2.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 498 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma.rs:526` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/xlora_models/gemma.rs:544` calls `dtype` and `mistralrs-core/src/xlora_models/gemma2.rs:574` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (12–17 lines × 2) · ×2
  • Duplicated block (12–17 lines × 2) mistralrs-core/src/models/granite.rs:1104 — mistralrs-core/src/models/granite.rs:1104-1115 | mistralrs-core/src/models/granite.rs:1138-1154 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (12–17 lines × 2) mistralrs-core/src/vision_models/gemma3n/audio.rs:749 — mistralrs-core/src/vision_models/gemma3n/audio.rs:749-765 | mistralrs-core/src/vision_models/gemma4/audio.rs:757-768 — `mistralrs-core/src/vision_models/gemma3n/audio.rs` and `mistralrs-core/src/vision_models/gemma4/audio.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 20 separate duplicated blocks between them, totalling at least 352 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3n/audio.rs:749` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (15–17 lines × 2) · ×2
  • Duplicated block (15–17 lines × 2) mistralrs-core/src/vision_models/gemma3n/audio.rs:672 — mistralrs-core/src/vision_models/gemma3n/audio.rs:672-688 | mistralrs-core/src/vision_models/gemma4/audio.rs:702-716 — `mistralrs-core/src/vision_models/gemma3n/audio.rs` and `mistralrs-core/src/vision_models/gemma4/audio.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 20 separate duplicated blocks between them, totalling at least 352 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3n/audio.rs:672` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15–17 lines × 2) mistralrs-core/src/xlora_models/quantized_llama.rs:803 — mistralrs-core/src/xlora_models/quantized_llama.rs:803-819 | mistralrs-core/src/xlora_models/quantized_phi3.rs:471-485 — before extracting anything, compare `mistralrs-core/src/xlora_models/quantized_llama.rs` and `mistralrs-core/src/xlora_models/quantized_phi3.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 219 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (14–17 lines × 2) · ×2
  • Duplicated block (14–17 lines × 2) mistralrs-mcp/src/client.rs:441 — mistralrs-mcp/src/client.rs:441-454 | mistralrs-mcp/src/client.rs:596-612 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-mcp/src/client.rs:441` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (14–17 lines × 2) mistralrs-quant/src/metal_kernels/mod.rs:2667 — mistralrs-quant/src/metal_kernels/mod.rs:2667-2683 | mistralrs-quant/src/metal_kernels/mod.rs:2814-2827 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (15–16 lines × 7) · ×2
  • Duplicated block (15–16 lines × 7) mistralrs-core/src/models/glm4.rs:276 — mistralrs-core/src/models/glm4.rs:276-291 | mistralrs-core/src/models/glm4_moe.rs:341-356 | mistralrs-core/src/models/granite.rs:1602-1617 | mistralrs-core/src/vision_models/phi3/mod.rs:307-322 | mistralrs-core/src/vision_models/phi4/mod.rs:176-191 | mistralrs-core/src/vision_models/qwen3_5/text.rs:396-410 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:261-275 — before extracting anything, compare `mistralrs-core/src/models/glm4.rs` and `mistralrs-core/src/models/glm4_moe.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 359 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/glm4.rs:276` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/vision_models/qwen3_5/text.rs:393` calls `ok_or_else`, `msg` and `mistralrs-core/src/models/glm4.rs:275` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (15–16 lines × 7) mistralrs-core/src/xlora_models/gemma.rs:459 — mistralrs-core/src/xlora_models/gemma.rs:459-474 | mistralrs-core/src/xlora_models/gemma2.rs:490-504 | mistralrs-core/src/xlora_models/mistral.rs:456-470 | mistralrs-core/src/xlora_models/mixtral.rs:586-601 | mistralrs-core/src/xlora_models/phi2.rs:442-456 | mistralrs-core/src/xlora_models/phi3.rs:415-429 | mistralrs-core/src/xlora_models/starcoder2.rs:445-459 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/gemma2.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 498 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma.rs:459` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/xlora_models/gemma.rs:476` calls `clone` and `mistralrs-core/src/xlora_models/phi2.rs:458` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (16 lines × 6) · ×2
  • Duplicated block (16 lines × 6) mistralrs-core/src/vision_models/gemma3n/inputs_processor.rs:379 — mistralrs-core/src/vision_models/gemma3n/inputs_processor.rs:379-394 | mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1586-1601 | mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:483-498 | mistralrs-core/src/vision_models/lfm2_vl/inputs_processor.rs:735-750 | mistralrs-core/src/vision_models/llama4/inputs_processor.rs:461-476 | mistralrs-core/src/vision_models/mistral3/inputs_processor.rs:388-403 — before extracting anything, compare `mistralrs-core/src/vision_models/gemma3n/inputs_processor.rs` and `mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 98 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3n/inputs_processor.rs:379` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 6) mistralrs-core/src/xlora_models/gemma.rs:426 — mistralrs-core/src/xlora_models/gemma.rs:426-441 | mistralrs-core/src/xlora_models/gemma2.rs:457-472 | mistralrs-core/src/xlora_models/mistral.rs:422-437 | mistralrs-core/src/xlora_models/mixtral.rs:552-567 | mistralrs-core/src/xlora_models/phi3.rs:389-404 | mistralrs-core/src/xlora_models/starcoder2.rs:411-426 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/gemma2.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 498 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/xlora_models/mistral.rs:438` calls `head_dim` and `mistralrs-core/src/xlora_models/gemma.rs:442` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (15 lines × 7) · ×2
  • Duplicated block (15 lines × 7) mistralrs-core/src/models/flint.rs:849 — mistralrs-core/src/models/flint.rs:849-863 | mistralrs-core/src/models/glm4.rs:516-530 | mistralrs-core/src/models/hunyuan_v1_dense.rs:481-495 | mistralrs-core/src/models/hunyuan_v1_moe.rs:975-989 | mistralrs-core/src/models/mistral.rs:522-536 | mistralrs-core/src/models/qwen3.rs:475-489 | mistralrs-core/src/models/qwen3_moe.rs:655-669 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/glm4.rs` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 240 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/flint.rs:849` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (15 lines × 7) mistralrs-core/src/models/glm4.rs:497 — mistralrs-core/src/models/glm4.rs:497-511 | mistralrs-core/src/models/hunyuan_v1_dense.rs:462-476 | mistralrs-core/src/models/hunyuan_v1_moe.rs:956-970 | mistralrs-core/src/models/mistral.rs:503-517 | mistralrs-core/src/models/mixtral.rs:458-472 | mistralrs-core/src/models/qwen2.rs:488-502 | mistralrs-core/src/models/qwen3.rs:456-470 — before extracting anything, compare `mistralrs-core/src/models/glm4.rs` and `mistralrs-core/src/models/hunyuan_v1_dense.rs` as WHOLE FILES: this scan already matched 43 separate duplicated blocks between them, totalling at least 508 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/glm4.rs:497` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (15 lines × 6) · ×2
  • Duplicated block (15 lines × 6) mistralrs-core/src/models/gemma.rs:133 — mistralrs-core/src/models/gemma.rs:133-147 | mistralrs-core/src/models/mixtral.rs:117-131 | mistralrs-core/src/models/qwen2.rs:205-219 | mistralrs-core/src/models/starcoder2.rs:193-207 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:162-176 | mistralrs-core/src/vision_models/qwen2vl/text.rs:163-177 — before extracting anything, compare `mistralrs-core/src/models/gemma.rs` and `mistralrs-core/src/models/mixtral.rs` as WHOLE FILES: this scan already matched 31 separate duplicated blocks between them, totalling at least 329 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma.rs:133` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (15 lines × 6) mistralrs/src/model_builder_trait.rs:548 — mistralrs/src/model_builder_trait.rs:548-562 | mistralrs/src/model_builder_trait.rs:625-639 | mistralrs/src/model_builder_trait.rs:775-789 | mistralrs/src/model_builder_trait.rs:928-942 | mistralrs/src/model_builder_trait.rs:1098-1112 | mistralrs/src/model_builder_trait.rs:1552-1566 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs/src/model_builder_trait.rs:548` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (15 lines × 5) · ×2
  • Duplicated block (15 lines × 5) mistralrs-core/src/pipeline/multimodal.rs:1186 — mistralrs-core/src/pipeline/multimodal.rs:1186-1200 | mistralrs-core/src/pipeline/multimodal.rs:1236-1250 | mistralrs-core/src/pipeline/normal.rs:1238-1252 | mistralrs-core/src/pipeline/normal.rs:1288-1302 | mistralrs-core/src/pipeline/normal.rs:1371-1385 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (15 lines × 5) mistralrs-core/src/vision_models/grid_processor.rs:1308 — mistralrs-core/src/vision_models/grid_processor.rs:1308-1322 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:222-236 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:512-526 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:788-802 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1120-1134 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:1308` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (13–15 lines × 3) · ×2
  • Duplicated block (13–15 lines × 3) mistralrs-core/src/sampler.rs:1175 — mistralrs-core/src/sampler.rs:1175-1189 | mistralrs-core/src/sampler.rs:1255-1269 | mistralrs-core/src/sampler.rs:1872-1884 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/sampler.rs:1175` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13–15 lines × 3) mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:640 — mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:640-654 | mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:575-587 | mistralrs-core/src/vision_models/mistral3/inputs_processor.rs:409-423 — `mistralrs-core/src/vision_models/idefics3/inputs_processor.rs` and `mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 41 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:575` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (14 lines × 11) · ×2
  • Duplicated block (14 lines × 11) mistralrs-core/src/models/glm4.rs:584 — mistralrs-core/src/models/glm4.rs:584-597 | mistralrs-core/src/models/mistral.rs:594-608 | mistralrs-core/src/models/mixtral.rs:532-546 | mistralrs-core/src/models/phi3.rs:540-554 | mistralrs-core/src/models/phi3_5_moe.rs:613-627 | mistralrs-core/src/models/qwen2.rs:586-599 | mistralrs-core/src/models/qwen3.rs:547-561 | mistralrs-core/src/models/qwen3_moe.rs:727-741 | mistralrs-core/src/models/starcoder2.rs:534-547 | mistralrs-core/src/vision_models/phi3/mod.rs:1343-1356 | mistralrs-core/src/vision_models/phi4/mod.rs:505-518 — before extracting anything, compare `mistralrs-core/src/models/glm4.rs` and `mistralrs-core/src/models/mistral.rs` as WHOLE FILES: this scan already matched 44 separate duplicated blocks between them, totalling at least 529 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: the declarations holding them bind `ctx` to `&mut ModelForwardContext<'_>` in one and `&mut crate::pipeline::ModelForwardContext<'_>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (14 lines × 11) mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:777 — mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:777-790 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1560-1573 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1868-1881 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2168-2181 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2941-2954 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4364-4377 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1546-1559 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2226-2239 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2674-2687 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4505-4518 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5394-5407 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/embedding_loaders.rs` and `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 180 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:777` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1575` calls `non_mapped_sub_models`, `Some` and `mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1560` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (14 lines × 8) · ×2
  • Duplicated block (14 lines × 8) mistralrs-core/src/models/deepseek2.rs:723 — mistralrs-core/src/models/deepseek2.rs:723-736 | mistralrs-core/src/models/deepseek3.rs:786-799 | mistralrs-core/src/models/glm4_moe.rs:623-636 | mistralrs-core/src/models/glm4_moe_lite.rs:732-745 | mistralrs-core/src/xlora_models/llama.rs:355-368 | mistralrs-core/src/xlora_models/mistral.rs:335-348 | mistralrs-core/src/xlora_models/mixtral.rs:462-475 | mistralrs-core/src/xlora_models/phi3.rs:300-313 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:723` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/models/deepseek2.rs:722` calls `pp` and `mistralrs-core/src/xlora_models/llama.rs:354` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14 lines × 8) mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:576 — mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:576-589 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2585-2598 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3295-3308 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3637-3650 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6545-6558 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1298-1311 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2455-2468 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5835-5848 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/embedding_loaders.rs` and `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 180 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:576` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:591` calls `non_mapped_sub_models` and `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3651` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (14 lines × 6) · ×2
  • Duplicated block (14 lines × 6) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1174 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1174-1187 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5156-5169 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:854-867 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1986-1999 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2930-2943 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3818-3831 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` and `mistralrs-core/src/pipeline/loaders/normal_loaders.rs` as WHOLE FILES: this scan already matched 34 separate duplicated blocks between them, totalling at least 445 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1174` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1189` calls `non_mapped_sub_models`, `Some` and `mistralrs-core/src/pipeline/loaders/normal_loaders.rs:868` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14 lines × 6) mistralrs-core/src/pipeline/multimodal.rs:1161 — mistralrs-core/src/pipeline/multimodal.rs:1161-1174 | mistralrs-core/src/pipeline/multimodal.rs:1218-1231 | mistralrs-core/src/pipeline/multimodal.rs:1270-1283 | mistralrs-core/src/pipeline/normal.rs:1213-1226 | mistralrs-core/src/pipeline/normal.rs:1270-1283 | mistralrs-core/src/pipeline/normal.rs:1346-1359 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (13–14 lines × 3) · ×2
  • Duplicated block (13–14 lines × 3) mistralrs-core/src/pipeline/gguf.rs:677 — mistralrs-core/src/pipeline/gguf.rs:677-690 | mistralrs-core/src/pipeline/gguf.rs:777-789 | mistralrs-core/src/pipeline/gguf.rs:901-913 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/gguf.rs:677` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13–14 lines × 3) mistralrs-quant/src/hqq/mod.rs:469 — mistralrs-quant/src/hqq/mod.rs:469-482 | mistralrs-quant/src/hqq/mod.rs:533-545 | mistralrs-quant/src/hqq/mod.rs:556-568 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/hqq/mod.rs:533` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (12–13 lines × 8) · ×2
  • Duplicated block (12–13 lines × 8) mistralrs-core/src/models/deepseek2.rs:956 — mistralrs-core/src/models/deepseek2.rs:956-968 | mistralrs-core/src/models/deepseek3.rs:1019-1031 | mistralrs-core/src/models/gemma.rs:469-481 | mistralrs-core/src/models/glm4_moe.rs:835-846 | mistralrs-core/src/models/glm4_moe_lite.rs:972-983 | mistralrs-core/src/models/llama.rs:495-507 | mistralrs-core/src/models/phi2.rs:548-560 | mistralrs-core/src/models/smollm3.rs:514-526 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: the declarations holding them bind `ctx` to `&mut ModelForwardContext<'_>` in one and `&mut crate::pipeline::ModelForwardContext<'_>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (12–13 lines × 8) mistralrs-core/src/models/mixtral.rs:479 — mistralrs-core/src/models/mixtral.rs:479-490 | mistralrs-core/src/models/qwen2.rs:510-521 | mistralrs-core/src/vision_models/gemma3/text.rs:529-541 | mistralrs-core/src/vision_models/gemma3n/text.rs:1472-1484 | mistralrs-core/src/vision_models/phi3/mod.rs:1273-1284 | mistralrs-core/src/vision_models/phi4/mod.rs:388-399 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:474-485 | mistralrs-core/src/vision_models/qwen2vl/text.rs:476-487 — before extracting anything, compare `mistralrs-core/src/models/mixtral.rs` and `mistralrs-core/src/models/qwen2.rs` as WHOLE FILES: this scan already matched 46 separate duplicated blocks between them, totalling at least 556 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/mixtral.rs:479` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/models/qwen2.rs:523` calls `iter`, `flatten`, `next` and `mistralrs-core/src/models/mixtral.rs:492` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (13 lines × 5) · ×2
  • Duplicated block (13 lines × 5) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1401 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1401-1413 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6810-6822 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7252-7264 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7723-7735 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:8245-8257 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1401` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 5) mistralrs-core/src/xlora_models/llama.rs:552 — mistralrs-core/src/xlora_models/llama.rs:552-564 | mistralrs-core/src/xlora_models/mistral.rs:519-531 | mistralrs-core/src/xlora_models/mixtral.rs:649-661 | mistralrs-core/src/xlora_models/phi2.rs:493-505 | mistralrs-core/src/xlora_models/phi3.rs:469-481 — before extracting anything, compare `mistralrs-core/src/xlora_models/llama.rs` and `mistralrs-core/src/xlora_models/mistral.rs` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 274 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/llama.rs:552` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (11–12 lines × 4) · ×2
  • Duplicated block (11–12 lines × 4) mistralrs-core/src/embedding_models/embedding_gemma.rs:389 — mistralrs-core/src/embedding_models/embedding_gemma.rs:389-400 | mistralrs-core/src/models/gemma.rs:358-368 | mistralrs-core/src/models/gemma2.rs:431-441 | mistralrs-core/src/models/phi3_5_moe.rs:491-501 — `mistralrs-core/src/embedding_models/embedding_gemma.rs` and `mistralrs-core/src/models/gemma.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 9 separate duplicated blocks between them, totalling at least 133 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/embedding_gemma.rs:389` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11–12 lines × 4) mistralrs-core/src/pipeline/multimodal.rs:1149 — mistralrs-core/src/pipeline/multimodal.rs:1149-1159 | mistralrs-core/src/pipeline/multimodal.rs:1253-1264 | mistralrs-core/src/pipeline/normal.rs:1201-1211 | mistralrs-core/src/pipeline/normal.rs:1329-1340 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:1149` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (9–12 lines × 2) · ×2
  • Duplicated block (9–12 lines × 2) mistralrs-core/src/vision_models/gemma3n/audio.rs:1392 — mistralrs-core/src/vision_models/gemma3n/audio.rs:1392-1403 | mistralrs-core/src/vision_models/gemma4/audio.rs:1075-1083 — `mistralrs-core/src/vision_models/gemma3n/audio.rs` and `mistralrs-core/src/vision_models/gemma4/audio.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 20 separate duplicated blocks between them, totalling at least 352 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3n/audio.rs:1392` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/vision_models/gemma4/audio.rs:1074` calls `dim`, `div_ceil` and `mistralrs-core/src/vision_models/gemma3n/audio.rs:1391` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9–12 lines × 2) mistralrs-core/src/vision_models/gemma3n/inputs_processor.rs:190 — mistralrs-core/src/vision_models/gemma3n/inputs_processor.rs:190-198 | mistralrs-core/src/vision_models/phi4/inputs_processor.rs:217-228 — `mistralrs-core/src/vision_models/gemma3n/inputs_processor.rs` and `mistralrs-core/src/vision_models/phi4/inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 33 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3n/inputs_processor.rs:190` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (11 lines × 12) · ×2
  • Duplicated block (11 lines × 12) mistralrs-core/src/models/flint.rs:846 — mistralrs-core/src/models/flint.rs:846-856 | mistralrs-core/src/models/glm4.rs:513-523 | mistralrs-core/src/models/hunyuan_v1_dense.rs:478-488 | mistralrs-core/src/models/hunyuan_v1_moe.rs:972-982 | mistralrs-core/src/models/mistral.rs:519-529 | mistralrs-core/src/models/mixtral.rs:474-484 | mistralrs-core/src/models/phi3.rs:487-497 | mistralrs-core/src/models/qwen2.rs:505-515 | mistralrs-core/src/models/qwen3.rs:472-482 | mistralrs-core/src/models/qwen3_moe.rs:652-662 | mistralrs-core/src/vision_models/phi3/mod.rs:1268-1278 | mistralrs-core/src/vision_models/phi4/mod.rs:383-393 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/glm4.rs` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 240 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/flint.rs:846` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/models/qwen3_moe.rs:650` calls `clone` and `mistralrs-core/src/models/glm4.rs:511` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (11 lines × 12) mistralrs-core/src/models/glm4.rs:492 — mistralrs-core/src/models/glm4.rs:492-502 | mistralrs-core/src/models/hunyuan_v1_dense.rs:457-467 | mistralrs-core/src/models/hunyuan_v1_moe.rs:951-961 | mistralrs-core/src/models/llama.rs:419-429 | mistralrs-core/src/models/mistral.rs:498-508 | mistralrs-core/src/models/mixtral.rs:453-463 | mistralrs-core/src/models/qwen2.rs:483-493 | mistralrs-core/src/models/qwen3.rs:451-461 | mistralrs-core/src/vision_models/llama4/text.rs:854-864 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:445-455 | mistralrs-core/src/vision_models/qwen2vl/text.rs:447-457 | mistralrs-core/src/vision_models/voxtral/mod.rs:667-677 — before extracting anything, compare `mistralrs-core/src/models/glm4.rs` and `mistralrs-core/src/models/hunyuan_v1_dense.rs` as WHOLE FILES: this scan already matched 43 separate duplicated blocks between them, totalling at least 508 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/glm4.rs:492` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (9–11 lines × 2) · ×2
  • Duplicated block (9–11 lines × 2) mistralrs-core/src/engine/mod.rs:2312 — mistralrs-core/src/engine/mod.rs:2312-2322 | mistralrs-core/src/engine/mod.rs:2423-2431 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/engine/mod.rs:2312` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9–11 lines × 2) mistralrs-core/src/kv_cache/mod.rs:1261 — mistralrs-core/src/kv_cache/mod.rs:1261-1269 | mistralrs-core/src/kv_cache/mod.rs:1318-1328 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/kv_cache/mod.rs:1261` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (10 lines × 22) · ×2
  • Duplicated block (10 lines × 22) mistralrs-core/src/embedding_models/embedding_gemma.rs:432 — mistralrs-core/src/embedding_models/embedding_gemma.rs:432-441 | mistralrs-core/src/models/deepseek2.rs:868-877 | mistralrs-core/src/models/deepseek3.rs:931-940 | mistralrs-core/src/models/gemma.rs:383-392 | mistralrs-core/src/models/gemma2.rs:456-465 | mistralrs-core/src/models/glm4_moe.rs:767-776 | mistralrs-core/src/models/glm4_moe_lite.rs:878-887 | mistralrs-core/src/models/llama.rs:412-421 | mistralrs-core/src/models/mistral.rs:491-500 | mistralrs-core/src/models/mixtral.rs:446-455 | mistralrs-core/src/models/phi2.rs:473-482 | mistralrs-core/src/models/phi3.rs:461-470 | mistralrs-core/src/models/phi3_5_moe.rs:530-539 | mistralrs-core/src/models/starcoder2.rs:444-453 | mistralrs-core/src/vision_models/gemma3/text.rs:491-500 | mistralrs-core/src/vision_models/gemma4/text.rs:1717-1726 | mistralrs-core/src/vision_models/phi3/mod.rs:1242-1251 | mistralrs-core/src/vision_models/phi4/mod.rs:357-366 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:438-447 | mistralrs-core/src/vision_models/qwen2vl/text.rs:440-449 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:428-437 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:548-557 — before extracting anything, compare `mistralrs-core/src/embedding_models/embedding_gemma.rs` and `mistralrs-core/src/models/deepseek2.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 31 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/embedding_gemma.rs:432` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/embedding_models/embedding_gemma.rs:430` calls `pp` and `mistralrs-core/src/vision_models/phi3/mod.rs:1240` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10 lines × 22) mistralrs-core/src/models/flint.rs:391 — mistralrs-core/src/models/flint.rs:391-400 | mistralrs-core/src/models/gemma.rs:196-205 | mistralrs-core/src/models/glm4.rs:243-252 | mistralrs-core/src/models/glm4_moe.rs:311-320 | mistralrs-core/src/models/gpt_oss.rs:276-285 | mistralrs-core/src/models/granite.rs:1572-1581 | mistralrs-core/src/models/hunyuan_v1_dense.rs:222-231 | mistralrs-core/src/models/hunyuan_v1_moe.rs:408-417 | mistralrs-core/src/models/llama.rs:104-113 | mistralrs-core/src/models/mistral.rs:244-253 | mistralrs-core/src/models/mixtral.rs:180-189 | mistralrs-core/src/models/phi2.rs:292-301 | mistralrs-core/src/models/phi3_5_moe.rs:210-219 | mistralrs-core/src/models/qwen3.rs:229-238 | mistralrs-core/src/models/qwen3_moe.rs:232-241 | mistralrs-core/src/models/qwen3_next.rs:316-325 | mistralrs-core/src/models/smollm3.rs:121-130 | mistralrs-core/src/models/starcoder2.rs:256-265 | mistralrs-core/src/vision_models/gemma3/text.rs:246-255 | mistralrs-core/src/vision_models/llama4/text.rs:476-485 | mistralrs-core/src/vision_models/mllama/text.rs:192-201 | mistralrs-core/src/vision_models/voxtral/mod.rs:157-166 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/gemma.rs` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 152 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/flint.rs:391` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/models/granite.rs:1571` calls `flash_params` and `mistralrs-core/src/models/flint.rs:389` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (10 lines × 11) · ×2
  • Duplicated block (10 lines × 11) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1525 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1525-1534 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1832-1841 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2132-2141 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2548-2557 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3260-3269 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3602-3611 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5119-5128 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:819-828 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1263-1272 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3991-4000 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5800-5809 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` and `mistralrs-core/src/pipeline/loaders/normal_loaders.rs` as WHOLE FILES: this scan already matched 34 separate duplicated blocks between them, totalling at least 445 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (10 lines × 11) mistralrs-quant/src/cutile/fp8_gemm.rs:349 — mistralrs-quant/src/cutile/fp8_gemm.rs:349-358 | mistralrs-quant/src/cutile/fp8_gemm.rs:359-368 | mistralrs-quant/src/cutile/fp8_w8a16.rs:455-464 | mistralrs-quant/src/cutile/fp8_w8a8.rs:533-542 | mistralrs-quant/src/cutile/fp8_w8a8.rs:543-552 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:926-935 | mistralrs-quant/src/cutile/nvfp4_gemv.rs:328-337 | mistralrs-quant/src/cutile/nvfp4_matmul.rs:655-664 | mistralrs-quant/src/cutile/nvfp4_matmul.rs:1157-1166 | mistralrs-quant/src/nvfp4/decode.rs:129-138 | mistralrs-quant/src/nvfp4/portable.rs:318-327 — before extracting anything, compare `mistralrs-quant/src/cutile/fp8_gemm.rs` and `mistralrs-quant/src/cutile/fp8_w8a16.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 40 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (10 lines × 5) · ×2
  • Duplicated block (10 lines × 5) mistralrs-core/src/embedding_models/embedding_gemma.rs:538 — mistralrs-core/src/embedding_models/embedding_gemma.rs:538-547 | mistralrs-core/src/models/gemma2.rs:609-618 | mistralrs-core/src/vision_models/gemma3/text.rs:857-866 | mistralrs-core/src/vision_models/gemma3n/text.rs:1958-1967 | mistralrs-core/src/vision_models/gemma4/text.rs:2614-2623 — before extracting anything, compare `mistralrs-core/src/embedding_models/embedding_gemma.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 175 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/vision_models/gemma4/text.rs:2611` calls `Some`, `pp`, `add` and `mistralrs-core/src/embedding_models/embedding_gemma.rs:537` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10 lines × 5) mistralrs-core/src/pipeline/loaders/lfm3_vl.rs:153 — mistralrs-core/src/pipeline/loaders/lfm3_vl.rs:153-162 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6627-6636 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7028-7037 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7505-7514 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7980-7989 — there are 5 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 5 sites; resolving a subset leaves the remainder to drift apart.
D4 · Code Duplication · Duplicated block (9–10 lines × 5) · ×2
  • Duplicated block (9–10 lines × 5) mistralrs-core/src/embedding_models/qwen3_embedding.rs:447 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:447-456 | mistralrs-core/src/xlora_models/mistral.rs:590-598 | mistralrs-core/src/xlora_models/mixtral.rs:720-728 | mistralrs-core/src/xlora_models/phi3.rs:541-550 | mistralrs-core/src/xlora_models/starcoder2.rs:574-583 — before extracting anything, compare `mistralrs-core/src/embedding_models/qwen3_embedding.rs` and `mistralrs-core/src/xlora_models/mistral.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 81 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/qwen3_embedding.rs:447` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (9–10 lines × 5) mistralrs-core/src/models/deepseek2.rs:814 — mistralrs-core/src/models/deepseek2.rs:814-823 | mistralrs-core/src/models/deepseek3.rs:877-886 | mistralrs-core/src/models/glm4_moe.rs:714-723 | mistralrs-core/src/models/glm4_moe_lite.rs:824-833 | mistralrs-core/src/models/gpt_oss.rs:720-728 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:814` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (7–9 lines × 3) · ×2
  • Duplicated block (7–9 lines × 3) mistralrs-core/src/vision_models/grid_processor.rs:1697 — mistralrs-core/src/vision_models/grid_processor.rs:1697-1705 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:868-874 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1433-1439 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:1697` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (7–9 lines × 3) mistralrs-quant/src/uqff/reader.rs:242 — mistralrs-quant/src/uqff/reader.rs:242-248 | mistralrs-quant/src/uqff/reader.rs:264-272 | mistralrs-quant/src/uqff/reader.rs:289-295 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/uqff/reader.rs:264` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (8 lines × 12) · ×2
  • Duplicated block (8 lines × 12) mistralrs-core/src/models/flint.rs:740 — mistralrs-core/src/models/flint.rs:740-747 | mistralrs-core/src/models/gemma.rs:312-319 | mistralrs-core/src/models/gpt_oss.rs:682-689 | mistralrs-core/src/models/hunyuan_v1_dense.rs:339-346 | mistralrs-core/src/models/hunyuan_v1_moe.rs:829-836 | mistralrs-core/src/models/mistral.rs:360-367 | mistralrs-core/src/models/mixtral.rs:369-376 | mistralrs-core/src/models/phi3.rs:373-380 | mistralrs-core/src/models/qwen3.rs:348-355 | mistralrs-core/src/models/qwen3_moe.rs:522-529 | mistralrs-core/src/vision_models/phi3/mod.rs:464-471 | mistralrs-core/src/vision_models/phi4/mod.rs:294-301 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/gemma.rs` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 152 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (8 lines × 12) mistralrs-core/src/models/gemma.rs:502 — mistralrs-core/src/models/gemma.rs:502-510 | mistralrs-core/src/models/mistral.rs:630-638 | mistralrs-core/src/models/mixtral.rs:568-576 | mistralrs-core/src/models/phi3.rs:577-585 | mistralrs-core/src/models/qwen2.rs:633-641 | mistralrs-core/src/models/starcoder2.rs:569-577 | mistralrs-core/src/vision_models/llama4/vision.rs:352-360 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:579-586 | mistralrs-core/src/vision_models/phi3/mod.rs:1382-1390 | mistralrs-core/src/vision_models/phi4/mod.rs:644-652 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:569-577 | mistralrs-core/src/vision_models/qwen2vl/text.rs:571-579 — before extracting anything, compare `mistralrs-core/src/models/gemma.rs` and `mistralrs-core/src/models/mistral.rs` as WHOLE FILES: this scan already matched 36 separate duplicated blocks between them, totalling at least 416 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma.rs:502` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (8 lines × 8) · ×2
  • Duplicated block (8 lines × 8) mistralrs-core/src/vision_models/phi3/mod.rs:1230 — mistralrs-core/src/vision_models/phi3/mod.rs:1230-1237 | mistralrs-core/src/vision_models/phi4/mod.rs:345-352 | mistralrs-core/src/xlora_models/gemma.rs:443-450 | mistralrs-core/src/xlora_models/gemma2.rs:474-481 | mistralrs-core/src/xlora_models/mistral.rs:440-447 | mistralrs-core/src/xlora_models/mixtral.rs:570-577 | mistralrs-core/src/xlora_models/phi2.rs:425-433 | mistralrs-core/src/xlora_models/phi3.rs:406-413 — `mistralrs-core/src/vision_models/phi3/mod.rs` and `mistralrs-core/src/vision_models/phi4/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 48 separate duplicated blocks between them, totalling at least 586 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/phi3/mod.rs:1230` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/xlora_models/phi2.rs:424` calls `with_capacity` and `mistralrs-core/src/vision_models/phi3/mod.rs:1229` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (8 lines × 8) mistralrs-core/src/vision_models/qwen3_5/mod.rs:223 — mistralrs-core/src/vision_models/qwen3_5/mod.rs:223-230 | mistralrs-core/src/vision_models/qwen3_5/mod.rs:284-291 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:206-213 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:267-274 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:743-750 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:818-825 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:189-196 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:264-271 — `mistralrs-core/src/vision_models/qwen3_5/mod.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 24 separate duplicated blocks between them, totalling at least 425 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_5/mod.rs:223` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (8 lines × 7) · ×2
  • Duplicated block (8 lines × 7) mistralrs-core/src/models/mixtral.rs:426 — mistralrs-core/src/models/mixtral.rs:426-433 | mistralrs-core/src/models/qwen2.rs:453-461 | mistralrs-core/src/models/starcoder2.rs:423-431 | mistralrs-core/src/vision_models/llama4/text.rs:830-837 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:418-426 | mistralrs-core/src/vision_models/qwen2vl/text.rs:419-427 | mistralrs-core/src/xlora_models/starcoder2.rs:429-436 — before extracting anything, compare `mistralrs-core/src/models/mixtral.rs` and `mistralrs-core/src/models/qwen2.rs` as WHOLE FILES: this scan already matched 46 separate duplicated blocks between them, totalling at least 556 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/mixtral.rs:426` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/models/starcoder2.rs:422` calls `pp` and `mistralrs-core/src/models/mixtral.rs:425` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (8 lines × 7) mistralrs-quant/src/blockwise_fp8/deepgemm.rs:514 — mistralrs-quant/src/blockwise_fp8/deepgemm.rs:514-521 | mistralrs-quant/src/blockwise_fp8/deepgemm.rs:523-530 | mistralrs-quant/src/blockwise_fp8/deepgemm.rs:607-615 | mistralrs-quant/src/blockwise_fp8/deepgemm.rs:617-624 | mistralrs-quant/src/blockwise_fp8/deepgemm.rs:626-633 | mistralrs-quant/src/blockwise_fp8/ops.rs:1856-1863 | mistralrs-quant/src/blockwise_fp8/ops.rs:1865-1872 — before extracting anything, compare `mistralrs-quant/src/blockwise_fp8/deepgemm.rs` and `mistralrs-quant/src/blockwise_fp8/ops.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 65 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/blockwise_fp8/deepgemm.rs:514` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (6–8 lines × 4) · ×2
  • Duplicated block (6–8 lines × 4) mistralrs-core/src/engine/mod.rs:2296 — mistralrs-core/src/engine/mod.rs:2296-2303 | mistralrs-core/src/engine/mod.rs:2371-2378 | mistralrs-core/src/engine/mod.rs:2390-2397 | mistralrs-core/src/engine/mod.rs:2416-2421 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (6–8 lines × 4) mistralrs-quant/src/blockwise_fp8/mod.rs:688 — mistralrs-quant/src/blockwise_fp8/mod.rs:688-693 | mistralrs-quant/src/mxfp4/mod.rs:111-116 | mistralrs-quant/src/mxfp4/mod.rs:133-140 | mistralrs-quant/src/mxfp4/mod.rs:687-692 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/blockwise_fp8/mod.rs:688` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (4–8 lines × 4) · ×2
  • Duplicated block (4–8 lines × 4) REDACTED:687 — REDACTED:687-694 | mistralrs-core/src/vision_models/idefics3/vision.rs:506-513 | mistralrs-core/src/vision_models/lfm2_vl/vision.rs:386-389 | mistralrs-core/src/vision_models/siglip.rs:529-536 — before extracting anything, compare `REDACTED` and `mistralrs-core/src/vision_models/idefics3/vision.rs` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 221 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:687` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/vision_models/lfm2_vl/vision.rs:386` calls `pp` and `mistralrs-core/src/vision_models/idefics3/vision.rs:506` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (4–8 lines × 4) mistralrs-quant/src/cutile/nvfp4_gemv.rs:127 — mistralrs-quant/src/cutile/nvfp4_gemv.rs:127-134 | mistralrs-quant/src/cutile/nvfp4_gemv.rs:231-238 | mistralrs-quant/src/cutile/nvfp4_matmul.rs:147-150 | mistralrs-quant/src/cutile/nvfp4_matmul.rs:250-253 — before extracting anything, compare `mistralrs-quant/src/cutile/nvfp4_gemv.rs` and `mistralrs-quant/src/cutile/nvfp4_matmul.rs` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 98 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cutile/nvfp4_gemv.rs:127` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (7–8 lines × 2) · ×2
  • Duplicated block (7–8 lines × 2) mistralrs-core/src/cuda/dflash_context.rs:165 — mistralrs-core/src/cuda/dflash_context.rs:165-172 | mistralrs-core/src/cuda/dflash_context.rs:294-300 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/dflash_context.rs:165` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (7–8 lines × 2) mistralrs-server-core/src/openai.rs:139 — mistralrs-server-core/src/openai.rs:139-146 | mistralrs-server-core/src/openai.rs:158-164 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-server-core/src/openai.rs:139` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-server-core/src/openai.rs:164` calls `insert`, `to_string` and `mistralrs-server-core/src/openai.rs:146` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (7 lines × 7) · ×2
  • Duplicated block (7 lines × 7) mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:321 — mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:321-327 | mistralrs-core/src/vision_models/qwen2vl/mod.rs:478-484 | mistralrs-core/src/vision_models/qwen3_5/mod.rs:398-404 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:383-389 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:967-973 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:413-419 | mistralrs-core/src/vision_models/qwen4_exp/mod.rs:378-384 — `mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs` and `mistralrs-core/src/vision_models/qwen2vl/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 16 separate duplicated blocks between them, totalling at least 396 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (7 lines × 7) mistralrs-core/src/vision_models/diffusion_gemma/mod.rs:291 — mistralrs-core/src/vision_models/diffusion_gemma/mod.rs:291-297 | mistralrs-core/src/vision_models/gemma3/mod.rs:181-187 | mistralrs-core/src/vision_models/gemma4/mod.rs:543-549 | mistralrs-core/src/vision_models/gemma4/mod.rs:666-672 | mistralrs-core/src/vision_models/gemma4/mod.rs:856-862 | mistralrs-core/src/vision_models/lfm2_vl/mod.rs:221-227 | mistralrs-core/src/vision_models/mistral3/mod.rs:325-331 — there are 7 copies across 5 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 7 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/diffusion_gemma/mod.rs:291` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/vision_models/gemma4/mod.rs:542` calls `dim` and `mistralrs-core/src/vision_models/lfm2_vl/mod.rs:219` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (6–7 lines × 3) · ×2
  • Duplicated block (6–7 lines × 3) mistralrs-core/src/pipeline/diffusion.rs:121 — mistralrs-core/src/pipeline/diffusion.rs:121-126 | mistralrs-core/src/pipeline/gguf.rs:1310-1316 | mistralrs-core/src/pipeline/speech.rs:223-228 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/diffusion.rs:121` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6–7 lines × 3) mistralrs-quant/src/afq/ops.rs:1752 — mistralrs-quant/src/afq/ops.rs:1752-1757 | mistralrs-quant/src/afq/ops.rs:1870-1875 | mistralrs-quant/src/afq/ops.rs:1989-1995 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/afq/ops.rs:1752` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (6 lines × 7) · ×2
  • Duplicated block (6 lines × 7) mistralrs-paged-attn/src/cuda/backend/fa3.rs:188 — mistralrs-paged-attn/src/cuda/backend/fa3.rs:188-193 | mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:127-132 | mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:317-322 | mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:609-614 | mistralrs-paged-attn/src/cuda/backend/mla.rs:35-40 | mistralrs-paged-attn/src/cuda/backend/mla.rs:322-327 | mistralrs-paged-attn/src/cuda/backend/mla.rs:685-690 — before extracting anything, compare `mistralrs-paged-attn/src/cuda/backend/flashinfer.rs` and `mistralrs-paged-attn/src/cuda/backend/mla.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 50 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/cuda/backend/fa3.rs:188` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-paged-attn/src/cuda/backend/mla.rs:33` calls `storage_and_layout` and `mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:125` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (6 lines × 7) REDACTED:553 — REDACTED:553-560 | mistralrs-core/src/vision_models/idefics3/vision.rs:350-357 | mistralrs-core/src/vision_models/lfm2_vl/vision.rs:279-284 | mistralrs-core/src/vision_models/muse_glimmer/vision.rs:424-429 | mistralrs-core/src/vision_models/muse_glimmer/vision.rs:516-521 | mistralrs-core/src/vision_models/qwen2vl/vision.rs:97-102 | mistralrs-core/src/vision_models/siglip.rs:361-368 — before extracting anything, compare `REDACTED` and `mistralrs-core/src/vision_models/idefics3/vision.rs` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 221 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (4–6 lines × 3) · ×2
  • Duplicated block (4–6 lines × 3) mistralrs-quant/src/cutile/fp8_w8a16.rs:443 — mistralrs-quant/src/cutile/fp8_w8a16.rs:443-448 | mistralrs-quant/src/cutile/fp8_w8a8.rs:516-521 | mistralrs-quant/src/cutile/nvfp4_gemv.rs:300-303 — before extracting anything, compare `mistralrs-quant/src/cutile/fp8_w8a16.rs` and `mistralrs-quant/src/cutile/fp8_w8a8.rs` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 212 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cutile/fp8_w8a16.rs:443` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-quant/src/cutile/nvfp4_gemv.rs:306` calls `storage_and_layout` and `mistralrs-quant/src/cutile/fp8_w8a8.rs:524` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (4–6 lines × 3) mistralrs-quant/src/mxfp4/mod.rs:639 — mistralrs-quant/src/mxfp4/mod.rs:639-642 | mistralrs-quant/src/mxfp4/mod.rs:703-708 | mistralrs-quant/src/mxfp4/mod.rs:776-781 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
D4 · Code Duplication · Duplicated block (5–6 lines × 2) · ×2
  • Duplicated block (5–6 lines × 2) mistralrs-quant/src/rotary/mod.rs:19 — mistralrs-quant/src/rotary/mod.rs:19-23 | mistralrs-quant/src/rotary/mod.rs:223-228 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/rotary/mod.rs:223` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (5–6 lines × 2) mistralrs-quant/src/rotary/mod.rs:26 — mistralrs-quant/src/rotary/mod.rs:26-30 | mistralrs-quant/src/rotary/mod.rs:234-239 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/rotary/mod.rs:234` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (5 lines × 7) · ×2
  • Duplicated block (5 lines × 7) mistralrs-core/src/embedding_models/qwen3_embedding.rs:455 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:455-459 | mistralrs-core/src/models/gemma2.rs:574-578 | mistralrs-core/src/models/qwen2.rs:602-606 | mistralrs-core/src/vision_models/gemma3/text.rs:744-748 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:524-528 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:645-649 | mistralrs-core/src/xlora_models/gemma2.rs:643-647 — before extracting anything, compare `mistralrs-core/src/embedding_models/qwen3_embedding.rs` and `mistralrs-core/src/models/qwen2.rs` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 122 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/qwen3_embedding.rs:455` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 7) mistralrs-core/src/layers.rs:1630 — mistralrs-core/src/layers.rs:1630-1634 | mistralrs-core/src/layers.rs:1770-1774 | mistralrs-core/src/layers.rs:1941-1945 | mistralrs-core/src/layers.rs:3071-3075 | mistralrs-core/src/layers.rs:3204-3208 | mistralrs-core/src/models/glm4.rs:81-85 | mistralrs-core/src/models/glm4_moe.rs:107-111 — before extracting anything, compare `mistralrs-core/src/models/glm4.rs` and `mistralrs-core/src/models/glm4_moe.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 359 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/layers.rs:1777` calls `interleave_indices` and `mistralrs-core/src/layers.rs:1636` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (4–5 lines × 3) · ×2
  • Duplicated block (4–5 lines × 3) mistralrs-core/src/cuda/input_packing.rs:41 — mistralrs-core/src/cuda/input_packing.rs:41-45 | mistralrs-core/src/cuda/input_packing.rs:66-69 | mistralrs-core/src/cuda/input_packing.rs:134-138 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (4–5 lines × 3) mistralrs-quant/src/metal_kernels/mod.rs:4379 — mistralrs-quant/src/metal_kernels/mod.rs:4379-4383 | mistralrs-quant/src/metal_kernels/mod.rs:4478-4483 | mistralrs-quant/src/metal_kernels/mod.rs:5136-5139 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/metal_kernels/mod.rs:4379` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-quant/src/metal_kernels/mod.rs:5134` calls `encoder`, `as_ref`, `set_compute_pipeline_state` and `mistralrs-quant/src/metal_kernels/mod.rs:4478` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (8 lines × 5) · ×2
  • Duplicated block (8 lines × 5) mistralrs-core/src/models/granite.rs:1835 — mistralrs-core/src/models/granite.rs:1835-1842 | mistralrs-core/src/vision_models/qwen3_5/mod.rs:334-341 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:317-324 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:869-876 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:315-322 — `mistralrs-core/src/vision_models/qwen3_5/mod.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 24 separate duplicated blocks between them, totalling at least 425 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (8 lines × 5) mistralrs-core/src/ops.rs:88 — mistralrs-core/src/ops.rs:88-95 | mistralrs-core/src/ops.rs:437-444 | mistralrs-core/src/ops.rs:593-600 | mistralrs-core/src/ops.rs:755-762 | mistralrs-core/src/ops.rs:4652-4659 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/ops.rs:98` calls `BF16`, `device_ptr`, `F16` and `mistralrs-core/src/ops.rs:603` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
X15 · Unvalidated length from an untrusted reader · Length read from the parsed input is spent without ever being bounded · ×2
  • Length read from the parsed input is spent without ever being bounded mistralrs-quant/src/imatrix.rs:212 — `key_len` is read from the bytes being parsed at line 211 (`read_u64`), then used to size a `vec![…; n]` at line 212 — and nowhere in its scope is `key_len` compared to anything, clamped, or bounded against the input that remains. Whoever wrote those bytes therefore chooses the allocation directly: it reserves the whole length before a single byte of the payload is known to exist, so a 32-bit length asks for up to 4 GiB, and an allocation the allocator refuses aborts the process with `memory allocation of … bytes failed` — an abort, not a panic, so no `catch_unwind` intercepts it and the whole process dies; a 64-bit length past `isize::MAX` panics with `capacity overflow` instead, out of a parser whose failure path was written for malformed input, not for hostile input. Bound `key_len` against the bytes actually remaining and a maximum the format allows before allocating.
  • Length read from the parsed input is spent without ever being bounded mistralrs-quant/src/imatrix.rs:217 — `len_data` is read from the bytes being parsed at line 216 (`read_u64`), then used to size a `Vec::with_capacity` at line 217 — and nowhere in its scope is `len_data` compared to anything, clamped, or bounded against the input that remains. Whoever wrote those bytes therefore chooses the allocation directly: it reserves the whole length before a single byte of the payload is known to exist, so a 32-bit length asks for up to 4 GiB, and an allocation the allocator refuses aborts the process with `memory allocation of … bytes failed` — an abort, not a panic, so no `catch_unwind` intercepts it and the whole process dies; a 64-bit length past `isize::MAX` panics with `capacity overflow` instead, out of a parser whose failure path was written for malformed input, not for hostile input. Bound `len_data` against the bytes actually remaining and a maximum the format allows before allocating.
D1 · Cyclomatic Complexity · Pipeline · ×1
  • Pipeline::submit_step (cyclomatic 110) mistralrs-core/src/pipeline/mod.rs:2255 — Pipeline::submit_step has cyclomatic complexity 110 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MultimodalLoader · ×1
  • MultimodalLoader::load_model_from_path (cyclomatic 100) mistralrs-core/src/pipeline/multimodal.rs:526 — MultimodalLoader::load_model_from_path has cyclomatic complexity 100 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · NormalLoader · ×1
  • NormalLoader::load_model_from_path (cyclomatic 68) mistralrs-core/src/pipeline/normal.rs:659 — NormalLoader::load_model_from_path has cyclomatic complexity 68 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · FlashAttnVarLen · ×1
  • FlashAttnVarLen::cuda_fwd_t (cyclomatic 57) mistralrs-flash-attn/src/flash.rs:470 — FlashAttnVarLen::cuda_fwd_t has cyclomatic complexity 57 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · Gemma4Model · ×1
  • Gemma4Model::forward_inner (cyclomatic 47) mistralrs-core/src/vision_models/gemma4/mod.rs:341 — Gemma4Model::forward_inner has cyclomatic complexity 47 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Qwen3_5TextModel · ×1
  • Qwen3_5TextModel::forward_embeds (cyclomatic 44) mistralrs-core/src/vision_models/qwen3_5/text.rs:1358 — Qwen3_5TextModel::forward_embeds has cyclomatic complexity 44 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · streaming.streamChatCompletion (cyclomatic 42) · ×1
  • streaming.streamChatCompletion (cyclomatic 42) mistralrs-cli/webui/src/lib/services/streaming.ts:21 — streaming.streamChatCompletion has cyclomatic complexity 42 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · bench_decode_serving.validate_args (cyclomatic 41) · ×1
  • bench_decode_serving.validate_args (cyclomatic 41) releases/v0.9.3/scripts/bench_decode_serving.py:216 — bench_decode_serving.validate_args has cyclomatic complexity 41 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · Qwen3VLModel · ×1
  • Qwen3VLModel::forward (cyclomatic 39) mistralrs-core/src/vision_models/qwen3_vl/mod.rs:653 — Qwen3VLModel::forward has cyclomatic complexity 39 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Qwen3VLMoEModel · ×1
  • Qwen3VLMoEModel::forward (cyclomatic 39) mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:99 — Qwen3VLMoEModel::forward has cyclomatic complexity 39 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Qwen4ExpTextModel · ×1
  • Qwen4ExpTextModel::forward_embeds (cyclomatic 39) mistralrs-core/src/vision_models/qwen4_exp/text.rs:810 — Qwen4ExpTextModel::forward_embeds has cyclomatic complexity 39 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · EmbeddingLoader · ×1
  • EmbeddingLoader::load_model_from_path (cyclomatic 37) mistralrs-core/src/pipeline/embedding.rs:209 — EmbeddingLoader::load_model_from_path has cyclomatic complexity 37 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · OpenResponsesStreamer · ×1
  • OpenResponsesStreamer::poll_next (cyclomatic 37) mistralrs-server-core/src/responses.rs:1158 — OpenResponsesStreamer::poll_next has cyclomatic complexity 37 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Runner · ×1
  • Runner::new (cyclomatic 35) mistralrs-pyo3/src/lib.rs:1264 — Runner::new has cyclomatic complexity 35 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · LoraConfig · ×1
  • LoraConfig::validate_dynamic (cyclomatic 33) mistralrs-quant/src/lora/mod.rs:316 — LoraConfig::validate_dynamic has cyclomatic complexity 33 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · ChatStore.generateAssistant (cyclomatic 32) · ×1
  • ChatStore.generateAssistant (cyclomatic 32) mistralrs-cli/webui/src/lib/stores/chat.svelte.ts:378 — ChatStore.generateAssistant has cyclomatic complexity 32 (threshold 15). Most of this is not in the body itself: 10 of the 32 points are its own statements and the rest belongs to 8 function items inside it that branch (a function literal at line 445, a function literal at line 447, accountTokens, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
D1 · Cyclomatic Complexity · Qwen3_5MoeModel · ×1
  • Qwen3_5MoeModel::forward (cyclomatic 31) mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:101 — Qwen3_5MoeModel::forward has cyclomatic complexity 31 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · PrefixCacheManagerV2 · ×1
  • PrefixCacheManagerV2::search_for_matching_cache (cyclomatic 30) mistralrs-core/src/prefix_cacher.rs:735 — PrefixCacheManagerV2::search_for_matching_cache has cyclomatic complexity 30 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Gemma3ImageProcessor · ×1
  • Gemma3ImageProcessor::process_inputs (cyclomatic 30) mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:382 — Gemma3ImageProcessor::process_inputs has cyclomatic complexity 30 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MLlamaImageProcessor · ×1
  • MLlamaImageProcessor::process_inputs (cyclomatic 30) mistralrs-core/src/vision_models/mllama/inputs_processor.rs:320 — MLlamaImageProcessor::process_inputs has cyclomatic complexity 30 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MiniCpmOImageProcessor · ×1
  • MiniCpmOImageProcessor::process_inputs (cyclomatic 29) mistralrs-core/src/vision_models/minicpmo/inputs_processor.rs:297 — MiniCpmOImageProcessor::process_inputs has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · XLoraClassifier · ×1
  • XLoraClassifier::new (cyclomatic 29) mistralrs-core/src/xlora_models/classifier.rs:32 — XLoraClassifier::new has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MistralRs · ×1
  • MistralRs::init_external_tool_callbacks (cyclomatic 27) mistralrs-core/src/lib.rs:1378 — MistralRs::init_external_tool_callbacks has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Idefics2 · ×1
  • Idefics2::forward_inner (cyclomatic 27) REDACTED:1148 — Idefics2::forward_inner has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · LLaVAInputProcessor · ×1
  • LLaVAInputProcessor::process_inputs (cyclomatic 27) mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:273 — LLaVAInputProcessor::process_inputs has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · LLaVANextInputProcessor · ×1
  • LLaVANextInputProcessor::process_inputs (cyclomatic 27) mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:309 — LLaVANextInputProcessor::process_inputs has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Qwen2_5VLModel · ×1
  • Qwen2_5VLModel::forward (cyclomatic 26) mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:169 — Qwen2_5VLModel::forward has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MistralRsForServerBuilder · ×1
  • MistralRsForServerBuilder::build_multi_model (cyclomatic 26) mistralrs-server-core/src/mistralrs_for_server_builder.rs:911 — MistralRsForServerBuilder::build_multi_model has cyclomatic complexity 26 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · Idefics3ImageProcessor · ×1
  • Idefics3ImageProcessor::process_inputs (cyclomatic 25) mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:422 — Idefics3ImageProcessor::process_inputs has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · CublasLTBatchMatmulF8Scalar · ×1
  • CublasLTBatchMatmulF8Scalar::fwd_f8e4m3_scalar (cyclomatic 25) mistralrs-quant/src/cublaslt/api.rs:46 — CublasLTBatchMatmulF8Scalar::fwd_f8e4m3_scalar has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Gemma3nAudioAttention · ×1
  • Gemma3nAudioAttention::forward (cyclomatic 24) mistralrs-core/src/vision_models/gemma3n/audio.rs:587 — Gemma3nAudioAttention::forward has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ChatCompletionStreamer · ×1
  • ChatCompletionStreamer::poll_next (cyclomatic 24) mistralrs-server-core/src/chat_completion.rs:389 — ChatCompletionStreamer::poll_next has cyclomatic complexity 24 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · PerTensorFP8Linear · ×1
  • PerTensorFP8Linear::apply_isq (cyclomatic 24) mistralrs-quant/src/pertensor_fp8/mod.rs:642 — PerTensorFP8Linear::apply_isq has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Phi3InputsProcessor · ×1
  • Phi3InputsProcessor::process_inputs (cyclomatic 23) mistralrs-core/src/vision_models/phi3/phi3_inputs_processor.rs:282 — Phi3InputsProcessor::process_inputs has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · AgentStream · ×1
  • AgentStream::next (cyclomatic 22) mistralrs/src/agent.rs:199 — AgentStream::next has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · NormalPipeline · ×1
  • NormalPipeline::try_cuda_decode_graph_forward (cyclomatic 22) mistralrs-core/src/pipeline/normal.rs:1886 — NormalPipeline::try_cuda_decode_graph_forward has cyclomatic complexity 22 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This is NOT this file's highest cyclomatic complexity: NormalLoaderBuilder::build_inner (cyclomatic 29) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · FlashAttn · ×1
  • FlashAttn::cuda_fwd_t (cyclomatic 22) mistralrs-flash-attn/src/flash.rs:22 — FlashAttn::cuda_fwd_t has cyclomatic complexity 22 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · ShardedSafeTensors · ×1
  • ShardedSafeTensors::get (cyclomatic 22) mistralrs-quant/src/safetensors.rs:728 — ShardedSafeTensors::get has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Gemma4AudioAttention · ×1
  • Gemma4AudioAttention::forward (cyclomatic 21) mistralrs-core/src/vision_models/gemma4/audio.rs:643 — Gemma4AudioAttention::forward has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ReplicatedLayer · ×1
  • ReplicatedLayer::new_layers_matformer_indices (cyclomatic 21) mistralrs-quant/src/distributed/layers.rs:1560 — ReplicatedLayer::new_layers_matformer_indices has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · RoutedExperts · ×1
  • RoutedExperts::forward_grouped (cyclomatic 21) mistralrs-quant/src/routed_moe/cuda.rs:275 — RoutedExperts::forward_grouped has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · TagReasoningContext · ×1
  • TagReasoningContext::process_text (cyclomatic 20) mistralrs-core/src/reasoning_parsers/tag_based.rs:179 — TagReasoningContext::process_text has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · BuiltinMtpProposer · ×1
  • BuiltinMtpProposer::propose (cyclomatic 20) mistralrs-core/src/speculative/builtin_mtp.rs:216 — BuiltinMtpProposer::propose has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Gemma3nImageProcessor · ×1
  • Gemma3nImageProcessor::prepare_prompt_plans (cyclomatic 20) mistralrs-core/src/vision_models/gemma3n/inputs_processor.rs:462 — Gemma3nImageProcessor::prepare_prompt_plans has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Llama4ImageProcessor · ×1
  • Llama4ImageProcessor::process_inputs (cyclomatic 20) mistralrs-core/src/vision_models/llama4/inputs_processor.rs:392 — Llama4ImageProcessor::process_inputs has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Phi4MMInputsProcessor · ×1
  • Phi4MMInputsProcessor::process_image_batch (cyclomatic 20) mistralrs-core/src/vision_models/phi4/inputs_processor.rs:754 — Phi4MMInputsProcessor::process_image_batch has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · HqqBits · ×1
  • HqqBits::bitpack_type (cyclomatic 20) mistralrs-quant/src/hqq/mod.rs:156 — HqqBits::bitpack_type has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · CumSum · ×1
  • CumSum::cpu_fwd (cyclomatic 20) mistralrs-quant/src/utils/ops.rs:1402 — CumSum::cpu_fwd has cyclomatic complexity 20 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D1 · Cyclomatic Complexity · render_pyi._render_class (cyclomatic 20) · ×1
  • render_pyi._render_class (cyclomatic 20) docs/scripts/render_pyi.py:451 — render_pyi._render_class has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · GraniteMoeHybrid · ×1
  • GraniteMoeHybrid::forward (cyclomatic 19) mistralrs-core/src/models/granite.rs:2180 — GraniteMoeHybrid::forward has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · CudaGraphCaptureMemory · ×1
  • CudaGraphCaptureMemory::shape (cyclomatic 19) mistralrs-core/src/pipeline/cuda_graph.rs:89 — CudaGraphCaptureMemory::shape has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Llama4Model · ×1
  • Llama4Model::forward (cyclomatic 19) mistralrs-core/src/vision_models/llama4/mod.rs:105 — Llama4Model::forward has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Mistral3ImageProcessor · ×1
  • Mistral3ImageProcessor::process_inputs (cyclomatic 19) mistralrs-core/src/vision_models/mistral3/inputs_processor.rs:254 — Mistral3ImageProcessor::process_inputs has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · SliceReader · ×1
  • SliceReader::read_value (cyclomatic 19) mistralrs-quant/src/gguf/archive.rs:1080 — SliceReader::read_value has cyclomatic complexity 19 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing. This is NOT this file's highest cyclomatic complexity: GgufDType::name (cyclomatic 35) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · IndexedMoeLoraDecode · ×1
  • IndexedMoeLoraDecode::new (cyclomatic 19) mistralrs-quant/src/gguf/cuda.rs:1155 — IndexedMoeLoraDecode::new has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · CacheEngine · ×1
  • CacheEngine::allocate_gpu_cache (cyclomatic 18) mistralrs-core/src/paged_attention/cache_engine.rs:201 — CacheEngine::allocate_gpu_cache has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · GdnTransitionLayers · ×1
  • GdnTransitionLayers::stage_prefixes (cyclomatic 18) mistralrs-core/src/speculative/gdn_transitions.rs:285 — GdnTransitionLayers::stage_prefixes has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Gemma3nModel · ×1
  • Gemma3nModel::forward (cyclomatic 18) mistralrs-core/src/vision_models/gemma3n/mod.rs:334 — Gemma3nModel::forward has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Qwen4ExpModel · ×1
  • Qwen4ExpModel::forward (cyclomatic 18) mistralrs-core/src/vision_models/qwen4_exp/mod.rs:225 — Qwen4ExpModel::forward has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · VoxtralInputsProcessor · ×1
  • VoxtralInputsProcessor::process_inputs (cyclomatic 18) mistralrs-core/src/vision_models/voxtral/inputs_processor.rs:195 — VoxtralInputsProcessor::process_inputs has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · GptqLayer · ×1
  • GptqLayer::gptq_gemm (cyclomatic 18) mistralrs-quant/src/gptq/gptq_cuda.rs:83 — GptqLayer::gptq_gemm has cyclomatic complexity 18 (threshold 15). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
D1 · Cyclomatic Complexity · KvCache · ×1
  • KvCache::append (cyclomatic 17) mistralrs-core/src/kv_cache/mod.rs:152 — KvCache::append has cyclomatic complexity 17 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · DFlashDraftModel · ×1
  • DFlashDraftModel::precapture_cuda_graphs (cyclomatic 17) mistralrs-core/src/speculative/dflash.rs:2459 — DFlashDraftModel::precapture_cuda_graphs has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MetalPagedPrefillShape · ×1
  • MetalPagedPrefillShape::dispatch (cyclomatic 17) mistralrs-paged-attn/src/metal/backend/paged_prefill.rs:187 — MetalPagedPrefillShape::dispatch has cyclomatic complexity 17 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · ManagedEmbedding · ×1
  • ManagedEmbedding::prepare_mapped (cyclomatic 17) mistralrs-quant/src/embedding/storage.rs:749 — ManagedEmbedding::prepare_mapped has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ParsedShard · ×1
  • ParsedShard::finish (cyclomatic 17) mistralrs-quant/src/gguf/archive.rs:847 — ParsedShard::finish has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: GgufDType::name (cyclomatic 35) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · SoftmaxWithSinks · ×1
  • SoftmaxWithSinks::cpu_fwd (cyclomatic 17) mistralrs-quant/src/utils/ops.rs:1870 — SoftmaxWithSinks::cpu_fwd has cyclomatic complexity 17 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D1 · Cyclomatic Complexity · MultiModelBuilder · ×1
  • MultiModelBuilder::build (cyclomatic 16) mistralrs/src/model_builder_trait.rs:241 — MultiModelBuilder::build has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · NormalCacheManager · ×1
  • NormalCacheManager::clone_in_cache (cyclomatic 16) mistralrs-core/src/kv_cache/mod.rs:486 — NormalCacheManager::clone_in_cache has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Config · ×1
  • Config::validate (cyclomatic 16) mistralrs-core/src/models/hunyuan_v1_moe.rs:199 — Config::validate has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MoEExpertsBackend · ×1
  • MoEExpertsBackend::resolve (cyclomatic 16) mistralrs-core/src/moe/experts/config.rs:200 — MoEExpertsBackend::resolve has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · AnyMoePipeline · ×1
  • AnyMoePipeline::amoe_pre_train (cyclomatic 16) mistralrs-core/src/pipeline/amoe.rs:500 — AnyMoePipeline::amoe_pre_train has cyclomatic complexity 16 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
D1 · Cyclomatic Complexity · CudaGraphDecodeStep · ×1
  • CudaGraphDecodeStep::one_token_continuation (cyclomatic 16) mistralrs-core/src/pipeline/cuda_graph.rs:957 — CudaGraphDecodeStep::one_token_continuation has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · CudaGraphPinnedBuffer · ×1
  • CudaGraphPinnedBuffer::copy_from (cyclomatic 16) mistralrs-core/src/pipeline/cuda_graph.rs:3522 — CudaGraphPinnedBuffer::copy_from has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · CudaDecodeGraphState · ×1
  • CudaDecodeGraphState::replay (cyclomatic 16) mistralrs-core/src/pipeline/cuda_graph.rs:2347 — CudaDecodeGraphState::replay has cyclomatic complexity 16 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · SequenceGroup · ×1
  • SequenceGroup::maybe_send_streaming_response (cyclomatic 16) mistralrs-core/src/sequence.rs:2584 — SequenceGroup::maybe_send_streaming_response has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Topology · ×1
  • Topology::from_str (cyclomatic 16) mistralrs-core/src/topology/mod.rs:104 — Topology::from_str has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · GgufDeviceMapLoaderInner · ×1
  • GgufDeviceMapLoaderInner::layer_sizes_in_bytes (cyclomatic 16) mistralrs-core/src/utils/gguf_metadata.rs:401 — GgufDeviceMapLoaderInner::layer_sizes_in_bytes has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Idefics3Model · ×1
  • Idefics3Model::forward_inner (cyclomatic 16) REDACTED:119 — Idefics3Model::forward_inner has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · RopeParameters · ×1
  • RopeParameters::validate_scaling (cyclomatic 16) mistralrs-core/src/vision_models/qwen3_5/config.rs:82 — RopeParameters::validate_scaling has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · RowParallelLayer · ×1
  • RowParallelLayer::new_with_lora_spec (cyclomatic 16) mistralrs-quant/src/distributed/layers.rs:398 — RowParallelLayer::new_with_lora_spec has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · PreQuantizedExperts · ×1
  • PreQuantizedExperts::new (cyclomatic 16) mistralrs-quant/src/distributed/layers.rs:1939 — PreQuantizedExperts::new has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · State · ×1
  • State::forward (cyclomatic 16) mistralrs-quant/src/nvfp4/cutlass.rs:342 — State::forward has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · AnthropicStreamer · ×1
  • AnthropicStreamer::poll_next (cyclomatic 16) mistralrs-server-core/src/anthropic.rs:1542 — AnthropicStreamer::poll_next has cyclomatic complexity 16 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D15 · Churn × Complexity Hotspots · Repeated repair · ×1
  • Repeated repair: mistralrs-core/src/tools/parsers/qwen.rs mistralrs-core/src/tools/parsers/qwen.rs:119 — mistralrs-core/src/tools/parsers/qwen.rs changed 4 times in last 90 days and 3 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 9 (its worst body is mistralrs_core::tools::parsers::qwen::parse_qwen_tool_calls at line 119), AT OR UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(lfm3): fix tool call special token parsing (#2531)”; “fix(core): only honor tool-call and reasoning delimiters emitted as special tokens (#2455)”; “fix(qwen3.8): fixes around gdn rollback for qwen3.8 (#2377)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-08-10..2026-11-08, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-10 21:43:10 -05:00' --until='2026-11-08 21:43:10 -05:00' --full-history --no-merges -- mistralrs-core/src/tools/parsers/qwen.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
D2 · Cognitive Complexity · Pipeline · ×1
  • Pipeline::submit_step (cognitive 255) mistralrs-core/src/pipeline/mod.rs:2255 — Pipeline::submit_step has cognitive complexity 255 (threshold 15). Drivers by points: if/else 57 (153 pts), loops 17 (55 pts), boolean chains 25, match/switch 8 (22 pts) (nesting depth added 148). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · MultimodalLoader · ×1
  • MultimodalLoader::load_model_from_path (cognitive 167) mistralrs-core/src/pipeline/multimodal.rs:526 — MultimodalLoader::load_model_from_path has cognitive complexity 167 (threshold 15). Drivers by points: if/else 90 (126 pts), match/switch 17 (25 pts), boolean chains 8, loops 6 (8 pts) (nesting depth added 46). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · NormalLoader · ×1
  • NormalLoader::load_model_from_path (cognitive 118) mistralrs-core/src/pipeline/normal.rs:659 — NormalLoader::load_model_from_path has cognitive complexity 118 (threshold 15). Drivers by points: if/else 66 (92 pts), match/switch 12 (18 pts), boolean chains 4, loops 3 (4 pts) (nesting depth added 33). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AgentStream · ×1
  • AgentStream::next (cognitive 106) mistralrs/src/agent.rs:199 — AgentStream::next has cognitive complexity 106 (threshold 15). Drivers by points: if/else 18 (85 pts), match/switch 4 (16 pts), loops 2 (5 pts) (nesting depth added 82). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · OpenResponsesStreamer · ×1
  • OpenResponsesStreamer::poll_next (cognitive 90) mistralrs-server-core/src/responses.rs:1158 — OpenResponsesStreamer::poll_next has cognitive complexity 90 (threshold 15). Drivers by points: if/else 23 (73 pts), loops 3 (12 pts), match/switch 3 (4 pts), boolean chains 1 (nesting depth added 60). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · streaming.streamChatCompletion (cognitive 90) · ×1
  • streaming.streamChatCompletion (cognitive 90) mistralrs-cli/webui/src/lib/services/streaming.ts:21 — streaming.streamChatCompletion has cognitive complexity 90 (threshold 15). Drivers by points: if/else 33 (76 pts), error handling 4 (8 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 48). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · XLoraClassifier · ×1
  • XLoraClassifier::new (cognitive 85) mistralrs-core/src/xlora_models/classifier.rs:32 — XLoraClassifier::new has cognitive complexity 85 (threshold 15). Drivers by points: if/else 49 (83 pts), loops 1 (2 pts) (nesting depth added 35). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Qwen3VLModel · ×1
  • Qwen3VLModel::forward (cognitive 81) mistralrs-core/src/vision_models/qwen3_vl/mod.rs:653 — Qwen3VLModel::forward has cognitive complexity 81 (threshold 15). Drivers by points: if/else 30 (51 pts), loops 8 (23 pts), match/switch 3 (5 pts), boolean chains 2 (nesting depth added 38). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Qwen3VLMoEModel · ×1
  • Qwen3VLMoEModel::forward (cognitive 81) mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:99 — Qwen3VLMoEModel::forward has cognitive complexity 81 (threshold 15). Drivers by points: if/else 30 (51 pts), loops 8 (23 pts), match/switch 3 (5 pts), boolean chains 2 (nesting depth added 38). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FlashAttnVarLen · ×1
  • FlashAttnVarLen::cuda_fwd_t (cognitive 81) mistralrs-flash-attn/src/flash.rs:470 — FlashAttnVarLen::cuda_fwd_t has cognitive complexity 81 (threshold 15). Drivers by points: if/else 46 (57 pts), match/switch 9 (14 pts), boolean chains 10 (nesting depth added 16). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · Qwen4ExpTextModel · ×1
  • Qwen4ExpTextModel::forward_embeds (cognitive 77) mistralrs-core/src/vision_models/qwen4_exp/text.rs:810 — Qwen4ExpTextModel::forward_embeds has cognitive complexity 77 (threshold 15). Drivers by points: if/else 23 (46 pts), match/switch 7 (16 pts), boolean chains 9, loops 3 (6 pts) (nesting depth added 35). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Idefics2 · ×1
  • Idefics2::forward_inner (cognitive 76) REDACTED:1148 — Idefics2::forward_inner has cognitive complexity 76 (threshold 15). Drivers by points: if/else 26 (58 pts), loops 5 (14 pts), boolean chains 4 (nesting depth added 41). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · TagReasoningContext · ×1
  • TagReasoningContext::process_text (cognitive 71) mistralrs-core/src/reasoning_parsers/tag_based.rs:179 — TagReasoningContext::process_text has cognitive complexity 71 (threshold 15). Drivers by points: if/else 23 (69 pts), boolean chains 1, loops 1 (nesting depth added 46). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · MiniCpmOImageProcessor · ×1
  • MiniCpmOImageProcessor::process_inputs (cognitive 71) mistralrs-core/src/vision_models/minicpmo/inputs_processor.rs:297 — MiniCpmOImageProcessor::process_inputs has cognitive complexity 71 (threshold 15). Drivers by points: if/else 23 (45 pts), loops 7 (23 pts), boolean chains 3 (nesting depth added 38). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Qwen2_5VLModel · ×1
  • Qwen2_5VLModel::forward (cognitive 69) mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:169 — Qwen2_5VLModel::forward has cognitive complexity 69 (threshold 15). Drivers by points: if/else 26 (41 pts), loops 5 (20 pts), match/switch 2 (6 pts), boolean chains 2 (nesting depth added 34). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · EmbeddingLoader · ×1
  • EmbeddingLoader::load_model_from_path (cognitive 63) mistralrs-core/src/pipeline/embedding.rs:209 — EmbeddingLoader::load_model_from_path has cognitive complexity 63 (threshold 15). Drivers by points: if/else 42 (53 pts), loops 4 (5 pts), match/switch 3 (5 pts) (nesting depth added 14). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · Qwen3_5MoeModel · ×1
  • Qwen3_5MoeModel::forward (cognitive 58) mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:101 — Qwen3_5MoeModel::forward has cognitive complexity 58 (threshold 15). Drivers by points: if/else 21 (35 pts), loops 7 (17 pts), match/switch 3 (4 pts), boolean chains 2 (nesting depth added 25). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Runner · ×1
  • Runner::new (cognitive 58) mistralrs-pyo3/src/lib.rs:1264 — Runner::new has cognitive complexity 58 (threshold 15). Drivers by points: if/else 25 (34 pts), loops 3 (9 pts), boolean chains 8, match/switch 6 (7 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ShardedSafeTensors · ×1
  • ShardedSafeTensors::get (cognitive 53) mistralrs-quant/src/safetensors.rs:728 — ShardedSafeTensors::get has cognitive complexity 53 (threshold 15). Drivers by points: if/else 19 (46 pts), match/switch 4 (7 pts) (nesting depth added 30). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Llama4Model · ×1
  • Llama4Model::forward (cognitive 51) mistralrs-core/src/vision_models/llama4/mod.rs:105 — Llama4Model::forward has cognitive complexity 51 (threshold 15). Drivers by points: if/else 16 (39 pts), loops 3 (9 pts), boolean chains 3 (nesting depth added 29). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · bench_decode_serving.validate_args (cognitive 48) · ×1
  • bench_decode_serving.validate_args (cognitive 48) releases/v0.9.3/scripts/bench_decode_serving.py:216 — bench_decode_serving.validate_args has cognitive complexity 48 (threshold 15). Drivers by points: if/else 27 (35 pts), boolean chains 12, loops 1 (nesting depth added 8). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · Idefics3Model · ×1
  • Idefics3Model::forward_inner (cognitive 47) REDACTED:119 — Idefics3Model::forward_inner has cognitive complexity 47 (threshold 15). Drivers by points: if/else 15 (32 pts), loops 5 (14 pts), boolean chains 1 (nesting depth added 26). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · MLlamaImageProcessor · ×1
  • MLlamaImageProcessor::process_inputs (cognitive 46) mistralrs-core/src/vision_models/mllama/inputs_processor.rs:320 — MLlamaImageProcessor::process_inputs has cognitive complexity 46 (threshold 15). Drivers by points: if/else 21 (29 pts), boolean chains 9, match/switch 3 (6 pts), loops 1 (2 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CudaGraphCaptureMemory · ×1
  • CudaGraphCaptureMemory::shape (cognitive 44) mistralrs-core/src/pipeline/cuda_graph.rs:89 — CudaGraphCaptureMemory::shape has cognitive complexity 44 (threshold 15). Drivers by points: if/else 13 (35 pts), boolean chains 5, loops 3 (4 pts) (nesting depth added 23). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · Gemma3nAudioAttention · ×1
  • Gemma3nAudioAttention::forward (cognitive 43) mistralrs-core/src/vision_models/gemma3n/audio.rs:587 — Gemma3nAudioAttention::forward has cognitive complexity 43 (threshold 15). Drivers by points: if/else 21 (32 pts), boolean chains 5, match/switch 3 (4 pts), loops 1 (2 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CublasLTBatchMatmulF8Scalar · ×1
  • CublasLTBatchMatmulF8Scalar::fwd_f8e4m3_scalar (cognitive 42) mistralrs-quant/src/cublaslt/api.rs:46 — CublasLTBatchMatmulF8Scalar::fwd_f8e4m3_scalar has cognitive complexity 42 (threshold 15). Drivers by points: if/else 18 (31 pts), match/switch 5 (7 pts), boolean chains 3, loops 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Llama4ImageProcessor · ×1
  • Llama4ImageProcessor::process_inputs (cognitive 39) mistralrs-core/src/vision_models/llama4/inputs_processor.rs:392 — Llama4ImageProcessor::process_inputs has cognitive complexity 39 (threshold 15). Drivers by points: if/else 19 (31 pts), loops 3 (7 pts), boolean chains 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Mistral3ImageProcessor · ×1
  • Mistral3ImageProcessor::process_inputs (cognitive 39) mistralrs-core/src/vision_models/mistral3/inputs_processor.rs:254 — Mistral3ImageProcessor::process_inputs has cognitive complexity 39 (threshold 15). Drivers by points: if/else 26 (36 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Gemma4AudioAttention · ×1
  • Gemma4AudioAttention::forward (cognitive 38) mistralrs-core/src/vision_models/gemma4/audio.rs:643 — Gemma4AudioAttention::forward has cognitive complexity 38 (threshold 15). Drivers by points: if/else 20 (29 pts), boolean chains 4, match/switch 2 (3 pts), loops 1 (2 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · VoxtralInputsProcessor · ×1
  • VoxtralInputsProcessor::process_inputs (cognitive 38) mistralrs-core/src/vision_models/voxtral/inputs_processor.rs:195 — VoxtralInputsProcessor::process_inputs has cognitive complexity 38 (threshold 15). Drivers by points: if/else 17 (32 pts), loops 3 (6 pts) (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CumSum · ×1
  • CumSum::cpu_fwd (cognitive 38) mistralrs-quant/src/utils/ops.rs:1402 — CumSum::cpu_fwd has cognitive complexity 38 (threshold 15). Drivers by points: loops 8 (28 pts), if/else 7 (9 pts), match/switch 1 (nesting depth added 22). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · CacheEngine · ×1
  • CacheEngine::allocate_gpu_cache (cognitive 37) mistralrs-core/src/paged_attention/cache_engine.rs:201 — CacheEngine::allocate_gpu_cache has cognitive complexity 37 (threshold 15). Drivers by points: if/else 17 (31 pts), boolean chains 3, match/switch 1 (2 pts), loops 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ManagedEmbedding · ×1
  • ManagedEmbedding::prepare_mapped (cognitive 37) mistralrs-quant/src/embedding/storage.rs:749 — ManagedEmbedding::prepare_mapped has cognitive complexity 37 (threshold 15). Drivers by points: if/else 12 (23 pts), loops 5 (14 pts) (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · HarmonyContext · ×1
  • HarmonyContext::extract_delta (cognitive 36) mistralrs-core/src/reasoning_parsers/harmony.rs:181 — HarmonyContext::extract_delta has cognitive complexity 36 (threshold 15). Drivers by points: if/else 12 (33 pts), match/switch 1 (2 pts), boolean chains 1 (nesting depth added 22). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · Phi3InputsProcessor · ×1
  • Phi3InputsProcessor::process_inputs (cognitive 36) mistralrs-core/src/vision_models/phi3/phi3_inputs_processor.rs:282 — Phi3InputsProcessor::process_inputs has cognitive complexity 36 (threshold 15). Drivers by points: if/else 20 (29 pts), loops 3 (4 pts), boolean chains 3 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LoraConfig · ×1
  • LoraConfig::validate_dynamic (cognitive 36) mistralrs-quant/src/lora/mod.rs:316 — LoraConfig::validate_dynamic has cognitive complexity 36 (threshold 15). Drivers by points: if/else 20 (25 pts), boolean chains 4, loops 3 (4 pts), match/switch 2 (3 pts) (nesting depth added 7). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · MistralRsForServerBuilder · ×1
  • MistralRsForServerBuilder::build_multi_model (cognitive 36) mistralrs-server-core/src/mistralrs_for_server_builder.rs:911 — MistralRsForServerBuilder::build_multi_model has cognitive complexity 36 (threshold 15). Drivers by points: if/else 27 (34 pts), boolean chains 1, loops 1 (nesting depth added 7). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · PackedMultimodalLayout · ×1
  • PackedMultimodalLayout::new (cognitive 35) mistralrs-core/src/vision_models/multimodal_layout.rs:156 — PackedMultimodalLayout::new has cognitive complexity 35 (threshold 15). Drivers by points: if/else 6 (22 pts), loops 4 (10 pts), boolean chains 3 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ChatStore.generateAssistant (cognitive 35) · ×1
  • ChatStore.generateAssistant (cognitive 35) mistralrs-cli/webui/src/lib/stores/chat.svelte.ts:378 — ChatStore.generateAssistant has cognitive complexity 35 (threshold 15). Drivers by points: if/else 16 (23 pts), boolean chains 11, ternaries 1 (nesting depth added 7). Most of this is not in the body itself: 9 of the 35 points are its own statements and the rest belongs to 8 function items inside it that branch (a function literal at line 445, appendText, a function literal at line 491, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
D2 · Cognitive Complexity · Topology · ×1
  • Topology::from_str (cognitive 34) mistralrs-core/src/topology/mod.rs:104 — Topology::from_str has cognitive complexity 34 (threshold 15). Drivers by points: if/else 14 (25 pts), loops 3 (4 pts), match/switch 1 (4 pts), boolean chains 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ReplicatedLayer · ×1
  • ReplicatedLayer::new_layers_matformer_indices (cognitive 34) mistralrs-quant/src/distributed/layers.rs:1560 — ReplicatedLayer::new_layers_matformer_indices has cognitive complexity 34 (threshold 15). Drivers by points: if/else 15 (25 pts), match/switch 3 (8 pts), boolean chains 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AnyMoePipeline · ×1
  • AnyMoePipeline::amoe_pre_train (cognitive 33) mistralrs-core/src/pipeline/amoe.rs:500 — AnyMoePipeline::amoe_pre_train has cognitive complexity 33 (threshold 15). Drivers by points: if/else 9 (13 pts), loops 5 (11 pts), match/switch 2 (9 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Gemma3nModel · ×1
  • Gemma3nModel::forward (cognitive 32) mistralrs-core/src/vision_models/gemma3n/mod.rs:334 — Gemma3nModel::forward has cognitive complexity 32 (threshold 15). Drivers by points: if/else 11 (21 pts), loops 2 (6 pts), boolean chains 4, match/switch 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Qwen4ExpModel · ×1
  • Qwen4ExpModel::forward (cognitive 32) mistralrs-core/src/vision_models/qwen4_exp/mod.rs:225 — Qwen4ExpModel::forward has cognitive complexity 32 (threshold 15). Drivers by points: if/else 13 (19 pts), loops 4 (8 pts), match/switch 2 (3 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · HqqBits · ×1
  • HqqBits::bitpack_type (cognitive 31) mistralrs-quant/src/hqq/mod.rs:156 — HqqBits::bitpack_type has cognitive complexity 31 (threshold 15). Drivers by points: if/else 11 (19 pts), match/switch 8 (12 pts) (nesting depth added 12). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · Qwen3_5MoeTextModel · ×1
  • Qwen3_5MoeTextModel::forward_embeds (cognitive 30) mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:790 — Qwen3_5MoeTextModel::forward_embeds has cognitive complexity 30 (threshold 15). Drivers by points: if/else 14 (25 pts), match/switch 2 (3 pts), boolean chains 1, loops 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SumAllReduce · ×1
  • SumAllReduce::cuda_fwd (cognitive 30) mistralrs-quant/src/distributed/mod.rs:546 — SumAllReduce::cuda_fwd has cognitive complexity 30 (threshold 15). Drivers by points: if/else 6 (18 pts), match/switch 5 (12 pts) (nesting depth added 19). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident. This shape REPEATS in the file: one other method here (AllGather::cuda_fwd) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D2 · Cognitive Complexity · AllGather · ×1
  • AllGather::cuda_fwd (cognitive 30) mistralrs-quant/src/distributed/mod.rs:692 — AllGather::cuda_fwd has cognitive complexity 30 (threshold 15). Drivers by points: if/else 6 (18 pts), match/switch 5 (12 pts) (nesting depth added 19). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident. This shape REPEATS in the file: one other method here (SumAllReduce::cuda_fwd) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D2 · Cognitive Complexity · SoftmaxWithSinks · ×1
  • SoftmaxWithSinks::cpu_fwd (cognitive 29) mistralrs-quant/src/utils/ops.rs:1870 — SoftmaxWithSinks::cpu_fwd has cognitive complexity 29 (threshold 15). Drivers by points: loops 9 (18 pts), if/else 3 (9 pts), match/switch 2 (nesting depth added 15). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · Gemma3nLoader · ×1
  • Gemma3nLoader::non_mapped_size_in_bytes (cognitive 28) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6002 — Gemma3nLoader::non_mapped_size_in_bytes has cognitive complexity 28 (threshold 15). Drivers by points: if/else 11 (20 pts), loops 4 (5 pts), match/switch 1 (3 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · VisionModel · ×1
  • VisionModel::position_embeddings (cognitive 28) mistralrs-core/src/vision_models/lfm3_vl/vision.rs:379 — VisionModel::position_embeddings has cognitive complexity 28 (threshold 15). Drivers by points: loops 7 (28 pts) (nesting depth added 21). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · DequantizeOp · ×1
  • DequantizeOp::dequantize_cpu (cognitive 28) mistralrs-quant/src/bitsandbytes/op.rs:130 — DequantizeOp::dequantize_cpu has cognitive complexity 28 (threshold 15). Drivers by points: loops 6 (15 pts), if/else 6 (12 pts), match/switch 1 (nesting depth added 15). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · render_pyi._render_class (cognitive 28) · ×1
  • render_pyi._render_class (cognitive 28) docs/scripts/render_pyi.py:451 — render_pyi._render_class has cognitive complexity 28 (threshold 15). Drivers by points: if/else 10 (17 pts), loops 5 (9 pts), boolean chains 1, ternaries 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SmolLm3 · ×1
  • SmolLm3::create_anymoe_layers (cognitive 27) mistralrs-core/src/models/smollm3.rs:623 — SmolLm3::create_anymoe_layers has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (19 pts), loops 4 (5 pts), match/switch 1 (3 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CudaGraphDecodeStep · ×1
  • CudaGraphDecodeStep::one_token_continuation (cognitive 27) mistralrs-core/src/pipeline/cuda_graph.rs:957 — CudaGraphDecodeStep::one_token_continuation has cognitive complexity 27 (threshold 15). Drivers by points: if/else 13 (23 pts), match/switch 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FlashAttn · ×1
  • FlashAttn::cuda_fwd_t (cognitive 27) mistralrs-flash-attn/src/flash.rs:22 — FlashAttn::cuda_fwd_t has cognitive complexity 27 (threshold 15). Drivers by points: if/else 19 (21 pts), boolean chains 4, match/switch 1 (2 pts) (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · PreQuantizedExperts · ×1
  • PreQuantizedExperts::new (cognitive 27) mistralrs-quant/src/distributed/layers.rs:1939 — PreQuantizedExperts::new has cognitive complexity 27 (threshold 15). Drivers by points: if/else 12 (19 pts), match/switch 2 (4 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · bench_decode_serving.plot_summary (cognitive 27) · ×1
  • bench_decode_serving.plot_summary (cognitive 27) releases/v0.9.3/scripts/bench_decode_serving.py:1558 — bench_decode_serving.plot_summary has cognitive complexity 27 (threshold 15). Drivers by points: loops 4 (9 pts), if/else 4 (8 pts), ternaries 2 (7 pts), boolean chains 3 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AudioEmbedding · ×1
  • AudioEmbedding::forward (cognitive 26) mistralrs-core/src/vision_models/phi4/audio_embedding.rs:208 — AudioEmbedding::forward has cognitive complexity 26 (threshold 15). Drivers by points: if/else 15 (24 pts), boolean chains 1, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CudaPeerAccess · ×1
  • CudaPeerAccess::new_cuda (cognitive 25) mistralrs-core/src/device_map/peer.rs:58 — CudaPeerAccess::new_cuda has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (18 pts), loops 3 (4 pts), match/switch 1 (3 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AutoLoader · ×1
  • AutoLoader::detect (cognitive 25) mistralrs-core/src/pipeline/auto.rs:378 — AutoLoader::detect has cognitive complexity 25 (threshold 15). Drivers by points: if/else 14 (24 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GgufMatMul · ×1
  • GgufMatMul::apply_isq (cognitive 25) mistralrs-quant/src/gguf/mod.rs:700 — GgufMatMul::apply_isq has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11 (21 pts), match/switch 2 (4 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · bench_decode_serving.write_summaries (cognitive 25) · ×1
  • bench_decode_serving.write_summaries (cognitive 25) releases/v0.9.3/scripts/bench_decode_serving.py:1511 — bench_decode_serving.write_summaries has cognitive complexity 25 (threshold 15). Drivers by points: if/else 4 (14 pts), loops 5 (11 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MoEExpertsBackend · ×1
  • MoEExpertsBackend::resolve (cognitive 24) mistralrs-core/src/moe/experts/config.rs:200 — MoEExpertsBackend::resolve has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (18 pts), boolean chains 4, match/switch 1 (2 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ModelWeights · ×1
  • ModelWeights::from_gguf (cognitive 24) mistralrs-core/src/xlora_models/quantized_llama.rs:464 — ModelWeights::from_gguf has cognitive complexity 24 (threshold 15). Drivers by points: loops 5 (11 pts), if/else 7 (8 pts), match/switch 1 (3 pts), boolean chains 2 (nesting depth added 9). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · RowParallelLayer · ×1
  • RowParallelLayer::new_with_lora_spec (cognitive 24) mistralrs-quant/src/distributed/layers.rs:398 — RowParallelLayer::new_with_lora_spec has cognitive complexity 24 (threshold 15). Drivers by points: if/else 15 (20 pts), boolean chains 2, match/switch 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · render_pyi._parse_doc_sections (cognitive 24) · ×1
  • render_pyi._parse_doc_sections (cognitive 24) docs/scripts/render_pyi.py:262 — render_pyi._parse_doc_sections has cognitive complexity 24 (threshold 15). Drivers by points: if/else 10 (19 pts), loops 2 (3 pts), boolean chains 1, ternaries 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RotatingCache · ×1
  • RotatingCache::append (cognitive 23) mistralrs-core/src/kv_cache/rotating_cache.rs:261 — RotatingCache::append has cognitive complexity 23 (threshold 15). Drivers by points: if/else 14 (22 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Config · ×1
  • Config::validate (cognitive 23) mistralrs-core/src/models/hunyuan_v1_moe.rs:199 — Config::validate has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (16 pts), boolean chains 4, loops 3 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SequenceGroup · ×1
  • SequenceGroup::maybe_send_streaming_response (cognitive 23) mistralrs-core/src/sequence.rs:2584 — SequenceGroup::maybe_send_streaming_response has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (14 pts), boolean chains 5, loops 2 (4 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AudioModel · ×1
  • AudioModel::forward (cognitive 23) mistralrs-core/src/vision_models/gemma3n/audio.rs:1311 — AudioModel::forward has cognitive complexity 23 (threshold 15). Drivers by points: if/else 13 (17 pts), loops 3 (4 pts), boolean chains 2 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · DecisionPrompt · ×1
  • DecisionPrompt::plan (cognitive 23) mistralrs-core/src/vision_models/lfm3_d1/prompt.rs:274 — DecisionPrompt::plan has cognitive complexity 23 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 5 (8 pts), boolean chains 4 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · mistralrs_macros · ×1
  • mistralrs_macros::generate_tool_impl (cognitive 23) mistralrs-macros/src/lib.rs:127 — mistralrs_macros::generate_tool_impl has cognitive complexity 23 (threshold 15). Drivers by points: if/else 12 (19 pts), boolean chains 2, loops 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MetalPagedPrefillShape · ×1
  • MetalPagedPrefillShape::dispatch (cognitive 23) mistralrs-paged-attn/src/metal/backend/paged_prefill.rs:187 — MetalPagedPrefillShape::dispatch has cognitive complexity 23 (threshold 15). Drivers by points: if/else 18 (19 pts), boolean chains 4 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · RegisteredShape · ×1
  • RegisteredShape::warm (cognitive 23) mistralrs-quant/src/cutile/nvfp4.rs:543 — RegisteredShape::warm has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (16 pts), loops 3 (5 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RowCodec · ×1
  • RowCodec::decode_row (cognitive 23) mistralrs-quant/src/embedding/mod.rs:305 — RowCodec::decode_row has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 5 (10 pts), match/switch 1 (nesting depth added 11). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · GptqLayer · ×1
  • GptqLayer::gptq_gemm (cognitive 23) mistralrs-quant/src/gptq/gptq_cuda.rs:83 — GptqLayer::gptq_gemm has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (13 pts), match/switch 6, boolean chains 4 (nesting depth added 3). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
D2 · Cognitive Complexity · bench_cpu_sweep.main (cognitive 23) · ×1
  • bench_cpu_sweep.main (cognitive 23) releases/v0.9.0/scripts/bench_cpu_sweep.py:189 — bench_cpu_sweep.main has cognitive complexity 23 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 5 (11 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · IntervalLogger · ×1
  • IntervalLogger::new (cognitive 22) mistralrs-core/src/engine/logger.rs:58 — IntervalLogger::new has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (19 pts), boolean chains 1, loops 1, match/switch 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Mistral3Model · ×1
  • Mistral3Model::forward (cognitive 22) mistralrs-core/src/vision_models/mistral3/mod.rs:230 — Mistral3Model::forward has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (15 pts), loops 2 (7 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · VisualEncoder · ×1
  • VisualEncoder::encode (cognitive 22) mistralrs-core/src/vision_models/qwen3_vl/mod.rs:434 — VisualEncoder::encode has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (11 pts), loops 4 (9 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GgufArchive · ×1
  • GgufArchive::merge_components (cognitive 22) mistralrs-quant/src/gguf/archive.rs:470 — GgufArchive::merge_components has cognitive complexity 22 (threshold 15). Drivers by points: if/else 3 (10 pts), loops 5 (8 pts), match/switch 1 (3 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MuseGlimmerImageProcessor · ×1
  • MuseGlimmerImageProcessor::process_inputs (cognitive 21) mistralrs-core/src/vision_models/muse_glimmer/inputs_processor.rs:904 — MuseGlimmerImageProcessor::process_inputs has cognitive complexity 21 (threshold 15). Drivers by points: if/else 13 (14 pts), loops 3 (6 pts), boolean chains 1 (nesting depth added 4). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · Fp8BlockwiseQuantize · ×1
  • Fp8BlockwiseQuantize::dispatch_quant_blockwise (cognitive 21) mistralrs-quant/src/blockwise_fp8/ops.rs:370 — Fp8BlockwiseQuantize::dispatch_quant_blockwise has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 4 (6 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GgufWeightSource · ×1
  • GgufWeightSource::materialize_mxfp4_component (cognitive 21) mistralrs-quant/src/gguf/weight_source.rs:494 — GgufWeightSource::materialize_mxfp4_component has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (17 pts), loops 2 (4 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CpuInputs · ×1
  • CpuInputs::run (cognitive 21) mistralrs-quant/src/lfm3_conv.rs:131 — CpuInputs::run has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (17 pts), loops 2 (4 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · merge_results.build_summary (cognitive 21) · ×1
  • merge_results.build_summary (cognitive 21) releases/v0.9.3/scripts/merge_results.py:74 — merge_results.build_summary has cognitive complexity 21 (threshold 15). Drivers by points: if/else 4 (11 pts), loops 5 (10 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · mistralrs · ×1
  • mistralrs::messages::resolve_pending (cognitive 20) mistralrs/src/messages.rs:1349 — mistralrs::messages::resolve_pending has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (16 pts), loops 2 (3 pts), match/switch 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · KvCache · ×1
  • KvCache::append (cognitive 20) mistralrs-core/src/kv_cache/mod.rs:152 — KvCache::append has cognitive complexity 20 (threshold 15). Drivers by points: if/else 5 (9 pts), match/switch 6 (9 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LoraLinear · ×1
  • LoraLinear::lora_forward (cognitive 20) mistralrs-core/src/lora/loralinear.rs:168 — LoraLinear::lora_forward has cognitive complexity 20 (threshold 15). Drivers by points: if/else 12 (17 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FixedBucketingManager · ×1
  • FixedBucketingManager::bucket_and_waitlist_seqs_waiting (cognitive 20) mistralrs-core/src/scheduler/default_scheduler.rs:124 — FixedBucketingManager::bucket_and_waitlist_seqs_waiting has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (11 pts), loops 3 (6 pts), match/switch 1 (2 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GemmaLarkBuilder · ×1
  • GemmaLarkBuilder::emit_constrained_args (cognitive 20) mistralrs-core/src/tools/parsers/gemma4_strict.rs:61 — GemmaLarkBuilder::emit_constrained_args has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (15 pts), loops 4 (5 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CublasLTBatchMatmul · ×1
  • CublasLTBatchMatmul::fwd (cognitive 20) mistralrs-quant/src/cublaslt/api.rs:358 — CublasLTBatchMatmul::fwd has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (16 pts), match/switch 2 (4 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · IndexedMoeLoraDecode · ×1
  • IndexedMoeLoraDecode::new (cognitive 20) mistralrs-quant/src/gguf/cuda.rs:1155 — IndexedMoeLoraDecode::new has cognitive complexity 20 (threshold 15). Drivers by points: if/else 12 (14 pts), boolean chains 4, loops 2 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · MultiModelBuilder · ×1
  • MultiModelBuilder::build (cognitive 19) mistralrs/src/model_builder_trait.rs:241 — MultiModelBuilder::build has cognitive complexity 19 (threshold 15). Drivers by points: if/else 13 (17 pts), loops 2 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · HybridPagedPrefixValidator · ×1
  • HybridPagedPrefixValidator::validate_prefix_cache_hit (cognitive 19) mistralrs-core/src/engine/mod.rs:386 — HybridPagedPrefixValidator::validate_prefix_cache_hit has cognitive complexity 19 (threshold 15). Drivers by points: if/else 12 (19 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SamplingParams · ×1
  • SamplingParams::apply_model_defaults (cognitive 19) mistralrs-core/src/sampler.rs:154 — SamplingParams::apply_model_defaults has cognitive complexity 19 (threshold 15). Drivers by points: if/else 11 (17 pts), loops 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DefaultScheduler · ×1
  • DefaultScheduler::schedule (cognitive 19) mistralrs-core/src/scheduler/default_scheduler.rs:227 — DefaultScheduler::schedule has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 3 (4 pts), match/switch 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Sequence · ×1
  • Sequence::take_ready_streaming_emissions (cognitive 19) mistralrs-core/src/sequence.rs:1595 — Sequence::take_ready_streaming_emissions has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 3 (5 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DecisionPlan · ×1
  • DecisionPlan::read_span (cognitive 19) mistralrs-core/src/vision_models/lfm3_d1/readout.rs:109 — DecisionPlan::read_span has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 3, match/switch 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · QsaAttention · ×1
  • QsaAttention::forward_paged (cognitive 19) mistralrs-core/src/vision_models/qwen4_exp/qsa.rs:376 — QsaAttention::forward_paged has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (10 pts), match/switch 3 (7 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ParamArgs · ×1
  • ParamArgs::from_attrs (cognitive 19) mistralrs-macros/src/lib.rs:60 — ParamArgs::from_attrs has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (18 pts), loops 1 (nesting depth added 12). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · Matmul · ×1
  • Matmul::cpu_fwd (cognitive 19) mistralrs-quant/src/mxfp8/mod.rs:596 — Matmul::cpu_fwd has cognitive complexity 19 (threshold 15). Drivers by points: loops 4 (10 pts), if/else 6 (8 pts), match/switch 1 (nesting depth added 8). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · plot_results.plot_speedup (cognitive 19) · ×1
  • plot_results.plot_speedup (cognitive 19) releases/v0.9.0/scripts/plot_results.py:67 — plot_results.plot_speedup has cognitive complexity 19 (threshold 15). Drivers by points: if/else 2 (8 pts), loops 4 (8 pts), ternaries 1 (2 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · bench_decode_serving.main (cognitive 19) · ×1
  • bench_decode_serving.main (cognitive 19) releases/v0.9.3/scripts/bench_decode_serving.py:1657 — bench_decode_serving.main has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (10 pts), loops 3 (6 pts), boolean chains 3 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Agent · ×1
  • Agent::run (cognitive 18) mistralrs/src/agent.rs:535 — Agent::run has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (9 pts), loops 3 (6 pts), match/switch 1 (3 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FormatOptions · ×1
  • FormatOptions::derive_local_model_root (cognitive 18) mistralrs-cli/src/args/model.rs:155 — FormatOptions::derive_local_model_root has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (15 pts), boolean chains 2, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · T5Attention · ×1
  • T5Attention::forward (cognitive 18) mistralrs-core/src/diffusion_models/t5/mod.rs:350 — T5Attention::forward has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (10 pts), match/switch 5 (8 pts) (nesting depth added 8). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · Content · ×1
  • Content::print_metadata (cognitive 18) mistralrs-core/src/gguf/content.rs:205 — Content::print_metadata has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (9 pts), loops 5 (9 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AutoDeviceMapQuantization · ×1
  • AutoDeviceMapQuantization::pack_factor_for_candidates (cognitive 18) mistralrs-core/src/pipeline/loaders/mod.rs:1026 — AutoDeviceMapQuantization::pack_factor_for_candidates has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 2 (4 pts), match/switch 1 (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · SpeculativeTapRouting · ×1
  • SpeculativeTapRouting::new (cognitive 18) mistralrs-core/src/speculative/proposer.rs:89 — SpeculativeTapRouting::new has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 2 (4 pts), match/switch 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Qwen3VLVisionModel · ×1
  • Qwen3VLVisionModel::rot_pos_emb (cognitive 18) mistralrs-core/src/vision_models/qwen3_vl/vision.rs:620 — Qwen3VLVisionModel::rot_pos_emb has cognitive complexity 18 (threshold 15). Drivers by points: loops 7 (18 pts) (nesting depth added 11). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · BitWise · ×1
  • BitWise::cpu_fwd (cognitive 18) mistralrs-quant/src/utils/ops.rs:261 — BitWise::cpu_fwd has cognitive complexity 18 (threshold 15). Drivers by points: match/switch 11 (13 pts), if/else 4, boolean chains 1 (nesting depth added 2). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · StreamingAudioCapture · ×1
  • StreamingAudioCapture::stage (cognitive 18) mistralrs-server-core/src/audio_history.rs:270 — StreamingAudioCapture::stage has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (17 pts), loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MessageContent · ×1
  • MessageContent::to_text (cognitive 18) mistralrs-server-core/src/openai.rs:205 — MessageContent::to_text has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (12 pts), loops 2 (5 pts), match/switch 1 (nesting depth added 11). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · executor.execute_code (cognitive 18) · ×1
  • executor.execute_code (cognitive 18) REDACTED:325 — executor.execute_code has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (14 pts), error handling 3, boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Gemma4Loader · ×1
  • Gemma4Loader::non_mapped_size_in_bytes (cognitive 17) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9704 — Gemma4Loader::non_mapped_size_in_bytes has cognitive complexity 17 (threshold 15). Drivers by points: if/else 14, loops 1 (2 pts), boolean chains 1 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · McpClient · ×1
  • McpClient::convert_mcp_schema_to_parameters (cognitive 17) mistralrs-mcp/src/client.rs:516 — McpClient::convert_mcp_schema_to_parameters has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (9 pts), loops 2 (7 pts), match/switch 1 (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · mistralrs_metal_compile · ×1
  • mistralrs_metal_compile::preprocess_includes (cognitive 17) mistralrs-metal-compile/src/lib.rs:420 — mistralrs_metal_compile::preprocess_includes has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (15 pts), boolean chains 1, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Fp8W8A8Kernel · ×1
  • Fp8W8A8Kernel::warm (cognitive 17) mistralrs-quant/src/cutile/fp8_w8a8.rs:743 — Fp8W8A8Kernel::warm has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (8 pts), match/switch 2 (5 pts), loops 3 (4 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Descent · ×1
  • Descent::search (cognitive 17) mistralrs-quant/src/cutile/tune.rs:711 — Descent::search has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · State · ×1
  • State::forward (cognitive 17) mistralrs-quant/src/nvfp4/cutlass.rs:342 — State::forward has cognitive complexity 17 (threshold 15). Drivers by points: if/else 12 (13 pts), match/switch 2, boolean chains 1, loops 1 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · AnthropicStreamer · ×1
  • AnthropicStreamer::poll_next (cognitive 17) mistralrs-server-core/src/anthropic.rs:1542 — AnthropicStreamer::poll_next has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (11 pts), match/switch 2 (5 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · plot_results.plot_concurrency (cognitive 17) · ×1
  • plot_results.plot_concurrency (cognitive 17) releases/v0.9.5/scripts/plot_results.py:146 — plot_results.plot_concurrency has cognitive complexity 17 (threshold 15). Drivers by points: ternaries 4 (12 pts), loops 3 (5 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SearchPipeline · ×1
  • SearchPipeline::chunk_document (cognitive 16) mistralrs-core/src/search/rag.rs:166 — SearchPipeline::chunk_document has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 2 (3 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DFlashCudaGraphState · ×1
  • DFlashCudaGraphState::run (cognitive 16) mistralrs-core/src/speculative/dflash.rs:1865 — DFlashCudaGraphState::run has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (11 pts), match/switch 3 (4 pts), boolean chains 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Grid · ×1
  • Grid::new (cognitive 16) mistralrs-core/src/vision_models/lfm3_d1/prompt.rs:32 — Grid::new has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (13 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · GenerationCache · ×1
  • GenerationCache::audio_inputs (cognitive 16) mistralrs-core/src/vision_models/lfm3_omni/mod.rs:81 — GenerationCache::audio_inputs has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 2 (4 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ColumnParallelLayer · ×1
  • ColumnParallelLayer::new_with_shard_and_key (cognitive 16) mistralrs-quant/src/distributed/layers.rs:796 — ColumnParallelLayer::new_with_shard_and_key has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (12 pts), boolean chains 2, match/switch 1 (2 pts) (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · render_examples.main (cognitive 16) · ×1
  • render_examples.main (cognitive 16) docs/scripts/render_examples.py:148 — render_examples.main has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (7 pts), ternaries 2 (6 pts), loops 2 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D29 · Static Analysis (SAST) · REDACTED · ×1
  • REDACTED
D3 · God Classes · TooManyFunctions · ×1
  • TooManyFunctions: mistralrs_core::pipeline::hf mistralrs-core/src/pipeline/hf.rs:25 — TooManyFunctions — 41 free functions. The bar is 30 free functions; this is 11 over it, 1.37× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
D35 · Change Coupling · Change-coupling hub · ×1
  • Change-coupling hub: diffusion.rs → gguf.rs, multimodal.rs, normal.rs mistralrs-core/src/pipeline/diffusion.rs — `mistralrs-core/src/pipeline/diffusion.rs` changes together with 3 other files — `mistralrs-core/src/pipeline/gguf.rs`, `mistralrs-core/src/pipeline/multimodal.rs`, `mistralrs-core/src/pipeline/normal.rs` — none of which declares a dependency on it: one file is the hub of 3 separate couplings, not 3 unrelated pairs. Read the hub first: if the others each duplicate a part of what it does, the shared concern belongs in ONE unit and extracting it clears every edge at once; if the hub is a registry, dispatcher or barrel that must name each of them, the coupling is structural and the question is whether that list can be discovered instead of enumerated. Fixing the hub is one change; breaking the couplings one pair at a time is 3.
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D4 · Code Duplication · Near-duplicate member family (25 members, 30 shared lines) · ×1
  • Near-duplicate member family (25 members, 30 shared lines) mistralrs-core/src/models/flint.rs:347 — mistralrs-core/src/models/flint.rs:347-454 | mistralrs-core/src/models/gemma2.rs:208-297 | mistralrs-core/src/models/glm4.rs:209-296 | mistralrs-core/src/models/glm4_moe.rs:272-361 | mistralrs-core/src/models/gpt_oss.rs:248-326 | mistralrs-core/src/models/granite.rs:1538-1622 | mistralrs-core/src/models/hunyuan_v1_dense.rs:191-272 | mistralrs-core/src/models/hunyuan_v1_moe.rs:374-458 | mistralrs-core/src/models/llama.rs:75-157 | mistralrs-core/src/models/mistral.rs:206-297 | mistralrs-core/src/models/mixtral.rs:151-233 | mistralrs-core/src/models/phi3_5_moe.rs:178-263 | mistralrs-core/src/models/qwen2.rs:240-327 | mistralrs-core/src/models/qwen3.rs:192-282 | mistralrs-core/src/models/qwen3_moe.rs:195-285 | mistralrs-core/src/models/qwen3_next.rs:272-378 | mistralrs-core/src/models/smollm3.rs:90-174 | mistralrs-core/src/models/starcoder2.rs:227-309 | mistralrs-core/src/vision_models/muse_glimmer/text.rs:226-322 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:194-294 | mistralrs-core/src/vision_models/qwen2vl/text.rs:195-295 | mistralrs-core/src/vision_models/qwen3_5/text.rs:280-427 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:189-285 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:194-287 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:300-390 — These 25 members are variants of one another: a block of 30 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 25 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 25 times.
D4 · Code Duplication · Near-duplicate member family (24 members, 26 shared lines) · ×1
  • Near-duplicate member family (24 members, 26 shared lines) mistralrs-core/src/models/flint.rs:347 — mistralrs-core/src/models/flint.rs:347-454 | mistralrs-core/src/models/gemma.rs:167-249 | mistralrs-core/src/models/gemma2.rs:208-297 | mistralrs-core/src/models/glm4.rs:209-296 | mistralrs-core/src/models/glm4_moe.rs:272-361 | mistralrs-core/src/models/gpt_oss.rs:248-326 | mistralrs-core/src/models/hunyuan_v1_dense.rs:191-272 | mistralrs-core/src/models/hunyuan_v1_moe.rs:374-458 | mistralrs-core/src/models/lfm2.rs:481-564 | mistralrs-core/src/models/mistral.rs:206-297 | mistralrs-core/src/models/mixtral.rs:151-233 | mistralrs-core/src/models/phi2.rs:254-347 | mistralrs-core/src/models/phi3_5_moe.rs:178-263 | mistralrs-core/src/models/qwen2.rs:240-327 | mistralrs-core/src/models/qwen3.rs:192-282 | mistralrs-core/src/models/qwen3_moe.rs:195-285 | mistralrs-core/src/models/starcoder2.rs:227-309 | mistralrs-core/src/vision_models/gemma3/text.rs:182-302 | mistralrs-core/src/vision_models/mllama/text.rs:158-247 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:194-294 | mistralrs-core/src/vision_models/qwen2vl/text.rs:195-295 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:194-287 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:300-390 | mistralrs-core/src/vision_models/voxtral/mod.rs:126-208 — These 24 members are variants of one another: a block of 26 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 24 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 24 times.
D4 · Code Duplication · Near-duplicate member family (23 members, 23 shared lines) · ×1
  • Near-duplicate member family (23 members, 23 shared lines) mistralrs-core/src/models/flint.rs:347 — mistralrs-core/src/models/flint.rs:347-454 | mistralrs-core/src/models/gemma2.rs:208-297 | mistralrs-core/src/models/glm4.rs:209-296 | mistralrs-core/src/models/glm4_moe.rs:272-361 | mistralrs-core/src/models/gpt_oss.rs:248-326 | mistralrs-core/src/models/granite.rs:1538-1622 | mistralrs-core/src/models/hunyuan_v1_dense.rs:191-272 | mistralrs-core/src/models/hunyuan_v1_moe.rs:374-458 | mistralrs-core/src/models/llama.rs:75-157 | mistralrs-core/src/models/mistral.rs:206-297 | mistralrs-core/src/models/mixtral.rs:151-233 | mistralrs-core/src/models/phi3_5_moe.rs:178-263 | mistralrs-core/src/models/qwen2.rs:240-327 | mistralrs-core/src/models/qwen3.rs:192-282 | mistralrs-core/src/models/qwen3_moe.rs:195-285 | mistralrs-core/src/models/smollm3.rs:90-174 | mistralrs-core/src/models/starcoder2.rs:227-309 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:58-132 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:227-306 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:194-294 | mistralrs-core/src/vision_models/qwen2vl/text.rs:195-295 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:194-287 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:300-390 — These 23 members are variants of one another: a block of 23 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 23 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 23 times.
D4 · Code Duplication · Near-duplicate member family (20 members, 22 shared lines) · ×1
  • Near-duplicate member family (20 members, 22 shared lines) mistralrs-core/src/models/flint.rs:347 — mistralrs-core/src/models/flint.rs:347-454 | mistralrs-core/src/models/gemma.rs:167-249 | mistralrs-core/src/models/gemma2.rs:208-297 | mistralrs-core/src/models/gpt_oss.rs:248-326 | mistralrs-core/src/models/hunyuan_v1_dense.rs:191-272 | mistralrs-core/src/models/hunyuan_v1_moe.rs:374-458 | mistralrs-core/src/models/llama.rs:75-157 | mistralrs-core/src/models/mistral.rs:206-297 | mistralrs-core/src/models/mixtral.rs:151-233 | mistralrs-core/src/models/phi2.rs:254-347 | mistralrs-core/src/models/phi3_5_moe.rs:178-263 | mistralrs-core/src/models/qwen2.rs:240-327 | mistralrs-core/src/models/qwen3.rs:192-282 | mistralrs-core/src/models/qwen3_moe.rs:195-285 | mistralrs-core/src/models/qwen3_next.rs:272-378 | mistralrs-core/src/models/smollm3.rs:90-174 | mistralrs-core/src/models/starcoder2.rs:227-309 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:58-132 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:227-306 | mistralrs-core/src/vision_models/voxtral/mod.rs:126-208 — These 20 members are variants of one another: a block of 22 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 20 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 20 times.
D4 · Code Duplication · Near-duplicate member family (19 members, 28 shared lines) · ×1
  • Near-duplicate member family (19 members, 28 shared lines) mistralrs-core/src/models/flint.rs:347 — mistralrs-core/src/models/flint.rs:347-454 | mistralrs-core/src/models/gemma.rs:167-249 | mistralrs-core/src/models/gemma2.rs:208-297 | mistralrs-core/src/models/gpt_oss.rs:248-326 | mistralrs-core/src/models/hunyuan_v1_dense.rs:191-272 | mistralrs-core/src/models/hunyuan_v1_moe.rs:374-458 | mistralrs-core/src/models/lfm2.rs:481-564 | mistralrs-core/src/models/lfm3.rs:485-540 | mistralrs-core/src/models/llama.rs:75-157 | mistralrs-core/src/models/mistral.rs:206-297 | mistralrs-core/src/models/mixtral.rs:151-233 | mistralrs-core/src/models/phi2.rs:254-347 | mistralrs-core/src/models/qwen2.rs:240-327 | mistralrs-core/src/models/qwen3.rs:192-282 | mistralrs-core/src/models/qwen3_moe.rs:195-285 | mistralrs-core/src/models/qwen3_next.rs:272-378 | mistralrs-core/src/models/smollm3.rs:90-174 | mistralrs-core/src/models/starcoder2.rs:227-309 | mistralrs-core/src/vision_models/voxtral/mod.rs:126-208 — These 19 members are variants of one another: a block of 28 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 19 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 19 times.
D4 · Code Duplication · Near-duplicate member family (18 members, 26 shared lines) · ×1
  • Near-duplicate member family (18 members, 26 shared lines) mistralrs-core/src/models/flint.rs:347 — mistralrs-core/src/models/flint.rs:347-454 | mistralrs-core/src/models/gemma.rs:167-249 | mistralrs-core/src/models/gemma2.rs:208-297 | mistralrs-core/src/models/gpt_oss.rs:248-326 | mistralrs-core/src/models/hunyuan_v1_dense.rs:191-272 | mistralrs-core/src/models/hunyuan_v1_moe.rs:374-458 | mistralrs-core/src/models/lfm2.rs:481-564 | mistralrs-core/src/models/mistral.rs:206-297 | mistralrs-core/src/models/mixtral.rs:151-233 | mistralrs-core/src/models/phi2.rs:254-347 | mistralrs-core/src/models/phi3_5_moe.rs:178-263 | mistralrs-core/src/models/qwen2.rs:240-327 | mistralrs-core/src/models/qwen3.rs:192-282 | mistralrs-core/src/models/qwen3_moe.rs:195-285 | mistralrs-core/src/models/qwen3_next.rs:272-378 | mistralrs-core/src/models/starcoder2.rs:227-309 | mistralrs-core/src/vision_models/mllama/text.rs:158-247 | mistralrs-core/src/vision_models/voxtral/mod.rs:126-208 — These 18 members are variants of one another: a block of 26 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 18 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 18 times.
D4 · Code Duplication · Near-duplicate member family (18 members, 22 shared lines) · ×1
  • Near-duplicate member family (18 members, 22 shared lines) mistralrs-core/src/models/flint.rs:347 — mistralrs-core/src/models/flint.rs:347-454 | mistralrs-core/src/models/gemma2.rs:208-297 | mistralrs-core/src/models/gpt_oss.rs:248-326 | mistralrs-core/src/models/hunyuan_v1_dense.rs:191-272 | mistralrs-core/src/models/hunyuan_v1_moe.rs:374-458 | mistralrs-core/src/models/llama.rs:75-157 | mistralrs-core/src/models/mistral.rs:206-297 | mistralrs-core/src/models/mixtral.rs:151-233 | mistralrs-core/src/models/phi3.rs:143-236 | mistralrs-core/src/models/phi3_5_moe.rs:178-263 | mistralrs-core/src/models/qwen2.rs:240-327 | mistralrs-core/src/models/qwen3.rs:192-282 | mistralrs-core/src/models/qwen3_moe.rs:195-285 | mistralrs-core/src/models/qwen3_next.rs:272-378 | mistralrs-core/src/models/smollm3.rs:90-174 | mistralrs-core/src/models/starcoder2.rs:227-309 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:58-132 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:227-306 — These 18 members are variants of one another: a block of 22 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 18 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 18 times.
D4 · Code Duplication · Near-duplicate member family (17 members, 31 shared lines) · ×1
  • Near-duplicate member family (17 members, 31 shared lines) mistralrs-core/src/models/flint.rs:347 — mistralrs-core/src/models/flint.rs:347-454 | mistralrs-core/src/models/glm4.rs:209-296 | mistralrs-core/src/models/glm4_moe.rs:272-361 | mistralrs-core/src/models/gpt_oss.rs:248-326 | mistralrs-core/src/models/granite.rs:1538-1622 | mistralrs-core/src/models/hunyuan_v1_dense.rs:191-272 | mistralrs-core/src/models/hunyuan_v1_moe.rs:374-458 | mistralrs-core/src/models/llama.rs:75-157 | mistralrs-core/src/models/mistral.rs:206-297 | mistralrs-core/src/models/mixtral.rs:151-233 | mistralrs-core/src/models/phi3_5_moe.rs:178-263 | mistralrs-core/src/models/qwen3.rs:192-282 | mistralrs-core/src/models/qwen3_moe.rs:195-285 | mistralrs-core/src/models/qwen3_next.rs:272-378 | mistralrs-core/src/models/smollm3.rs:90-174 | mistralrs-core/src/models/starcoder2.rs:227-309 | mistralrs-core/src/vision_models/llama4/text.rs:426-528 — These 17 members are variants of one another: a block of 31 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 17 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 17 times.
D4 · Code Duplication · Near-duplicate member family (16 members, 25 shared lines) · ×1
  • Near-duplicate member family (16 members, 25 shared lines) mistralrs-core/src/models/flint.rs:347 — mistralrs-core/src/models/flint.rs:347-454 | mistralrs-core/src/models/gemma.rs:167-249 | mistralrs-core/src/models/gpt_oss.rs:248-326 | mistralrs-core/src/models/hunyuan_v1_dense.rs:191-272 | mistralrs-core/src/models/hunyuan_v1_moe.rs:374-458 | mistralrs-core/src/models/mistral.rs:206-297 | mistralrs-core/src/models/mixtral.rs:151-233 | mistralrs-core/src/models/phi2.rs:254-347 | mistralrs-core/src/models/phi3_5_moe.rs:178-263 | mistralrs-core/src/models/qwen3.rs:192-282 | mistralrs-core/src/models/qwen3_moe.rs:195-285 | mistralrs-core/src/models/qwen3_next.rs:272-378 | mistralrs-core/src/models/starcoder2.rs:227-309 | mistralrs-core/src/vision_models/gemma3/text.rs:182-302 | mistralrs-core/src/vision_models/mllama/text.rs:158-247 | mistralrs-core/src/vision_models/voxtral/mod.rs:126-208 — These 16 members are variants of one another: a block of 25 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 16 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 16 times.
D4 · Code Duplication · Near-duplicate member family (13 members, 33 shared lines) · ×1
  • Near-duplicate member family (13 members, 33 shared lines) mistralrs-core/src/models/gemma.rs:585 — mistralrs-core/src/models/gemma.rs:585-676 | mistralrs-core/src/models/gemma2.rs:702-793 | mistralrs-core/src/models/glm4.rs:704-795 | mistralrs-core/src/models/hunyuan_v1_dense.rs:672-763 | mistralrs-core/src/models/mistral.rs:713-804 | mistralrs-core/src/models/phi2.rs:661-744 | mistralrs-core/src/models/phi3.rs:656-739 | mistralrs-core/src/models/qwen2.rs:716-807 | mistralrs-core/src/models/qwen3.rs:690-781 | mistralrs-core/src/models/starcoder2.rs:652-735 | mistralrs-core/src/vision_models/gemma3/text.rs:927-1018 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:669-763 | mistralrs-core/src/vision_models/phi3/mod.rs:1492-1574 — These 13 members are variants of one another: a block of 33 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 13 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 13 times.
D4 · Code Duplication · Near-duplicate member family (13 members, 24 shared lines) · ×1
  • Near-duplicate member family (13 members, 24 shared lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1515 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1515-1550 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1822-1857 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2122-2157 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2527-2574 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2897-2931 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3250-3285 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3592-3627 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4320-4354 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5108-5144 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:809-844 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1253-1288 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2180-2215 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5790-5825 — These 13 members are variants of one another: a block of 24 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 13 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 13 times.
D4 · Code Duplication · Near-duplicate member family (10 members, 54 shared lines) · ×1
  • Near-duplicate member family (10 members, 54 shared lines) mistralrs-core/src/models/gemma.rs:585 — mistralrs-core/src/models/gemma.rs:585-676 | mistralrs-core/src/models/gemma2.rs:702-793 | mistralrs-core/src/models/glm4.rs:704-795 | mistralrs-core/src/models/hunyuan_v1_dense.rs:672-763 | mistralrs-core/src/models/mistral.rs:713-804 | mistralrs-core/src/models/qwen2.rs:716-807 | mistralrs-core/src/models/qwen3.rs:690-781 | mistralrs-core/src/vision_models/gemma3/text.rs:927-1018 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:669-763 | mistralrs-core/src/vision_models/muse_glimmer/text.rs:683-769 — These 10 members are variants of one another: a block of 54 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 10 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 10 times.
D4 · Code Duplication · Near-duplicate member family (10 members, 31 shared lines) · ×1
  • Near-duplicate member family (10 members, 31 shared lines) mistralrs-core/src/models/deepseek2.rs:813 — mistralrs-core/src/models/deepseek2.rs:813-948 | mistralrs-core/src/models/deepseek3.rs:876-1011 | mistralrs-core/src/models/glm4_moe.rs:713-827 | mistralrs-core/src/models/glm4_moe_lite.rs:823-964 | mistralrs-core/src/models/mixtral.rs:405-520 | mistralrs-core/src/vision_models/gemma3/text.rs:432-581 | mistralrs-core/src/vision_models/phi3/mod.rs:1209-1317 | mistralrs-core/src/vision_models/phi4/mod.rs:330-438 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:399-515 | mistralrs-core/src/vision_models/qwen2vl/text.rs:400-517 — These 10 members are variants of one another: a block of 31 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 10 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 10 times.
D4 · Code Duplication · Near-duplicate member family (9 members, 40 shared lines) · ×1
  • Near-duplicate member family (9 members, 40 shared lines) mistralrs-core/src/xlora_models/gemma.rs:633 — mistralrs-core/src/xlora_models/gemma.rs:633-692 | mistralrs-core/src/xlora_models/gemma2.rs:684-743 | mistralrs-core/src/xlora_models/llama.rs:459-518 | mistralrs-core/src/xlora_models/mistral.rs:629-688 | mistralrs-core/src/xlora_models/mixtral.rs:759-818 | mistralrs-core/src/xlora_models/phi2.rs:599-658 | mistralrs-core/src/xlora_models/quantized_llama.rs:849-908 | mistralrs-core/src/xlora_models/quantized_phi3.rs:514-573 | mistralrs-core/src/xlora_models/starcoder2.rs:614-673 — These 9 members are variants of one another: a block of 40 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 9 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 9 times.
D4 · Code Duplication · Near-duplicate member family (9 members, 32 shared lines) · ×1
  • Near-duplicate member family (9 members, 32 shared lines) mistralrs-core/src/models/glm4.rs:209 — mistralrs-core/src/models/glm4.rs:209-296 | mistralrs-core/src/models/glm4_moe.rs:272-361 | mistralrs-core/src/vision_models/phi3/mod.rs:235-327 | mistralrs-core/src/vision_models/phi4/mod.rs:104-196 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:194-294 | mistralrs-core/src/vision_models/qwen2vl/text.rs:195-295 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:189-285 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:194-287 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:300-390 — These 9 members are variants of one another: a block of 32 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 9 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 9 times.
D4 · Code Duplication · Near-duplicate member family (9 members, 22 shared lines) · ×1
  • Near-duplicate member family (9 members, 22 shared lines) mistralrs-core/src/models/glm4.rs:209 — mistralrs-core/src/models/glm4.rs:209-296 | mistralrs-core/src/models/glm4_moe.rs:272-361 | mistralrs-core/src/models/granite.rs:1538-1622 | mistralrs-core/src/vision_models/phi3/mod.rs:235-327 | mistralrs-core/src/vision_models/phi4/mod.rs:104-196 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:194-294 | mistralrs-core/src/vision_models/qwen2vl/text.rs:195-295 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:194-287 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:300-390 — These 9 members are variants of one another: a block of 22 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 9 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 9 times.
D4 · Code Duplication · Near-duplicate member family (9 members, 17 shared lines) · ×1
  • Near-duplicate member family (9 members, 17 shared lines) mistralrs-core/src/models/deepseek2.rs:950 — mistralrs-core/src/models/deepseek2.rs:950-977 | mistralrs-core/src/models/deepseek3.rs:1013-1040 | mistralrs-core/src/models/glm4_moe.rs:829-855 | mistralrs-core/src/models/glm4_moe_lite.rs:966-992 | mistralrs-core/src/models/mixtral.rs:526-556 | mistralrs-core/src/models/phi2.rs:542-569 | mistralrs-core/src/models/phi3.rs:534-565 | mistralrs-core/src/models/phi3_5_moe.rs:607-638 | mistralrs-core/src/models/starcoder2.rs:527-557 — These 9 members are variants of one another: a block of 17 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 9 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 9 times.
D4 · Code Duplication · Near-duplicate member family (7 members, 37 shared lines) · ×1
  • Near-duplicate member family (7 members, 37 shared lines) mistralrs-core/src/models/flint.rs:774 — mistralrs-core/src/models/flint.rs:774-900 | mistralrs-core/src/models/glm4.rs:439-564 | mistralrs-core/src/models/hunyuan_v1_dense.rs:392-522 | mistralrs-core/src/models/hunyuan_v1_moe.rs:882-1016 | mistralrs-core/src/models/mistral.rs:414-565 | mistralrs-core/src/models/qwen3.rs:402-523 | mistralrs-core/src/models/qwen3_moe.rs:576-703 — These 7 members are variants of one another: a block of 37 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 7 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 7 times.
D4 · Code Duplication · Near-duplicate member family (7 members, 35 shared lines) · ×1
  • Near-duplicate member family (7 members, 35 shared lines) mistralrs-core/src/models/glm4.rs:439 — mistralrs-core/src/models/glm4.rs:439-564 | mistralrs-core/src/models/hunyuan_v1_dense.rs:392-522 | mistralrs-core/src/models/hunyuan_v1_moe.rs:882-1016 | mistralrs-core/src/models/mistral.rs:414-565 | mistralrs-core/src/models/mixtral.rs:405-520 | mistralrs-core/src/models/qwen2.rs:432-549 | mistralrs-core/src/models/qwen3.rs:402-523 — These 7 members are variants of one another: a block of 35 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 7 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 7 times.
D4 · Code Duplication · Near-duplicate member family (7 members, 32 shared lines) · ×1
  • Near-duplicate member family (7 members, 32 shared lines) mistralrs-core/src/models/glm4.rs:439 — mistralrs-core/src/models/glm4.rs:439-564 | mistralrs-core/src/models/hunyuan_v1_dense.rs:392-522 | mistralrs-core/src/models/hunyuan_v1_moe.rs:882-1016 | mistralrs-core/src/models/llama.rs:345-468 | mistralrs-core/src/models/mistral.rs:414-565 | mistralrs-core/src/models/qwen3.rs:402-523 | mistralrs-core/src/vision_models/llama4/text.rs:794-905 — These 7 members are variants of one another: a block of 32 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 7 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 7 times.
D4 · Code Duplication · Near-duplicate member family (7 members, 28 shared lines) · ×1
  • Near-duplicate member family (7 members, 28 shared lines) mistralrs-core/src/xlora_models/gemma.rs:232 — mistralrs-core/src/xlora_models/gemma.rs:232-298 | mistralrs-core/src/xlora_models/gemma2.rs:237-305 | mistralrs-core/src/xlora_models/llama.rs:55-115 | mistralrs-core/src/xlora_models/mistral.rs:222-294 | mistralrs-core/src/xlora_models/mixtral.rs:135-207 | mistralrs-core/src/xlora_models/phi2.rs:217-288 | mistralrs-core/src/xlora_models/starcoder2.rs:209-283 — These 7 members are variants of one another: a block of 28 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 7 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 7 times.
D4 · Code Duplication · Near-duplicate member family (6 members, 39 shared lines) · ×1
  • Near-duplicate member family (6 members, 39 shared lines) mistralrs-core/src/models/glm4.rs:209 — mistralrs-core/src/models/glm4.rs:209-296 | mistralrs-core/src/models/glm4_moe.rs:272-361 | mistralrs-core/src/models/granite.rs:1538-1622 | mistralrs-core/src/vision_models/phi3/mod.rs:235-327 | mistralrs-core/src/vision_models/phi4/mod.rs:104-196 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:189-285 — These 6 members are variants of one another: a block of 39 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
D4 · Code Duplication · Near-duplicate member family (6 members, 32 shared lines) · ×1
  • Near-duplicate member family (6 members, 32 shared lines) mistralrs-core/src/models/mixtral.rs:405 — mistralrs-core/src/models/mixtral.rs:405-520 | mistralrs-core/src/models/qwen2.rs:432-549 | mistralrs-core/src/vision_models/phi3/mod.rs:1209-1317 | mistralrs-core/src/vision_models/phi4/mod.rs:330-438 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:399-515 | mistralrs-core/src/vision_models/qwen2vl/text.rs:400-517 — These 6 members are variants of one another: a block of 32 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
D4 · Code Duplication · Near-duplicate member family (6 members, 29 shared lines) · ×1
  • Near-duplicate member family (6 members, 29 shared lines) mistralrs-core/src/models/deepseek2.rs:813 — mistralrs-core/src/models/deepseek2.rs:813-948 | mistralrs-core/src/models/deepseek3.rs:876-1011 | mistralrs-core/src/models/glm4_moe.rs:713-827 | mistralrs-core/src/models/glm4_moe_lite.rs:823-964 | mistralrs-core/src/models/mixtral.rs:405-520 | mistralrs-core/src/models/phi3.rs:407-532 — These 6 members are variants of one another: a block of 29 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
D4 · Code Duplication · Near-duplicate member family (6 members, 23 shared lines) · ×1
  • Near-duplicate member family (6 members, 23 shared lines) mistralrs-core/src/embedding_models/qwen3_embedding.rs:235 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:235-269 | mistralrs-core/src/models/llama.rs:271-303 | mistralrs-core/src/models/mistral.rs:318-350 | mistralrs-core/src/models/qwen2.rs:349-382 | mistralrs-core/src/models/qwen3.rs:303-338 | mistralrs-core/src/models/smollm3.rs:287-319 — These 6 members are variants of one another: a block of 23 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
D4 · Code Duplication · Near-duplicate member family (5 members, 40 shared lines) · ×1
  • Near-duplicate member family (5 members, 40 shared lines) mistralrs-core/src/embedding_models/embedding_gemma.rs:111 — mistralrs-core/src/embedding_models/embedding_gemma.rs:111-197 | mistralrs-core/src/models/gemma.rs:91-158 | mistralrs-core/src/models/gemma2.rs:124-198 | mistralrs-core/src/vision_models/gemma3/text.rs:86-170 | mistralrs-core/src/vision_models/gemma3n/text.rs:314-414 — These 5 members are variants of one another: a block of 40 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D4 · Code Duplication · Near-duplicate member family (5 members, 30 shared lines) · ×1
  • Near-duplicate member family (5 members, 30 shared lines) mistralrs-core/src/vision_models/qwen3_5/mod.rs:136 — mistralrs-core/src/vision_models/qwen3_5/mod.rs:136-435 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:119-420 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:671-1001 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:117-447 | mistralrs-core/src/vision_models/qwen4_exp/mod.rs:243-407 — These 5 members are variants of one another: a block of 30 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D4 · Code Duplication · Near-duplicate member family (5 members, 29 shared lines) · ×1
  • Near-duplicate member family (5 members, 29 shared lines) mistralrs-core/src/models/gemma.rs:346 — mistralrs-core/src/models/gemma.rs:346-456 | mistralrs-core/src/models/gemma2.rs:419-532 | mistralrs-core/src/vision_models/gemma3/text.rs:432-581 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:391-500 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:511-621 — These 5 members are variants of one another: a block of 29 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D4 · Code Duplication · Near-duplicate member family (5 members, 26 shared lines) · ×1
  • Near-duplicate member family (5 members, 26 shared lines) mistralrs-core/src/models/mixtral.rs:405 — mistralrs-core/src/models/mixtral.rs:405-520 | mistralrs-core/src/models/qwen2.rs:432-549 | mistralrs-core/src/models/qwen3.rs:402-523 | mistralrs-core/src/models/qwen3_moe.rs:576-703 | mistralrs-core/src/models/starcoder2.rs:404-521 — These 5 members are variants of one another: a block of 26 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D4 · Code Duplication · Near-duplicate member family (5 members, 18 shared lines) · ×1
  • Near-duplicate member family (5 members, 18 shared lines) mistralrs-core/src/xlora_models/mistral.rs:570 — mistralrs-core/src/xlora_models/mistral.rs:570-615 | mistralrs-core/src/xlora_models/mixtral.rs:700-745 | mistralrs-core/src/xlora_models/phi2.rs:543-585 | mistralrs-core/src/xlora_models/phi3.rs:521-568 | mistralrs-core/src/xlora_models/starcoder2.rs:553-600 — These 5 members are variants of one another: a block of 18 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D4 · Code Duplication · Near-duplicate member family (5 members, 12 shared lines) · ×1
  • Near-duplicate member family (5 members, 12 shared lines) mistralrs-quant/src/metal_kernels/mod.rs:474 — mistralrs-quant/src/metal_kernels/mod.rs:474-498 | mistralrs-quant/src/metal_kernels/mod.rs:512-544 | mistralrs-quant/src/metal_kernels/mod.rs:558-590 | mistralrs-quant/src/metal_kernels/mod.rs:604-636 | mistralrs-quant/src/metal_kernels/mod.rs:649-676 — These 5 members are variants of one another: a block of 12 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 183 shared lines) · ×1
  • Near-duplicate member family (4 members, 183 shared lines) mistralrs-core/src/vision_models/qwen3_5/mod.rs:136 — mistralrs-core/src/vision_models/qwen3_5/mod.rs:136-435 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:119-420 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:671-1001 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:117-447 — These 4 members are variants of one another: a block of 183 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 42 shared lines) · ×1
  • Near-duplicate member family (4 members, 42 shared lines) mistralrs-core/src/xlora_models/mistral.rs:222 — mistralrs-core/src/xlora_models/mistral.rs:222-294 | mistralrs-core/src/xlora_models/mixtral.rs:135-207 | mistralrs-core/src/xlora_models/phi3.rs:113-182 | mistralrs-core/src/xlora_models/starcoder2.rs:209-283 — These 4 members are variants of one another: a block of 42 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 41 shared lines) · ×1
  • Near-duplicate member family (4 members, 41 shared lines) mistralrs-core/src/models/deepseek2.rs:718 — mistralrs-core/src/models/deepseek2.rs:718-770 | mistralrs-core/src/models/deepseek3.rs:781-833 | mistralrs-core/src/models/glm4_moe.rs:618-670 | mistralrs-core/src/models/glm4_moe_lite.rs:727-780 — These 4 members are variants of one another: a block of 41 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 36 shared lines) · ×1
  • Near-duplicate member family (4 members, 36 shared lines) mistralrs-core/src/xlora_models/gemma.rs:232 — mistralrs-core/src/xlora_models/gemma.rs:232-298 | mistralrs-core/src/xlora_models/mistral.rs:222-294 | mistralrs-core/src/xlora_models/mixtral.rs:135-207 | mistralrs-core/src/xlora_models/phi3.rs:113-182 — These 4 members are variants of one another: a block of 36 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 35 shared lines) · ×1
  • Near-duplicate member family (4 members, 35 shared lines) mistralrs-cli/src/ui/handlers/api.rs:169 — mistralrs-cli/src/ui/handlers/api.rs:169-216 | mistralrs-cli/src/ui/handlers/api.rs:221-268 | mistralrs-cli/src/ui/handlers/api.rs:273-320 | mistralrs-cli/src/ui/handlers/api.rs:325-376 — These 4 members are variants of one another: a block of 35 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 34 shared lines) · ×1
  • Near-duplicate member family (4 members, 34 shared lines) mistralrs-core/src/models/flint.rs:230 — mistralrs-core/src/models/flint.rs:230-338 | mistralrs-core/src/models/glm4_moe.rs:177-263 | mistralrs-core/src/models/hunyuan_v1_dense.rs:108-182 | mistralrs-core/src/models/hunyuan_v1_moe.rs:285-365 — These 4 members are variants of one another: a block of 34 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 30 shared lines) · ×1
  • Near-duplicate member family (4 members, 30 shared lines) mistralrs-core/src/vision_models/qwen3_5/mod.rs:72 — mistralrs-core/src/vision_models/qwen3_5/mod.rs:72-115 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:60-98 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:613-650 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:59-96 — These 4 members are variants of one another: a block of 30 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 29 shared lines) · ×1
  • Near-duplicate member family (4 members, 29 shared lines) mistralrs-core/src/models/mixtral.rs:405 — mistralrs-core/src/models/mixtral.rs:405-520 | mistralrs-core/src/vision_models/phi3/mod.rs:1209-1317 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:391-500 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:511-621 — These 4 members are variants of one another: a block of 29 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 27 shared lines) · ×1
  • Near-duplicate member family (4 members, 27 shared lines) mistralrs-core/src/models/gemma.rs:346 — mistralrs-core/src/models/gemma.rs:346-456 | mistralrs-core/src/models/gemma2.rs:419-532 | mistralrs-core/src/models/glm4_moe.rs:713-827 | mistralrs-core/src/models/mixtral.rs:405-520 — These 4 members are variants of one another: a block of 27 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 22 shared lines) · ×1
  • Near-duplicate member family (4 members, 22 shared lines) mistralrs-core/src/embedding_models/embedding_gemma.rs:274 — mistralrs-core/src/embedding_models/embedding_gemma.rs:274-320 | mistralrs-core/src/models/gemma2.rs:320-365 | mistralrs-core/src/vision_models/gemma3/text.rs:326-373 | mistralrs-core/src/xlora_models/gemma2.rs:330-382 — These 4 members are variants of one another: a block of 22 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 20 shared lines) · ×1
  • Near-duplicate member family (4 members, 20 shared lines) mistralrs-core/src/models/deepseek2.rs:517 — mistralrs-core/src/models/deepseek2.rs:517-594 | mistralrs-core/src/models/deepseek3.rs:530-646 | mistralrs-core/src/models/glm4_moe.rs:451-499 | mistralrs-core/src/models/glm4_moe_lite.rs:548-603 — These 4 members are variants of one another: a block of 20 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 19 shared lines) · ×1
  • Near-duplicate member family (4 members, 19 shared lines) mistralrs-core/src/models/glm4_moe.rs:859 — mistralrs-core/src/models/glm4_moe.rs:859-897 | mistralrs-core/src/models/glm4_moe.rs:899-942 | mistralrs-core/src/models/glm4_moe_lite.rs:996-1037 | mistralrs-core/src/models/glm4_moe_lite.rs:1039-1093 — These 4 members are variants of one another: a block of 19 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 18 shared lines) · ×1
  • Near-duplicate member family (4 members, 18 shared lines) mistralrs-core/src/xlora_models/gemma2.rs:608 — mistralrs-core/src/xlora_models/gemma2.rs:608-670 | mistralrs-core/src/xlora_models/phi2.rs:543-585 | mistralrs-core/src/xlora_models/quantized_llama.rs:775-835 | mistralrs-core/src/xlora_models/quantized_phi3.rs:437-500 — These 4 members are variants of one another: a block of 18 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (4 members, 17 shared lines) · ×1
  • Near-duplicate member family (4 members, 17 shared lines) mistralrs-core/src/xlora_models/phi2.rs:543 — mistralrs-core/src/xlora_models/phi2.rs:543-585 | mistralrs-core/src/xlora_models/quantized_llama.rs:775-835 | mistralrs-core/src/xlora_models/quantized_phi3.rs:437-500 | mistralrs-core/src/xlora_models/starcoder2.rs:553-600 — These 4 members are variants of one another: a block of 17 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Near-duplicate member family (3 members, 436 shared lines) · ×1
  • Near-duplicate member family (3 members, 436 shared lines) mistralrs-core/src/vision_models/grid_processor.rs:1153 — mistralrs-core/src/vision_models/grid_processor.rs:1153-1825 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:366-973 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:932-1538 — These 3 members are variants of one another: a block of 436 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
D4 · Code Duplication · Near-duplicate member family (3 members, 163 shared lines) · ×1
  • Near-duplicate member family (3 members, 163 shared lines) mistralrs-core/src/models/deepseek2.rs:294 — mistralrs-core/src/models/deepseek2.rs:294-489 | mistralrs-core/src/models/deepseek3.rs:295-490 | mistralrs-core/src/models/glm4_moe_lite.rs:255-454 — These 3 members are variants of one another: a block of 163 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
D4 · Code Duplication · Near-duplicate member family (3 members, 128 shared lines) · ×1
  • Near-duplicate member family (3 members, 128 shared lines) mistralrs-core/src/vision_models/grid_processor.rs:891 — mistralrs-core/src/vision_models/grid_processor.rs:891-1137 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:125-350 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:691-916 — These 3 members are variants of one another: a block of 128 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
D4 · Code Duplication · Near-duplicate member family (3 members, 68 shared lines) · ×1
  • Near-duplicate member family (3 members, 68 shared lines) mistralrs-paged-attn/src/cuda/backend/mla.rs:16 — mistralrs-paged-attn/src/cuda/backend/mla.rs:16-224 | mistralrs-paged-attn/src/cuda/backend/mla.rs:240-641 | mistralrs-paged-attn/src/cuda/backend/mla.rs:649-897 — These 3 members are variants of one another: a block of 68 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
D4 · Code Duplication · Near-duplicate member family (3 members, 65 shared lines) · ×1
  • Near-duplicate member family (3 members, 65 shared lines) mistralrs-core/src/vision_models/grid_processor.rs:1933 — mistralrs-core/src/vision_models/grid_processor.rs:1933-2052 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:1022-1117 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1587-1682 — These 3 members are variants of one another: a block of 65 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
D4 · Code Duplication · Near-duplicate member family (3 members, 58 shared lines) · ×1
  • Near-duplicate member family (3 members, 58 shared lines) mistralrs-core/src/layers.rs:1120 — mistralrs-core/src/layers.rs:1120-1225 | mistralrs-core/src/layers.rs:1232-1315 | mistralrs-core/src/layers.rs:1479-1584 — These 3 members are variants of one another: a block of 58 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
D4 · Code Duplication · Near-duplicate member family (3 members, 41 shared lines) · ×1
  • Near-duplicate member family (3 members, 41 shared lines) mistralrs-core/src/ops.rs:4401 — mistralrs-core/src/ops.rs:4401-4578 | mistralrs-core/src/ops.rs:4586-4729 | mistralrs-core/src/ops.rs:5345-5574 — These 3 members are variants of one another: a block of 41 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
D4 · Code Duplication · Near-duplicate member family (3 members, 32 shared lines) · ×1
  • Near-duplicate member family (3 members, 32 shared lines) mistralrs-quant/src/gemv/mod.rs:337 — mistralrs-quant/src/gemv/mod.rs:337-398 | mistralrs-quant/src/gemv/mod.rs:411-469 | mistralrs-quant/src/gemv/mod.rs:482-540 — These 3 members are variants of one another: a block of 32 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
D4 · Code Duplication · Near-duplicate member family (3 members, 19 shared lines) · ×1
  • Near-duplicate member family (3 members, 19 shared lines) mistralrs-core/src/models/phi3.rs:339 — mistralrs-core/src/models/phi3.rs:339-363 | mistralrs-core/src/vision_models/phi3/mod.rs:430-454 | mistralrs-core/src/vision_models/phi4/mod.rs:259-284 — These 3 members are variants of one another: a block of 19 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
D4 · Code Duplication · Near-duplicate member family (3 members, 17 shared lines) · ×1
  • Near-duplicate member family (3 members, 17 shared lines) mistralrs-core/src/models/quantized_llama.rs:79 — mistralrs-core/src/models/quantized_llama.rs:79-134 | mistralrs-core/src/xlora_models/quantized_llama.rs:199-248 | mistralrs-core/src/xlora_models/quantized_phi3.rs:153-219 — These 3 members are variants of one another: a block of 17 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
D4 · Code Duplication · Near-duplicate member family (3 members, 12 shared lines) · ×1
  • Near-duplicate member family (3 members, 12 shared lines) mistralrs-quant/src/metal_kernels/mod.rs:4077 — mistralrs-quant/src/metal_kernels/mod.rs:4077-4100 | mistralrs-quant/src/metal_kernels/mod.rs:4112-4135 | mistralrs-quant/src/metal_kernels/mod.rs:4149-4175 — These 3 members are variants of one another: a block of 12 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
D4 · Code Duplication · Near-duplicate member family (3 members, 9 shared lines) · ×1
  • Near-duplicate member family (3 members, 9 shared lines) mistralrs-quant/src/gguf/fast_mmvq.rs:391 — mistralrs-quant/src/gguf/fast_mmvq.rs:391-581 | mistralrs-quant/src/gguf/fast_mmvq.rs:832-1032 | mistralrs-quant/src/gguf/fast_mmvq.rs:1056-1323 — These 3 members are variants of one another: a block of 9 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
D4 · Code Duplication · Near-duplicate member pair (200 shared lines) · ×1
  • Near-duplicate member pair (200 shared lines) mistralrs-core/src/model_loader.rs:292 — mistralrs-core/src/model_loader.rs:292-931 | mistralrs-core/src/toml_selector.rs:811-1248 — These two members are variants of one another: 200 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (177 shared lines) · ×1
  • Near-duplicate member pair (177 shared lines) mistralrs-core/src/vision_models/qwen3_5/text.rs:811 — mistralrs-core/src/vision_models/qwen3_5/text.rs:811-1078 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:543-782 — These two members are variants of one another: 177 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (145 shared lines) · ×1
  • Near-duplicate member pair (145 shared lines) mistralrs-core/src/pipeline/multimodal.rs:2132 — mistralrs-core/src/pipeline/multimodal.rs:2132-2358 | mistralrs-core/src/pipeline/normal.rs:1889-2086 — These two members are variants of one another: 145 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (114 shared lines) · ×1
  • Near-duplicate member pair (114 shared lines) mistralrs-quant/src/afq/ops.rs:2108 — mistralrs-quant/src/afq/ops.rs:2108-2585 | mistralrs-quant/src/afq/ops.rs:2596-3197 — These two members are variants of one another: 114 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (106 shared lines) · ×1
  • Near-duplicate member pair (106 shared lines) mistralrs-cli/src/commands/run/interactive.rs:873 — mistralrs-cli/src/commands/run/interactive.rs:873-1056 | mistralrs-cli/src/commands/run/interactive.rs:1533-1853 — These two members are variants of one another: 106 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (101 shared lines) · ×1
  • Near-duplicate member pair (101 shared lines) mistralrs-quant/src/mxfp4/ops.rs:21 — mistralrs-quant/src/mxfp4/ops.rs:21-214 | mistralrs-quant/src/mxfp4/ops.rs:319-586 — These two members are variants of one another: 101 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (99 shared lines) · ×1
  • Near-duplicate member pair (99 shared lines) mistralrs-core/src/ops.rs:556 — mistralrs-core/src/ops.rs:556-710 | mistralrs-core/src/ops.rs:718-850 — These two members are variants of one another: 99 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (96 shared lines) · ×1
  • Near-duplicate member pair (96 shared lines) mistralrs-core/src/pipeline/multimodal.rs:2556 — mistralrs-core/src/pipeline/multimodal.rs:2556-2758 | mistralrs-core/src/pipeline/normal.rs:2192-2322 — These two members are variants of one another: 96 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (95 shared lines) · ×1
  • Near-duplicate member pair (95 shared lines) mistralrs-core/src/xlora_models/quantized_llama.rs:274 — mistralrs-core/src/xlora_models/quantized_llama.rs:274-459 | mistralrs-core/src/xlora_models/quantized_llama.rs:474-761 — These two members are variants of one another: 95 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (87 shared lines) · ×1
  • Near-duplicate member pair (87 shared lines) REDACTED:1154 — REDACTED:1154-1380 | REDACTED:123-317 — These two members are variants of one another: 87 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (84 shared lines) · ×1
  • Near-duplicate member pair (84 shared lines) mistralrs-quant/src/blockwise_fp8/ops.rs:1015 — mistralrs-quant/src/blockwise_fp8/ops.rs:1015-1162 | mistralrs-quant/src/blockwise_fp8/ops.rs:1178-1358 — These two members are variants of one another: 84 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (77 shared lines) · ×1
  • Near-duplicate member pair (77 shared lines) mistralrs-quant/src/cutile/fp8_w8a16.rs:397 — mistralrs-quant/src/cutile/fp8_w8a16.rs:397-599 | mistralrs-quant/src/cutile/fp8_w8a8.rs:455-667 — These two members are variants of one another: 77 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (70 shared lines) · ×1
  • Near-duplicate member pair (70 shared lines) mistralrs-quant/src/metal_kernels/mod.rs:4304 — mistralrs-quant/src/metal_kernels/mod.rs:4304-4507 | mistralrs-quant/src/metal_kernels/mod.rs:5057-5163 — These two members are variants of one another: 70 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (69 shared lines) · ×1
  • Near-duplicate member pair (69 shared lines) mistralrs-cli/src/commands/run/interactive.rs:1874 — mistralrs-cli/src/commands/run/interactive.rs:1874-1991 | mistralrs-cli/src/commands/run/interactive.rs:2000-2119 — These two members are variants of one another: 69 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (63 shared lines) · ×1
  • Near-duplicate member pair (63 shared lines) mistralrs-quant/src/blockwise_fp8/ops.rs:509 — mistralrs-quant/src/blockwise_fp8/ops.rs:509-612 | mistralrs-quant/src/blockwise_fp8/ops.rs:632-775 — These two members are variants of one another: 63 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (58 shared lines) · ×1
  • Near-duplicate member pair (58 shared lines) mistralrs-pyo3/src/lib.rs:1860 — mistralrs-pyo3/src/lib.rs:1860-1964 | mistralrs-pyo3/src/lib.rs:2350-2454 — These two members are variants of one another: 58 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (57 shared lines) · ×1
  • Near-duplicate member pair (57 shared lines) mistralrs-quant/src/cutile/nvfp4_matmul.rs:606 — mistralrs-quant/src/cutile/nvfp4_matmul.rs:606-831 | mistralrs-quant/src/cutile/nvfp4_matmul.rs:1114-1372 — These two members are variants of one another: 57 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (55 shared lines) · ×1
  • Near-duplicate member pair (55 shared lines) mistralrs-quant/src/metal_kernels/mod.rs:3909 — mistralrs-quant/src/metal_kernels/mod.rs:3909-3971 | mistralrs-quant/src/metal_kernels/mod.rs:4000-4061 — These two members are variants of one another: 55 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (54 shared lines) · ×1
  • Near-duplicate member pair (54 shared lines) mistralrs-quant/src/cublaslt/api.rs:54 — mistralrs-quant/src/cublaslt/api.rs:54-228 | mistralrs-quant/src/cublaslt/api.rs:366-456 — These two members are variants of one another: 54 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (49 shared lines) · ×1
  • Near-duplicate member pair (49 shared lines) mistralrs-core/src/cuda/gdn.rs:5229 — mistralrs-core/src/cuda/gdn.rs:5229-5466 | mistralrs-core/src/cuda/gdn.rs:5495-5621 — These two members are variants of one another: 49 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (48 shared lines) · ×1
  • Near-duplicate member pair (48 shared lines) mistralrs-core/src/vision_models/grid_processor.rs:574 — mistralrs-core/src/vision_models/grid_processor.rs:574-633 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:360-419 — These two members are variants of one another: 48 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (43 shared lines) · ×1
  • Near-duplicate member pair (43 shared lines) mistralrs-core/src/vision_models/grid_processor.rs:489 — mistralrs-core/src/vision_models/grid_processor.rs:489-538 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:272-321 — These two members are variants of one another: 43 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (41 shared lines) · ×1
  • Near-duplicate member pair (41 shared lines) mistralrs-server-core/src/anthropic.rs:1852 — mistralrs-server-core/src/anthropic.rs:1852-1941 | mistralrs-server-core/src/chat_completion.rs:1195-1313 — These two members are variants of one another: 41 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (37 shared lines) · ×1
  • Near-duplicate member pair (37 shared lines) mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:78 — mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:78-232 | mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:558-699 — These two members are variants of one another: 37 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (30 shared lines) · ×1
  • Near-duplicate member pair (30 shared lines) mistralrs-quant/src/gguf/cuda.rs:672 — mistralrs-quant/src/gguf/cuda.rs:672-719 | mistralrs-quant/src/gguf/cuda.rs:735-779 — These two members are variants of one another: 30 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (22 shared lines) · ×1
  • Near-duplicate member pair (22 shared lines) mistralrs-quant/src/cutile/nvfp4_matmul.rs:118 — mistralrs-quant/src/cutile/nvfp4_matmul.rs:118-173 | mistralrs-quant/src/cutile/nvfp4_matmul.rs:200-308 — These two members are variants of one another: 22 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Members sharing a duplicated core (27 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (27 members, 50+ identical tokens) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1062 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1062-1127 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2819-2889 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3865-3966 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4243-4312 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4637-4711 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5039-5100 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5451-5529 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:778-801 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1222-1245 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1466-1489 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1693-1716 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1913-1936 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2149-2172 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2846-2869 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3143-3165 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3476-3498 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3739-3761 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3951-3973 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4200-4222 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4431-4453 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4703-4725 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5015-5037 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5298-5320 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5759-5782 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6005-6028 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6268-6291 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6557-6580 — These 27 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 27 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 27 times.
D4 · Code Duplication · Members sharing a duplicated core (22 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (22 members, 50+ identical tokens) mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:434 — mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:434-447 | mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:637-650 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1275-1288 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1656-1669 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1964-1977 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2687-2700 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4115-4128 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4488-4501 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4893-4906 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5706-5740 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9513-9533 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:10759-10774 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:709-722 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:935-948 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1156-1169 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2057-2074 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2308-2321 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3666-3679 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3887-3898 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4100-4121 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5205-5223 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5693-5706 — These 22 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 22 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 22 times.
D4 · Code Duplication · Members sharing a duplicated core (14 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (14 members, 50+ identical tokens) mistralrs-core/src/models/deepseek2.rs:950 — mistralrs-core/src/models/deepseek2.rs:950-977 | mistralrs-core/src/models/deepseek3.rs:1013-1040 | mistralrs-core/src/models/flint.rs:920-977 | mistralrs-core/src/models/gemma.rs:462-490 | mistralrs-core/src/models/glm4.rs:580-607 | mistralrs-core/src/models/glm4_moe.rs:829-855 | mistralrs-core/src/models/glm4_moe_lite.rs:966-992 | mistralrs-core/src/models/hunyuan_v1_dense.rs:542-569 | mistralrs-core/src/models/hunyuan_v1_moe.rs:1036-1063 | mistralrs-core/src/models/mistral.rs:590-618 | mistralrs-core/src/models/mixtral.rs:526-556 | mistralrs-core/src/models/phi2.rs:542-569 | mistralrs-core/src/models/qwen3.rs:543-571 | mistralrs-core/src/models/qwen3_moe.rs:723-752 — These 14 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 14 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 14 times.
D4 · Code Duplication · Members sharing a duplicated core (12 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (12 members, 50+ identical tokens) mistralrs-core/src/models/flint.rs:739 — mistralrs-core/src/models/flint.rs:739-750 | mistralrs-core/src/models/gemma.rs:311-322 | mistralrs-core/src/models/gpt_oss.rs:681-693 | mistralrs-core/src/models/hunyuan_v1_dense.rs:338-349 | mistralrs-core/src/models/hunyuan_v1_moe.rs:828-839 | mistralrs-core/src/models/mistral.rs:359-370 | mistralrs-core/src/models/mixtral.rs:368-381 | mistralrs-core/src/models/phi3.rs:372-383 | mistralrs-core/src/models/qwen3.rs:347-358 | mistralrs-core/src/models/qwen3_moe.rs:521-532 | mistralrs-core/src/vision_models/phi3/mod.rs:463-474 | mistralrs-core/src/vision_models/phi4/mod.rs:293-304 — These 12 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 12 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 12 times.
D4 · Code Duplication · Members sharing a duplicated core (8 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (8 members, 50+ identical tokens) mistralrs-core/src/xlora_models/gemma.rs:425 — mistralrs-core/src/xlora_models/gemma.rs:425-564 | mistralrs-core/src/xlora_models/gemma2.rs:456-596 | mistralrs-core/src/xlora_models/llama.rs:530-667 | mistralrs-core/src/xlora_models/mistral.rs:421-558 | mistralrs-core/src/xlora_models/mixtral.rs:551-688 | mistralrs-core/src/xlora_models/phi2.rs:402-531 | mistralrs-core/src/xlora_models/phi3.rs:388-508 | mistralrs-core/src/xlora_models/starcoder2.rs:410-541 — These 8 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 8 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 8 times.
D4 · Code Duplication · Edited copy of a member (189 corresponding lines) · ×1
  • Edited copy of a member (189 corresponding lines) mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:187 — mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:187-376 | mistralrs-core/src/vision_models/qwen2vl/mod.rs:344-532 — These two members are one piece of code written twice and then edited apart: 189 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (232 corresponding lines) · ×1
  • Edited copy of a member (232 corresponding lines) mistralrs-core/src/models/granite.rs:1947 — mistralrs-core/src/models/granite.rs:1947-2178 | mistralrs-core/src/models/qwen3_next.rs:729-962 — These two members are one piece of code written twice and then edited apart: 232 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (126 corresponding lines) · ×1
  • Edited copy of a member (126 corresponding lines) mistralrs-core/src/attention/backends/metal_flash_attn.rs:17 — mistralrs-core/src/attention/backends/metal_flash_attn.rs:17-142 | mistralrs-core/src/attention/backends/metal_flash_attn.rs:152-284 — These two members are one piece of code written twice and then edited apart: 126 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (96 corresponding lines) · ×1
  • Edited copy of a member (96 corresponding lines) mistralrs-quant/src/rotary/mod.rs:575 — mistralrs-quant/src/rotary/mod.rs:575-670 | mistralrs-quant/src/rotary/mod.rs:680-802 — These two members are one piece of code written twice and then edited apart: 96 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (98 corresponding lines) · ×1
  • Edited copy of a member (98 corresponding lines) mistralrs-paged-attn/src/metal/kernels/mod.rs:521 — mistralrs-paged-attn/src/metal/kernels/mod.rs:521-618 | mistralrs-paged-attn/src/metal/kernels/mod.rs:658-784 — These two members are one piece of code written twice and then edited apart: 98 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (124 corresponding lines) · ×1
  • Edited copy of a member (124 corresponding lines) mistralrs-core/src/models/llama.rs:345 — mistralrs-core/src/models/llama.rs:345-468 | mistralrs-core/src/models/smollm3.rs:361-491 — These two members are one piece of code written twice and then edited apart: 124 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (83 corresponding lines) · ×1
  • Edited copy of a member (83 corresponding lines) releases/v0.9.5/scripts/plot_results.py:61 — releases/v0.9.5/scripts/plot_results.py:61-143 | releases/v0.9.5/scripts/plot_results.py:147-255 — These two members are one piece of code written twice and then edited apart: 83 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 80+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 80+ corresponding lines) REDACTED:327 — REDACTED:327-406 | mistralrs-core/src/vision_models/idefics3/vision.rs:139-218 | mistralrs-core/src/vision_models/siglip.rs:135-222 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 80 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copy of a member (125 corresponding lines) · ×1
  • Edited copy of a member (125 corresponding lines) mistralrs-core/src/pipeline/multimodal.rs:2937 — mistralrs-core/src/pipeline/multimodal.rs:2937-3062 | mistralrs-core/src/pipeline/normal.rs:2544-2668 — These two members are one piece of code written twice and then edited apart: 125 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 101+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 101+ corresponding lines) mistralrs-core/src/cuda/gdn.rs:938 — mistralrs-core/src/cuda/gdn.rs:938-1046 | mistralrs-core/src/cuda/gdn.rs:1058-1158 | mistralrs-core/src/cuda/gdn.rs:1170-1292 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 101 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copy of a member (113 corresponding lines) · ×1
  • Edited copy of a member (113 corresponding lines) mistralrs-quant/src/utils/ops.rs:1591 — mistralrs-quant/src/utils/ops.rs:1591-1714 | mistralrs-quant/src/utils/ops.rs:1733-1845 — These two members are one piece of code written twice and then edited apart: 113 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 92+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 92+ corresponding lines) mistralrs-core/src/models/llama.rs:612 — mistralrs-core/src/models/llama.rs:612-703 | mistralrs-core/src/models/smollm3.rs:631-722 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:625-719 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 92 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copy of a member (74 corresponding lines) · ×1
  • Edited copy of a member (74 corresponding lines) mistralrs-core/src/lora/loralinear.rs:174 — mistralrs-core/src/lora/loralinear.rs:174-247 | mistralrs-core/src/lora/qloralinear.rs:219-296 — These two members are one piece of code written twice and then edited apart: 74 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (70 corresponding lines) · ×1
  • Edited copy of a member (70 corresponding lines) mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:97 — mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:97-166 | mistralrs-core/src/vision_models/qwen2vl/mod.rs:120-189 — These two members are one piece of code written twice and then edited apart: 70 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (92 corresponding lines) · ×1
  • Edited copy of a member (92 corresponding lines) mistralrs-core/src/vision_models/qwen3_5/config.rs:266 — mistralrs-core/src/vision_models/qwen3_5/config.rs:266-357 | mistralrs-core/src/vision_models/qwen3_5_moe/config.rs:71-172 — These two members are one piece of code written twice and then edited apart: 92 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (54 corresponding lines) · ×1
  • Edited copy of a member (54 corresponding lines) mistralrs-core/src/models/deepseek2.rs:1021 — mistralrs-core/src/models/deepseek2.rs:1021-1074 | mistralrs-core/src/models/deepseek3.rs:1085-1139 — These two members are one piece of code written twice and then edited apart: 54 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (78 corresponding lines) · ×1
  • Edited copy of a member (78 corresponding lines) mistralrs-core/src/moe/experts/backends.rs:872 — mistralrs-core/src/moe/experts/backends.rs:872-949 | mistralrs-core/src/moe/experts/backends.rs:951-1037 — These two members are one piece of code written twice and then edited apart: 78 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (82 corresponding lines) · ×1
  • Edited copy of a member (82 corresponding lines) mistralrs-core/src/pipeline/multimodal.rs:3432 — mistralrs-core/src/pipeline/multimodal.rs:3432-3513 | mistralrs-core/src/pipeline/normal.rs:2860-2949 — These two members are one piece of code written twice and then edited apart: 82 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (53 corresponding lines) · ×1
  • Edited copy of a member (53 corresponding lines) REDACTED:455 — REDACTED:455-507 | REDACTED:806-862 — These two members are one piece of code written twice and then edited apart: 53 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (65 corresponding lines) · ×1
  • Edited copy of a member (65 corresponding lines) mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:207 — mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:207-271 | mistralrs-core/src/vision_models/mistral3/inputs_processor.rs:104-186 — These two members are one piece of code written twice and then edited apart: 65 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 51+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 51+ corresponding lines) mistralrs-pyo3/src/util.rs:201 — mistralrs-pyo3/src/util.rs:201-251 | mistralrs-pyo3/src/util.rs:255-305 | mistralrs-pyo3/src/util.rs:315-375 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 51 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copy of a member (51 corresponding lines) · ×1
  • Edited copy of a member (51 corresponding lines) mistralrs-quant/src/gguf/fast_mmq.rs:433 — mistralrs-quant/src/gguf/fast_mmq.rs:433-488 | mistralrs-quant/src/gguf/fast_mmq.rs:516-566 — These two members are one piece of code written twice and then edited apart: 51 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (64 corresponding lines) · ×1
  • Edited copy of a member (64 corresponding lines) mistralrs-quant/src/scalar_fp8/ops.rs:59 — mistralrs-quant/src/scalar_fp8/ops.rs:59-126 | mistralrs-quant/src/scalar_fp8/ops.rs:222-285 — These two members are one piece of code written twice and then edited apart: 64 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (61 corresponding lines) · ×1
  • Edited copy of a member (61 corresponding lines) mistralrs-pyo3/src/lib.rs:1984 — mistralrs-pyo3/src/lib.rs:1984-2044 | mistralrs-pyo3/src/lib.rs:2056-2120 — These two members are one piece of code written twice and then edited apart: 61 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copies of one member (5 members, 66+ corresponding lines) · ×1
  • Edited copies of one member (5 members, 66+ corresponding lines) mistralrs-core/src/models/lfm2.rs:407 — mistralrs-core/src/models/lfm2.rs:407-472 | mistralrs-core/src/models/lfm3.rs:394-476 | mistralrs-core/src/models/phi2.rs:171-245 | mistralrs-core/src/models/qwen3_next.rs:194-263 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:99-178 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 66 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 5 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 63+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 63+ corresponding lines) mistralrs-core/src/xlora_models/gemma2.rs:148 — mistralrs-core/src/xlora_models/gemma2.rs:148-223 | mistralrs-core/src/xlora_models/llama.rs:129-191 | mistralrs-core/src/xlora_models/phi2.rs:134-204 | mistralrs-core/src/xlora_models/starcoder2.rs:127-196 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 63 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copy of a member (67 corresponding lines) · ×1
  • Edited copy of a member (67 corresponding lines) mistralrs-core/src/models/mistral.rs:130 — mistralrs-core/src/models/mistral.rs:130-197 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:150-216 — These two members are one piece of code written twice and then edited apart: 67 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 45+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 45+ corresponding lines) mistralrs-core/src/models/qwen3_next.rs:1135 — mistralrs-core/src/models/qwen3_next.rs:1135-1182 | mistralrs-core/src/vision_models/qwen3_5/text.rs:1741-1785 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:965-1011 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 45 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 67+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 67+ corresponding lines) mistralrs-core/src/models/qwen2.rs:164 — mistralrs-core/src/models/qwen2.rs:164-230 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:121-187 | mistralrs-core/src/vision_models/qwen2vl/text.rs:122-188 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 67 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 38+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 38+ corresponding lines) mistralrs-core/src/pipeline/cuda_graph.rs:3598 — mistralrs-core/src/pipeline/cuda_graph.rs:3598-3635 | mistralrs-core/src/pipeline/cuda_graph.rs:3643-3680 | mistralrs-core/src/pipeline/cuda_graph.rs:3688-3725 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 38 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copy of a member (58 corresponding lines) · ×1
  • Edited copy of a member (58 corresponding lines) mistralrs/src/model_builder_trait.rs:1249 — mistralrs/src/model_builder_trait.rs:1249-1306 | mistralrs/src/model_builder_trait.rs:1312-1373 — These two members are one piece of code written twice and then edited apart: 58 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 53+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 53+ corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5537 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5537-5589 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7336-7398 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5328-5384 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 53 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 41+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 41+ corresponding lines) mistralrs-quant/src/metal_kernels/mod.rs:4523 — mistralrs-quant/src/metal_kernels/mod.rs:4523-4568 | mistralrs-quant/src/metal_kernels/mod.rs:4585-4627 | mistralrs-quant/src/metal_kernels/mod.rs:5186-5226 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 41 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 34+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 34+ corresponding lines) mistralrs-quant/src/moe/cuda.rs:222 — mistralrs-quant/src/moe/cuda.rs:222-255 | mistralrs-quant/src/moe/cuda.rs:258-291 | mistralrs-quant/src/moe/cuda.rs:298-332 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 34 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copy of a member (52 corresponding lines) · ×1
  • Edited copy of a member (52 corresponding lines) mistralrs-core/src/vision_models/gemma3n/text.rs:1688 — mistralrs-core/src/vision_models/gemma3n/text.rs:1688-1741 | mistralrs-core/src/vision_models/gemma4/text.rs:2019-2070 — These two members are one piece of code written twice and then edited apart: 52 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 40+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 40+ corresponding lines) mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:526 — mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:526-565 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4719-4764 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1026-1065 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2406-2445 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 40 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 44+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 44+ corresponding lines) mistralrs-core/src/models/flint.rs:687 — mistralrs-core/src/models/flint.rs:687-730 | mistralrs-core/src/models/qwen3_moe.rs:466-512 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:412-461 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 44 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 33+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 33+ corresponding lines) mistralrs-core/src/vision_models/idefics3/vision.rs:271 — mistralrs-core/src/vision_models/idefics3/vision.rs:271-303 | mistralrs-core/src/vision_models/lfm2_vl/vision.rs:205-237 | mistralrs-core/src/vision_models/siglip.rs:269-314 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 33 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copy of a member (44 corresponding lines) · ×1
  • Edited copy of a member (44 corresponding lines) mistralrs-core/src/sampler.rs:1393 — mistralrs-core/src/sampler.rs:1393-1440 | mistralrs-core/src/sampler.rs:1603-1646 — These two members are one piece of code written twice and then edited apart: 44 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (42 corresponding lines) · ×1
  • Edited copy of a member (42 corresponding lines) mistralrs-core/src/tools/parsers/deepseek.rs:56 — mistralrs-core/src/tools/parsers/deepseek.rs:56-101 | mistralrs-core/src/tools/parsers/harmony.rs:12-53 — These two members are one piece of code written twice and then edited apart: 42 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 44+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 44+ corresponding lines) mistralrs-server-core/src/embeddings.rs:257 — mistralrs-server-core/src/embeddings.rs:257-300 | mistralrs-server-core/src/embeddings.rs:307-350 | mistralrs/src/model.rs:656-713 | mistralrs/src/model.rs:737-793 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 44 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 39+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 39+ corresponding lines) mistralrs-core/src/xlora_models/gemma.rs:56 — mistralrs-core/src/xlora_models/gemma.rs:56-98 | mistralrs-core/src/xlora_models/gemma2.rs:50-92 | mistralrs-core/src/xlora_models/llama.rs:240-278 | mistralrs-core/src/xlora_models/mistral.rs:52-91 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 39 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 35+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 35+ corresponding lines) mistralrs-quant/src/utils/ops.rs:155 — mistralrs-quant/src/utils/ops.rs:155-189 | mistralrs-quant/src/utils/ops.rs:755-790 | mistralrs-quant/src/utils/ops.rs:1520-1556 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 35 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (8 members, 26+ corresponding lines) · ×1
  • Edited copies of one member (8 members, 26+ corresponding lines) mistralrs-quant/src/metal_kernels/mod.rs:281 — mistralrs-quant/src/metal_kernels/mod.rs:281-306 | mistralrs-quant/src/metal_kernels/mod.rs:320-345 | mistralrs-quant/src/metal_kernels/mod.rs:359-384 | mistralrs-quant/src/metal_kernels/mod.rs:398-423 | mistralrs-quant/src/metal_kernels/mod.rs:437-462 | mistralrs-quant/src/metal_kernels/mod.rs:690-723 | mistralrs-quant/src/metal_kernels/mod.rs:737-770 | mistralrs-quant/src/metal_kernels/mod.rs:784-817 — These 8 members are one piece of code written 8 times and then edited apart: every two of them correspond over at least 26 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 8 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (5 members, 25+ corresponding lines) · ×1
  • Edited copies of one member (5 members, 25+ corresponding lines) mistralrs-core/src/models/qwen3.rs:575 — mistralrs-core/src/models/qwen3.rs:575-599 | mistralrs-core/src/models/qwen3_moe.rs:756-783 | mistralrs-core/src/vision_models/gemma3/text.rs:840-870 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:599-624 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:720-749 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 25 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 5 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 22+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 22+ corresponding lines) mistralrs-pyo3/src/lib.rs:2191 — mistralrs-pyo3/src/lib.rs:2191-2217 | mistralrs-pyo3/src/lib.rs:2227-2249 | mistralrs-pyo3/src/lib.rs:2608-2629 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 22 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (5 members, 41+ corresponding lines) · ×1
  • Edited copies of one member (5 members, 41+ corresponding lines) mistralrs-core/src/xlora_models/gemma.rs:321 — mistralrs-core/src/xlora_models/gemma.rs:321-361 | mistralrs-core/src/xlora_models/llama.rs:337-377 | mistralrs-core/src/xlora_models/mixtral.rs:444-484 | mistralrs-core/src/xlora_models/phi3.rs:282-322 | mistralrs-core/src/xlora_models/starcoder2.rs:306-346 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 41 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 5 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 31+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 31+ corresponding lines) REDACTED:70 — REDACTED:70-101 | mistralrs-core/src/vision_models/llama4/mod.rs:73-103 | mistralrs-core/src/vision_models/mistral3/mod.rs:183-214 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 31 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 23+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 23+ corresponding lines) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5937 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5937-5967 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6495-6519 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6773-6795 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 23 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (6 members, 16+ corresponding lines) · ×1
  • Edited copies of one member (6 members, 16+ corresponding lines) mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:201 — mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:201-223 | mistralrs-core/src/vision_models/gemma3n/inputs_processor.rs:212-232 | mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:804-825 | mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:207-228 | mistralrs-core/src/vision_models/phi3/phi3_inputs_processor.rs:163-184 | mistralrs-core/src/vision_models/phi4/inputs_processor.rs:244-259 — These 6 members are one piece of code written 6 times and then edited apart: every two of them correspond over at least 16 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 6 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 15+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 15+ corresponding lines) mistralrs-core/src/attention/backends/cpu/avx.rs:13 — mistralrs-core/src/attention/backends/cpu/avx.rs:13-30 | mistralrs-core/src/attention/backends/cpu/avx.rs:67-82 | mistralrs-core/src/attention/backends/cpu/avx.rs:85-99 | mistralrs-core/src/attention/backends/cpu/avx.rs:326-341 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 15 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 17+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 17+ corresponding lines) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1762 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1762-1778 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4028-4044 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4291-4307 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6102-6118 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 17 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (6 members, 24+ corresponding lines) · ×1
  • Edited copies of one member (6 members, 24+ corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:997 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:997-1023 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1325-1348 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3105-3128 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3454-3477 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3788-3814 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4172-4201 — These 6 members are one piece of code written 6 times and then edited apart: every two of them correspond over at least 24 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 6 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 25+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 25+ corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1029 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1029-1053 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1354-1381 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3134-3161 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3483-3510 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 25 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (6 members, 17+ corresponding lines) · ×1
  • Edited copies of one member (6 members, 17+ corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1171 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1171-1187 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5152-5169 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:851-867 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1983-1999 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2927-2943 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3815-3831 — These 6 members are one piece of code written 6 times and then edited apart: every two of them correspond over at least 17 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 6 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (5 members, 23+ corresponding lines) · ×1
  • Edited copies of one member (5 members, 23+ corresponding lines) mistralrs-core/src/xlora_models/gemma2.rs:396 — mistralrs-core/src/xlora_models/gemma2.rs:396-425 | mistralrs-core/src/xlora_models/llama.rs:301-323 | mistralrs-core/src/xlora_models/mistral.rs:370-392 | mistralrs-core/src/xlora_models/mixtral.rs:497-522 | mistralrs-core/src/xlora_models/phi3.rs:336-359 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 23 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 5 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (5 members, 17+ corresponding lines) · ×1
  • Edited copies of one member (5 members, 17+ corresponding lines) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4777 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4777-4798 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6942-6959 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7406-7423 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1072-1088 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6651-6667 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 17 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 5 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 16+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 16+ corresponding lines) mistralrs-core/src/sequence.rs:592 — mistralrs-core/src/sequence.rs:592-607 | mistralrs-core/src/sequence.rs:617-635 | mistralrs-core/src/vision_models/mistral3/inputs_processor.rs:39-57 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 16 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (5 members, 6+ corresponding lines) · ×1
  • Edited copies of one member (5 members, 6+ corresponding lines) mistralrs-core/src/vision_models/gemma4/vision.rs:178 — mistralrs-core/src/vision_models/gemma4/vision.rs:178-183 | mistralrs-core/src/vision_models/muse_glimmer/vision.rs:171-176 | mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:134-139 | mistralrs-core/src/vision_models/qwen2vl/vision.rs:105-110 | mistralrs-core/src/vision_models/qwen3_vl/vision.rs:137-142 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 6 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 5 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (6 members, 8+ corresponding lines) · ×1
  • Edited copies of one member (6 members, 8+ corresponding lines) mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:82 — mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:82-89 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:81-89 | mistralrs-core/src/vision_models/qwen2_5_vl/vision.rs:115-123 | mistralrs-core/src/vision_models/qwen2vl/text.rs:82-90 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:69-77 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:76-83 — These 6 members are one piece of code written 6 times and then edited apart: every two of them correspond over at least 8 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 6 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (6 members, 9+ corresponding lines) · ×1
  • Edited copies of one member (6 members, 9+ corresponding lines) mistralrs-cli/src/args/mod.rs:465 — mistralrs-cli/src/args/mod.rs:465-473 | mistralrs-cli/src/commands/bench.rs:68-77 | mistralrs-cli/src/commands/serve.rs:900-908 | mistralrs-cli/src/commands/serve.rs:910-918 | mistralrs-cli/src/commands/serve.rs:920-929 | mistralrs-cli/src/commands/serve.rs:931-940 — These 6 members are one piece of code written 6 times and then edited apart: every two of them correspond over at least 9 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 6 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (6 members, 6+ corresponding lines) · ×1
  • Edited copies of one member (6 members, 6+ corresponding lines) mistralrs-core/src/models/flint.rs:507 — mistralrs-core/src/models/flint.rs:507-513 | mistralrs-core/src/models/quantized_llama.rs:46-51 | mistralrs-core/src/models/qwen3_moe.rs:338-344 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:258-264 | mistralrs-core/src/vision_models/voxtral/encoder.rs:146-152 | mistralrs-core/src/vision_models/voxtral/mod.rs:235-241 — These 6 members are one piece of code written 6 times and then edited apart: every two of them correspond over at least 6 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 6 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (5 members, 8+ corresponding lines) · ×1
  • Edited copies of one member (5 members, 8+ corresponding lines) mistralrs-core/src/cuda/hyper_connection.rs:161 — mistralrs-core/src/cuda/hyper_connection.rs:161-168 | mistralrs-core/src/cuda/qwen4_exp.rs:219-226 | mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:13-20 | mistralrs-paged-attn/src/metal/backend/paged_prefill.rs:392-400 | mistralrs-quant/src/moe/weighted_reduce.rs:25-32 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 8 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 5 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 6+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 6+ corresponding lines) mistralrs-core/src/flashinfer/metadata.rs:604 — mistralrs-core/src/flashinfer/metadata.rs:604-609 | mistralrs-core/src/paged_attention/plan.rs:1059-1065 | mistralrs-quant/src/gguf/archive.rs:1400-1406 | mistralrs-quant/src/gguf/weight_source.rs:1427-1433 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 6 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (7 members, 4+ corresponding lines) · ×1
  • Edited copies of one member (7 members, 4+ corresponding lines) mistralrs/src/auto_model.rs:201 — mistralrs/src/auto_model.rs:201-204 | mistralrs/src/diffusion_model.rs:77-80 | mistralrs/src/embedding_model.rs:225-228 | mistralrs/src/gguf.rs:465-468 | mistralrs/src/multimodal_model.rs:175-179 | mistralrs/src/speech_model.rs:88-91 | mistralrs/src/text_model.rs:238-241 — These 7 members are one piece of code written 7 times and then edited apart: every two of them correspond over at least 4 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 7 times and the copies will drift further apart.
D4 · Code Duplication · Duplicated block (148–157 lines × 2) · ×1
  • Duplicated block (148–157 lines × 2) mistralrs-quant/src/blockwise_fp8/mod.rs:1087 — mistralrs-quant/src/blockwise_fp8/mod.rs:1087-1243 | mistralrs-quant/src/pertensor_fp8/mod.rs:651-798 — `mistralrs-quant/src/blockwise_fp8/mod.rs` and `mistralrs-quant/src/pertensor_fp8/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 186 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/blockwise_fp8/mod.rs:1087` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (110 lines × 2) · ×1
  • Duplicated block (110 lines × 2) mistralrs-core/src/pipeline/mod.rs:2467 — mistralrs-core/src/pipeline/mod.rs:2467-2576 | mistralrs-core/src/pipeline/mod.rs:3134-3243 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/mod.rs:2467` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (88 lines × 2) · ×1
  • Duplicated block (88 lines × 2) mistralrs-core/src/vision_models/qwen3_5/config.rs:267 — mistralrs-core/src/vision_models/qwen3_5/config.rs:267-354 | mistralrs-core/src/vision_models/qwen3_5_moe/config.rs:72-159 — `mistralrs-core/src/vision_models/qwen3_5/config.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/config.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 2 separate duplicated blocks between them, totalling at least 101 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (85 lines × 2) · ×1
  • Duplicated block (85 lines × 2) mistralrs-core/src/vision_models/qwen3_5/text.rs:883 — mistralrs-core/src/vision_models/qwen3_5/text.rs:883-967 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:594-678 — `mistralrs-core/src/vision_models/qwen3_5/text.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 26 separate duplicated blocks between them, totalling at least 469 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_5/text.rs:883` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (79 lines × 2) · ×1
  • Duplicated block (79 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:3433 — mistralrs-core/src/pipeline/multimodal.rs:3433-3511 | mistralrs-core/src/pipeline/normal.rs:2861-2939 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/normal.rs:2861` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (77 lines × 2) · ×1
  • Duplicated block (77 lines × 2) mistralrs-core/src/vision_models/qwen3_vl/text.rs:107 — mistralrs-core/src/vision_models/qwen3_vl/text.rs:107-183 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:213-289 — `mistralrs-core/src/vision_models/qwen3_vl/text.rs` and `mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 45 separate duplicated blocks between them, totalling at least 674 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (117 lines × 3) · ×1
  • Duplicated block (117 lines × 3) mistralrs-core/src/vision_models/grid_processor.rs:1240 — mistralrs-core/src/vision_models/grid_processor.rs:1240-1356 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:444-560 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1052-1168 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:1240` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (71 lines × 2) · ×1
  • Duplicated block (71 lines × 2) mistralrs-quant/src/gguf/fast_mmq.rs:938 — mistralrs-quant/src/gguf/fast_mmq.rs:938-1008 | mistralrs-quant/src/gguf/fast_mmq.rs:1409-1479 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/gguf/fast_mmq.rs:938` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (4–68 lines × 5) · ×1
  • Duplicated block (4–68 lines × 5) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4295 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4295-4298 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6799-6866 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7241-7308 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7712-7777 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:8234-8299 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6799` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (160 lines × 2) · ×1
  • Duplicated block (160 lines × 2) mistralrs-core/src/models/deepseek2.rs:321 — mistralrs-core/src/models/deepseek2.rs:321-480 | mistralrs-core/src/models/deepseek3.rs:322-481 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (65 lines × 2) · ×1
  • Duplicated block (65 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:1169 — mistralrs-core/src/pipeline/multimodal.rs:1169-1233 | mistralrs-core/src/pipeline/normal.rs:1221-1285 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:1169` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (297 lines × 2) · ×1
  • Duplicated block (297 lines × 2) mistralrs-core/src/vision_models/qwen3_vl/mod.rs:672 — mistralrs-core/src/vision_models/qwen3_vl/mod.rs:672-968 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:118-414 — `mistralrs-core/src/vision_models/qwen3_vl/mod.rs` and `mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 25 separate duplicated blocks between them, totalling at least 658 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_vl/mod.rs:672` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (63 lines × 2) · ×1
  • Duplicated block (63 lines × 2) mistralrs/src/messages.rs:420 — mistralrs/src/messages.rs:420-482 | mistralrs/src/messages.rs:925-987 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (62 lines × 2) · ×1
  • Duplicated block (62 lines × 2) mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:1032 — mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:1032-1093 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1597-1658 — `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` and `mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 45 separate duplicated blocks between them, totalling at least 1082 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:1032` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (147–148 lines × 2) · ×1
  • Duplicated block (147–148 lines × 2) mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:188 — mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:188-335 | mistralrs-core/src/vision_models/qwen2vl/mod.rs:345-491 — `mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs` and `mistralrs-core/src/vision_models/qwen2vl/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 16 separate duplicated blocks between them, totalling at least 396 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:188` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (59 lines × 2) · ×1
  • Duplicated block (59 lines × 2) mistralrs-server-core/src/responses.rs:2129 — mistralrs-server-core/src/responses.rs:2129-2187 | mistralrs-server-core/src/responses.rs:2248-2306 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-server-core/src/responses.rs:2129` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (58 lines × 3) · ×1
  • Duplicated block (58 lines × 3) mistralrs-core/src/vision_models/grid_processor.rs:942 — mistralrs-core/src/vision_models/grid_processor.rs:942-999 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:165-222 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:731-788 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:942` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (58 lines × 2) · ×1
  • Duplicated block (58 lines × 2) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3175 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3175-3232 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3508-3565 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3175` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (57 lines × 3) · ×1
  • Duplicated block (57 lines × 3) mistralrs-core/src/models/deepseek2.rs:327 — mistralrs-core/src/models/deepseek2.rs:327-383 | mistralrs-core/src/models/deepseek3.rs:328-384 | mistralrs-core/src/models/glm4_moe_lite.rs:291-347 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:327` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/models/glm4_moe_lite.rs:348` calls `seqlen_offsets` and `mistralrs-core/src/models/deepseek2.rs:384` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (60 lines × 2) · ×1
  • Duplicated block (60 lines × 2) mistralrs-paged-attn/src/metal/kernels/mod.rs:549 — mistralrs-paged-attn/src/metal/kernels/mod.rs:549-608 | mistralrs-paged-attn/src/metal/kernels/mod.rs:693-752 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/metal/kernels/mod.rs:549` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-paged-attn/src/metal/kernels/mod.rs:691` calls `set_output_buffer`, `Some` and `mistralrs-paged-attn/src/metal/kernels/mod.rs:547` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (62 lines × 4) · ×1
  • Duplicated block (62 lines × 4) mistralrs-core/src/vision_models/qwen3_5/mod.rs:316 — mistralrs-core/src/vision_models/qwen3_5/mod.rs:316-377 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:299-360 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:851-912 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:297-358 — `mistralrs-core/src/vision_models/qwen3_5/mod.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 24 separate duplicated blocks between them, totalling at least 425 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (88–89 lines × 2) · ×1
  • Duplicated block (88–89 lines × 2) mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:428 — mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:428-515 | mistralrs-core/src/vision_models/qwen2vl/text.rs:429-517 — `mistralrs-core/src/vision_models/qwen2_5_vl/text.rs` and `mistralrs-core/src/vision_models/qwen2vl/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 42 separate duplicated blocks between them, totalling at least 716 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:428` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `rotary_emb` to `Arc<Qwen2_5VLRotaryEmbedding>` in one and `Arc<Qwen2VLRotaryEmbedding>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (50 lines × 7) · ×1
  • Duplicated block (50 lines × 7) mistralrs-core/src/xlora_models/gemma.rs:643 — mistralrs-core/src/xlora_models/gemma.rs:643-692 | mistralrs-core/src/xlora_models/gemma2.rs:694-743 | mistralrs-core/src/xlora_models/llama.rs:469-518 | mistralrs-core/src/xlora_models/mistral.rs:639-688 | mistralrs-core/src/xlora_models/mixtral.rs:769-818 | mistralrs-core/src/xlora_models/phi2.rs:609-658 | mistralrs-core/src/xlora_models/starcoder2.rs:624-673 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/gemma2.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 498 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma.rs:643` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (50 lines × 3) · ×1
  • Duplicated block (50 lines × 3) REDACTED:355 — REDACTED:355-404 | mistralrs-core/src/vision_models/idefics3/vision.rs:167-216 | mistralrs-core/src/vision_models/siglip.rs:168-217 — before extracting anything, compare `REDACTED` and `mistralrs-core/src/vision_models/idefics3/vision.rs` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 221 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:355` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (49–50 lines × 2) · ×1
  • Duplicated block (49–50 lines × 2) mistralrs-mcp/src/client.rs:461 — mistralrs-mcp/src/client.rs:461-509 | mistralrs-mcp/src/client.rs:616-665 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-mcp/src/client.rs:461` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (47–49 lines × 2) · ×1
  • Duplicated block (47–49 lines × 2) mistralrs-core/src/models/lfm2.rs:514 — mistralrs-core/src/models/lfm2.rs:514-562 | mistralrs-core/src/models/lfm3.rs:492-538 — before extracting anything, compare `mistralrs-core/src/models/lfm2.rs` and `mistralrs-core/src/models/lfm3.rs` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 402 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/lfm2.rs:514` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (48 lines × 2) · ×1
  • Duplicated block (48 lines × 2) mistralrs-core/src/models/deepseek2.rs:616 — mistralrs-core/src/models/deepseek2.rs:616-663 | mistralrs-core/src/models/deepseek3.rs:679-726 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (46–48 lines × 2) · ×1
  • Duplicated block (46–48 lines × 2) mistralrs-core/src/models/glm4_moe.rs:521 — mistralrs-core/src/models/glm4_moe.rs:521-566 | mistralrs-core/src/models/glm4_moe_lite.rs:625-672 — before extracting anything, compare `mistralrs-core/src/models/glm4_moe.rs` and `mistralrs-core/src/models/glm4_moe_lite.rs` as WHOLE FILES: this scan already matched 44 separate duplicated blocks between them, totalling at least 596 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (117 lines × 2) · ×1
  • Duplicated block (117 lines × 2) mistralrs-core/src/models/deepseek2.rs:169 — mistralrs-core/src/models/deepseek2.rs:169-285 | mistralrs-core/src/models/deepseek3.rs:170-286 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (45 lines × 3) · ×1
  • Duplicated block (45 lines × 3) mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:532 — mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:532-576 | mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:539-583 | mistralrs-core/src/vision_models/phi3/phi3_inputs_processor.rs:469-513 — before extracting anything, compare `mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs` and `mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 222 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:532` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (44 lines × 3) · ×1
  • Duplicated block (44 lines × 3) mistralrs-core/src/models/mistral.rs:135 — mistralrs-core/src/models/mistral.rs:135-178 | mistralrs-core/src/models/mixtral.rs:81-124 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:155-198 — before extracting anything, compare `mistralrs-core/src/models/mistral.rs` and `mistralrs-core/src/models/mixtral.rs` as WHOLE FILES: this scan already matched 47 separate duplicated blocks between them, totalling at least 619 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/mistral.rs:135` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (38–42 lines × 2) · ×1
  • Duplicated block (38–42 lines × 2) mistralrs-core/src/moe/experts/backends.rs:876 — mistralrs-core/src/moe/experts/backends.rs:876-917 | mistralrs-core/src/moe/experts/backends.rs:952-989 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (41 lines × 2) · ×1
  • Duplicated block (41 lines × 2) mistralrs-core/src/vision_models/qwen3_5/mod.rs:157 — mistralrs-core/src/vision_models/qwen3_5/mod.rs:157-197 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:140-180 — `mistralrs-core/src/vision_models/qwen3_5/mod.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 24 separate duplicated blocks between them, totalling at least 425 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_5/mod.rs:157` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (39–40 lines × 10) · ×1
  • Duplicated block (39–40 lines × 10) mistralrs-core/src/models/gemma.rs:612 — mistralrs-core/src/models/gemma.rs:612-651 | mistralrs-core/src/models/gemma2.rs:729-768 | mistralrs-core/src/models/glm4.rs:731-770 | mistralrs-core/src/models/hunyuan_v1_dense.rs:699-738 | mistralrs-core/src/models/mistral.rs:740-779 | mistralrs-core/src/models/qwen2.rs:743-782 | mistralrs-core/src/models/qwen3.rs:717-756 | mistralrs-core/src/vision_models/gemma3/text.rs:954-993 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:699-738 | mistralrs-core/src/vision_models/muse_glimmer/text.rs:707-745 — before extracting anything, compare `mistralrs-core/src/models/gemma.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 707 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma.rs:612` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (40 lines × 3) · ×1
  • Duplicated block (40 lines × 3) mistralrs-core/src/vision_models/grid_processor.rs:1485 — mistralrs-core/src/vision_models/grid_processor.rs:1485-1524 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:679-718 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1288-1327 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:1485` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (21–40 lines × 2) · ×1
  • Duplicated block (21–40 lines × 2) mistralrs-core/src/cuda/speculative_rejection.rs:521 — mistralrs-core/src/cuda/speculative_rejection.rs:521-560 | mistralrs-core/src/cuda/speculative_rejection.rs:588-608 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/speculative_rejection.rs:588` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (37–40 lines × 2) · ×1
  • Duplicated block (37–40 lines × 2) mistralrs-core/src/models/lfm2.rs:1014 — mistralrs-core/src/models/lfm2.rs:1014-1053 | mistralrs-core/src/models/lfm3.rs:916-952 — before extracting anything, compare `mistralrs-core/src/models/lfm2.rs` and `mistralrs-core/src/models/lfm3.rs` as WHOLE FILES: this scan already matched 25 separate duplicated blocks between them, totalling at least 402 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/lfm2.rs:1014` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (38–40 lines × 2) · ×1
  • Duplicated block (38–40 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:2569 — mistralrs-core/src/pipeline/multimodal.rs:2569-2608 | mistralrs-core/src/pipeline/normal.rs:2201-2238 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (30–40 lines × 2) · ×1
  • Duplicated block (30–40 lines × 2) mistralrs-core/src/vision_models/gemma3/text.rs:794 — mistralrs-core/src/vision_models/gemma3/text.rs:794-833 | mistralrs-core/src/vision_models/gemma4/text.rs:2464-2493 — `mistralrs-core/src/vision_models/gemma3/text.rs` and `mistralrs-core/src/vision_models/gemma4/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 8 separate duplicated blocks between them, totalling at least 99 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (39 lines × 4) · ×1
  • Duplicated block (39 lines × 4) mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:366 — mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:366-404 | mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:352-390 | mistralrs-core/src/vision_models/phi3/phi3_inputs_processor.rs:321-359 | mistralrs-core/src/vision_models/phi4/inputs_processor.rs:376-414 — before extracting anything, compare `mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs` and `mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 222 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:366` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (39 lines × 3) · ×1
  • Duplicated block (39 lines × 3) mistralrs-core/src/models/deepseek2.rs:209 — mistralrs-core/src/models/deepseek2.rs:209-247 | mistralrs-core/src/models/deepseek3.rs:210-248 | mistralrs-core/src/models/glm4_moe_lite.rs:170-208 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:209` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (37–39 lines × 2) · ×1
  • Duplicated block (37–39 lines × 2) mistralrs-quant/src/metal_kernels/mod.rs:4440 — mistralrs-quant/src/metal_kernels/mod.rs:4440-4478 | mistralrs-quant/src/metal_kernels/mod.rs:5096-5132 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/metal_kernels/mod.rs:4440` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-quant/src/metal_kernels/mod.rs:5134` calls `encoder`, `as_ref` and `mistralrs-quant/src/metal_kernels/mod.rs:4480` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (74 lines × 2) · ×1
  • Duplicated block (74 lines × 2) mistralrs-core/src/models/gemma.rs:363 — mistralrs-core/src/models/gemma.rs:363-436 | mistralrs-core/src/models/gemma2.rs:436-509 — before extracting anything, compare `mistralrs-core/src/models/gemma.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 707 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma.rs:363` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (29–37 lines × 2) · ×1
  • Duplicated block (29–37 lines × 2) mistralrs-core/src/vision_models/gemma3n/audio.rs:337 — mistralrs-core/src/vision_models/gemma3n/audio.rs:337-373 | mistralrs-core/src/vision_models/gemma4/audio.rs:146-174 — `mistralrs-core/src/vision_models/gemma3n/audio.rs` and `mistralrs-core/src/vision_models/gemma4/audio.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 20 separate duplicated blocks between them, totalling at least 352 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3n/audio.rs:337` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (70 lines × 2) · ×1
  • Duplicated block (70 lines × 2) mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:221 — mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:221-290 | mistralrs-core/src/vision_models/qwen2vl/text.rs:222-291 — `mistralrs-core/src/vision_models/qwen2_5_vl/text.rs` and `mistralrs-core/src/vision_models/qwen2vl/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 42 separate duplicated blocks between them, totalling at least 716 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:221` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (56 lines × 2) · ×1
  • Duplicated block (56 lines × 2) mistralrs-core/src/ops.rs:1506 — mistralrs-core/src/ops.rs:1506-1561 | mistralrs-core/src/ops.rs:1728-1783 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (34 lines × 6) · ×1
  • Duplicated block (34 lines × 6) mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:590 — mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:590-623 | mistralrs-core/src/vision_models/grid_processor.rs:1535-1568 | mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:597-630 | mistralrs-core/src/vision_models/mllama/inputs_processor.rs:358-391 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:729-762 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1005-1038 — `mistralrs-core/src/vision_models/gemma3/inputs_processor.rs` and `mistralrs-core/src/vision_models/idefics3/inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 10 separate duplicated blocks between them, totalling at least 146 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:590` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (33 lines × 5) · ×1
  • Duplicated block (33 lines × 5) mistralrs-core/src/vision_models/qwen3_5/mod.rs:456 — mistralrs-core/src/vision_models/qwen3_5/mod.rs:456-488 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:464-496 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:1026-1058 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:470-502 | mistralrs-core/src/vision_models/qwen4_exp/mod.rs:441-473 — `mistralrs-core/src/vision_models/qwen3_5/mod.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 24 separate duplicated blocks between them, totalling at least 425 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_5/mod.rs:456` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (32–33 lines × 4) · ×1
  • Duplicated block (32–33 lines × 4) mistralrs-core/src/models/granite.rs:1644 — mistralrs-core/src/models/granite.rs:1644-1675 | mistralrs-core/src/models/llama.rs:181-213 | mistralrs-core/src/models/smollm3.rs:198-230 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:155-187 — before extracting anything, compare `mistralrs-core/src/models/granite.rs` and `mistralrs-core/src/models/llama.rs` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 244 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/granite.rs:1644` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (28–33 lines × 4) · ×1
  • Duplicated block (28–33 lines × 4) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3227 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3227-3254 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3560-3587 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4782-4814 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5093-5125 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3227` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (32–33 lines × 2) · ×1
  • Duplicated block (32–33 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:1513 — mistralrs-core/src/pipeline/multimodal.rs:1513-1545 | mistralrs-core/src/pipeline/normal.rs:209-240 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (29–33 lines × 2) · ×1
  • Duplicated block (29–33 lines × 2) mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:630 — mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:630-662 | mistralrs-core/src/vision_models/mistral3/inputs_processor.rs:403-431 — `mistralrs-core/src/vision_models/idefics3/inputs_processor.rs` and `mistralrs-core/src/vision_models/mistral3/inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 13 separate duplicated blocks between them, totalling at least 194 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:630` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (31–33 lines × 2) · ×1
  • Duplicated block (31–33 lines × 2) mistralrs-core/src/vision_models/llava/llava15.rs:193 — mistralrs-core/src/vision_models/llava/llava15.rs:193-225 | mistralrs-core/src/vision_models/llava/llava_next.rs:158-188 — before extracting anything, compare `mistralrs-core/src/vision_models/llava/llava15.rs` and `mistralrs-core/src/vision_models/llava/llava_next.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 109 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/llava/llava15.rs:193` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (29–32 lines × 10) · ×1
  • Duplicated block (29–32 lines × 10) mistralrs-core/src/models/glm4.rs:244 — mistralrs-core/src/models/glm4.rs:244-275 | mistralrs-core/src/models/glm4_moe.rs:312-340 | mistralrs-core/src/models/granite.rs:1573-1601 | mistralrs-core/src/vision_models/muse_glimmer/text.rs:272-300 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:239-267 | mistralrs-core/src/vision_models/qwen2vl/text.rs:240-268 | mistralrs-core/src/vision_models/qwen3_5/text.rs:364-392 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:232-260 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:236-267 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:342-370 — before extracting anything, compare `mistralrs-core/src/models/glm4.rs` and `mistralrs-core/src/models/glm4_moe.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 359 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/glm4.rs:244` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/vision_models/qwen3_5/text.rs:393` calls `ok_or_else`, `msg` and `mistralrs-core/src/models/glm4.rs:276` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (30–32 lines × 5) · ×1
  • Duplicated block (30–32 lines × 5) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1472 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1472-1501 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3204-3235 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3546-3577 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3922-3953 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4671-4702 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (32 lines × 3) · ×1
  • Duplicated block (32 lines × 3) mistralrs-quant/src/afq/ops.rs:1827 — mistralrs-quant/src/afq/ops.rs:1827-1858 | mistralrs-quant/src/afq/ops.rs:1945-1976 | mistralrs-quant/src/afq/ops.rs:2065-2096 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/afq/ops.rs:1827` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (41 lines × 3) · ×1
  • Duplicated block (41 lines × 3) mistralrs-quant/src/gguf/fast_mmvq.rs:1170 — mistralrs-quant/src/gguf/fast_mmvq.rs:1170-1210 | mistralrs-quant/src/gguf/fast_mmvq.rs:1225-1265 | mistralrs-quant/src/gguf/fast_mmvq.rs:1280-1320 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/gguf/fast_mmvq.rs:1170` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (45 lines × 2) · ×1
  • Duplicated block (45 lines × 2) mistralrs-core/src/models/llama.rs:424 — mistralrs-core/src/models/llama.rs:424-468 | mistralrs-core/src/models/smollm3.rs:447-491 — before extracting anything, compare `mistralrs-core/src/models/llama.rs` and `mistralrs-core/src/models/smollm3.rs` as WHOLE FILES: this scan already matched 47 separate duplicated blocks between them, totalling at least 727 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/llama.rs:424` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/models/llama.rs:470` calls `get_input_embeddings`, `embedding_forward`, `into` and `mistralrs-core/src/models/smollm3.rs:493` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (31 lines × 3) · ×1
  • Duplicated block (31 lines × 3) mistralrs-core/src/model_loader.rs:543 — mistralrs-core/src/model_loader.rs:543-573 | mistralrs-core/src/toml_selector.rs:875-905 | mistralrs-core/src/toml_selector.rs:922-952 — before extracting anything, compare `mistralrs-core/src/model_loader.rs` and `mistralrs-core/src/toml_selector.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 199 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/model_loader.rs:543` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (26–31 lines × 2) · ×1
  • Duplicated block (26–31 lines × 2) mistralrs-quant/src/afq/ops.rs:2423 — mistralrs-quant/src/afq/ops.rs:2423-2448 | mistralrs-quant/src/afq/ops.rs:3000-3030 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/afq/ops.rs:2423` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (30 lines × 7) · ×1
  • Duplicated block (30 lines × 7) mistralrs-core/src/vision_models/gemma3n/inputs_processor.rs:365 — mistralrs-core/src/vision_models/gemma3n/inputs_processor.rs:365-394 | mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:469-498 | mistralrs-core/src/vision_models/lfm2_vl/inputs_processor.rs:721-750 | mistralrs-core/src/vision_models/llama4/inputs_processor.rs:447-476 | mistralrs-core/src/vision_models/minicpmo/inputs_processor.rs:495-524 | mistralrs-core/src/vision_models/mistral3/inputs_processor.rs:374-403 | mistralrs-core/src/vision_models/voxtral/inputs_processor.rs:280-309 — before extracting anything, compare `mistralrs-core/src/vision_models/gemma3n/inputs_processor.rs` and `mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 98 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3n/inputs_processor.rs:365` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/vision_models/minicpmo/inputs_processor.rs:527` calls `dim`, `collect` and `mistralrs-core/src/vision_models/gemma3n/inputs_processor.rs:396` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (26–30 lines × 2) · ×1
  • Duplicated block (26–30 lines × 2) mistralrs-core/src/ops.rs:1565 — mistralrs-core/src/ops.rs:1565-1590 | mistralrs-core/src/ops.rs:1803-1832 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (23–50 lines × 3) · ×1
  • Duplicated block (23–50 lines × 3) mistralrs-core/src/vision_models/muse_glimmer/mod.rs:134 — mistralrs-core/src/vision_models/muse_glimmer/mod.rs:134-156 | mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:117-166 | mistralrs-core/src/vision_models/qwen2vl/mod.rs:140-189 — `mistralrs-core/src/vision_models/muse_glimmer/mod.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 66 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/muse_glimmer/mod.rs:134` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (28–29 lines × 7) · ×1
  • Duplicated block (28–29 lines × 7) mistralrs-core/src/models/flint.rs:474 — mistralrs-core/src/models/flint.rs:474-502 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:222-249 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:45-72 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:49-76 | mistralrs-core/src/vision_models/qwen2vl/text.rs:50-77 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:37-64 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:43-71 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/vision_models/llava/llava_llm/llama.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 175 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/flint.rs:474` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `cfg` to `&Config` in one and `&TextConfig` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (28–29 lines × 2) · ×1
  • Duplicated block (28–29 lines × 2) mistralrs-core/src/paged_attention/cache_engine.rs:254 — mistralrs-core/src/paged_attention/cache_engine.rs:254-282 | mistralrs-core/src/paged_attention/cache_engine.rs:389-416 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/paged_attention/cache_engine.rs:254` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (13–29 lines × 2) · ×1
  • Duplicated block (13–29 lines × 2) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1290 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1290-1302 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3057-3085 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (52 lines × 2) · ×1
  • Duplicated block (52 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:1409 — mistralrs-core/src/pipeline/multimodal.rs:1409-1460 | mistralrs-core/src/pipeline/normal.rs:1452-1503 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:1409` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (25–28 lines × 17) · ×1
  • Duplicated block (25–28 lines × 17) mistralrs-core/src/models/flint.rs:395 — mistralrs-core/src/models/flint.rs:395-419 | mistralrs-core/src/models/gemma2.rs:247-274 | mistralrs-core/src/models/gpt_oss.rs:280-304 | mistralrs-core/src/models/hunyuan_v1_dense.rs:226-250 | mistralrs-core/src/models/hunyuan_v1_moe.rs:412-436 | mistralrs-core/src/models/llama.rs:108-135 | mistralrs-core/src/models/mistral.rs:248-275 | mistralrs-core/src/models/mixtral.rs:184-211 | mistralrs-core/src/models/phi3_5_moe.rs:214-241 | mistralrs-core/src/models/qwen2.rs:278-305 | mistralrs-core/src/models/qwen3.rs:233-260 | mistralrs-core/src/models/qwen3_moe.rs:236-263 | mistralrs-core/src/models/qwen3_next.rs:320-344 | mistralrs-core/src/models/smollm3.rs:125-152 | mistralrs-core/src/models/starcoder2.rs:260-287 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:82-109 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:251-278 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 190 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/flint.rs:395` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (28 lines × 5) · ×1
  • Duplicated block (28 lines × 5) mistralrs-core/src/embedding_models/embedding_gemma.rs:117 — mistralrs-core/src/embedding_models/embedding_gemma.rs:117-144 | mistralrs-core/src/models/gemma.rs:97-124 | mistralrs-core/src/models/gemma2.rs:130-157 | mistralrs-core/src/models/starcoder2.rs:157-184 | mistralrs-core/src/vision_models/gemma3n/text.rs:320-347 — `mistralrs-core/src/embedding_models/embedding_gemma.rs` and `mistralrs-core/src/models/gemma.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 9 separate duplicated blocks between them, totalling at least 133 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/embedding_gemma.rs:117` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (22–28 lines × 3) · ×1
  • Duplicated block (22–28 lines × 3) mistralrs-core/src/models/deepseek3.rs:575 — mistralrs-core/src/models/deepseek3.rs:575-602 | mistralrs-core/src/models/glm4_moe.rs:466-487 | mistralrs-core/src/models/glm4_moe_lite.rs:565-592 — before extracting anything, compare `mistralrs-core/src/models/deepseek3.rs` and `mistralrs-core/src/models/glm4_moe.rs` as WHOLE FILES: this scan already matched 39 separate duplicated blocks between them, totalling at least 479 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (28 lines × 3) · ×1
  • Duplicated block (28 lines × 3) mistralrs-paged-attn/src/cuda/backend/mla.rs:456 — mistralrs-paged-attn/src/cuda/backend/mla.rs:456-483 | mistralrs-paged-attn/src/cuda/backend/mla.rs:515-542 | mistralrs-paged-attn/src/cuda/backend/mla.rs:574-601 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/cuda/backend/mla.rs:456` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (19–28 lines × 2) · ×1
  • Duplicated block (19–28 lines × 2) mistralrs-core/src/gguf/gemma3n_bindings.rs:232 — mistralrs-core/src/gguf/gemma3n_bindings.rs:232-250 | mistralrs-core/src/gguf/muse_glimmer_bindings.rs:66-93 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/gguf/gemma3n_bindings.rs:232` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (26–28 lines × 2) · ×1
  • Duplicated block (26–28 lines × 2) mistralrs-core/src/ops.rs:1081 — mistralrs-core/src/ops.rs:1081-1108 | mistralrs-core/src/ops.rs:1312-1337 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:1081` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/ops.rs:1338` calls `topk_large_ranked_state_words_per_row` and `mistralrs-core/src/ops.rs:1109` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (26–27 lines × 6) · ×1
  • Duplicated block (26–27 lines × 6) mistralrs-core/src/embedding_models/embedding_gemma.rs:129 — mistralrs-core/src/embedding_models/embedding_gemma.rs:129-155 | mistralrs-core/src/models/gemma.rs:109-135 | mistralrs-core/src/models/gemma2.rs:142-168 | mistralrs-core/src/models/starcoder2.rs:169-195 | mistralrs-core/src/vision_models/gemma3/text.rs:102-127 | mistralrs-core/src/vision_models/gemma3n/text.rs:332-358 — `mistralrs-core/src/embedding_models/embedding_gemma.rs` and `mistralrs-core/src/models/gemma.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 9 separate duplicated blocks between them, totalling at least 133 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/embedding_gemma.rs:129` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (27 lines × 5) · ×1
  • Duplicated block (27 lines × 5) mistralrs-core/src/xlora_models/gemma.rs:466 — mistralrs-core/src/xlora_models/gemma.rs:466-492 | mistralrs-core/src/xlora_models/gemma2.rs:496-522 | mistralrs-core/src/xlora_models/mistral.rs:462-488 | mistralrs-core/src/xlora_models/mixtral.rs:593-619 | mistralrs-core/src/xlora_models/phi3.rs:421-447 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/gemma2.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 498 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma.rs:466` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (55 lines × 3) · ×1
  • Duplicated block (55 lines × 3) mistralrs-core/src/pipeline/embedding.rs:429 — mistralrs-core/src/pipeline/embedding.rs:429-483 | mistralrs-core/src/pipeline/multimodal.rs:980-1034 | mistralrs-core/src/pipeline/normal.rs:983-1037 — before extracting anything, compare `mistralrs-core/src/pipeline/embedding.rs` and `mistralrs-core/src/pipeline/multimodal.rs` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 178 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/embedding.rs:429` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (26–27 lines × 2) · ×1
  • Duplicated block (26–27 lines × 2) mistralrs-core/src/vision_models/gemma3/text.rs:499 — mistralrs-core/src/vision_models/gemma3/text.rs:499-524 | mistralrs-core/src/vision_models/gemma3n/text.rs:1439-1465 — `mistralrs-core/src/vision_models/gemma3/text.rs` and `mistralrs-core/src/vision_models/gemma3n/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 16 separate duplicated blocks between them, totalling at least 214 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3n/text.rs:1439` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (19–27 lines × 2) · ×1
  • Duplicated block (19–27 lines × 2) mistralrs-core/src/vision_models/gemma3n/audio.rs:264 — mistralrs-core/src/vision_models/gemma3n/audio.rs:264-290 | mistralrs-core/src/vision_models/gemma4/audio.rs:93-111 — `mistralrs-core/src/vision_models/gemma3n/audio.rs` and `mistralrs-core/src/vision_models/gemma4/audio.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 20 separate duplicated blocks between them, totalling at least 352 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (24–26 lines × 18) · ×1
  • Duplicated block (24–26 lines × 18) mistralrs-core/src/models/gemma.rs:216 — mistralrs-core/src/models/gemma.rs:216-240 | mistralrs-core/src/models/gemma2.rs:263-288 | mistralrs-core/src/models/gpt_oss.rs:293-317 | mistralrs-core/src/models/hunyuan_v1_dense.rs:239-263 | mistralrs-core/src/models/hunyuan_v1_moe.rs:425-449 | mistralrs-core/src/models/lfm2.rs:533-556 | mistralrs-core/src/models/lfm3.rs:509-532 | mistralrs-core/src/models/llama.rs:124-148 | mistralrs-core/src/models/mistral.rs:264-288 | mistralrs-core/src/models/mixtral.rs:200-224 | mistralrs-core/src/models/phi2.rs:312-336 | mistralrs-core/src/models/qwen2.rs:294-318 | mistralrs-core/src/models/qwen3.rs:249-273 | mistralrs-core/src/models/qwen3_moe.rs:252-276 | mistralrs-core/src/models/qwen3_next.rs:333-356 | mistralrs-core/src/models/smollm3.rs:141-165 | mistralrs-core/src/models/starcoder2.rs:276-300 | mistralrs-core/src/vision_models/voxtral/mod.rs:176-199 — before extracting anything, compare `mistralrs-core/src/models/gemma.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 707 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma.rs:216` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/models/gemma.rs:214` calls `is_none` and `mistralrs-core/src/models/lfm2.rs:531` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (26 lines × 9) · ×1
  • Duplicated block (26 lines × 9) mistralrs-core/src/xlora_models/gemma.rs:634 — mistralrs-core/src/xlora_models/gemma.rs:634-659 | mistralrs-core/src/xlora_models/gemma2.rs:685-710 | mistralrs-core/src/xlora_models/llama.rs:460-485 | mistralrs-core/src/xlora_models/mistral.rs:630-655 | mistralrs-core/src/xlora_models/mixtral.rs:760-785 | mistralrs-core/src/xlora_models/phi2.rs:600-625 | mistralrs-core/src/xlora_models/quantized_llama.rs:850-875 | mistralrs-core/src/xlora_models/quantized_phi3.rs:515-540 | mistralrs-core/src/xlora_models/starcoder2.rs:615-640 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/gemma2.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 498 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma.rs:634` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (23–26 lines × 2) · ×1
  • Duplicated block (23–26 lines × 2) mistralrs-core/src/vision_models/gemma3n/audio.rs:295 — mistralrs-core/src/vision_models/gemma3n/audio.rs:295-320 | mistralrs-core/src/vision_models/gemma4/audio.rs:114-136 — `mistralrs-core/src/vision_models/gemma3n/audio.rs` and `mistralrs-core/src/vision_models/gemma4/audio.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 20 separate duplicated blocks between them, totalling at least 352 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (25 lines × 5) · ×1
  • Duplicated block (25 lines × 5) mistralrs-core/src/xlora_models/gemma.rs:233 — mistralrs-core/src/xlora_models/gemma.rs:233-257 | mistralrs-core/src/xlora_models/gemma2.rs:238-262 | mistralrs-core/src/xlora_models/mistral.rs:223-247 | mistralrs-core/src/xlora_models/mixtral.rs:136-160 | mistralrs-core/src/xlora_models/starcoder2.rs:210-234 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/gemma2.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 498 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma.rs:233` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (23–25 lines × 3) · ×1
  • Duplicated block (23–25 lines × 3) mistralrs-core/src/pipeline/embedding.rs:370 — mistralrs-core/src/pipeline/embedding.rs:370-392 | mistralrs-core/src/pipeline/multimodal.rs:935-959 | mistralrs-core/src/pipeline/normal.rs:938-962 — before extracting anything, compare `mistralrs-core/src/pipeline/embedding.rs` and `mistralrs-core/src/pipeline/multimodal.rs` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 178 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/embedding.rs:370` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (21–25 lines × 2) · ×1
  • Duplicated block (21–25 lines × 2) mistralrs-core/src/vision_models/gemma3n/audio.rs:384 — mistralrs-core/src/vision_models/gemma3n/audio.rs:384-408 | mistralrs-core/src/vision_models/gemma4/audio.rs:183-203 — `mistralrs-core/src/vision_models/gemma3n/audio.rs` and `mistralrs-core/src/vision_models/gemma4/audio.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 20 separate duplicated blocks between them, totalling at least 352 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3n/audio.rs:384` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/vision_models/gemma4/audio.rs:182` calls `reshape` and `mistralrs-core/src/vision_models/gemma3n/audio.rs:383` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (23–25 lines × 2) · ×1
  • Duplicated block (23–25 lines × 2) mistralrs-quant/src/metal_kernels/mod.rs:3925 — mistralrs-quant/src/metal_kernels/mod.rs:3925-3949 | mistralrs-quant/src/metal_kernels/mod.rs:4016-4038 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/metal_kernels/mod.rs:3925` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (24 lines × 4) · ×1
  • Duplicated block (24 lines × 4) mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:537 — mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:537-560 | mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:544-567 | mistralrs-core/src/vision_models/phi3/phi3_inputs_processor.rs:474-497 | mistralrs-core/src/vision_models/phi4/inputs_processor.rs:452-475 — before extracting anything, compare `mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs` and `mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs` as WHOLE FILES: this scan already matched 11 separate duplicated blocks between them, totalling at least 222 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/vision_models/phi4/inputs_processor.rs:477` calls `and_then` and `mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:562` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (82 lines × 3) · ×1
  • Duplicated block (82 lines × 3) mistralrs-core/src/models/deepseek2.rs:848 — mistralrs-core/src/models/deepseek2.rs:848-929 | mistralrs-core/src/models/deepseek3.rs:911-992 | mistralrs-core/src/models/glm4_moe_lite.rs:858-939 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:848` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (24 lines × 3) · ×1
  • Duplicated block (24 lines × 3) REDACTED:328 — REDACTED:328-351 | mistralrs-core/src/vision_models/idefics3/vision.rs:140-163 | mistralrs-core/src/vision_models/siglip.rs:136-159 — before extracting anything, compare `REDACTED` and `mistralrs-core/src/vision_models/idefics3/vision.rs` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 221 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `REDACTED:328` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/vision_models/siglip.rs:160` calls `Some`, `i` and `REDACTED:352` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (80 lines × 2) · ×1
  • Duplicated block (80 lines × 2) mistralrs-core/src/models/hunyuan_v1_dense.rs:430 — mistralrs-core/src/models/hunyuan_v1_dense.rs:430-509 | mistralrs-core/src/models/hunyuan_v1_moe.rs:924-1003 — before extracting anything, compare `mistralrs-core/src/models/hunyuan_v1_dense.rs` and `mistralrs-core/src/models/hunyuan_v1_moe.rs` as WHOLE FILES: this scan already matched 55 separate duplicated blocks between them, totalling at least 766 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/hunyuan_v1_dense.rs:430` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (22–24 lines × 2) · ×1
  • Duplicated block (22–24 lines × 2) mistralrs-core/src/pipeline/sampling.rs:1476 — mistralrs-core/src/pipeline/sampling.rs:1476-1497 | mistralrs-core/src/pipeline/sampling.rs:1564-1587 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/sampling.rs:1476` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (22–23 lines × 14) · ×1
  • Duplicated block (22–23 lines × 14) mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:583 — mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:583-605 | mistralrs-core/src/vision_models/gemma3n/inputs_processor.rs:356-377 | mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1538-1559 | mistralrs-core/src/vision_models/grid_processor.rs:1528-1550 | mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:460-481 | mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:590-612 | mistralrs-core/src/vision_models/lfm2_vl/inputs_processor.rs:712-733 | mistralrs-core/src/vision_models/llama4/inputs_processor.rs:438-459 | mistralrs-core/src/vision_models/minicpmo/inputs_processor.rs:486-507 | mistralrs-core/src/vision_models/mistral3/inputs_processor.rs:365-386 | mistralrs-core/src/vision_models/mllama/inputs_processor.rs:351-373 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:722-744 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:998-1020 | mistralrs-core/src/vision_models/voxtral/inputs_processor.rs:271-292 — `mistralrs-core/src/vision_models/gemma3/inputs_processor.rs` and `mistralrs-core/src/vision_models/gemma3n/inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 4 separate duplicated blocks between them, totalling at least 75 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:583` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (23 lines × 6) · ×1
  • Duplicated block (23 lines × 6) mistralrs-core/src/models/glm4.rs:500 — mistralrs-core/src/models/glm4.rs:500-522 | mistralrs-core/src/models/hunyuan_v1_dense.rs:465-487 | mistralrs-core/src/models/hunyuan_v1_moe.rs:959-981 | mistralrs-core/src/models/mistral.rs:506-528 | mistralrs-core/src/models/mixtral.rs:461-483 | mistralrs-core/src/models/qwen3.rs:459-481 — before extracting anything, compare `mistralrs-core/src/models/glm4.rs` and `mistralrs-core/src/models/hunyuan_v1_dense.rs` as WHOLE FILES: this scan already matched 43 separate duplicated blocks between them, totalling at least 508 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/glm4.rs:500` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (22–23 lines × 4) · ×1
  • Duplicated block (22–23 lines × 4) mistralrs-core/src/models/flint.rs:252 — mistralrs-core/src/models/flint.rs:252-273 | mistralrs-core/src/models/glm4_moe.rs:195-217 | mistralrs-core/src/models/hunyuan_v1_dense.rs:122-143 | mistralrs-core/src/models/hunyuan_v1_moe.rs:299-320 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/glm4_moe.rs` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 188 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/flint.rs:252` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (21–23 lines × 2) · ×1
  • Duplicated block (21–23 lines × 2) mistralrs-quant/src/cublaslt/api.rs:134 — mistralrs-quant/src/cublaslt/api.rs:134-156 | mistralrs-quant/src/cublaslt/api.rs:404-424 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cublaslt/api.rs:134` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (21–22 lines × 6) · ×1
  • Duplicated block (21–22 lines × 6) mistralrs-core/src/models/glm4.rs:266 — mistralrs-core/src/models/glm4.rs:266-287 | mistralrs-core/src/models/glm4_moe.rs:331-352 | mistralrs-core/src/models/granite.rs:1592-1613 | mistralrs-core/src/vision_models/phi3/mod.rs:297-318 | mistralrs-core/src/vision_models/phi4/mod.rs:166-187 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:251-271 — before extracting anything, compare `mistralrs-core/src/models/glm4.rs` and `mistralrs-core/src/models/glm4_moe.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 359 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/glm4.rs:266` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (22 lines × 4) · ×1
  • Duplicated block (22 lines × 4) mistralrs/src/model_builder_trait.rs:802 — mistralrs/src/model_builder_trait.rs:802-823 | mistralrs/src/model_builder_trait.rs:957-978 | mistralrs/src/model_builder_trait.rs:1130-1151 | mistralrs/src/model_builder_trait.rs:1579-1600 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs/src/model_builder_trait.rs:802` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (20–22 lines × 2) · ×1
  • Duplicated block (20–22 lines × 2) mistralrs-quant/src/cublaslt/api.rs:187 — mistralrs-quant/src/cublaslt/api.rs:187-208 | mistralrs-quant/src/cublaslt/api.rs:429-448 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cublaslt/api.rs:187` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (21 lines × 8) · ×1
  • Duplicated block (21 lines × 8) mistralrs-core/src/vision_models/qwen3_5/mod.rs:233 — mistralrs-core/src/vision_models/qwen3_5/mod.rs:233-253 | mistralrs-core/src/vision_models/qwen3_5/mod.rs:294-314 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:216-236 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:277-297 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:753-773 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:828-848 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:199-219 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:274-294 — `mistralrs-core/src/vision_models/qwen3_5/mod.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 24 separate duplicated blocks between them, totalling at least 425 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_5/mod.rs:233` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (21 lines × 7) · ×1
  • Duplicated block (21 lines × 7) mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:438 — mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:438-458 | mistralrs-core/src/vision_models/qwen2vl/mod.rs:594-614 | mistralrs-core/src/vision_models/qwen3_5/mod.rs:479-499 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:487-507 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:1049-1069 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:493-513 | mistralrs-core/src/vision_models/qwen4_exp/mod.rs:464-484 — `mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs` and `mistralrs-core/src/vision_models/qwen2vl/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 16 separate duplicated blocks between them, totalling at least 396 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen2_5_vl/mod.rs:438` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (21 lines × 4) · ×1
  • Duplicated block (21 lines × 4) mistralrs-core/src/models/deepseek2.rs:750 — mistralrs-core/src/models/deepseek2.rs:750-770 | mistralrs-core/src/models/deepseek3.rs:813-833 | mistralrs-core/src/models/glm4_moe.rs:650-670 | mistralrs-core/src/models/glm4_moe_lite.rs:760-780 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:750` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (27–28 lines × 3) · ×1
  • Duplicated block (27–28 lines × 3) mistralrs-pyo3/src/util.rs:221 — mistralrs-pyo3/src/util.rs:221-248 | mistralrs-pyo3/src/util.rs:276-302 | mistralrs-pyo3/src/util.rs:336-362 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-pyo3/src/util.rs:221` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (20 lines × 6) · ×1
  • Duplicated block (20 lines × 6) mistralrs-core/src/models/mistral.rs:162 — mistralrs-core/src/models/mistral.rs:162-181 | mistralrs-core/src/models/mixtral.rs:108-127 | mistralrs-core/src/models/qwen2.rs:196-215 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:182-201 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:153-172 | mistralrs-core/src/vision_models/qwen2vl/text.rs:154-173 — before extracting anything, compare `mistralrs-core/src/models/mistral.rs` and `mistralrs-core/src/models/mixtral.rs` as WHOLE FILES: this scan already matched 47 separate duplicated blocks between them, totalling at least 619 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/mistral.rs:162` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/models/mistral.rs:184` calls `attention_temperature` and `mistralrs-core/src/models/mixtral.rs:130` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (19–20 lines × 4) · ×1
  • Duplicated block (19–20 lines × 4) mistralrs-core/src/pipeline/multimodal.rs:1161 — mistralrs-core/src/pipeline/multimodal.rs:1161-1179 | mistralrs-core/src/pipeline/multimodal.rs:1269-1288 | mistralrs-core/src/pipeline/normal.rs:1213-1231 | mistralrs-core/src/pipeline/normal.rs:1345-1364 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:1161` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (18–20 lines × 4) · ×1
  • Duplicated block (18–20 lines × 4) mistralrs-core/src/xlora_models/mistral.rs:270 — mistralrs-core/src/xlora_models/mistral.rs:270-287 | mistralrs-core/src/xlora_models/mixtral.rs:183-200 | mistralrs-core/src/xlora_models/phi3.rs:158-175 | mistralrs-core/src/xlora_models/starcoder2.rs:257-276 — before extracting anything, compare `mistralrs-core/src/xlora_models/mistral.rs` and `mistralrs-core/src/xlora_models/mixtral.rs` as WHOLE FILES: this scan already matched 53 separate duplicated blocks between them, totalling at least 787 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/mistral.rs:270` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (15–20 lines × 3) · ×1
  • Duplicated block (15–20 lines × 3) mistralrs-quant/src/blockwise_fp8/mod.rs:1088 — mistralrs-quant/src/blockwise_fp8/mod.rs:1088-1107 | mistralrs-quant/src/pertensor_fp8/mod.rs:651-665 | mistralrs-quant/src/unquantized/mod.rs:431-450 — `mistralrs-quant/src/blockwise_fp8/mod.rs` and `mistralrs-quant/src/pertensor_fp8/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 186 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/blockwise_fp8/mod.rs:1088` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-quant/src/pertensor_fp8/mod.rs:650` calls `dequantize_w` and `mistralrs-quant/src/unquantized/mod.rs:430` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (18–19 lines × 11) · ×1
  • Duplicated block (18–19 lines × 11) mistralrs-core/src/models/gemma.rs:637 — mistralrs-core/src/models/gemma.rs:637-654 | mistralrs-core/src/models/gemma2.rs:754-771 | mistralrs-core/src/models/glm4.rs:756-773 | mistralrs-core/src/models/hunyuan_v1_dense.rs:724-741 | mistralrs-core/src/models/mistral.rs:765-782 | mistralrs-core/src/models/phi3.rs:700-718 | mistralrs-core/src/models/qwen2.rs:768-785 | mistralrs-core/src/models/qwen3.rs:742-759 | mistralrs-core/src/vision_models/gemma3/text.rs:979-996 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:724-741 | mistralrs-core/src/vision_models/phi3/mod.rs:1535-1553 — before extracting anything, compare `mistralrs-core/src/models/gemma.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 707 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma.rs:637` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (18–19 lines × 5) · ×1
  • Duplicated block (18–19 lines × 5) mistralrs-core/src/models/granite.rs:1960 — mistralrs-core/src/models/granite.rs:1960-1977 | mistralrs-core/src/models/llama.rs:358-375 | mistralrs-core/src/models/qwen3_next.rs:750-768 | mistralrs-core/src/models/smollm3.rs:374-391 | mistralrs-core/src/vision_models/llama4/text.rs:807-824 — before extracting anything, compare `mistralrs-core/src/models/granite.rs` and `mistralrs-core/src/models/llama.rs` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 244 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/granite.rs:1960` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (19 lines × 5) · ×1
  • Duplicated block (19 lines × 5) mistralrs-quant/src/hqq/hqq_op.rs:88 — mistralrs-quant/src/hqq/hqq_op.rs:88-106 | mistralrs-quant/src/hqq/hqq_op.rs:199-217 | mistralrs-quant/src/hqq/hqq_op.rs:312-330 | mistralrs-quant/src/hqq/hqq_op.rs:429-447 | mistralrs-quant/src/hqq/hqq_op.rs:548-566 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/hqq/hqq_op.rs:88` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (17–19 lines × 2) · ×1
  • Duplicated block (17–19 lines × 2) mistralrs-core/src/pipeline/multimodal.rs:2621 — mistralrs-core/src/pipeline/multimodal.rs:2621-2639 | mistralrs-core/src/pipeline/normal.rs:2247-2263 — before extracting anything, compare `mistralrs-core/src/pipeline/multimodal.rs` and `mistralrs-core/src/pipeline/normal.rs` as WHOLE FILES: this scan already matched 74 separate duplicated blocks between them, totalling at least 1605 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/multimodal.rs:2621` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (16–19 lines × 2) · ×1
  • Duplicated block (16–19 lines × 2) mistralrs-core/src/vision_models/gemma3n/audio.rs:982 — mistralrs-core/src/vision_models/gemma3n/audio.rs:982-1000 | mistralrs-core/src/vision_models/gemma4/audio.rs:471-486 — `mistralrs-core/src/vision_models/gemma3n/audio.rs` and `mistralrs-core/src/vision_models/gemma4/audio.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 20 separate duplicated blocks between them, totalling at least 352 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3n/audio.rs:982` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (18 lines × 15) · ×1
  • Duplicated block (18 lines × 15) mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:548 — mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:548-565 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1533-1550 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2914-2931 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3268-3285 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3610-3627 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4337-4354 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4747-4764 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5127-5144 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:827-844 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1048-1065 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1271-1288 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2198-2215 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2428-2445 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4478-4495 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5808-5825 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/embedding_loaders.rs` and `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 180 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:548` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (18 lines × 7) · ×1
  • Duplicated block (18 lines × 7) mistralrs-core/src/xlora_models/gemma.rs:235 — mistralrs-core/src/xlora_models/gemma.rs:235-252 | mistralrs-core/src/xlora_models/gemma2.rs:240-257 | mistralrs-core/src/xlora_models/llama.rs:58-75 | mistralrs-core/src/xlora_models/mistral.rs:225-242 | mistralrs-core/src/xlora_models/mixtral.rs:138-155 | mistralrs-core/src/xlora_models/phi2.rs:219-236 | mistralrs-core/src/xlora_models/starcoder2.rs:212-229 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/gemma2.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 498 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (18 lines × 5) · ×1
  • Duplicated block (18 lines × 5) mistralrs-quant/src/metal_kernels/mod.rs:289 — mistralrs-quant/src/metal_kernels/mod.rs:289-306 | mistralrs-quant/src/metal_kernels/mod.rs:328-345 | mistralrs-quant/src/metal_kernels/mod.rs:367-384 | mistralrs-quant/src/metal_kernels/mod.rs:406-423 | mistralrs-quant/src/metal_kernels/mod.rs:445-462 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/metal_kernels/mod.rs:289` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (18 lines × 4) · ×1
  • Duplicated block (18 lines × 4) mistralrs-core/src/vision_models/qwen3_5/mod.rs:74 — mistralrs-core/src/vision_models/qwen3_5/mod.rs:74-91 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:63-80 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:615-632 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:61-78 — `mistralrs-core/src/vision_models/qwen3_5/mod.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 24 separate duplicated blocks between them, totalling at least 425 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:61` calls `validate_text_checkpoint_namespace` and `mistralrs-core/src/vision_models/qwen3_5/mod.rs:72` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (17–18 lines × 4) · ×1
  • Duplicated block (17–18 lines × 4) mistralrs-core/src/xlora_models/gemma2.rs:612 — mistralrs-core/src/xlora_models/gemma2.rs:612-629 | mistralrs-core/src/xlora_models/phi2.rs:547-563 | mistralrs-core/src/xlora_models/phi3.rs:525-541 | mistralrs-core/src/xlora_models/starcoder2.rs:558-574 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma2.rs` and `mistralrs-core/src/xlora_models/phi2.rs` as WHOLE FILES: this scan already matched 22 separate duplicated blocks between them, totalling at least 304 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma2.rs:612` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (7–18 lines × 3) · ×1
  • Duplicated block (7–18 lines × 3) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7834 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7834-7848 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:8356-8373 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6618-6624 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` and `mistralrs-core/src/pipeline/loaders/normal_loaders.rs` as WHOLE FILES: this scan already matched 34 separate duplicated blocks between them, totalling at least 445 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (15–18 lines × 2) · ×1
  • Duplicated block (15–18 lines × 2) mistralrs-core/src/xlora_models/quantized_llama.rs:776 — mistralrs-core/src/xlora_models/quantized_llama.rs:776-790 | mistralrs-core/src/xlora_models/quantized_phi3.rs:438-455 — before extracting anything, compare `mistralrs-core/src/xlora_models/quantized_llama.rs` and `mistralrs-core/src/xlora_models/quantized_phi3.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 219 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/quantized_phi3.rs:438` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (17 lines × 22) · ×1
  • Duplicated block (17 lines × 22) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1064 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1064-1080 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3867-3883 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:781-797 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1225-1241 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1469-1485 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1696-1712 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1916-1932 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2152-2168 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2849-2865 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3145-3161 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3478-3494 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3741-3757 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3953-3969 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4202-4218 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4433-4449 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4705-4721 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5017-5033 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5300-5316 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5762-5778 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6008-6024 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6271-6287 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6560-6576 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` and `mistralrs-core/src/pipeline/loaders/normal_loaders.rs` as WHOLE FILES: this scan already matched 34 separate duplicated blocks between them, totalling at least 445 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1064` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (17 lines × 17) · ×1
  • Duplicated block (17 lines × 17) mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:546 — mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:546-562 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1531-1547 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1838-1854 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2138-2154 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2912-2928 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3266-3282 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3608-3624 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4335-4351 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4745-4761 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5125-5141 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:825-841 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1046-1062 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1269-1285 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2196-2212 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2426-2442 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4476-4492 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5806-5822 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/embedding_loaders.rs` and `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 180 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:546` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (17 lines × 14) · ×1
  • Duplicated block (17 lines × 14) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1528 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1528-1544 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1835-1851 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2135-2151 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2551-2567 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2909-2925 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3263-3279 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3605-3621 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4332-4348 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5122-5138 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:822-838 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1266-1282 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2193-2209 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4473-4489 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5803-5819 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` and `mistralrs-core/src/pipeline/loaders/normal_loaders.rs` as WHOLE FILES: this scan already matched 34 separate duplicated blocks between them, totalling at least 445 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (17 lines × 13) · ×1
  • Duplicated block (17 lines × 13) mistralrs-core/src/models/gemma.rs:587 — mistralrs-core/src/models/gemma.rs:587-603 | mistralrs-core/src/models/gemma2.rs:704-720 | mistralrs-core/src/models/glm4.rs:706-722 | mistralrs-core/src/models/hunyuan_v1_dense.rs:674-690 | mistralrs-core/src/models/mistral.rs:715-731 | mistralrs-core/src/models/phi2.rs:663-679 | mistralrs-core/src/models/phi3.rs:658-674 | mistralrs-core/src/models/qwen2.rs:718-734 | mistralrs-core/src/models/qwen3.rs:692-708 | mistralrs-core/src/models/starcoder2.rs:654-670 | mistralrs-core/src/vision_models/gemma3/text.rs:929-945 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:671-687 | mistralrs-core/src/vision_models/phi3/mod.rs:1494-1510 — before extracting anything, compare `mistralrs-core/src/models/gemma.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 707 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma.rs:587` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/models/phi2.rs:680` calls `dtype_device` and `mistralrs-core/src/vision_models/phi3/mod.rs:1511` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (16–17 lines × 10) · ×1
  • Duplicated block (16–17 lines × 10) mistralrs-core/src/models/glm4.rs:582 — mistralrs-core/src/models/glm4.rs:582-597 | mistralrs-core/src/models/mistral.rs:592-608 | mistralrs-core/src/models/mixtral.rs:530-546 | mistralrs-core/src/models/phi3.rs:538-554 | mistralrs-core/src/models/phi3_5_moe.rs:611-627 | mistralrs-core/src/models/qwen3.rs:545-561 | mistralrs-core/src/models/qwen3_moe.rs:725-741 | mistralrs-core/src/models/starcoder2.rs:532-547 | mistralrs-core/src/vision_models/phi3/mod.rs:1341-1356 | mistralrs-core/src/vision_models/phi4/mod.rs:503-518 — before extracting anything, compare `mistralrs-core/src/models/glm4.rs` and `mistralrs-core/src/models/mistral.rs` as WHOLE FILES: this scan already matched 44 separate duplicated blocks between them, totalling at least 529 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: the declarations holding them bind `ctx` to `&mut ModelForwardContext<'_>` in one and `&mut crate::pipeline::ModelForwardContext<'_>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (15–17 lines × 5) · ×1
  • Duplicated block (15–17 lines × 5) mistralrs-core/src/models/deepseek2.rs:823 — mistralrs-core/src/models/deepseek2.rs:823-837 | mistralrs-core/src/models/deepseek3.rs:886-900 | mistralrs-core/src/models/glm4_moe.rs:723-737 | mistralrs-core/src/models/glm4_moe_lite.rs:833-847 | mistralrs-core/src/vision_models/mllama/text.rs:765-781 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:823` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/vision_models/mllama/text.rs:784` calls `pp` and `mistralrs-core/src/models/deepseek2.rs:839` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (16–17 lines × 5) · ×1
  • Duplicated block (16–17 lines × 5) mistralrs-core/src/vision_models/qwen3_5/mod.rs:406 — mistralrs-core/src/vision_models/qwen3_5/mod.rs:406-422 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:391-407 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:975-990 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:421-436 | mistralrs-core/src/vision_models/qwen4_exp/mod.rs:386-402 — `mistralrs-core/src/vision_models/qwen3_5/mod.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 24 separate duplicated blocks between them, totalling at least 425 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_5/mod.rs:406` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (16–17 lines × 4) · ×1
  • Duplicated block (16–17 lines × 4) mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3036 — mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3036-3051 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3369-3384 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4602-4618 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4919-4935 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3036` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (33–34 lines × 3) · ×1
  • Duplicated block (33–34 lines × 3) mistralrs-core/src/vision_models/grid_processor.rs:1590 — mistralrs-core/src/vision_models/grid_processor.rs:1590-1623 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:779-811 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1344-1376 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:1590` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (13–16 lines × 27) · ×1
  • Duplicated block (13–16 lines × 27) mistralrs-core/src/models/flint.rs:403 — mistralrs-core/src/models/flint.rs:403-415 | mistralrs-core/src/models/gemma2.rs:255-270 | mistralrs-core/src/models/glm4.rs:255-270 | mistralrs-core/src/models/glm4_moe.rs:323-335 | mistralrs-core/src/models/gpt_oss.rs:288-300 | mistralrs-core/src/models/granite.rs:1584-1596 | mistralrs-core/src/models/hunyuan_v1_dense.rs:234-246 | mistralrs-core/src/models/hunyuan_v1_moe.rs:420-432 | mistralrs-core/src/models/llama.rs:116-131 | mistralrs-core/src/models/mistral.rs:256-271 | mistralrs-core/src/models/mixtral.rs:192-207 | mistralrs-core/src/models/phi3_5_moe.rs:222-237 | mistralrs-core/src/models/qwen2.rs:286-301 | mistralrs-core/src/models/qwen3.rs:241-256 | mistralrs-core/src/models/qwen3_moe.rs:244-259 | mistralrs-core/src/models/qwen3_next.rs:328-340 | mistralrs-core/src/models/smollm3.rs:133-148 | mistralrs-core/src/models/starcoder2.rs:268-283 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:90-105 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:259-274 | mistralrs-core/src/vision_models/muse_glimmer/text.rs:283-295 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:250-262 | mistralrs-core/src/vision_models/qwen2vl/text.rs:251-263 | mistralrs-core/src/vision_models/qwen3_5/text.rs:375-387 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:243-255 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:247-262 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:353-365 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 190 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/flint.rs:403` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (15–16 lines × 19) · ×1
  • Duplicated block (15–16 lines × 19) mistralrs-core/src/models/flint.rs:407 — mistralrs-core/src/models/flint.rs:407-421 | mistralrs-core/src/models/gemma.rs:215-229 | mistralrs-core/src/models/gemma2.rs:262-277 | mistralrs-core/src/models/gpt_oss.rs:292-306 | mistralrs-core/src/models/hunyuan_v1_dense.rs:238-252 | mistralrs-core/src/models/hunyuan_v1_moe.rs:424-438 | mistralrs-core/src/models/lfm2.rs:532-546 | mistralrs-core/src/models/lfm3.rs:508-522 | mistralrs-core/src/models/llama.rs:123-137 | mistralrs-core/src/models/mistral.rs:263-277 | mistralrs-core/src/models/mixtral.rs:199-213 | mistralrs-core/src/models/phi2.rs:311-325 | mistralrs-core/src/models/qwen2.rs:293-307 | mistralrs-core/src/models/qwen3.rs:248-262 | mistralrs-core/src/models/qwen3_moe.rs:251-265 | mistralrs-core/src/models/qwen3_next.rs:332-346 | mistralrs-core/src/models/smollm3.rs:140-154 | mistralrs-core/src/models/starcoder2.rs:275-289 | mistralrs-core/src/vision_models/voxtral/mod.rs:175-189 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/gemma.rs` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 152 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/flint.rs:407` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/models/gemma.rs:214` calls `is_none` and `mistralrs-core/src/models/lfm2.rs:531` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (16 lines × 18) · ×1
  • Duplicated block (16 lines × 18) mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:545 — mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:545-560 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1530-1545 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1837-1852 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2137-2152 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2553-2568 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2911-2926 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3265-3280 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3607-3622 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4334-4349 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4744-4759 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5124-5139 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:824-839 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1045-1060 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1268-1283 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2195-2210 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2425-2440 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4475-4490 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5805-5820 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/embedding_loaders.rs` and `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 180 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:545` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (16 lines × 9) · ×1
  • Duplicated block (16 lines × 9) mistralrs-core/src/embedding_models/qwen3_embedding.rs:352 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:352-367 | mistralrs-core/src/models/mixtral.rs:428-443 | mistralrs-core/src/models/qwen2.rs:456-471 | mistralrs-core/src/models/qwen3.rs:425-440 | mistralrs-core/src/models/qwen3_moe.rs:599-614 | mistralrs-core/src/models/starcoder2.rs:426-441 | mistralrs-core/src/xlora_models/mistral.rs:442-457 | mistralrs-core/src/xlora_models/mixtral.rs:572-587 | mistralrs-core/src/xlora_models/starcoder2.rs:431-446 — before extracting anything, compare `mistralrs-core/src/embedding_models/qwen3_embedding.rs` and `mistralrs-core/src/models/mixtral.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 63 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/xlora_models/mistral.rs:439` calls `with_capacity`, `pp` and `mistralrs-core/src/embedding_models/qwen3_embedding.rs:350` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (15–16 lines × 8) · ×1
  • Duplicated block (15–16 lines × 8) mistralrs-core/src/xlora_models/gemma.rs:651 — mistralrs-core/src/xlora_models/gemma.rs:651-666 | mistralrs-core/src/xlora_models/gemma2.rs:702-717 | mistralrs-core/src/xlora_models/llama.rs:477-492 | mistralrs-core/src/xlora_models/mistral.rs:647-662 | mistralrs-core/src/xlora_models/mixtral.rs:777-792 | mistralrs-core/src/xlora_models/phi2.rs:617-632 | mistralrs-core/src/xlora_models/phi3.rs:603-617 | mistralrs-core/src/xlora_models/starcoder2.rs:632-647 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/gemma2.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 498 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma.rs:651` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (33 lines × 6) · ×1
  • Duplicated block (33 lines × 6) mistralrs-core/src/vision_models/grid_processor.rs:965 — mistralrs-core/src/vision_models/grid_processor.rs:965-997 | mistralrs-core/src/vision_models/grid_processor.rs:1274-1306 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:188-220 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:478-510 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:754-786 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1086-1118 — before extracting anything, compare `mistralrs-core/src/vision_models/grid_processor.rs` and `mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs` as WHOLE FILES: this scan already matched 35 separate duplicated blocks between them, totalling at least 780 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/grid_processor.rs:965` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (14–16 lines × 5) · ×1
  • Duplicated block (14–16 lines × 5) mistralrs-core/src/models/deepseek2.rs:563 — mistralrs-core/src/models/deepseek2.rs:563-578 | mistralrs-core/src/models/deepseek3.rs:583-598 | mistralrs-core/src/models/deepseek3.rs:613-628 | mistralrs-core/src/models/glm4_moe.rs:472-485 | mistralrs-core/src/models/glm4_moe_lite.rs:573-588 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (15–16 lines × 5) · ×1
  • Duplicated block (15–16 lines × 5) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2795 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2795-2810 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6773-6788 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7215-7230 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7687-7701 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:8209-8223 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2795` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (14–16 lines × 4) · ×1
  • Duplicated block (14–16 lines × 4) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6738 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6738-6753 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7180-7195 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7655-7668 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:8177-8190 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6738` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (15–16 lines × 3) · ×1
  • Duplicated block (15–16 lines × 3) mistralrs-core/src/embedding_models/qwen3_embedding.rs:479 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:479-493 | mistralrs-core/src/models/qwen3.rs:585-599 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:609-624 — `mistralrs-core/src/embedding_models/qwen3_embedding.rs` and `mistralrs-core/src/models/qwen3.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 26 separate duplicated blocks between them, totalling at least 364 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/qwen3_embedding.rs:479` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (14–16 lines × 3) · ×1
  • Duplicated block (14–16 lines × 3) mistralrs-pyo3/src/lib.rs:1610 — mistralrs-pyo3/src/lib.rs:1610-1625 | mistralrs-pyo3/src/lib.rs:1871-1884 | mistralrs-pyo3/src/lib.rs:2361-2374 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-pyo3/src/lib.rs:1610` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `request` to `Py<ChatCompletionRequest>` in one and `Py<CompletionRequest>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (13–15 lines × 19) · ×1
  • Duplicated block (13–15 lines × 19) mistralrs-core/src/models/gemma.rs:231 — mistralrs-core/src/models/gemma.rs:231-243 | mistralrs-core/src/models/gemma2.rs:279-291 | mistralrs-core/src/models/gpt_oss.rs:308-320 | mistralrs-core/src/models/hunyuan_v1_dense.rs:254-266 | mistralrs-core/src/models/hunyuan_v1_moe.rs:440-452 | mistralrs-core/src/models/llama.rs:139-151 | mistralrs-core/src/models/mistral.rs:279-291 | mistralrs-core/src/models/mixtral.rs:215-227 | mistralrs-core/src/models/phi2.rs:327-341 | mistralrs-core/src/models/phi3.rs:218-230 | mistralrs-core/src/models/phi3_5_moe.rs:245-257 | mistralrs-core/src/models/qwen2.rs:309-321 | mistralrs-core/src/models/qwen3.rs:264-276 | mistralrs-core/src/models/qwen3_moe.rs:267-279 | mistralrs-core/src/models/qwen3_next.rs:347-359 | mistralrs-core/src/models/smollm3.rs:156-168 | mistralrs-core/src/models/starcoder2.rs:291-303 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:114-126 | mistralrs-core/src/vision_models/voxtral/mod.rs:190-202 — before extracting anything, compare `mistralrs-core/src/models/gemma.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 707 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma.rs:231` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (12–15 lines × 18) · ×1
  • Duplicated block (12–15 lines × 18) mistralrs-core/src/models/flint.rs:397 — mistralrs-core/src/models/flint.rs:397-408 | mistralrs-core/src/models/gemma2.rs:249-263 | mistralrs-core/src/models/gpt_oss.rs:282-293 | mistralrs-core/src/models/hunyuan_v1_dense.rs:228-239 | mistralrs-core/src/models/hunyuan_v1_moe.rs:414-425 | mistralrs-core/src/models/llama.rs:110-124 | mistralrs-core/src/models/mistral.rs:250-264 | mistralrs-core/src/models/mixtral.rs:186-200 | mistralrs-core/src/models/phi3.rs:189-203 | mistralrs-core/src/models/phi3_5_moe.rs:216-230 | mistralrs-core/src/models/qwen2.rs:280-294 | mistralrs-core/src/models/qwen3.rs:235-249 | mistralrs-core/src/models/qwen3_moe.rs:238-252 | mistralrs-core/src/models/qwen3_next.rs:322-333 | mistralrs-core/src/models/smollm3.rs:127-141 | mistralrs-core/src/models/starcoder2.rs:262-276 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:84-98 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:253-267 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 190 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/flint.rs:397` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (12–15 lines × 12) · ×1
  • Duplicated block (12–15 lines × 12) mistralrs-core/src/models/glm4.rs:249 — mistralrs-core/src/models/glm4.rs:249-263 | mistralrs-core/src/models/glm4_moe.rs:317-328 | mistralrs-core/src/models/granite.rs:1578-1589 | mistralrs-core/src/vision_models/muse_glimmer/text.rs:277-288 | mistralrs-core/src/vision_models/phi3/mod.rs:280-294 | mistralrs-core/src/vision_models/phi4/mod.rs:149-163 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:244-255 | mistralrs-core/src/vision_models/qwen2vl/text.rs:245-256 | mistralrs-core/src/vision_models/qwen3_5/text.rs:369-380 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:237-248 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:241-255 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:347-358 — before extracting anything, compare `mistralrs-core/src/models/glm4.rs` and `mistralrs-core/src/models/glm4_moe.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 359 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/glm4.rs:249` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (15 lines × 11) · ×1
  • Duplicated block (15 lines × 11) mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:676 — mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:676-690 | mistralrs-core/src/vision_models/gemma3n/inputs_processor.rs:444-458 | mistralrs-core/src/vision_models/idefics2/idefics2_input_processor.rs:656-670 | mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:698-712 | mistralrs-core/src/vision_models/llama4/inputs_processor.rs:599-613 | mistralrs-core/src/vision_models/mistral3/inputs_processor.rs:467-481 | mistralrs-core/src/vision_models/mllama/inputs_processor.rs:649-663 | mistralrs-core/src/vision_models/muse_glimmer/inputs_processor.rs:1088-1102 | mistralrs-core/src/vision_models/qwen2_5_vl/inputs_processor.rs:959-973 | mistralrs-core/src/vision_models/qwen2vl/inputs_processor.rs:1524-1538 | mistralrs-core/src/vision_models/voxtral/inputs_processor.rs:349-363 — `mistralrs-core/src/vision_models/gemma3/inputs_processor.rs` and `mistralrs-core/src/vision_models/gemma3n/inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 4 separate duplicated blocks between them, totalling at least 75 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:676` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/vision_models/voxtral/inputs_processor.rs:348` calls `Some` and `mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:675` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (14–15 lines × 9) · ×1
  • Duplicated block (14–15 lines × 9) mistralrs-paged-attn/src/cuda/backend/mla.rs:132 — mistralrs-paged-attn/src/cuda/backend/mla.rs:132-145 | mistralrs-paged-attn/src/cuda/backend/mla.rs:157-170 | mistralrs-paged-attn/src/cuda/backend/mla.rs:182-195 | mistralrs-paged-attn/src/cuda/backend/mla.rs:454-467 | mistralrs-paged-attn/src/cuda/backend/mla.rs:513-526 | mistralrs-paged-attn/src/cuda/backend/mla.rs:572-585 | mistralrs-paged-attn/src/cuda/backend/mla.rs:770-784 | mistralrs-paged-attn/src/cuda/backend/mla.rs:808-822 | mistralrs-paged-attn/src/cuda/backend/mla.rs:846-860 — all 9 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/cuda/backend/mla.rs:132` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-paged-attn/src/cuda/backend/mla.rs:453` calls `slice_ptr`, `start_offset` and `mistralrs-paged-attn/src/cuda/backend/mla.rs:770` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (14–15 lines × 8) · ×1
  • Duplicated block (14–15 lines × 8) mistralrs-core/src/xlora_models/gemma.rs:666 — mistralrs-core/src/xlora_models/gemma.rs:666-680 | mistralrs-core/src/xlora_models/gemma2.rs:717-731 | mistralrs-core/src/xlora_models/llama.rs:492-506 | mistralrs-core/src/xlora_models/mistral.rs:662-676 | mistralrs-core/src/xlora_models/mixtral.rs:792-806 | mistralrs-core/src/xlora_models/phi2.rs:632-646 | mistralrs-core/src/xlora_models/phi3.rs:619-632 | mistralrs-core/src/xlora_models/starcoder2.rs:647-661 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/gemma2.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 498 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma.rs:666` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (14–15 lines × 6) · ×1
  • Duplicated block (14–15 lines × 6) mistralrs-paged-attn/src/metal/kernels/mod.rs:441 — mistralrs-paged-attn/src/metal/kernels/mod.rs:441-455 | mistralrs-paged-attn/src/metal/kernels/mod.rs:557-571 | mistralrs-paged-attn/src/metal/kernels/mod.rs:582-596 | mistralrs-paged-attn/src/metal/kernels/mod.rs:701-715 | mistralrs-paged-attn/src/metal/kernels/mod.rs:726-740 | mistralrs-paged-attn/src/metal/kernels/mod.rs:831-844 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/metal/kernels/mod.rs:831` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-paged-attn/src/metal/kernels/mod.rs:572` calls `set_input_buffer`, `Some` and `mistralrs-paged-attn/src/metal/kernels/mod.rs:456` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (14–15 lines × 5) · ×1
  • Duplicated block (14–15 lines × 5) mistralrs-core/src/embedding_models/embedding_gemma.rs:112 — mistralrs-core/src/embedding_models/embedding_gemma.rs:112-126 | mistralrs-core/src/models/gemma.rs:92-106 | mistralrs-core/src/models/gemma2.rs:125-139 | mistralrs-core/src/vision_models/gemma3/text.rs:87-100 | mistralrs-core/src/vision_models/gemma3n/text.rs:315-329 — `mistralrs-core/src/embedding_models/embedding_gemma.rs` and `mistralrs-core/src/models/gemma.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 9 separate duplicated blocks between them, totalling at least 133 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/embedding_gemma.rs:112` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (12–15 lines × 4) · ×1
  • Duplicated block (12–15 lines × 4) mistralrs-core/src/models/flint.rs:239 — mistralrs-core/src/models/flint.rs:239-250 | mistralrs-core/src/models/glm4_moe.rs:178-192 | mistralrs-core/src/models/hunyuan_v1_dense.rs:109-120 | mistralrs-core/src/models/hunyuan_v1_moe.rs:286-297 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/glm4_moe.rs` as WHOLE FILES: this scan already matched 18 separate duplicated blocks between them, totalling at least 188 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/glm4_moe.rs:178` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (17–21 lines × 3) · ×1
  • Duplicated block (17–21 lines × 3) mistralrs-core/src/models/quantized_llama.rs:86 — mistralrs-core/src/models/quantized_llama.rs:86-106 | mistralrs-core/src/xlora_models/quantized_llama.rs:214-234 | mistralrs-core/src/xlora_models/quantized_phi3.rs:167-183 — `mistralrs-core/src/models/quantized_llama.rs` and `mistralrs-core/src/xlora_models/quantized_llama.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 4 separate duplicated blocks between them, totalling at least 58 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/quantized_phi3.rs:167` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (14–15 lines × 3) · ×1
  • Duplicated block (14–15 lines × 3) mistralrs-core/src/vision_models/gemma3n/audio_processing.rs:127 — mistralrs-core/src/vision_models/gemma3n/audio_processing.rs:127-141 | mistralrs-core/src/vision_models/gemma4/audio_processing.rs:337-351 | mistralrs-core/src/vision_models/voxtral/audio_processing.rs:91-104 — `mistralrs-core/src/vision_models/gemma3n/audio_processing.rs` and `mistralrs-core/src/vision_models/gemma4/audio_processing.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 43 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (14 lines × 9) · ×1
  • Duplicated block (14 lines × 9) mistralrs-core/src/xlora_models/gemma.rs:661 — mistralrs-core/src/xlora_models/gemma.rs:661-674 | mistralrs-core/src/xlora_models/gemma2.rs:712-725 | mistralrs-core/src/xlora_models/llama.rs:487-500 | mistralrs-core/src/xlora_models/mistral.rs:657-670 | mistralrs-core/src/xlora_models/mixtral.rs:787-800 | mistralrs-core/src/xlora_models/phi2.rs:627-640 | mistralrs-core/src/xlora_models/quantized_llama.rs:877-890 | mistralrs-core/src/xlora_models/quantized_phi3.rs:542-555 | mistralrs-core/src/xlora_models/starcoder2.rs:642-655 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/gemma2.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 498 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma.rs:661` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (13–14 lines × 6) · ×1
  • Duplicated block (13–14 lines × 6) mistralrs-core/src/embedding_models/qwen3_embedding.rs:477 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:477-489 | mistralrs-core/src/models/flint.rs:989-1001 | mistralrs-core/src/models/qwen3.rs:583-595 | mistralrs-core/src/models/qwen3_moe.rs:764-776 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:607-620 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:728-741 — before extracting anything, compare `mistralrs-core/src/embedding_models/qwen3_embedding.rs` and `mistralrs-core/src/models/flint.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 68 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/models/qwen3_moe.rs:777` calls `Moe`, `pp`, `add` and `mistralrs-core/src/embedding_models/qwen3_embedding.rs:490` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (13–14 lines × 4) · ×1
  • Duplicated block (13–14 lines × 4) mistralrs-core/src/models/mixtral.rs:420 — mistralrs-core/src/models/mixtral.rs:420-432 | mistralrs-core/src/models/qwen2.rs:447-460 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:412-425 | mistralrs-core/src/vision_models/qwen2vl/text.rs:413-426 — before extracting anything, compare `mistralrs-core/src/models/mixtral.rs` and `mistralrs-core/src/models/qwen2.rs` as WHOLE FILES: this scan already matched 46 separate duplicated blocks between them, totalling at least 556 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/mixtral.rs:420` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (4–14 lines × 6) · ×1
  • Duplicated block (4–14 lines × 6) mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:156 — mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:156-166 | mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:168-180 | mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:186-199 | mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:373-376 | mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:655-658 | mistralrs-paged-attn/src/cuda/backend/gather_kv.rs:202-205 — before extracting anything, compare `mistralrs-paged-attn/src/cuda/backend/flashinfer.rs` and `mistralrs-paged-attn/src/cuda/backend/gather_kv.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 39 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:156` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:167` calls `slice_ptr`, `start_offset` and `mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:186` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (13 lines × 25) · ×1
  • Duplicated block (13 lines × 25) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2830 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2830-2842 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4254-4266 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4653-4665 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5050-5062 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5461-5473 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:787-799 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1231-1243 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1475-1487 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1702-1714 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1922-1934 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2158-2170 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2855-2867 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3151-3163 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3484-3496 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3747-3759 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3959-3971 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4208-4220 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4439-4451 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4711-4723 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5023-5035 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5306-5318 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5768-5780 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6014-6026 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6277-6289 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:6566-6578 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` and `mistralrs-core/src/pipeline/loaders/normal_loaders.rs` as WHOLE FILES: this scan already matched 34 separate duplicated blocks between them, totalling at least 445 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2830` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (15 lines × 14) · ×1
  • Duplicated block (15 lines × 14) mistralrs-core/src/models/gemma.rs:662 — mistralrs-core/src/models/gemma.rs:662-676 | mistralrs-core/src/models/gemma2.rs:779-793 | mistralrs-core/src/models/glm4.rs:781-795 | mistralrs-core/src/models/hunyuan_v1_dense.rs:749-763 | mistralrs-core/src/models/mistral.rs:790-804 | mistralrs-core/src/models/phi2.rs:730-744 | mistralrs-core/src/models/phi3.rs:725-739 | mistralrs-core/src/models/qwen2.rs:793-807 | mistralrs-core/src/models/qwen3.rs:767-781 | mistralrs-core/src/models/starcoder2.rs:721-735 | mistralrs-core/src/vision_models/gemma3/text.rs:1004-1018 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:749-763 | mistralrs-core/src/vision_models/muse_glimmer/text.rs:755-769 | mistralrs-core/src/vision_models/phi3/mod.rs:1560-1574 — before extracting anything, compare `mistralrs-core/src/models/gemma.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 707 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma.rs:662` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (13 lines × 13) · ×1
  • Duplicated block (13 lines × 13) mistralrs-core/src/models/flint.rs:779 — mistralrs-core/src/models/flint.rs:779-791 | mistralrs-core/src/models/glm4.rs:441-453 | mistralrs-core/src/models/granite.rs:1949-1961 | mistralrs-core/src/models/hunyuan_v1_dense.rs:410-422 | mistralrs-core/src/models/hunyuan_v1_moe.rs:904-916 | mistralrs-core/src/models/lfm2.rs:1018-1030 | mistralrs-core/src/models/lfm3.rs:917-929 | mistralrs-core/src/models/llama.rs:347-359 | mistralrs-core/src/models/mistral.rs:416-428 | mistralrs-core/src/models/qwen3.rs:404-416 | mistralrs-core/src/models/qwen3_moe.rs:578-590 | mistralrs-core/src/models/smollm3.rs:363-375 | mistralrs-core/src/vision_models/llama4/text.rs:796-808 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/glm4.rs` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 240 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/flint.rs:779` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (12–13 lines × 13) · ×1
  • Duplicated block (12–13 lines × 13) mistralrs-core/src/models/glm4.rs:587 — mistralrs-core/src/models/glm4.rs:587-598 | mistralrs-core/src/models/mistral.rs:597-609 | mistralrs-core/src/models/mixtral.rs:535-547 | mistralrs-core/src/models/phi3.rs:543-555 | mistralrs-core/src/models/phi3_5_moe.rs:616-628 | mistralrs-core/src/models/qwen2.rs:589-600 | mistralrs-core/src/models/qwen3.rs:550-562 | mistralrs-core/src/models/qwen3_moe.rs:730-742 | mistralrs-core/src/models/starcoder2.rs:537-548 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:549-560 | mistralrs-core/src/vision_models/phi3/mod.rs:1346-1357 | mistralrs-core/src/vision_models/phi4/mod.rs:508-519 | mistralrs-core/src/vision_models/voxtral/mod.rs:884-896 — before extracting anything, compare `mistralrs-core/src/models/glm4.rs` and `mistralrs-core/src/models/mistral.rs` as WHOLE FILES: this scan already matched 44 separate duplicated blocks between them, totalling at least 529 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/glm4.rs:587` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note first that the copies are not typed on the same thing: the declarations holding them bind `ctx` to `&mut ModelForwardContext<'_>` in one and `&mut crate::pipeline::ModelForwardContext<'_>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (10–13 lines × 11) · ×1
  • Duplicated block (10–13 lines × 11) mistralrs-core/src/models/deepseek2.rs:863 — mistralrs-core/src/models/deepseek2.rs:863-875 | mistralrs-core/src/models/deepseek3.rs:926-938 | mistralrs-core/src/models/gemma.rs:379-390 | mistralrs-core/src/models/gemma2.rs:452-463 | mistralrs-core/src/models/glm4_moe.rs:762-774 | mistralrs-core/src/models/glm4_moe_lite.rs:873-885 | mistralrs-core/src/models/mistral.rs:489-498 | mistralrs-core/src/models/mixtral.rs:442-453 | mistralrs-core/src/models/phi2.rs:469-480 | mistralrs-core/src/models/phi3.rs:457-468 | mistralrs-core/src/models/phi3_5_moe.rs:526-537 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:863` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (13 lines × 9) · ×1
  • Duplicated block (13 lines × 9) mistralrs-core/src/models/gemma.rs:400 — mistralrs-core/src/models/gemma.rs:400-412 | mistralrs-core/src/models/gemma2.rs:473-485 | mistralrs-core/src/models/glm4.rs:502-514 | mistralrs-core/src/models/hunyuan_v1_dense.rs:467-479 | mistralrs-core/src/models/hunyuan_v1_moe.rs:961-973 | mistralrs-core/src/models/mistral.rs:508-520 | mistralrs-core/src/models/mixtral.rs:463-475 | mistralrs-core/src/models/qwen3.rs:461-473 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:445-457 — before extracting anything, compare `mistralrs-core/src/models/gemma.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 707 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma.rs:400` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (13 lines × 8) · ×1
  • Duplicated block (13 lines × 8) mistralrs-core/src/models/gemma.rs:136 — mistralrs-core/src/models/gemma.rs:136-148 | mistralrs-core/src/models/glm4.rs:177-189 | mistralrs-core/src/models/gpt_oss.rs:216-228 | mistralrs-core/src/models/mixtral.rs:120-132 | mistralrs-core/src/models/qwen2.rs:208-220 | mistralrs-core/src/models/starcoder2.rs:196-208 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:165-177 | mistralrs-core/src/vision_models/qwen2vl/text.rs:166-178 — before extracting anything, compare `mistralrs-core/src/models/gemma.rs` and `mistralrs-core/src/models/glm4.rs` as WHOLE FILES: this scan already matched 24 separate duplicated blocks between them, totalling at least 269 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma.rs:136` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (25 lines × 4) · ×1
  • Duplicated block (25 lines × 4) mistralrs-core/src/vision_models/phi3/mod.rs:594 — mistralrs-core/src/vision_models/phi3/mod.rs:594-618 | mistralrs-core/src/vision_models/phi3/mod.rs:626-650 | mistralrs-core/src/vision_models/phi4/image_embedding.rs:217-241 | mistralrs-core/src/vision_models/phi4/image_embedding.rs:249-273 — before extracting anything, compare `mistralrs-core/src/vision_models/phi3/mod.rs` and `mistralrs-core/src/vision_models/phi4/image_embedding.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 98 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/phi3/mod.rs:594` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (12–13 lines × 4) · ×1
  • Duplicated block (12–13 lines × 4) mistralrs-core/src/xlora_models/gemma.rs:286 — mistralrs-core/src/xlora_models/gemma.rs:286-298 | mistralrs-core/src/xlora_models/mistral.rs:283-294 | mistralrs-core/src/xlora_models/mixtral.rs:196-207 | mistralrs-core/src/xlora_models/phi3.rs:171-182 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/mistral.rs` as WHOLE FILES: this scan already matched 37 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma.rs:286` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (11–13 lines × 4) · ×1
  • Duplicated block (11–13 lines × 4) mistralrs/src/model_builder_trait.rs:789 — mistralrs/src/model_builder_trait.rs:789-800 | mistralrs/src/model_builder_trait.rs:942-954 | mistralrs/src/model_builder_trait.rs:1401-1411 | mistralrs/src/model_builder_trait.rs:1566-1577 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs/src/model_builder_trait.rs:789` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (9–13 lines × 3) · ×1
  • Duplicated block (9–13 lines × 3) mistralrs-cli/src/commands/bench.rs:119 — mistralrs-cli/src/commands/bench.rs:119-127 | mistralrs-cli/src/commands/run/mod.rs:55-63 | mistralrs-cli/src/commands/serve.rs:62-74 — before extracting anything, compare `mistralrs-cli/src/commands/run/mod.rs` and `mistralrs-cli/src/commands/serve.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 49 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (4–13 lines × 3) · ×1
  • Duplicated block (4–13 lines × 3) mistralrs-core/src/attention/backends/cpu/full.rs:212 — mistralrs-core/src/attention/backends/cpu/full.rs:212-224 | mistralrs-core/src/attention/backends/cpu/full.rs:469-481 | mistralrs-core/src/attention/backends/cpu/full.rs:587-590 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (8–13 lines × 2) · ×1
  • Duplicated block (8–13 lines × 2) mistralrs-core/src/utils/tiktoken.rs:123 — mistralrs-core/src/utils/tiktoken.rs:123-135 | mistralrs-core/src/utils/tokenizer.rs:121-128 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/utils/tiktoken.rs:123` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (10–13 lines × 2) · ×1
  • Duplicated block (10–13 lines × 2) mistralrs-core/src/vision_models/llama4/vision.rs:567 — mistralrs-core/src/vision_models/llama4/vision.rs:567-576 | mistralrs-core/src/vision_models/mllama/vision.rs:507-519 — `mistralrs-core/src/vision_models/llama4/vision.rs` and `mistralrs-core/src/vision_models/mllama/vision.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 6 separate duplicated blocks between them, totalling at least 67 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/mllama/vision.rs:507` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (9–13 lines × 2) · ×1
  • Duplicated block (9–13 lines × 2) mistralrs-quant/src/unquantized/mod.rs:185 — mistralrs-quant/src/unquantized/mod.rs:185-197 | mistralrs-quant/src/unquantized/mod.rs:234-242 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/unquantized/mod.rs:185` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (12 lines × 28) · ×1
  • Duplicated block (12 lines × 28) mistralrs-core/src/models/flint.rs:403 — mistralrs-core/src/models/flint.rs:403-414 | mistralrs-core/src/models/gemma2.rs:255-269 | mistralrs-core/src/models/glm4.rs:255-269 | mistralrs-core/src/models/glm4_moe.rs:323-334 | mistralrs-core/src/models/gpt_oss.rs:288-299 | mistralrs-core/src/models/granite.rs:1584-1595 | mistralrs-core/src/models/hunyuan_v1_dense.rs:234-245 | mistralrs-core/src/models/hunyuan_v1_moe.rs:420-431 | mistralrs-core/src/models/llama.rs:116-130 | mistralrs-core/src/models/mistral.rs:256-270 | mistralrs-core/src/models/mixtral.rs:192-206 | mistralrs-core/src/models/phi3_5_moe.rs:222-236 | mistralrs-core/src/models/qwen2.rs:286-300 | mistralrs-core/src/models/qwen3.rs:241-255 | mistralrs-core/src/models/qwen3_moe.rs:244-258 | mistralrs-core/src/models/qwen3_next.rs:328-339 | mistralrs-core/src/models/smollm3.rs:133-147 | mistralrs-core/src/models/starcoder2.rs:268-282 | mistralrs-core/src/vision_models/llama4/text.rs:488-502 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:90-104 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:259-273 | mistralrs-core/src/vision_models/muse_glimmer/text.rs:283-294 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:250-261 | mistralrs-core/src/vision_models/qwen2vl/text.rs:251-262 | mistralrs-core/src/vision_models/qwen3_5/text.rs:375-386 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:243-254 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:247-261 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:353-364 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 190 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/flint.rs:403` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (12 lines × 23) · ×1
  • Duplicated block (12 lines × 23) mistralrs-core/src/models/flint.rs:393 — mistralrs-core/src/models/flint.rs:393-404 | mistralrs-core/src/models/gemma.rs:198-209 | mistralrs-core/src/models/gemma2.rs:245-256 | mistralrs-core/src/models/gpt_oss.rs:278-289 | mistralrs-core/src/models/hunyuan_v1_dense.rs:224-235 | mistralrs-core/src/models/hunyuan_v1_moe.rs:410-421 | mistralrs-core/src/models/lfm2.rs:519-530 | mistralrs-core/src/models/lfm3.rs:495-506 | mistralrs-core/src/models/llama.rs:106-117 | mistralrs-core/src/models/mistral.rs:246-257 | mistralrs-core/src/models/mixtral.rs:182-193 | mistralrs-core/src/models/phi2.rs:294-305 | mistralrs-core/src/models/phi3_5_moe.rs:212-223 | mistralrs-core/src/models/qwen2.rs:276-287 | mistralrs-core/src/models/qwen3.rs:231-242 | mistralrs-core/src/models/qwen3_moe.rs:234-245 | mistralrs-core/src/models/qwen3_next.rs:318-329 | mistralrs-core/src/models/smollm3.rs:123-134 | mistralrs-core/src/models/starcoder2.rs:258-269 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:80-91 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:249-260 | mistralrs-core/src/vision_models/mllama/text.rs:194-205 | mistralrs-core/src/vision_models/voxtral/mod.rs:159-170 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/gemma.rs` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 152 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/flint.rs:393` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/models/gemma.rs:214` calls `is_none` and `mistralrs-core/src/models/lfm2.rs:532` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (10–12 lines × 18) · ×1
  • Duplicated block (10–12 lines × 18) mistralrs-core/src/models/flint.rs:389 — mistralrs-core/src/models/flint.rs:389-399 | mistralrs-core/src/models/gemma.rs:194-204 | mistralrs-core/src/models/gpt_oss.rs:275-284 | mistralrs-core/src/models/hunyuan_v1_dense.rs:220-230 | mistralrs-core/src/models/hunyuan_v1_moe.rs:406-416 | mistralrs-core/src/models/llama.rs:102-112 | mistralrs-core/src/models/mistral.rs:242-252 | mistralrs-core/src/models/mixtral.rs:178-188 | mistralrs-core/src/models/phi2.rs:290-300 | mistralrs-core/src/models/phi3_5_moe.rs:208-218 | mistralrs-core/src/models/qwen3.rs:227-237 | mistralrs-core/src/models/qwen3_moe.rs:230-240 | mistralrs-core/src/models/qwen3_next.rs:313-324 | mistralrs-core/src/models/smollm3.rs:119-129 | mistralrs-core/src/models/starcoder2.rs:254-264 | mistralrs-core/src/vision_models/gemma3/text.rs:245-254 | mistralrs-core/src/vision_models/mllama/text.rs:191-200 | mistralrs-core/src/vision_models/voxtral/mod.rs:156-165 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/gemma.rs` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 152 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/flint.rs:389` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/models/hunyuan_v1_dense.rs:218` calls `forward` and `mistralrs-core/src/models/gemma.rs:193` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (12 lines × 13) · ×1
  • Duplicated block (12 lines × 13) mistralrs-core/src/models/deepseek2.rs:827 — mistralrs-core/src/models/deepseek2.rs:827-838 | mistralrs-core/src/models/deepseek3.rs:890-901 | mistralrs-core/src/models/glm4_moe.rs:727-738 | mistralrs-core/src/models/glm4_moe_lite.rs:837-848 | mistralrs-core/src/models/mixtral.rs:480-491 | mistralrs-core/src/models/qwen2.rs:511-522 | mistralrs-core/src/vision_models/gemma3/text.rs:530-542 | mistralrs-core/src/vision_models/gemma3n/text.rs:1473-1485 | mistralrs-core/src/vision_models/mllama/text.rs:770-782 | mistralrs-core/src/vision_models/phi3/mod.rs:1274-1285 | mistralrs-core/src/vision_models/phi4/mod.rs:389-400 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:475-486 | mistralrs-core/src/vision_models/qwen2vl/text.rs:477-488 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:827` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/vision_models/mllama/text.rs:784` calls `pp` and `mistralrs-core/src/models/deepseek2.rs:839` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (10–12 lines × 13) · ×1
  • Duplicated block (10–12 lines × 13) mistralrs-core/src/models/glm4.rs:590 — mistralrs-core/src/models/glm4.rs:590-599 | mistralrs-core/src/models/hunyuan_v1_dense.rs:552-561 | mistralrs-core/src/models/hunyuan_v1_moe.rs:1046-1055 | mistralrs-core/src/models/mistral.rs:600-610 | mistralrs-core/src/models/mixtral.rs:538-548 | mistralrs-core/src/models/phi3.rs:546-557 | mistralrs-core/src/models/phi3_5_moe.rs:619-630 | mistralrs-core/src/models/qwen3.rs:553-563 | mistralrs-core/src/models/qwen3_moe.rs:733-743 | mistralrs-core/src/models/starcoder2.rs:540-550 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:552-561 | mistralrs-core/src/vision_models/phi3/mod.rs:1349-1359 | mistralrs-core/src/vision_models/phi4/mod.rs:511-521 — before extracting anything, compare `mistralrs-core/src/models/glm4.rs` and `mistralrs-core/src/models/hunyuan_v1_dense.rs` as WHOLE FILES: this scan already matched 43 separate duplicated blocks between them, totalling at least 508 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/glm4.rs:590` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `ctx` to `&mut ModelForwardContext<'_>` in one and `&mut crate::pipeline::ModelForwardContext<'_>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (12 lines × 10) · ×1
  • Duplicated block (12 lines × 10) mistralrs-core/src/models/deepseek2.rs:955 — mistralrs-core/src/models/deepseek2.rs:955-967 | mistralrs-core/src/models/deepseek3.rs:1018-1030 | mistralrs-core/src/models/gemma.rs:468-480 | mistralrs-core/src/models/gemma2.rs:544-556 | mistralrs-core/src/models/glm4_moe.rs:834-845 | mistralrs-core/src/models/glm4_moe_lite.rs:971-982 | mistralrs-core/src/models/llama.rs:494-506 | mistralrs-core/src/models/phi2.rs:547-559 | mistralrs-core/src/models/qwen2.rs:574-585 | mistralrs-core/src/models/smollm3.rs:513-525 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: the declarations holding them bind `ctx` to `&mut ModelForwardContext<'_>` in one and `&mut crate::pipeline::ModelForwardContext<'_>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (12 lines × 9) · ×1
  • Duplicated block (12 lines × 9) mistralrs-core/src/models/deepseek2.rs:725 — mistralrs-core/src/models/deepseek2.rs:725-736 | mistralrs-core/src/models/deepseek3.rs:788-799 | mistralrs-core/src/models/glm4_moe.rs:625-636 | mistralrs-core/src/models/glm4_moe_lite.rs:734-745 | mistralrs-core/src/models/mixtral.rs:339-350 | mistralrs-core/src/xlora_models/llama.rs:357-368 | mistralrs-core/src/xlora_models/mistral.rs:337-348 | mistralrs-core/src/xlora_models/mixtral.rs:464-475 | mistralrs-core/src/xlora_models/phi3.rs:302-313 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:725` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/models/deepseek2.rs:722` calls `pp` and `mistralrs-core/src/xlora_models/llama.rs:354` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (11–12 lines × 8) · ×1
  • Duplicated block (11–12 lines × 8) mistralrs-quant/src/metal_kernels/mod.rs:524 — mistralrs-quant/src/metal_kernels/mod.rs:524-535 | mistralrs-quant/src/metal_kernels/mod.rs:570-581 | mistralrs-quant/src/metal_kernels/mod.rs:616-627 | mistralrs-quant/src/metal_kernels/mod.rs:3266-3277 | mistralrs-quant/src/metal_kernels/mod.rs:3389-3399 | mistralrs-quant/src/metal_kernels/mod.rs:3453-3463 | mistralrs-quant/src/metal_kernels/mod.rs:3517-3527 | mistralrs-quant/src/metal_kernels/mod.rs:3582-3592 — all 8 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/metal_kernels/mod.rs:524` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (12 lines × 7) · ×1
  • Duplicated block (12 lines × 7) mistralrs-core/src/embedding_models/qwen3_embedding.rs:249 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:249-260 | mistralrs-core/src/models/glm4.rs:335-346 | mistralrs-core/src/models/llama.rs:283-294 | mistralrs-core/src/models/mistral.rs:330-341 | mistralrs-core/src/models/qwen2.rs:362-373 | mistralrs-core/src/models/qwen3.rs:318-329 | mistralrs-core/src/models/smollm3.rs:299-310 — before extracting anything, compare `mistralrs-core/src/embedding_models/qwen3_embedding.rs` and `mistralrs-core/src/models/glm4.rs` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 137 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/qwen3_embedding.rs:249` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (10–13 lines × 5) · ×1
  • Duplicated block (10–13 lines × 5) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4299 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4299-4308 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6869-6881 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7311-7323 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7779-7791 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:8301-8313 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4299` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (16–18 lines × 4) · ×1
  • Duplicated block (16–18 lines × 4) mistralrs-core/src/models/granite.rs:1544 — mistralrs-core/src/models/granite.rs:1544-1559 | mistralrs-core/src/models/llama.rs:81-98 | mistralrs-core/src/models/smollm3.rs:96-111 | mistralrs-core/src/xlora_models/llama.rs:77-94 — before extracting anything, compare `mistralrs-core/src/models/granite.rs` and `mistralrs-core/src/models/llama.rs` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 244 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/granite.rs:1544` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/models/granite.rs:1561` calls `Some` and `mistralrs-core/src/models/llama.rs:98` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (11–12 lines × 3) · ×1
  • Duplicated block (11–12 lines × 3) mistralrs-quant/src/cutile/fp8_gemm.rs:353 — mistralrs-quant/src/cutile/fp8_gemm.rs:353-364 | mistralrs-quant/src/cutile/fp8_w8a8.rs:537-548 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:921-931 — before extracting anything, compare `mistralrs-quant/src/cutile/fp8_gemm.rs` and `mistralrs-quant/src/cutile/fp8_w8a8.rs` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 88 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cutile/fp8_gemm.rs:353` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (9–12 lines × 3) · ×1
  • Duplicated block (9–12 lines × 3) mistralrs-quant/src/distributed/layers.rs:461 — mistralrs-quant/src/distributed/layers.rs:461-472 | mistralrs-quant/src/distributed/layers.rs:835-846 | mistralrs-quant/src/distributed/layers.rs:1641-1649 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/distributed/layers.rs:461` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (10–12 lines × 2) · ×1
  • Duplicated block (10–12 lines × 2) mistralrs-core/src/pipeline/mod.rs:2369 — mistralrs-core/src/pipeline/mod.rs:2369-2378 | mistralrs-core/src/pipeline/mod.rs:2950-2961 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/mod.rs:2369` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (9–11 lines × 31) · ×1
  • Duplicated block (9–11 lines × 31) mistralrs-core/src/models/flint.rs:442 — mistralrs-core/src/models/flint.rs:442-450 | mistralrs-core/src/models/gemma.rs:237-245 | mistralrs-core/src/models/gemma2.rs:285-293 | mistralrs-core/src/models/glm4.rs:284-292 | mistralrs-core/src/models/glm4_moe.rs:349-357 | mistralrs-core/src/models/gpt_oss.rs:314-322 | mistralrs-core/src/models/granite.rs:1610-1618 | mistralrs-core/src/models/hunyuan_v1_dense.rs:260-268 | mistralrs-core/src/models/hunyuan_v1_moe.rs:446-454 | mistralrs-core/src/models/llama.rs:145-153 | mistralrs-core/src/models/mistral.rs:285-293 | mistralrs-core/src/models/mixtral.rs:221-229 | mistralrs-core/src/models/phi2.rs:333-343 | mistralrs-core/src/models/phi3.rs:224-232 | mistralrs-core/src/models/phi3_5_moe.rs:251-259 | mistralrs-core/src/models/qwen2.rs:315-323 | mistralrs-core/src/models/qwen3.rs:270-278 | mistralrs-core/src/models/qwen3_moe.rs:273-281 | mistralrs-core/src/models/qwen3_next.rs:353-361 | mistralrs-core/src/models/smollm3.rs:162-170 | mistralrs-core/src/models/starcoder2.rs:297-305 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:120-128 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:294-302 | mistralrs-core/src/vision_models/muse_glimmer/text.rs:308-318 | mistralrs-core/src/vision_models/phi3/mod.rs:315-323 | mistralrs-core/src/vision_models/phi4/mod.rs:184-192 | mistralrs-core/src/vision_models/qwen3_5/text.rs:403-411 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:268-276 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:275-283 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:378-386 | mistralrs-core/src/vision_models/voxtral/mod.rs:196-204 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/gemma.rs` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 152 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/flint.rs:442` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:280` calls `sigmoid`, `to_dtype`, `dtype` and `mistralrs-core/src/models/flint.rs:452` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (10–11 lines × 25) · ×1
  • Duplicated block (10–11 lines × 25) mistralrs-core/src/embedding_models/qwen3_embedding.rs:255 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:255-264 | mistralrs-core/src/models/flint.rs:716-725 | mistralrs-core/src/models/gpt_oss.rs:657-667 | mistralrs-core/src/models/granite.rs:1485-1494 | mistralrs-core/src/models/granite.rs:1771-1780 | mistralrs-core/src/models/hunyuan_v1_dense.rs:315-324 | mistralrs-core/src/models/hunyuan_v1_moe.rs:805-814 | mistralrs-core/src/models/llama.rs:289-298 | mistralrs-core/src/models/mistral.rs:336-345 | mistralrs-core/src/models/mixtral.rs:345-354 | mistralrs-core/src/models/phi3.rs:349-358 | mistralrs-core/src/models/qwen2.rs:368-377 | mistralrs-core/src/models/qwen3.rs:324-333 | mistralrs-core/src/models/qwen3_moe.rs:498-507 | mistralrs-core/src/models/smollm3.rs:305-314 | mistralrs-core/src/vision_models/llama4/text.rs:694-703 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:360-369 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:342-351 | mistralrs-core/src/vision_models/phi3/mod.rs:440-449 | mistralrs-core/src/vision_models/phi4/mod.rs:269-279 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:447-456 | mistralrs-core/src/xlora_models/llama.rs:363-372 | mistralrs-core/src/xlora_models/mistral.rs:343-352 | mistralrs-core/src/xlora_models/mixtral.rs:470-479 | mistralrs-core/src/xlora_models/phi3.rs:308-317 — before extracting anything, compare `mistralrs-core/src/embedding_models/qwen3_embedding.rs` and `mistralrs-core/src/models/flint.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 68 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/qwen3_embedding.rs:255` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/models/phi3.rs:346` calls `set_device`, `pp` and `mistralrs-core/src/embedding_models/qwen3_embedding.rs:252` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (11 lines × 22) · ×1
  • Duplicated block (11 lines × 22) mistralrs-core/src/embedding_models/embedding_gemma.rs:433 — mistralrs-core/src/embedding_models/embedding_gemma.rs:433-443 | mistralrs-core/src/models/deepseek2.rs:869-879 | mistralrs-core/src/models/deepseek3.rs:932-942 | mistralrs-core/src/models/gemma.rs:384-394 | mistralrs-core/src/models/gemma2.rs:457-467 | mistralrs-core/src/models/glm4_moe.rs:768-778 | mistralrs-core/src/models/glm4_moe_lite.rs:879-889 | mistralrs-core/src/models/llama.rs:413-423 | mistralrs-core/src/models/mistral.rs:492-502 | mistralrs-core/src/models/mixtral.rs:447-457 | mistralrs-core/src/models/phi2.rs:474-484 | mistralrs-core/src/models/phi3.rs:462-472 | mistralrs-core/src/models/phi3_5_moe.rs:531-541 | mistralrs-core/src/models/starcoder2.rs:445-455 | mistralrs-core/src/vision_models/gemma3/text.rs:492-502 | mistralrs-core/src/vision_models/phi3/mod.rs:1243-1253 | mistralrs-core/src/vision_models/phi4/mod.rs:358-368 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:439-449 | mistralrs-core/src/vision_models/qwen2vl/text.rs:441-451 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:429-439 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:549-559 | mistralrs-core/src/vision_models/voxtral/mod.rs:661-671 — before extracting anything, compare `mistralrs-core/src/embedding_models/embedding_gemma.rs` and `mistralrs-core/src/models/deepseek2.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 31 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/embedding_gemma.rs:433` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/embedding_models/embedding_gemma.rs:430` calls `pp` and `mistralrs-core/src/vision_models/phi3/mod.rs:1240` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (10–11 lines × 22) · ×1
  • Duplicated block (10–11 lines × 22) mistralrs-quant/src/metal_kernels/mod.rs:286 — mistralrs-quant/src/metal_kernels/mod.rs:286-296 | mistralrs-quant/src/metal_kernels/mod.rs:325-335 | mistralrs-quant/src/metal_kernels/mod.rs:364-374 | mistralrs-quant/src/metal_kernels/mod.rs:403-413 | mistralrs-quant/src/metal_kernels/mod.rs:442-452 | mistralrs-quant/src/metal_kernels/mod.rs:695-705 | mistralrs-quant/src/metal_kernels/mod.rs:742-752 | mistralrs-quant/src/metal_kernels/mod.rs:789-799 | mistralrs-quant/src/metal_kernels/mod.rs:2027-2037 | mistralrs-quant/src/metal_kernels/mod.rs:3260-3270 | mistralrs-quant/src/metal_kernels/mod.rs:3383-3392 | mistralrs-quant/src/metal_kernels/mod.rs:3447-3456 | mistralrs-quant/src/metal_kernels/mod.rs:3511-3520 | mistralrs-quant/src/metal_kernels/mod.rs:3576-3585 | mistralrs-quant/src/metal_kernels/mod.rs:3638-3648 | mistralrs-quant/src/metal_kernels/mod.rs:4082-4092 | mistralrs-quant/src/metal_kernels/mod.rs:4117-4127 | mistralrs-quant/src/metal_kernels/mod.rs:4154-4164 | mistralrs-quant/src/metal_kernels/mod.rs:4528-4537 | mistralrs-quant/src/metal_kernels/mod.rs:4590-4599 | mistralrs-quant/src/metal_kernels/mod.rs:4969-4978 | mistralrs-quant/src/metal_kernels/mod.rs:5011-5020 — all 22 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/metal_kernels/mod.rs:286` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-quant/src/metal_kernels/mod.rs:4541` calls `is_some` and `mistralrs-quant/src/metal_kernels/mod.rs:4601` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (11 lines × 14) · ×1
  • Duplicated block (11 lines × 14) mistralrs-core/src/models/flint.rs:778 — mistralrs-core/src/models/flint.rs:778-788 | mistralrs-core/src/models/glm4.rs:440-450 | mistralrs-core/src/models/granite.rs:1948-1958 | mistralrs-core/src/models/hunyuan_v1_dense.rs:409-419 | mistralrs-core/src/models/hunyuan_v1_moe.rs:903-913 | mistralrs-core/src/models/lfm2.rs:1017-1027 | mistralrs-core/src/models/lfm3.rs:916-926 | mistralrs-core/src/models/llama.rs:346-356 | mistralrs-core/src/models/mistral.rs:415-425 | mistralrs-core/src/models/qwen3.rs:403-413 | mistralrs-core/src/models/qwen3_moe.rs:577-587 | mistralrs-core/src/models/smollm3.rs:362-372 | mistralrs-core/src/vision_models/llama4/text.rs:795-805 | mistralrs-core/src/vision_models/mllama/text.rs:749-759 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/glm4.rs` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 240 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/flint.rs:778` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/models/flint.rs:775` calls `validate`, `pp` and `mistralrs-core/src/models/glm4.rs:439` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (11 lines × 10) · ×1
  • Duplicated block (11 lines × 10) mistralrs-core/src/models/deepseek2.rs:726 — mistralrs-core/src/models/deepseek2.rs:726-736 | mistralrs-core/src/models/deepseek3.rs:789-799 | mistralrs-core/src/models/glm4_moe.rs:626-636 | mistralrs-core/src/models/glm4_moe_lite.rs:735-745 | mistralrs-core/src/models/mixtral.rs:340-350 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:355-365 | mistralrs-core/src/xlora_models/llama.rs:358-368 | mistralrs-core/src/xlora_models/mistral.rs:338-348 | mistralrs-core/src/xlora_models/mixtral.rs:465-475 | mistralrs-core/src/xlora_models/phi3.rs:303-313 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:726` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:353` calls `load`, `set_device`, `pp` and `mistralrs-core/src/models/deepseek2.rs:725` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (10–11 lines × 9) · ×1
  • Duplicated block (10–11 lines × 9) mistralrs-core/src/models/gemma.rs:347 — mistralrs-core/src/models/gemma.rs:347-357 | mistralrs-core/src/models/gemma2.rs:420-430 | mistralrs-core/src/models/mixtral.rs:406-415 | mistralrs-core/src/models/phi2.rs:431-440 | mistralrs-core/src/models/phi3.rs:408-417 | mistralrs-core/src/models/phi3_5_moe.rs:480-489 | mistralrs-core/src/models/qwen2.rs:433-442 | mistralrs-core/src/models/starcoder2.rs:405-414 | mistralrs-core/src/vision_models/gemma3/text.rs:433-443 — before extracting anything, compare `mistralrs-core/src/models/gemma.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 707 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/vision_models/gemma3/text.rs:444` calls `sqrt` and `mistralrs-core/src/models/mixtral.rs:417` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (11 lines × 8) · ×1
  • Duplicated block (11 lines × 8) mistralrs-quant/src/cutile/fp8_gemm.rs:356 — mistralrs-quant/src/cutile/fp8_gemm.rs:356-366 | mistralrs-quant/src/cutile/fp8_w8a8.rs:540-550 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:923-933 | mistralrs-quant/src/cutile/nvfp4_gemv.rs:325-335 | mistralrs-quant/src/cutile/nvfp4_matmul.rs:652-662 | mistralrs-quant/src/cutile/nvfp4_matmul.rs:1154-1164 | mistralrs-quant/src/nvfp4/decode.rs:126-136 | mistralrs-quant/src/nvfp4/portable.rs:315-325 — before extracting anything, compare `mistralrs-quant/src/cutile/fp8_gemm.rs` and `mistralrs-quant/src/cutile/fp8_w8a8.rs` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 88 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cutile/fp8_gemm.rs:356` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (11 lines × 7) · ×1
  • Duplicated block (11 lines × 7) mistralrs-core/src/embedding_models/qwen3_embedding.rs:348 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:348-358 | mistralrs-core/src/models/glm4.rs:458-468 | mistralrs-core/src/models/glm4_moe.rs:743-753 | mistralrs-core/src/models/hunyuan_v1_dense.rs:427-437 | mistralrs-core/src/models/hunyuan_v1_moe.rs:921-931 | mistralrs-core/src/models/qwen3.rs:421-431 | mistralrs-core/src/models/qwen3_moe.rs:595-605 — before extracting anything, compare `mistralrs-core/src/embedding_models/qwen3_embedding.rs` and `mistralrs-core/src/models/glm4.rs` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 137 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/qwen3_embedding.rs:348` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (9–11 lines × 5) · ×1
  • Duplicated block (9–11 lines × 5) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2758 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2758-2768 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6735-6745 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7177-7187 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7653-7661 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:8175-8183 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2758` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (11 lines × 5) · ×1
  • Duplicated block (11 lines × 5) mistralrs-core/src/xlora_models/gemma.rs:485 — mistralrs-core/src/xlora_models/gemma.rs:485-495 | mistralrs-core/src/xlora_models/gemma2.rs:515-525 | mistralrs-core/src/xlora_models/mistral.rs:481-491 | mistralrs-core/src/xlora_models/mixtral.rs:612-622 | mistralrs-core/src/xlora_models/phi2.rs:467-477 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/gemma2.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 498 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma.rs:485` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (15–24 lines × 4) · ×1
  • Duplicated block (15–24 lines × 4) mistralrs-core/src/layers.rs:936 — mistralrs-core/src/layers.rs:936-950 | mistralrs-core/src/layers.rs:953-975 | mistralrs-core/src/layers.rs:2259-2273 | mistralrs-core/src/layers.rs:2276-2299 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/layers.rs:953` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. Note first that the copies are not typed on the same thing: the declarations holding them bind `cfg` to `&PhiRopeConfig` in one and `&Phi4MMConfig` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (8–11 lines × 2) · ×1
  • Duplicated block (8–11 lines × 2) mistralrs-core/src/attention/backends/cpu/full.rs:436 — mistralrs-core/src/attention/backends/cpu/full.rs:436-443 | mistralrs-core/src/attention/backends/cpu/single_q.rs:201-211 — before extracting anything, compare `mistralrs-core/src/attention/backends/cpu/full.rs` and `mistralrs-core/src/attention/backends/cpu/single_q.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 44 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/attention/backends/cpu/full.rs:436` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (6–11 lines × 2) · ×1
  • Duplicated block (6–11 lines × 2) mistralrs-core/src/models/qwen3_next.rs:607 — mistralrs-core/src/models/qwen3_next.rs:607-612 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:437-447 — before extracting anything, compare `mistralrs-core/src/models/qwen3_next.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/text.rs` as WHOLE FILES: this scan already matched 30 separate duplicated blocks between them, totalling at least 461 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:437` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (2–11 lines × 3) · ×1
  • Duplicated block (2–11 lines × 3) mistralrs-core/src/vision_models/clip.rs:137 — mistralrs-core/src/vision_models/clip.rs:137-138 | mistralrs-core/src/vision_models/idefics3/vision.rs:250-260 | mistralrs-core/src/vision_models/siglip.rs:254-264 — before extracting anything, compare `mistralrs-core/src/vision_models/idefics3/vision.rs` and `mistralrs-core/src/vision_models/siglip.rs` as WHOLE FILES: this scan already matched 19 separate duplicated blocks between them, totalling at least 276 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/idefics3/vision.rs:250` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (2–11 lines × 4) · ×1
  • Duplicated block (2–11 lines × 4) mistralrs-quant/src/cutile/fused_moe.rs:98 — mistralrs-quant/src/cutile/fused_moe.rs:98-99 | mistralrs-quant/src/cutile/fused_moe.rs:105-115 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:111-112 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:118-128 — before extracting anything, compare `mistralrs-quant/src/cutile/fused_moe.rs` and `mistralrs-quant/src/cutile/fused_moe_fp8.rs` as WHOLE FILES: this scan already matched 24 separate duplicated blocks between them, totalling at least 298 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (10 lines × 33) · ×1
  • Duplicated block (10 lines × 33) mistralrs-core/src/embedding_models/qwen3_embedding.rs:253 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:253-262 | mistralrs-core/src/models/deepseek2.rs:729-738 | mistralrs-core/src/models/deepseek3.rs:792-801 | mistralrs-core/src/models/flint.rs:714-723 | mistralrs-core/src/models/glm4.rs:339-348 | mistralrs-core/src/models/glm4_moe.rs:629-638 | mistralrs-core/src/models/glm4_moe_lite.rs:738-747 | mistralrs-core/src/models/gpt_oss.rs:655-664 | mistralrs-core/src/models/granite.rs:1483-1492 | mistralrs-core/src/models/granite.rs:1769-1778 | mistralrs-core/src/models/hunyuan_v1_dense.rs:313-322 | mistralrs-core/src/models/hunyuan_v1_moe.rs:803-812 | mistralrs-core/src/models/llama.rs:287-296 | mistralrs-core/src/models/mistral.rs:334-343 | mistralrs-core/src/models/mixtral.rs:343-352 | mistralrs-core/src/models/phi3.rs:347-356 | mistralrs-core/src/models/qwen2.rs:366-375 | mistralrs-core/src/models/qwen3.rs:322-331 | mistralrs-core/src/models/qwen3_moe.rs:496-505 | mistralrs-core/src/models/smollm3.rs:303-312 | mistralrs-core/src/vision_models/gemma4/text.rs:990-999 | mistralrs-core/src/vision_models/llama4/text.rs:692-701 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:358-367 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:340-349 | mistralrs-core/src/vision_models/mllama/text.rs:284-293 | mistralrs-core/src/vision_models/mllama/text.rs:643-652 | mistralrs-core/src/vision_models/phi3/mod.rs:438-447 | mistralrs-core/src/vision_models/phi4/mod.rs:267-276 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:445-454 | mistralrs-core/src/xlora_models/llama.rs:361-370 | mistralrs-core/src/xlora_models/mistral.rs:341-350 | mistralrs-core/src/xlora_models/mixtral.rs:468-477 | mistralrs-core/src/xlora_models/phi3.rs:306-315 — before extracting anything, compare `mistralrs-core/src/embedding_models/qwen3_embedding.rs` and `mistralrs-core/src/models/deepseek2.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 35 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/models/phi3.rs:346` calls `set_device`, `pp` and `mistralrs-core/src/embedding_models/qwen3_embedding.rs:252` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (10 lines × 32) · ×1
  • Duplicated block (10 lines × 32) mistralrs-core/src/models/flint.rs:392 — mistralrs-core/src/models/flint.rs:392-401 | mistralrs-core/src/models/gemma.rs:197-206 | mistralrs-core/src/models/gemma2.rs:244-253 | mistralrs-core/src/models/glm4.rs:244-253 | mistralrs-core/src/models/glm4_moe.rs:312-321 | mistralrs-core/src/models/gpt_oss.rs:277-286 | mistralrs-core/src/models/granite.rs:1573-1582 | mistralrs-core/src/models/hunyuan_v1_dense.rs:223-232 | mistralrs-core/src/models/hunyuan_v1_moe.rs:409-418 | mistralrs-core/src/models/lfm2.rs:518-527 | mistralrs-core/src/models/lfm3.rs:494-503 | mistralrs-core/src/models/llama.rs:105-114 | mistralrs-core/src/models/mistral.rs:245-254 | mistralrs-core/src/models/mixtral.rs:181-190 | mistralrs-core/src/models/phi2.rs:293-302 | mistralrs-core/src/models/phi3_5_moe.rs:211-220 | mistralrs-core/src/models/qwen2.rs:275-284 | mistralrs-core/src/models/qwen3.rs:230-239 | mistralrs-core/src/models/qwen3_moe.rs:233-242 | mistralrs-core/src/models/qwen3_next.rs:317-326 | mistralrs-core/src/models/smollm3.rs:122-131 | mistralrs-core/src/models/starcoder2.rs:257-266 | mistralrs-core/src/vision_models/gemma3/text.rs:247-256 | mistralrs-core/src/vision_models/mllama/text.rs:193-202 | mistralrs-core/src/vision_models/muse_glimmer/text.rs:272-281 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:239-248 | mistralrs-core/src/vision_models/qwen2vl/text.rs:240-249 | mistralrs-core/src/vision_models/qwen3_5/text.rs:364-373 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:232-241 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:236-245 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:342-351 | mistralrs-core/src/vision_models/voxtral/mod.rs:158-167 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/gemma.rs` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 152 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/flint.rs:392` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/models/granite.rs:1571` calls `flash_params` and `mistralrs-core/src/models/flint.rs:389` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (10 lines × 23) · ×1
  • Duplicated block (10 lines × 23) mistralrs-core/src/embedding_models/embedding_gemma.rs:434 — mistralrs-core/src/embedding_models/embedding_gemma.rs:434-443 | mistralrs-core/src/models/deepseek2.rs:870-879 | mistralrs-core/src/models/deepseek3.rs:933-942 | mistralrs-core/src/models/gemma.rs:385-394 | mistralrs-core/src/models/gemma2.rs:458-467 | mistralrs-core/src/models/glm4_moe.rs:769-778 | mistralrs-core/src/models/glm4_moe_lite.rs:880-889 | mistralrs-core/src/models/llama.rs:414-423 | mistralrs-core/src/models/mistral.rs:493-502 | mistralrs-core/src/models/mixtral.rs:448-457 | mistralrs-core/src/models/phi2.rs:475-484 | mistralrs-core/src/models/phi3.rs:463-472 | mistralrs-core/src/models/phi3_5_moe.rs:532-541 | mistralrs-core/src/models/starcoder2.rs:446-455 | mistralrs-core/src/vision_models/gemma3/text.rs:493-502 | mistralrs-core/src/vision_models/llama4/text.rs:849-858 | mistralrs-core/src/vision_models/phi3/mod.rs:1244-1253 | mistralrs-core/src/vision_models/phi4/mod.rs:359-368 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:440-449 | mistralrs-core/src/vision_models/qwen2vl/text.rs:442-451 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:430-439 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:550-559 | mistralrs-core/src/vision_models/voxtral/mod.rs:662-671 — before extracting anything, compare `mistralrs-core/src/embedding_models/embedding_gemma.rs` and `mistralrs-core/src/models/deepseek2.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 31 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/embedding_gemma.rs:434` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (10 lines × 16) · ×1
  • Duplicated block (10 lines × 16) mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:436 — mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:436-447 | mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:639-650 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1277-1288 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1658-1669 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1966-1977 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2689-2700 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4117-4128 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4490-4501 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4895-4906 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:711-722 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:937-948 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1158-1169 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2310-2321 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3668-3679 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3889-3898 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5695-5706 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/embedding_loaders.rs` and `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 180 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:436` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (10 lines × 14) · ×1
  • Duplicated block (10 lines × 14) mistralrs-core/src/models/flint.rs:849 — mistralrs-core/src/models/flint.rs:849-858 | mistralrs-core/src/models/glm4.rs:516-525 | mistralrs-core/src/models/hunyuan_v1_dense.rs:481-490 | mistralrs-core/src/models/hunyuan_v1_moe.rs:975-984 | mistralrs-core/src/models/mistral.rs:522-531 | mistralrs-core/src/models/mixtral.rs:477-486 | mistralrs-core/src/models/qwen2.rs:508-517 | mistralrs-core/src/models/qwen3.rs:475-484 | mistralrs-core/src/models/qwen3_moe.rs:655-664 | mistralrs-core/src/vision_models/gemma3/text.rs:527-537 | mistralrs-core/src/vision_models/phi3/mod.rs:1271-1280 | mistralrs-core/src/vision_models/phi4/mod.rs:386-395 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:472-481 | mistralrs-core/src/vision_models/qwen2vl/text.rs:474-483 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/glm4.rs` as WHOLE FILES: this scan already matched 23 separate duplicated blocks between them, totalling at least 240 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/flint.rs:849` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (10 lines × 10) · ×1
  • Duplicated block (10 lines × 10) mistralrs-quant/src/cutile/fused_moe.rs:82 — mistralrs-quant/src/cutile/fused_moe.rs:82-91 | mistralrs-quant/src/cutile/fused_moe.rs:123-132 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:96-105 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:135-144 | mistralrs-quant/src/cutile/gdn_prefill.rs:269-278 | mistralrs-quant/src/cutile/qsa.rs:100-109 | mistralrs-quant/src/cutile/qsa.rs:306-315 | mistralrs-quant/src/cutile/qsa.rs:363-372 | mistralrs-quant/src/cutile/qsa_decode.rs:95-104 | mistralrs-quant/src/cutile/qsa_decode.rs:173-182 — before extracting anything, compare `mistralrs-quant/src/cutile/fused_moe.rs` and `mistralrs-quant/src/cutile/fused_moe_fp8.rs` as WHOLE FILES: this scan already matched 24 separate duplicated blocks between them, totalling at least 298 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cutile/fused_moe.rs:82` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-quant/src/cutile/gdn_prefill.rs:266` calls `broadcast_scalar`, `offset_tile` and `mistralrs-quant/src/cutile/fused_moe.rs:80` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (9–10 lines × 9) · ×1
  • Duplicated block (9–10 lines × 9) mistralrs-core/src/models/deepseek2.rs:951 — mistralrs-core/src/models/deepseek2.rs:951-959 | mistralrs-core/src/models/deepseek3.rs:1014-1022 | mistralrs-core/src/models/glm4_moe.rs:830-838 | mistralrs-core/src/models/glm4_moe_lite.rs:967-975 | mistralrs-core/src/models/mixtral.rs:527-535 | mistralrs-core/src/models/phi2.rs:543-551 | mistralrs-core/src/models/phi3.rs:535-543 | mistralrs-core/src/models/phi3_5_moe.rs:608-616 | mistralrs-core/src/models/starcoder2.rs:528-537 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:951` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `ctx` to `&mut ModelForwardContext<'_>` in one and `&mut crate::pipeline::ModelForwardContext<'_>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (10 lines × 8) · ×1
  • Duplicated block (10 lines × 8) mistralrs-core/src/embedding_models/embedding_gemma.rs:430 — mistralrs-core/src/embedding_models/embedding_gemma.rs:430-439 | mistralrs-core/src/models/qwen3_next.rs:817-826 | mistralrs-core/src/vision_models/gemma3/text.rs:489-498 | mistralrs-core/src/vision_models/gemma4/text.rs:1715-1724 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:444-453 | mistralrs-core/src/vision_models/muse_glimmer/text.rs:472-481 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:426-435 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:546-555 — before extracting anything, compare `mistralrs-core/src/embedding_models/embedding_gemma.rs` and `mistralrs-core/src/vision_models/gemma3/text.rs` as WHOLE FILES: this scan already matched 17 separate duplicated blocks between them, totalling at least 286 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/embedding_gemma.rs:430` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (9–10 lines × 7) · ×1
  • Duplicated block (9–10 lines × 7) mistralrs-core/src/models/deepseek2.rs:960 — mistralrs-core/src/models/deepseek2.rs:960-969 | mistralrs-core/src/models/deepseek3.rs:1023-1032 | mistralrs-core/src/models/gemma.rs:473-482 | mistralrs-core/src/models/glm4_moe.rs:839-847 | mistralrs-core/src/models/glm4_moe_lite.rs:976-984 | mistralrs-core/src/models/granite.rs:2254-2263 | mistralrs-core/src/models/phi2.rs:552-561 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:960` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note first that the copies are not typed on the same thing: the declarations holding them bind `ctx` to `&mut ModelForwardContext<'_>` in one and `&mut crate::pipeline::ModelForwardContext<'_>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (9–10 lines × 6) · ×1
  • Duplicated block (9–10 lines × 6) mistralrs-core/src/models/gpt_oss.rs:517 — mistralrs-core/src/models/gpt_oss.rs:517-526 | mistralrs-core/src/models/lfm2.rs:330-338 | mistralrs-core/src/models/qwen3_moe.rs:403-411 | mistralrs-core/src/models/qwen3_next.rs:474-482 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:378-386 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:142-150 — before extracting anything, compare `mistralrs-core/src/models/gpt_oss.rs` and `mistralrs-core/src/models/lfm2.rs` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 111 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gpt_oss.rs:517` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (10 lines × 6) · ×1
  • Duplicated block (10 lines × 6) mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:737 — mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:737-746 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2906-2915 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4329-4338 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2190-2199 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3778-3787 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4470-4479 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/embedding_loaders.rs` and `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 180 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:748` calls `head_dim` and `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2917` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (9–10 lines × 4) · ×1
  • Duplicated block (9–10 lines × 4) mistralrs-core/src/models/deepseek2.rs:480 — mistralrs-core/src/models/deepseek2.rs:480-489 | mistralrs-core/src/models/deepseek3.rs:481-490 | mistralrs-core/src/models/glm4_moe_lite.rs:445-454 | mistralrs-core/src/vision_models/llama4/text.rs:520-528 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:480` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (8–10 lines × 4) · ×1
  • Duplicated block (8–10 lines × 4) mistralrs-core/src/models/phi3.rs:170 — mistralrs-core/src/models/phi3.rs:170-179 | mistralrs-core/src/models/phi3_5_moe.rs:197-206 | mistralrs-core/src/vision_models/phi3/mod.rs:262-269 | mistralrs-core/src/vision_models/phi4/mod.rs:131-138 — before extracting anything, compare `mistralrs-core/src/models/phi3.rs` and `mistralrs-core/src/models/phi3_5_moe.rs` as WHOLE FILES: this scan already matched 28 separate duplicated blocks between them, totalling at least 343 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/phi3.rs:170` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (8–10 lines × 3) · ×1
  • Duplicated block (8–10 lines × 3) mistralrs-code-exec/src/lib.rs:463 — mistralrs-code-exec/src/lib.rs:463-471 | mistralrs-code-exec/src/shell.rs:193-202 | mistralrs-code-exec/src/shell.rs:257-264 — before extracting anything, compare `mistralrs-code-exec/src/lib.rs` and `mistralrs-code-exec/src/shell.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 64 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-code-exec/src/lib.rs:463` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (9–10 lines × 3) · ×1
  • Duplicated block (9–10 lines × 3) mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:839 — mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:839-847 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:571-580 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:692-701 — `mistralrs-core/src/vision_models/qwen3_5_moe/text.rs` and `mistralrs-core/src/vision_models/qwen3_vl/text.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 18 separate duplicated blocks between them, totalling at least 207 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:839` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (7–10 lines × 2) · ×1
  • Duplicated block (7–10 lines × 2) mistralrs-core/src/models/phi3_5_moe.rs:317 — mistralrs-core/src/models/phi3_5_moe.rs:317-323 | mistralrs-core/src/models/phi3_5_moe.rs:342-351 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (8–10 lines × 2) · ×1
  • Duplicated block (8–10 lines × 2) mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:398 — mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:398-405 | mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1740-1749 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (47 lines × 2) · ×1
  • Duplicated block (47 lines × 2) mistralrs-quant/src/cutile/nvfp4_gemv.rs:86 — mistralrs-quant/src/cutile/nvfp4_gemv.rs:86-132 | mistralrs-quant/src/cutile/nvfp4_gemv.rs:190-236 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cutile/nvfp4_gemv.rs:86` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (9 lines × 27) · ×1
  • Duplicated block (9 lines × 27) mistralrs-core/src/models/deepseek2.rs:873 — mistralrs-core/src/models/deepseek2.rs:873-881 | mistralrs-core/src/models/deepseek3.rs:936-944 | mistralrs-core/src/models/gemma.rs:388-396 | mistralrs-core/src/models/gemma2.rs:461-469 | mistralrs-core/src/models/glm4.rs:490-498 | mistralrs-core/src/models/glm4_moe.rs:772-780 | mistralrs-core/src/models/glm4_moe_lite.rs:883-891 | mistralrs-core/src/models/hunyuan_v1_dense.rs:455-463 | mistralrs-core/src/models/hunyuan_v1_moe.rs:949-957 | mistralrs-core/src/models/llama.rs:417-425 | mistralrs-core/src/models/mistral.rs:496-504 | mistralrs-core/src/models/mixtral.rs:451-459 | mistralrs-core/src/models/phi2.rs:478-486 | mistralrs-core/src/models/phi3.rs:466-474 | mistralrs-core/src/models/phi3_5_moe.rs:535-543 | mistralrs-core/src/models/qwen2.rs:481-489 | mistralrs-core/src/models/qwen3.rs:449-457 | mistralrs-core/src/models/qwen3_moe.rs:625-633 | mistralrs-core/src/models/starcoder2.rs:449-457 | mistralrs-core/src/vision_models/llama4/text.rs:852-860 | mistralrs-core/src/vision_models/phi3/mod.rs:1247-1255 | mistralrs-core/src/vision_models/phi4/mod.rs:362-370 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:443-451 | mistralrs-core/src/vision_models/qwen2vl/text.rs:445-453 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:433-441 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:553-561 | mistralrs-core/src/vision_models/voxtral/mod.rs:665-673 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:873` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (8–9 lines × 21) · ×1
  • Duplicated block (8–9 lines × 21) mistralrs-core/src/models/deepseek2.rs:963 — mistralrs-core/src/models/deepseek2.rs:963-970 | mistralrs-core/src/models/deepseek3.rs:1026-1033 | mistralrs-core/src/models/gemma.rs:476-483 | mistralrs-core/src/models/glm4.rs:593-600 | mistralrs-core/src/models/glm4_moe.rs:841-848 | mistralrs-core/src/models/glm4_moe_lite.rs:978-985 | mistralrs-core/src/models/granite.rs:2256-2264 | mistralrs-core/src/models/hunyuan_v1_dense.rs:555-562 | mistralrs-core/src/models/hunyuan_v1_moe.rs:1049-1056 | mistralrs-core/src/models/mistral.rs:604-611 | mistralrs-core/src/models/mixtral.rs:542-549 | mistralrs-core/src/models/phi2.rs:555-562 | mistralrs-core/src/models/phi3.rs:550-558 | mistralrs-core/src/models/phi3_5_moe.rs:623-631 | mistralrs-core/src/models/qwen3.rs:557-564 | mistralrs-core/src/models/qwen3_moe.rs:737-744 | mistralrs-core/src/models/qwen3_next.rs:1047-1055 | mistralrs-core/src/models/starcoder2.rs:543-551 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:555-562 | mistralrs-core/src/vision_models/phi3/mod.rs:1352-1360 | mistralrs-core/src/vision_models/phi4/mod.rs:514-522 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:963` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `ctx` to `&mut ModelForwardContext<'_>` in one and `&mut crate::pipeline::ModelForwardContext<'_>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (9 lines × 16) · ×1
  • Duplicated block (9 lines × 16) mistralrs-core/src/models/gemma.rs:590 — mistralrs-core/src/models/gemma.rs:590-598 | mistralrs-core/src/models/gemma2.rs:707-715 | mistralrs-core/src/models/glm4.rs:709-717 | mistralrs-core/src/models/hunyuan_v1_dense.rs:677-685 | mistralrs-core/src/models/llama.rs:617-625 | mistralrs-core/src/models/mistral.rs:718-726 | mistralrs-core/src/models/phi2.rs:666-674 | mistralrs-core/src/models/phi3.rs:661-669 | mistralrs-core/src/models/qwen2.rs:721-729 | mistralrs-core/src/models/qwen3.rs:695-703 | mistralrs-core/src/models/smollm3.rs:636-644 | mistralrs-core/src/models/starcoder2.rs:657-665 | mistralrs-core/src/vision_models/gemma3/text.rs:932-940 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:630-638 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:674-682 | mistralrs-core/src/vision_models/phi3/mod.rs:1497-1505 — before extracting anything, compare `mistralrs-core/src/models/gemma.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 707 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma.rs:590` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (9 lines × 15) · ×1
  • Duplicated block (9 lines × 15) mistralrs-core/src/embedding_models/qwen3_embedding.rs:351 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:351-359 | mistralrs-core/src/models/gemma.rs:364-372 | mistralrs-core/src/models/gemma2.rs:437-445 | mistralrs-core/src/models/glm4.rs:461-469 | mistralrs-core/src/models/glm4_moe.rs:746-754 | mistralrs-core/src/models/mixtral.rs:427-435 | mistralrs-core/src/models/qwen2.rs:455-463 | mistralrs-core/src/models/qwen3.rs:424-432 | mistralrs-core/src/models/qwen3_moe.rs:598-606 | mistralrs-core/src/models/starcoder2.rs:425-433 | mistralrs-core/src/xlora_models/gemma.rs:444-452 | mistralrs-core/src/xlora_models/gemma2.rs:475-483 | mistralrs-core/src/xlora_models/mistral.rs:441-449 | mistralrs-core/src/xlora_models/mixtral.rs:571-579 | mistralrs-core/src/xlora_models/starcoder2.rs:430-438 — before extracting anything, compare `mistralrs-core/src/embedding_models/qwen3_embedding.rs` and `mistralrs-core/src/models/glm4.rs` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 137 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/qwen3_embedding.rs:351` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/embedding_models/qwen3_embedding.rs:350` calls `head_dim` and `mistralrs-core/src/models/gemma.rs:363` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (9 lines × 14) · ×1
  • Duplicated block (9 lines × 14) mistralrs-quant/src/cutile/fused_moe.rs:81 — mistralrs-quant/src/cutile/fused_moe.rs:81-89 | mistralrs-quant/src/cutile/fused_moe.rs:122-130 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:95-103 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:134-142 | mistralrs-quant/src/cutile/gdn_prefill.rs:268-276 | mistralrs-quant/src/cutile/qsa.rs:66-74 | mistralrs-quant/src/cutile/qsa.rs:77-85 | mistralrs-quant/src/cutile/qsa.rs:88-96 | mistralrs-quant/src/cutile/qsa.rs:99-107 | mistralrs-quant/src/cutile/qsa.rs:294-302 | mistralrs-quant/src/cutile/qsa.rs:305-313 | mistralrs-quant/src/cutile/qsa.rs:362-370 | mistralrs-quant/src/cutile/qsa_decode.rs:94-102 | mistralrs-quant/src/cutile/qsa_decode.rs:172-180 — before extracting anything, compare `mistralrs-quant/src/cutile/fused_moe.rs` and `mistralrs-quant/src/cutile/fused_moe_fp8.rs` as WHOLE FILES: this scan already matched 24 separate duplicated blocks between them, totalling at least 298 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-quant/src/cutile/gdn_prefill.rs:266` calls `broadcast_scalar`, `offset_tile` and `mistralrs-quant/src/cutile/fused_moe.rs:80` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (9 lines × 13) · ×1
  • Duplicated block (9 lines × 13) mistralrs-quant/src/cutile/fused_moe.rs:122 — mistralrs-quant/src/cutile/fused_moe.rs:122-130 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:134-142 | mistralrs-quant/src/cutile/gdn_prefill.rs:268-276 | mistralrs-quant/src/cutile/qsa.rs:66-74 | mistralrs-quant/src/cutile/qsa.rs:77-85 | mistralrs-quant/src/cutile/qsa.rs:88-96 | mistralrs-quant/src/cutile/qsa.rs:99-107 | mistralrs-quant/src/cutile/qsa.rs:294-302 | mistralrs-quant/src/cutile/qsa.rs:305-313 | mistralrs-quant/src/cutile/qsa.rs:362-370 | mistralrs-quant/src/cutile/qsa_decode.rs:94-102 | mistralrs-quant/src/cutile/qsa_decode.rs:172-180 | mistralrs-quant/src/cutile/routed_lora.rs:172-180 — before extracting anything, compare `mistralrs-quant/src/cutile/fused_moe.rs` and `mistralrs-quant/src/cutile/fused_moe_fp8.rs` as WHOLE FILES: this scan already matched 24 separate duplicated blocks between them, totalling at least 298 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (8–9 lines × 9) · ×1
  • Duplicated block (8–9 lines × 9) mistralrs-core/src/models/deepseek2.rs:817 — mistralrs-core/src/models/deepseek2.rs:817-825 | mistralrs-core/src/models/deepseek3.rs:880-888 | mistralrs-core/src/models/glm4_moe.rs:717-725 | mistralrs-core/src/models/glm4_moe_lite.rs:827-835 | mistralrs-core/src/models/gpt_oss.rs:722-730 | mistralrs-core/src/models/mixtral.rs:415-423 | mistralrs-core/src/models/phi3.rs:417-425 | mistralrs-core/src/models/qwen2.rs:442-450 | mistralrs-core/src/vision_models/gemma3n/text.rs:1338-1345 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:817` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (10 lines × 9) · ×1
  • Duplicated block (10 lines × 9) mistralrs-core/src/xlora_models/gemma.rs:268 — mistralrs-core/src/xlora_models/gemma.rs:268-277 | mistralrs-core/src/xlora_models/gemma2.rs:273-282 | mistralrs-core/src/xlora_models/llama.rs:91-100 | mistralrs-core/src/xlora_models/mistral.rs:258-267 | mistralrs-core/src/xlora_models/mixtral.rs:171-180 | mistralrs-core/src/xlora_models/phi2.rs:261-270 | mistralrs-core/src/xlora_models/phi3.rs:146-155 | mistralrs-core/src/xlora_models/quantized_phi3.rs:184-193 | mistralrs-core/src/xlora_models/starcoder2.rs:245-254 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/gemma2.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 498 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma.rs:268` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (9 lines × 8) · ×1
  • Duplicated block (9 lines × 8) mistralrs-paged-attn/src/cuda/backend/fa3.rs:495 — mistralrs-paged-attn/src/cuda/backend/fa3.rs:495-503 | mistralrs-quant/src/cutile/fp8_gemm.rs:351-359 | mistralrs-quant/src/cutile/fp8_w8a8.rs:535-543 | mistralrs-quant/src/cutile/gdn_prefill.rs:712-720 | mistralrs-quant/src/cutile/nvfp4_gemv.rs:330-338 | mistralrs-quant/src/cutile/nvfp4_matmul.rs:657-665 | mistralrs-quant/src/cutile/nvfp4_matmul.rs:1159-1167 | mistralrs-quant/src/nvfp4/decode.rs:131-139 — before extracting anything, compare `mistralrs-paged-attn/src/cuda/backend/fa3.rs` and `mistralrs-quant/src/cutile/nvfp4_gemv.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 31 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/cuda/backend/fa3.rs:495` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (8–9 lines × 6) · ×1
  • Duplicated block (8–9 lines × 6) mistralrs-core/src/xlora_models/gemma.rs:442 — mistralrs-core/src/xlora_models/gemma.rs:442-449 | mistralrs-core/src/xlora_models/gemma2.rs:473-480 | mistralrs-core/src/xlora_models/mistral.rs:439-446 | mistralrs-core/src/xlora_models/mixtral.rs:569-576 | mistralrs-core/src/xlora_models/phi2.rs:424-432 | mistralrs-core/src/xlora_models/phi3.rs:405-412 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/gemma2.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 498 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma.rs:442` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/xlora_models/mistral.rs:438` calls `head_dim` and `mistralrs-core/src/xlora_models/gemma.rs:441` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (7–9 lines × 6) · ×1
  • Duplicated block (7–9 lines × 6) mistralrs-core/src/xlora_models/gemma2.rs:620 — mistralrs-core/src/xlora_models/gemma2.rs:620-628 | mistralrs-core/src/xlora_models/phi2.rs:554-562 | mistralrs-core/src/xlora_models/phi3.rs:532-540 | mistralrs-core/src/xlora_models/quantized_llama.rs:784-790 | mistralrs-core/src/xlora_models/quantized_phi3.rs:446-454 | mistralrs-core/src/xlora_models/starcoder2.rs:565-573 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma2.rs` and `mistralrs-core/src/xlora_models/phi2.rs` as WHOLE FILES: this scan already matched 22 separate duplicated blocks between them, totalling at least 304 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma2.rs:620` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (6–9 lines × 6) · ×1
  • Duplicated block (6–9 lines × 6) mistralrs-core/src/vision_models/conformer/encoder.rs:82 — mistralrs-core/src/vision_models/conformer/encoder.rs:82-90 | mistralrs-core/src/vision_models/idefics3/vision.rs:277-285 | mistralrs-core/src/vision_models/lfm2_vl/vision.rs:209-217 | mistralrs-core/src/vision_models/llama4/text.rs:427-432 | mistralrs-core/src/vision_models/mllama/vision.rs:202-210 | mistralrs-core/src/vision_models/siglip.rs:275-283 — `mistralrs-core/src/vision_models/idefics3/vision.rs` and `mistralrs-core/src/vision_models/lfm2_vl/vision.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 7 separate duplicated blocks between them, totalling at least 52 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/vision_models/conformer/encoder.rs:80` calls `qkv_projections` and `mistralrs-core/src/vision_models/llama4/text.rs:427` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (8–9 lines × 5) · ×1
  • Duplicated block (8–9 lines × 5) mistralrs-quant/src/blockwise_fp8/deepgemm.rs:518 — mistralrs-quant/src/blockwise_fp8/deepgemm.rs:518-525 | mistralrs-quant/src/blockwise_fp8/deepgemm.rs:602-610 | mistralrs-quant/src/blockwise_fp8/deepgemm.rs:621-628 | mistralrs-quant/src/blockwise_fp8/ops.rs:2033-2040 | mistralrs-quant/src/blockwise_fp8/ops.rs:2042-2050 — before extracting anything, compare `mistralrs-quant/src/blockwise_fp8/deepgemm.rs` and `mistralrs-quant/src/blockwise_fp8/ops.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 65 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (8–9 lines × 4) · ×1
  • Duplicated block (8–9 lines × 4) mistralrs-quant/src/metal_kernels/mod.rs:1363 — mistralrs-quant/src/metal_kernels/mod.rs:1363-1371 | mistralrs-quant/src/metal_kernels/mod.rs:1511-1519 | mistralrs-quant/src/metal_kernels/mod.rs:4769-4777 | mistralrs-quant/src/metal_kernels/mod.rs:4833-4840 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
D4 · Code Duplication · Duplicated block (12 lines × 38) · ×1
  • Duplicated block (12 lines × 38) mistralrs-core/src/models/flint.rs:357 — mistralrs-core/src/models/flint.rs:357-368 | mistralrs-core/src/models/gemma.rs:177-188 | mistralrs-core/src/models/gemma2.rs:218-229 | mistralrs-core/src/models/glm4.rs:220-231 | mistralrs-core/src/models/glm4_moe.rs:282-293 | mistralrs-core/src/models/gpt_oss.rs:258-269 | mistralrs-core/src/models/hunyuan_v1_dense.rs:201-212 | mistralrs-core/src/models/hunyuan_v1_moe.rs:384-395 | mistralrs-core/src/models/lfm2.rs:490-501 | mistralrs-core/src/models/lfm3.rs:551-562 | mistralrs-core/src/models/mistral.rs:216-227 | mistralrs-core/src/models/mixtral.rs:161-172 | mistralrs-core/src/models/phi2.rs:273-284 | mistralrs-core/src/models/phi3.rs:161-172 | mistralrs-core/src/models/phi3_5_moe.rs:188-199 | mistralrs-core/src/models/qwen2.rs:250-261 | mistralrs-core/src/models/qwen3.rs:202-213 | mistralrs-core/src/models/qwen3_moe.rs:205-216 | mistralrs-core/src/models/qwen3_next.rs:288-299 | mistralrs-core/src/models/starcoder2.rs:237-248 | mistralrs-core/src/vision_models/gemma3/text.rs:192-203 | mistralrs-core/src/vision_models/mllama/text.rs:172-183 | mistralrs-core/src/vision_models/phi3/mod.rs:253-264 | mistralrs-core/src/vision_models/phi4/mod.rs:122-133 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:211-222 | mistralrs-core/src/vision_models/qwen2vl/text.rs:212-223 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:203-214 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:204-215 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:310-321 | mistralrs-core/src/vision_models/voxtral/encoder.rs:91-102 | mistralrs-core/src/vision_models/voxtral/mod.rs:137-148 | mistralrs-core/src/xlora_models/gemma.rs:258-269 | mistralrs-core/src/xlora_models/gemma2.rs:263-274 | mistralrs-core/src/xlora_models/mistral.rs:248-259 | mistralrs-core/src/xlora_models/mixtral.rs:161-172 | mistralrs-core/src/xlora_models/phi2.rs:251-262 | mistralrs-core/src/xlora_models/phi3.rs:136-147 | mistralrs-core/src/xlora_models/starcoder2.rs:235-246 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/gemma.rs` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 152 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/flint.rs:357` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/models/phi3.rs:174` calls `position_ids_vec` and `mistralrs-core/src/models/gemma.rs:190` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (8 lines × 32) · ×1
  • Duplicated block (8 lines × 32) mistralrs-core/src/models/flint.rs:443 — mistralrs-core/src/models/flint.rs:443-450 | mistralrs-core/src/models/gemma.rs:238-245 | mistralrs-core/src/models/gemma2.rs:286-293 | mistralrs-core/src/models/glm4.rs:285-292 | mistralrs-core/src/models/glm4_moe.rs:350-357 | mistralrs-core/src/models/gpt_oss.rs:315-322 | mistralrs-core/src/models/granite.rs:1611-1618 | mistralrs-core/src/models/hunyuan_v1_dense.rs:261-268 | mistralrs-core/src/models/hunyuan_v1_moe.rs:447-454 | mistralrs-core/src/models/llama.rs:146-153 | mistralrs-core/src/models/mistral.rs:286-293 | mistralrs-core/src/models/mixtral.rs:222-229 | mistralrs-core/src/models/phi2.rs:334-343 | mistralrs-core/src/models/phi3.rs:225-232 | mistralrs-core/src/models/phi3_5_moe.rs:252-259 | mistralrs-core/src/models/qwen2.rs:316-323 | mistralrs-core/src/models/qwen3.rs:271-278 | mistralrs-core/src/models/qwen3_moe.rs:274-281 | mistralrs-core/src/models/qwen3_next.rs:354-361 | mistralrs-core/src/models/smollm3.rs:163-170 | mistralrs-core/src/models/starcoder2.rs:298-305 | mistralrs-core/src/vision_models/llama4/text.rs:518-525 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:121-128 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:295-302 | mistralrs-core/src/vision_models/muse_glimmer/text.rs:309-318 | mistralrs-core/src/vision_models/phi3/mod.rs:316-323 | mistralrs-core/src/vision_models/phi4/mod.rs:185-192 | mistralrs-core/src/vision_models/qwen3_5/text.rs:404-411 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:269-276 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:276-283 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:379-386 | mistralrs-core/src/vision_models/voxtral/mod.rs:197-204 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/gemma.rs` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 152 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/flint.rs:443` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:280` calls `sigmoid`, `to_dtype`, `dtype` and `mistralrs-core/src/models/flint.rs:452` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (8 lines × 25) · ×1
  • Duplicated block (8 lines × 25) mistralrs-quant/src/metal_kernels/mod.rs:289 — mistralrs-quant/src/metal_kernels/mod.rs:289-297 | mistralrs-quant/src/metal_kernels/mod.rs:328-336 | mistralrs-quant/src/metal_kernels/mod.rs:367-375 | mistralrs-quant/src/metal_kernels/mod.rs:406-414 | mistralrs-quant/src/metal_kernels/mod.rs:445-453 | mistralrs-quant/src/metal_kernels/mod.rs:698-706 | mistralrs-quant/src/metal_kernels/mod.rs:745-753 | mistralrs-quant/src/metal_kernels/mod.rs:792-800 | mistralrs-quant/src/metal_kernels/mod.rs:1798-1807 | mistralrs-quant/src/metal_kernels/mod.rs:1863-1872 | mistralrs-quant/src/metal_kernels/mod.rs:1933-1942 | mistralrs-quant/src/metal_kernels/mod.rs:2030-2038 | mistralrs-quant/src/metal_kernels/mod.rs:3263-3271 | mistralrs-quant/src/metal_kernels/mod.rs:3386-3393 | mistralrs-quant/src/metal_kernels/mod.rs:3450-3457 | mistralrs-quant/src/metal_kernels/mod.rs:3514-3521 | mistralrs-quant/src/metal_kernels/mod.rs:3579-3586 | mistralrs-quant/src/metal_kernels/mod.rs:3641-3649 | mistralrs-quant/src/metal_kernels/mod.rs:4085-4093 | mistralrs-quant/src/metal_kernels/mod.rs:4120-4128 | mistralrs-quant/src/metal_kernels/mod.rs:4157-4165 | mistralrs-quant/src/metal_kernels/mod.rs:4531-4538 | mistralrs-quant/src/metal_kernels/mod.rs:4593-4600 | mistralrs-quant/src/metal_kernels/mod.rs:4972-4979 | mistralrs-quant/src/metal_kernels/mod.rs:5014-5021 — all 25 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/metal_kernels/mod.rs:289` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-quant/src/metal_kernels/mod.rs:4541` calls `is_some` and `mistralrs-quant/src/metal_kernels/mod.rs:4601` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (8 lines × 22) · ×1
  • Duplicated block (8 lines × 22) mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:435 — mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:435-444 | mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:638-647 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1276-1285 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1657-1666 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1965-1974 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2688-2697 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4116-4125 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4489-4498 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4894-4903 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5707-5716 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9515-9522 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:10760-10767 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:710-719 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:936-945 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1157-1166 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2058-2067 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2309-2318 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3667-3676 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3888-3895 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:4101-4110 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5206-5215 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5694-5703 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/embedding_loaders.rs` and `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 180 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:435` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (8 lines × 16) · ×1
  • Duplicated block (8 lines × 16) mistralrs-core/src/models/deepseek2.rs:816 — mistralrs-core/src/models/deepseek2.rs:816-823 | mistralrs-core/src/models/deepseek3.rs:879-886 | mistralrs-core/src/models/flint.rs:785-792 | mistralrs-core/src/models/glm4.rs:447-454 | mistralrs-core/src/models/glm4_moe.rs:716-723 | mistralrs-core/src/models/glm4_moe_lite.rs:826-833 | mistralrs-core/src/models/gpt_oss.rs:721-728 | mistralrs-core/src/models/granite.rs:1955-1962 | mistralrs-core/src/models/hunyuan_v1_dense.rs:416-423 | mistralrs-core/src/models/hunyuan_v1_moe.rs:910-917 | mistralrs-core/src/models/llama.rs:353-360 | mistralrs-core/src/models/mistral.rs:422-429 | mistralrs-core/src/models/qwen3.rs:410-417 | mistralrs-core/src/models/qwen3_moe.rs:584-591 | mistralrs-core/src/models/smollm3.rs:369-376 | mistralrs-core/src/vision_models/llama4/text.rs:802-809 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:816` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (8 lines × 14) · ×1
  • Duplicated block (8 lines × 14) mistralrs-core/src/models/deepseek2.rs:820 — mistralrs-core/src/models/deepseek2.rs:820-827 | mistralrs-core/src/models/deepseek3.rs:883-890 | mistralrs-core/src/models/glm4_moe.rs:720-727 | mistralrs-core/src/models/glm4_moe_lite.rs:830-837 | mistralrs-core/src/models/mixtral.rs:418-425 | mistralrs-core/src/models/phi3.rs:420-427 | mistralrs-core/src/models/qwen2.rs:445-452 | mistralrs-core/src/vision_models/gemma3/text.rs:446-453 | mistralrs-core/src/vision_models/gemma3n/text.rs:1340-1347 | mistralrs-core/src/vision_models/muse_glimmer/text.rs:441-448 | mistralrs-core/src/vision_models/phi3/mod.rs:1215-1222 | mistralrs-core/src/vision_models/phi4/mod.rs:336-343 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:410-417 | mistralrs-core/src/vision_models/qwen2vl/text.rs:411-418 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:820` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/vision_models/gemma3/text.rs:444` calls `sqrt` and `mistralrs-core/src/models/phi3.rs:417` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (8 lines × 11) · ×1
  • Duplicated block (8 lines × 11) mistralrs-core/src/embedding_models/qwen3_embedding.rs:351 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:351-358 | mistralrs-core/src/models/glm4.rs:461-468 | mistralrs-core/src/models/glm4_moe.rs:746-753 | mistralrs-core/src/models/hunyuan_v1_dense.rs:430-437 | mistralrs-core/src/models/hunyuan_v1_moe.rs:924-931 | mistralrs-core/src/models/qwen3.rs:424-431 | mistralrs-core/src/models/qwen3_moe.rs:598-605 | mistralrs-core/src/xlora_models/gemma.rs:444-451 | mistralrs-core/src/xlora_models/gemma2.rs:475-482 | mistralrs-core/src/xlora_models/mistral.rs:441-448 | mistralrs-core/src/xlora_models/mixtral.rs:571-578 — before extracting anything, compare `mistralrs-core/src/embedding_models/qwen3_embedding.rs` and `mistralrs-core/src/models/glm4.rs` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 137 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/qwen3_embedding.rs:351` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/xlora_models/mistral.rs:439` calls `with_capacity`, `pp` and `mistralrs-core/src/embedding_models/qwen3_embedding.rs:350` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (7–8 lines × 5) · ×1
  • Duplicated block (7–8 lines × 5) mistralrs-core/src/models/flint.rs:958 — mistralrs-core/src/models/flint.rs:958-964 | mistralrs-core/src/models/gemma2.rs:568-574 | mistralrs-core/src/models/gpt_oss.rs:918-925 | mistralrs-core/src/models/qwen2.rs:596-602 | mistralrs-core/src/vision_models/muse_glimmer/text.rs:595-602 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 190 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/flint.rs:958` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (13–16 lines × 4) · ×1
  • Duplicated block (13–16 lines × 4) mistralrs-core/src/models/deepseek2.rs:667 — mistralrs-core/src/models/deepseek2.rs:667-682 | mistralrs-core/src/models/deepseek3.rs:730-745 | mistralrs-core/src/models/glm4_moe.rs:570-582 | mistralrs-core/src/models/glm4_moe_lite.rs:676-691 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:667` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (7–8 lines × 3) · ×1
  • Duplicated block (7–8 lines × 3) mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:730 — mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:730-736 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2880-2887 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:3771-3777 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/embedding_loaders.rs` and `mistralrs-core/src/pipeline/loaders/normal_loaders.rs` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 216 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:730` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (4–8 lines × 5) · ×1
  • Duplicated block (4–8 lines × 5) mistralrs-core/src/ops.rs:2211 — mistralrs-core/src/ops.rs:2211-2214 | mistralrs-core/src/ops.rs:3947-3954 | mistralrs-core/src/ops.rs:4074-4081 | mistralrs-flash-attn/src/flash.rs:168-171 | mistralrs-flash-attn/src/flash.rs:738-741 — there are 5 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 5 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/ops.rs:3947` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/ops.rs:2214` calls `device_ptr` and `mistralrs-flash-attn/src/flash.rs:171` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (1–8 lines × 7) · ×1
  • Duplicated block (1–8 lines × 7) mistralrs-core/src/xlora_models/gemma.rs:278 — mistralrs-core/src/xlora_models/gemma.rs:278-285 | mistralrs-core/src/xlora_models/llama.rs:100-101 | mistralrs-core/src/xlora_models/mistral.rs:267-268 | mistralrs-core/src/xlora_models/mixtral.rs:180-181 | mistralrs-core/src/xlora_models/phi2.rs:271-275 | mistralrs-core/src/xlora_models/quantized_llama.rs:236-236 | mistralrs-core/src/xlora_models/starcoder2.rs:254-255 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/llama.rs` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 163 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/xlora_models/gemma.rs:278` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/xlora_models/gemma.rs:278` calls `forward` and `mistralrs-core/src/xlora_models/llama.rs:100` does not — after which the two agree again for 5 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (7 lines × 38) · ×1
  • Duplicated block (7 lines × 38) mistralrs-core/src/models/flint.rs:353 — mistralrs-core/src/models/flint.rs:353-359 | mistralrs-core/src/models/gemma.rs:173-179 | mistralrs-core/src/models/gemma2.rs:214-220 | mistralrs-core/src/models/glm4.rs:216-222 | mistralrs-core/src/models/glm4_moe.rs:278-284 | mistralrs-core/src/models/gpt_oss.rs:254-260 | mistralrs-core/src/models/hunyuan_v1_dense.rs:197-203 | mistralrs-core/src/models/hunyuan_v1_moe.rs:380-386 | mistralrs-core/src/models/lfm2.rs:486-492 | mistralrs-core/src/models/lfm3.rs:547-553 | mistralrs-core/src/models/mistral.rs:212-218 | mistralrs-core/src/models/mixtral.rs:157-163 | mistralrs-core/src/models/phi2.rs:269-275 | mistralrs-core/src/models/phi3.rs:157-163 | mistralrs-core/src/models/phi3_5_moe.rs:184-190 | mistralrs-core/src/models/qwen2.rs:246-252 | mistralrs-core/src/models/qwen3.rs:198-204 | mistralrs-core/src/models/qwen3_moe.rs:201-207 | mistralrs-core/src/models/starcoder2.rs:233-239 | mistralrs-core/src/vision_models/gemma3/text.rs:188-194 | mistralrs-core/src/vision_models/gemma4/text.rs:806-812 | REDACTED:827-833 | mistralrs-core/src/vision_models/mllama/text.rs:168-174 | mistralrs-core/src/vision_models/phi3/mod.rs:249-255 | mistralrs-core/src/vision_models/phi4/mod.rs:118-124 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:207-213 | mistralrs-core/src/vision_models/qwen2vl/text.rs:208-214 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:200-206 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:306-312 | mistralrs-core/src/vision_models/voxtral/encoder.rs:87-93 | mistralrs-core/src/vision_models/voxtral/mod.rs:133-139 | mistralrs-core/src/xlora_models/gemma.rs:254-260 | mistralrs-core/src/xlora_models/gemma2.rs:259-265 | mistralrs-core/src/xlora_models/mistral.rs:244-250 | mistralrs-core/src/xlora_models/mixtral.rs:157-163 | mistralrs-core/src/xlora_models/phi2.rs:247-253 | mistralrs-core/src/xlora_models/phi3.rs:132-138 | mistralrs-core/src/xlora_models/starcoder2.rs:231-237 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/gemma.rs` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 152 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (7 lines × 34) · ×1
  • Duplicated block (7 lines × 34) mistralrs-core/src/models/flint.rs:443 — mistralrs-core/src/models/flint.rs:443-451 | mistralrs-core/src/models/gemma.rs:238-246 | mistralrs-core/src/models/gemma2.rs:286-294 | mistralrs-core/src/models/glm4.rs:285-293 | mistralrs-core/src/models/glm4_moe.rs:350-358 | mistralrs-core/src/models/gpt_oss.rs:315-323 | mistralrs-core/src/models/granite.rs:1611-1619 | mistralrs-core/src/models/hunyuan_v1_dense.rs:261-269 | mistralrs-core/src/models/hunyuan_v1_moe.rs:447-455 | mistralrs-core/src/models/llama.rs:146-154 | mistralrs-core/src/models/mistral.rs:286-294 | mistralrs-core/src/models/mixtral.rs:222-230 | mistralrs-core/src/models/phi2.rs:334-344 | mistralrs-core/src/models/phi3.rs:225-233 | mistralrs-core/src/models/phi3_5_moe.rs:252-260 | mistralrs-core/src/models/qwen2.rs:316-324 | mistralrs-core/src/models/qwen3.rs:271-279 | mistralrs-core/src/models/qwen3_moe.rs:274-282 | mistralrs-core/src/models/qwen3_next.rs:354-362 | mistralrs-core/src/models/smollm3.rs:163-171 | mistralrs-core/src/models/starcoder2.rs:298-306 | mistralrs-core/src/vision_models/llama4/text.rs:518-526 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:121-129 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:295-303 | mistralrs-core/src/vision_models/muse_glimmer/text.rs:309-319 | mistralrs-core/src/vision_models/phi3/mod.rs:316-324 | mistralrs-core/src/vision_models/phi4/mod.rs:185-193 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:285-291 | mistralrs-core/src/vision_models/qwen2vl/text.rs:286-292 | mistralrs-core/src/vision_models/qwen3_5/text.rs:404-412 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:269-277 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:276-284 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:379-387 | mistralrs-core/src/vision_models/voxtral/mod.rs:197-205 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/gemma.rs` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 152 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/flint.rs:443` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:283` calls `to_dtype`, `dtype` and `mistralrs-core/src/models/flint.rs:443` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (7 lines × 29) · ×1
  • Duplicated block (7 lines × 29) mistralrs-core/src/models/flint.rs:448 — mistralrs-core/src/models/flint.rs:448-454 | mistralrs-core/src/models/gemma.rs:243-249 | mistralrs-core/src/models/gemma2.rs:291-297 | mistralrs-core/src/models/glm4.rs:290-296 | mistralrs-core/src/models/glm4_moe.rs:355-361 | mistralrs-core/src/models/gpt_oss.rs:320-326 | mistralrs-core/src/models/granite.rs:1616-1622 | mistralrs-core/src/models/hunyuan_v1_dense.rs:266-272 | mistralrs-core/src/models/hunyuan_v1_moe.rs:452-458 | mistralrs-core/src/models/llama.rs:151-157 | mistralrs-core/src/models/mistral.rs:291-297 | mistralrs-core/src/models/mixtral.rs:227-233 | mistralrs-core/src/models/phi3.rs:230-236 | mistralrs-core/src/models/phi3_5_moe.rs:257-263 | mistralrs-core/src/models/qwen2.rs:321-327 | mistralrs-core/src/models/qwen3.rs:276-282 | mistralrs-core/src/models/qwen3_moe.rs:279-285 | mistralrs-core/src/models/smollm3.rs:168-174 | mistralrs-core/src/models/starcoder2.rs:303-309 | mistralrs-core/src/vision_models/gemma3/text.rs:296-302 | mistralrs-core/src/vision_models/gemma4/text.rs:764-770 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:126-132 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:300-306 | mistralrs-core/src/vision_models/phi3/mod.rs:321-327 | mistralrs-core/src/vision_models/phi4/mod.rs:190-196 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:288-294 | mistralrs-core/src/vision_models/qwen2vl/text.rs:289-295 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:281-287 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:384-390 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/gemma.rs` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 152 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/flint.rs:448` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (6–7 lines × 16) · ×1
  • Duplicated block (6–7 lines × 16) mistralrs-core/src/models/gemma.rs:186 — mistralrs-core/src/models/gemma.rs:186-191 | mistralrs-core/src/models/gemma2.rs:227-232 | mistralrs-core/src/models/gpt_oss.rs:267-272 | mistralrs-core/src/models/hunyuan_v1_dense.rs:210-215 | mistralrs-core/src/models/hunyuan_v1_moe.rs:393-398 | mistralrs-core/src/models/lfm2.rs:499-504 | mistralrs-core/src/models/mistral.rs:225-230 | mistralrs-core/src/models/mixtral.rs:170-175 | mistralrs-core/src/models/phi2.rs:282-287 | mistralrs-core/src/models/qwen2.rs:259-264 | mistralrs-core/src/models/qwen3.rs:211-216 | mistralrs-core/src/models/qwen3_moe.rs:214-219 | mistralrs-core/src/models/qwen3_next.rs:297-302 | mistralrs-core/src/models/starcoder2.rs:246-251 | mistralrs-core/src/vision_models/mllama/text.rs:181-187 | mistralrs-core/src/vision_models/voxtral/mod.rs:146-152 — before extracting anything, compare `mistralrs-core/src/models/gemma.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 707 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/gemma.rs:186` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (7 lines × 15) · ×1
  • Duplicated block (7 lines × 15) mistralrs-core/src/models/deepseek2.rs:820 — mistralrs-core/src/models/deepseek2.rs:820-826 | mistralrs-core/src/models/deepseek3.rs:883-889 | mistralrs-core/src/models/glm4_moe.rs:720-726 | mistralrs-core/src/models/glm4_moe_lite.rs:830-836 | mistralrs-core/src/models/mixtral.rs:418-424 | mistralrs-core/src/models/phi3.rs:420-426 | mistralrs-core/src/models/qwen2.rs:445-451 | mistralrs-core/src/vision_models/gemma3/text.rs:446-452 | mistralrs-core/src/vision_models/gemma3n/text.rs:1340-1346 | mistralrs-core/src/vision_models/gemma4/text.rs:1651-1659 | mistralrs-core/src/vision_models/muse_glimmer/text.rs:441-447 | mistralrs-core/src/vision_models/phi3/mod.rs:1215-1221 | mistralrs-core/src/vision_models/phi4/mod.rs:336-342 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:410-416 | mistralrs-core/src/vision_models/qwen2vl/text.rs:411-417 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/vision_models/gemma3/text.rs:444` calls `sqrt` and `mistralrs-core/src/models/phi3.rs:417` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (7 lines × 12) · ×1
  • Duplicated block (7 lines × 12) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1518 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1518-1524 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2541-2547 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2899-2905 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3253-3259 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3595-3601 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4322-4328 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5112-5118 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:812-818 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1256-1262 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1500-1506 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2183-2189 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5793-5799 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` and `mistralrs-core/src/pipeline/loaders/normal_loaders.rs` as WHOLE FILES: this scan already matched 34 separate duplicated blocks between them, totalling at least 445 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1518` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (7 lines × 10) · ×1
  • Duplicated block (7 lines × 10) mistralrs-core/src/models/deepseek2.rs:819 — mistralrs-core/src/models/deepseek2.rs:819-825 | mistralrs-core/src/models/deepseek3.rs:882-888 | mistralrs-core/src/models/glm4_moe.rs:719-725 | mistralrs-core/src/models/glm4_moe_lite.rs:829-835 | mistralrs-core/src/models/gpt_oss.rs:724-730 | mistralrs-core/src/models/mixtral.rs:417-423 | mistralrs-core/src/models/phi3.rs:419-425 | mistralrs-core/src/models/qwen2.rs:444-450 | mistralrs-core/src/vision_models/gemma3/text.rs:445-451 | mistralrs-core/src/vision_models/gemma3n/text.rs:1339-1345 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:819` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/vision_models/gemma3/text.rs:444` calls `sqrt` and `mistralrs-core/src/models/phi3.rs:417` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (7 lines × 8) · ×1
  • Duplicated block (7 lines × 8) mistralrs-core/src/vision_models/qwen3_5/mod.rs:195 — mistralrs-core/src/vision_models/qwen3_5/mod.rs:195-201 | mistralrs-core/src/vision_models/qwen3_5/mod.rs:258-264 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:178-184 | mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs:241-247 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:702-708 | mistralrs-core/src/vision_models/qwen3_vl/mod.rs:779-785 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:148-154 | mistralrs-core/src/vision_models/qwen3_vl_moe/mod.rs:225-231 — `mistralrs-core/src/vision_models/qwen3_5/mod.rs` and `mistralrs-core/src/vision_models/qwen3_5_moe/mod.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 24 separate duplicated blocks between them, totalling at least 425 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/qwen3_5/mod.rs:195` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (4–7 lines × 7) · ×1
  • Duplicated block (4–7 lines × 7) mistralrs-core/src/cuda/gated_add.rs:53 — mistralrs-core/src/cuda/gated_add.rs:53-59 | mistralrs-core/src/cuda/rounded_rope.rs:67-73 | mistralrs-quant/src/cutile/fp8_w8a8.rs:521-527 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:904-910 | mistralrs-quant/src/cutile/nvfp4_gemv.rs:304-310 | mistralrs-quant/src/embedding/packing.rs:28-31 | mistralrs-quant/src/nvfp4/portable.rs:301-307 — before extracting anything, compare `mistralrs-quant/src/cutile/fp8_w8a8.rs` and `mistralrs-quant/src/cutile/fused_moe_fp8.rs` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 83 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/cuda/gated_add.rs:53` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/cuda/rounded_rope.rs:66` calls `storage_and_layout` and `mistralrs-core/src/cuda/gated_add.rs:52` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (11–13 lines × 3) · ×1
  • Duplicated block (11–13 lines × 3) mistralrs-core/src/attention/backends/cpu/full.rs:516 — mistralrs-core/src/attention/backends/cpu/full.rs:516-526 | mistralrs-core/src/attention/backends/cpu/full.rs:623-635 | mistralrs-core/src/attention/backends/cpu/single_q.rs:315-325 — before extracting anything, compare `mistralrs-core/src/attention/backends/cpu/full.rs` and `mistralrs-core/src/attention/backends/cpu/single_q.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 44 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (5–7 lines × 2) · ×1
  • Duplicated block (5–7 lines × 2) mistralrs-quant/src/utils/ops.rs:2021 — mistralrs-quant/src/utils/ops.rs:2021-2027 | mistralrs-quant/src/utils/ops.rs:2825-2829 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/utils/ops.rs:2021` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (6 lines × 40) · ×1
  • Duplicated block (6 lines × 40) mistralrs-core/src/models/flint.rs:356 — mistralrs-core/src/models/flint.rs:356-361 | mistralrs-core/src/models/gemma.rs:176-181 | mistralrs-core/src/models/gemma2.rs:217-222 | mistralrs-core/src/models/glm4.rs:219-224 | mistralrs-core/src/models/glm4_moe.rs:281-286 | mistralrs-core/src/models/gpt_oss.rs:257-262 | mistralrs-core/src/models/hunyuan_v1_dense.rs:200-205 | mistralrs-core/src/models/hunyuan_v1_moe.rs:383-388 | mistralrs-core/src/models/lfm2.rs:489-494 | mistralrs-core/src/models/lfm3.rs:550-555 | mistralrs-core/src/models/mistral.rs:215-220 | mistralrs-core/src/models/mixtral.rs:160-165 | mistralrs-core/src/models/phi2.rs:272-277 | mistralrs-core/src/models/phi3.rs:160-165 | mistralrs-core/src/models/phi3_5_moe.rs:187-192 | mistralrs-core/src/models/qwen2.rs:249-254 | mistralrs-core/src/models/qwen3.rs:201-206 | mistralrs-core/src/models/qwen3_moe.rs:204-209 | mistralrs-core/src/models/qwen3_next.rs:287-292 | mistralrs-core/src/models/starcoder2.rs:236-241 | mistralrs-core/src/vision_models/gemma3/text.rs:191-196 | mistralrs-core/src/vision_models/gemma4/text.rs:809-814 | REDACTED:830-835 | mistralrs-core/src/vision_models/mllama/text.rs:171-176 | mistralrs-core/src/vision_models/phi3/mod.rs:252-257 | mistralrs-core/src/vision_models/phi4/mod.rs:121-126 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:210-215 | mistralrs-core/src/vision_models/qwen2vl/text.rs:211-216 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:202-207 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:203-208 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:309-314 | mistralrs-core/src/vision_models/voxtral/encoder.rs:90-95 | mistralrs-core/src/vision_models/voxtral/mod.rs:136-141 | mistralrs-core/src/xlora_models/gemma.rs:257-262 | mistralrs-core/src/xlora_models/gemma2.rs:262-267 | mistralrs-core/src/xlora_models/mistral.rs:247-252 | mistralrs-core/src/xlora_models/mixtral.rs:160-165 | mistralrs-core/src/xlora_models/phi2.rs:250-255 | mistralrs-core/src/xlora_models/phi3.rs:135-140 | mistralrs-core/src/xlora_models/starcoder2.rs:234-239 — before extracting anything, compare `mistralrs-core/src/models/flint.rs` and `mistralrs-core/src/models/gemma.rs` as WHOLE FILES: this scan already matched 16 separate duplicated blocks between them, totalling at least 152 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (6 lines × 37) · ×1
  • Duplicated block (6 lines × 37) mistralrs-core/src/embedding_models/qwen3_embedding.rs:476 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:476-481 | mistralrs-core/src/models/deepseek2.rs:988-993 | mistralrs-core/src/models/deepseek2.rs:1028-1033 | mistralrs-core/src/models/deepseek3.rs:1051-1056 | mistralrs-core/src/models/deepseek3.rs:1092-1097 | mistralrs-core/src/models/flint.rs:988-993 | mistralrs-core/src/models/gemma.rs:501-506 | mistralrs-core/src/models/gemma2.rs:607-612 | mistralrs-core/src/models/glm4.rs:618-623 | mistralrs-core/src/models/glm4_moe.rs:866-871 | mistralrs-core/src/models/glm4_moe.rs:906-911 | mistralrs-core/src/models/glm4_moe_lite.rs:1003-1008 | mistralrs-core/src/models/glm4_moe_lite.rs:1046-1051 | mistralrs-core/src/models/gpt_oss.rs:954-959 | mistralrs-core/src/models/hunyuan_v1_dense.rs:580-585 | mistralrs-core/src/models/hunyuan_v1_moe.rs:1072-1077 | mistralrs-core/src/models/mistral.rs:629-634 | mistralrs-core/src/models/mixtral.rs:567-572 | mistralrs-core/src/models/phi3.rs:576-581 | mistralrs-core/src/models/phi3_5_moe.rs:649-654 | mistralrs-core/src/models/phi3_5_moe.rs:668-673 | mistralrs-core/src/models/qwen2.rs:632-637 | mistralrs-core/src/models/qwen3.rs:582-587 | mistralrs-core/src/models/qwen3_moe.rs:763-768 | mistralrs-core/src/models/qwen3_next.rs:1141-1146 | mistralrs-core/src/models/starcoder2.rs:568-573 | mistralrs-core/src/vision_models/llama4/vision.rs:351-356 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:578-583 | mistralrs-core/src/vision_models/mllama/vision.rs:400-405 | mistralrs-core/src/vision_models/phi3/mod.rs:1381-1386 | mistralrs-core/src/vision_models/phi4/mod.rs:643-648 | mistralrs-core/src/vision_models/qwen2_5_vl/text.rs:568-573 | mistralrs-core/src/vision_models/qwen2vl/text.rs:570-575 | mistralrs-core/src/vision_models/qwen3_5/text.rs:1751-1756 | mistralrs-core/src/vision_models/qwen3_5_moe/text.rs:971-976 | mistralrs-core/src/vision_models/qwen3_vl/text.rs:606-611 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:727-732 — before extracting anything, compare `mistralrs-core/src/embedding_models/qwen3_embedding.rs` and `mistralrs-core/src/models/deepseek2.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 35 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/qwen3_embedding.rs:476` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/models/deepseek2.rs:984` calls `pp` and `mistralrs-core/src/embedding_models/qwen3_embedding.rs:471` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (6 lines × 15) · ×1
  • Duplicated block (6 lines × 15) mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1519 — mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1519-1524 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:1826-1831 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2126-2131 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2542-2547 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2900-2905 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3254-3259 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:3596-3601 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4323-4328 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5113-5118 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5544-5549 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:813-818 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1257-1262 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:1501-1506 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:2184-2189 | mistralrs-core/src/pipeline/loaders/normal_loaders.rs:5794-5799 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` and `mistralrs-core/src/pipeline/loaders/normal_loaders.rs` as WHOLE FILES: this scan already matched 34 separate duplicated blocks between them, totalling at least 445 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (7 lines × 14) · ×1
  • Duplicated block (7 lines × 14) mistralrs-core/src/models/gemma.rs:586 — mistralrs-core/src/models/gemma.rs:586-592 | mistralrs-core/src/models/gemma2.rs:703-709 | mistralrs-core/src/models/glm4.rs:705-711 | mistralrs-core/src/models/granite.rs:2469-2475 | mistralrs-core/src/models/hunyuan_v1_dense.rs:673-679 | mistralrs-core/src/models/mistral.rs:714-720 | mistralrs-core/src/models/phi2.rs:662-668 | mistralrs-core/src/models/phi3.rs:657-663 | mistralrs-core/src/models/qwen2.rs:717-723 | mistralrs-core/src/models/qwen3.rs:691-697 | mistralrs-core/src/models/starcoder2.rs:653-659 | mistralrs-core/src/vision_models/gemma3/text.rs:928-934 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:670-676 | mistralrs-core/src/vision_models/phi3/mod.rs:1493-1499 — before extracting anything, compare `mistralrs-core/src/models/gemma.rs` and `mistralrs-core/src/models/gemma2.rs` as WHOLE FILES: this scan already matched 49 separate duplicated blocks between them, totalling at least 707 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (6 lines × 10) · ×1
  • Duplicated block (6 lines × 10) mistralrs-core/src/vision_models/gemma4/mtp.rs:726 — mistralrs-core/src/vision_models/gemma4/mtp.rs:726-731 | mistralrs-core/src/xlora_models/gemma.rs:271-276 | mistralrs-core/src/xlora_models/gemma2.rs:276-281 | mistralrs-core/src/xlora_models/llama.rs:94-99 | mistralrs-core/src/xlora_models/mistral.rs:261-266 | mistralrs-core/src/xlora_models/mixtral.rs:174-179 | mistralrs-core/src/xlora_models/phi2.rs:264-269 | mistralrs-core/src/xlora_models/phi3.rs:149-154 | mistralrs-core/src/xlora_models/quantized_phi3.rs:187-192 | mistralrs-core/src/xlora_models/starcoder2.rs:248-253 — before extracting anything, compare `mistralrs-core/src/xlora_models/gemma.rs` and `mistralrs-core/src/xlora_models/gemma2.rs` as WHOLE FILES: this scan already matched 32 separate duplicated blocks between them, totalling at least 498 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (6 lines × 6) · ×1
  • Duplicated block (6 lines × 6) mistralrs-core/src/ops.rs:4469 — mistralrs-core/src/ops.rs:4469-4474 | mistralrs-core/src/ops.rs:4634-4639 | mistralrs-core/src/ops.rs:5428-5433 | mistralrs-core/src/ops.rs:5701-5706 | mistralrs-core/src/ops.rs:6123-6128 | mistralrs-core/src/ops.rs:6452-6457 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/ops.rs:4475` calls `transpose` and `mistralrs-core/src/ops.rs:4641` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (11–12 lines × 5) · ×1
  • Duplicated block (11–12 lines × 5) mistralrs-quant/src/cutile/fp8_gemm.rs:485 — mistralrs-quant/src/cutile/fp8_gemm.rs:485-495 | mistralrs-quant/src/cutile/fp8_w8a16.rs:638-648 | mistralrs-quant/src/cutile/fp8_w8a8.rs:729-739 | mistralrs-quant/src/cutile/fused_moe.rs:836-847 | mistralrs-quant/src/cutile/fused_moe_fp8.rs:753-764 — before extracting anything, compare `mistralrs-quant/src/cutile/fp8_gemm.rs` and `mistralrs-quant/src/cutile/fp8_w8a16.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 40 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-quant/src/cutile/fp8_gemm.rs:485` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (3–5 lines × 14) · ×1
  • Duplicated block (3–5 lines × 14) mistralrs-core/src/models/deepseek2.rs:973 — mistralrs-core/src/models/deepseek2.rs:973-977 | mistralrs-core/src/models/deepseek3.rs:1036-1040 | mistralrs-core/src/models/flint.rs:973-977 | mistralrs-core/src/models/gemma.rs:486-490 | mistralrs-core/src/models/glm4.rs:603-607 | mistralrs-core/src/models/glm4_moe.rs:851-855 | mistralrs-core/src/models/glm4_moe_lite.rs:988-992 | mistralrs-core/src/models/hunyuan_v1_dense.rs:565-569 | mistralrs-core/src/models/hunyuan_v1_moe.rs:1059-1063 | mistralrs-core/src/models/mistral.rs:614-618 | mistralrs-core/src/models/mixtral.rs:552-556 | mistralrs-core/src/models/phi2.rs:563-565 | mistralrs-core/src/models/qwen3.rs:567-571 | mistralrs-core/src/models/qwen3_moe.rs:748-752 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/deepseek2.rs:973` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. Note first that the copies are not typed on the same thing: the declarations holding them bind `ctx` to `&mut ModelForwardContext<'_>` in one and `&mut crate::pipeline::ModelForwardContext<'_>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/models/deepseek2.rs:973` calls `to_device` and `mistralrs-core/src/models/phi2.rs:563` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (3–5 lines × 9) · ×1
  • Duplicated block (3–5 lines × 9) mistralrs-paged-attn/src/cuda/backend/mla.rs:129 — mistralrs-paged-attn/src/cuda/backend/mla.rs:129-131 | mistralrs-paged-attn/src/cuda/backend/mla.rs:154-156 | mistralrs-paged-attn/src/cuda/backend/mla.rs:179-181 | mistralrs-paged-attn/src/cuda/backend/mla.rs:440-444 | mistralrs-paged-attn/src/cuda/backend/mla.rs:499-503 | mistralrs-paged-attn/src/cuda/backend/mla.rs:558-562 | mistralrs-paged-attn/src/cuda/backend/mla.rs:764-769 | mistralrs-paged-attn/src/cuda/backend/mla.rs:802-807 | mistralrs-paged-attn/src/cuda/backend/mla.rs:840-845 — all 9 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/cuda/backend/mla.rs:129` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-paged-attn/src/cuda/backend/mla.rs:769` calls `slice_ptr`, `start_offset` and `mistralrs-paged-attn/src/cuda/backend/mla.rs:131` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (3–5 lines × 5) · ×1
  • Duplicated block (3–5 lines × 5) mistralrs-core/src/gguf/base_model.rs:139 — mistralrs-core/src/gguf/base_model.rs:139-143 | mistralrs-core/src/gguf/multimodal_binding_utils.rs:112-116 | mistralrs-core/src/gguf/normal_bindings.rs:951-955 | mistralrs-core/src/gguf/qwen_multimodal_bindings.rs:306-310 | mistralrs-quant/src/gguf/archive.rs:1390-1392 — before extracting anything, compare `mistralrs-core/src/gguf/multimodal_binding_utils.rs` and `mistralrs-core/src/gguf/qwen_multimodal_bindings.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 40 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/gguf/base_model.rs:139` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/gguf/base_model.rs:143` calls `U64`, `I8` and `mistralrs-quant/src/gguf/archive.rs:1392` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (3–5 lines × 7) · ×1
  • Duplicated block (3–5 lines × 7) mistralrs-core/src/layers.rs:1185 — mistralrs-core/src/layers.rs:1185-1189 | mistralrs-core/src/layers.rs:1212-1214 | mistralrs-core/src/layers.rs:1275-1279 | mistralrs-core/src/layers.rs:1302-1304 | mistralrs-core/src/layers.rs:1374-1379 | mistralrs-core/src/layers.rs:1544-1548 | mistralrs-core/src/layers.rs:1571-1573 — all 7 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/layers.rs:1185` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. Note first that the copies are not typed on the same thing: the declarations holding them bind `cfg` to `&llama4::TextConfig` in one and `&smollm3::Config` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/layers.rs:1189` calls `arange`, `to_dtype` and `mistralrs-core/src/layers.rs:1214` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (2–5 lines × 11) · ×1
  • Duplicated block (2–5 lines × 11) mistralrs-core/src/cuda/dflash_context.rs:302 — mistralrs-core/src/cuda/dflash_context.rs:302-303 | mistralrs-core/src/cuda/speculative_rejection.rs:614-615 | mistralrs-core/src/ops.rs:1116-1120 | mistralrs-core/src/ops.rs:1345-1349 | mistralrs-core/src/ops.rs:1593-1594 | mistralrs-core/src/ops.rs:1835-1836 | mistralrs-core/src/ops.rs:4151-4152 | mistralrs-core/src/ops.rs:4332-4333 | mistralrs-core/src/ops.rs:5697-5698 | mistralrs-core/src/ops.rs:6120-6121 | mistralrs-core/src/ops.rs:6449-6450 — there are 11 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 11 sites; resolving a subset leaves the remainder to drift apart. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-core/src/cuda/dflash_context.rs:306` calls `try_from`, `map_err` and `mistralrs-core/src/ops.rs:4337` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (3–5 lines × 3) · ×1
  • Duplicated block (3–5 lines × 3) mistralrs-core/src/speculative/config.rs:115 — mistralrs-core/src/speculative/config.rs:115-117 | mistralrs-core/src/speculative/dflash.rs:2239-2243 | mistralrs-core/src/vision_models/gemma4/mtp.rs:127-131 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/speculative/config.rs:115` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (2–5 lines × 13) · ×1
  • Duplicated block (2–5 lines × 13) mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:153 — mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:153-154 | mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:371-372 | mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:377-378 | mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:384-385 | mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:391-392 | mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:639-640 | mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:646-647 | mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:653-654 | mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:659-660 | mistralrs-paged-attn/src/cuda/backend/gather_kv.rs:172-176 | mistralrs-paged-attn/src/cuda/backend/gather_kv.rs:182-186 | mistralrs-paged-attn/src/cuda/backend/gather_kv.rs:200-201 | mistralrs-paged-attn/src/cuda/backend/gather_kv.rs:206-207 — before extracting anything, compare `mistralrs-paged-attn/src/cuda/backend/flashinfer.rs` and `mistralrs-paged-attn/src/cuda/backend/gather_kv.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 39 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/cuda/backend/gather_kv.rs:172` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:380` calls `slice_ptr`, `start_offset` and `mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:156` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (6 lines × 8) · ×1
  • Duplicated block (6 lines × 8) mistralrs-core/src/models/deepseek2.rs:691 — mistralrs-core/src/models/deepseek2.rs:691-696 | mistralrs-core/src/models/deepseek3.rs:754-759 | mistralrs-core/src/models/flint.rs:671-676 | mistralrs-core/src/models/glm4_moe.rs:591-596 | mistralrs-core/src/models/glm4_moe_lite.rs:700-705 | mistralrs-core/src/models/qwen3_moe.rs:439-444 | mistralrs-core/src/vision_models/llama4/text.rs:626-631 | mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs:178-183 — before extracting anything, compare `mistralrs-core/src/models/deepseek2.rs` and `mistralrs-core/src/models/deepseek3.rs` as WHOLE FILES: this scan already matched 59 separate duplicated blocks between them, totalling at least 1246 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (12 lines × 11) · ×1
  • Duplicated block (12 lines × 11) mistralrs-core/src/models/glm4.rs:419 — mistralrs-core/src/models/glm4.rs:419-430 | mistralrs-core/src/models/granite.rs:1927-1938 | mistralrs-core/src/models/hunyuan_v1_dense.rs:372-383 | mistralrs-core/src/models/hunyuan_v1_moe.rs:862-873 | mistralrs-core/src/models/llama.rs:325-336 | mistralrs-core/src/models/mistral.rs:394-405 | mistralrs-core/src/models/qwen3.rs:382-393 | mistralrs-core/src/models/qwen3_moe.rs:556-567 | mistralrs-core/src/models/smollm3.rs:341-352 | mistralrs-core/src/vision_models/llama4/text.rs:774-785 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:407-418 — before extracting anything, compare `mistralrs-core/src/models/glm4.rs` and `mistralrs-core/src/models/granite.rs` as WHOLE FILES: this scan already matched 20 separate duplicated blocks between them, totalling at least 254 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/models/glm4.rs:419` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (10 lines × 15) · ×1
  • Duplicated block (10 lines × 15) mistralrs-core/src/pipeline/loaders/lfm3.rs:48 — mistralrs-core/src/pipeline/loaders/lfm3.rs:48-58 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:2636-2645 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4064-4073 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:4406-4415 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:5643-5652 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6586-6595 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:6987-6996 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7464-7473 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:7939-7948 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:8481-8490 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9093-9102 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9414-9423 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:9994-10003 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:10330-10339 | mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs:10678-10687 — before extracting anything, compare `mistralrs-core/src/pipeline/loaders/lfm3.rs` and `mistralrs-core/src/pipeline/loaders/multimodal_loaders.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 35 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/pipeline/loaders/lfm3.rs:48` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (22 lines × 5) · ×1
  • Duplicated block (22 lines × 5) mistralrs-core/src/gguf/gemma3_bindings.rs:194 — mistralrs-core/src/gguf/gemma3_bindings.rs:194-215 | mistralrs-core/src/gguf/idefics3_bindings.rs:63-84 | mistralrs-core/src/gguf/lfm2_vl_bindings.rs:98-119 | mistralrs-core/src/gguf/llama4_bindings.rs:221-242 | mistralrs-core/src/gguf/muse_glimmer_bindings.rs:133-154 — before extracting anything, compare `mistralrs-core/src/gguf/gemma3_bindings.rs` and `mistralrs-core/src/gguf/muse_glimmer_bindings.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 62 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/gguf/gemma3_bindings.rs:194` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/gguf/muse_glimmer_bindings.rs:129` calls `bind_required_linear` and `mistralrs-core/src/gguf/gemma3_bindings.rs:191` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (2–13 lines × 4) · ×1
  • Duplicated block (2–13 lines × 4) mistralrs-core/src/cuda/speculative_rejection.rs:613 — mistralrs-core/src/cuda/speculative_rejection.rs:613-614 | mistralrs-core/src/ops.rs:5683-5696 | mistralrs-core/src/ops.rs:6107-6119 | mistralrs-core/src/ops.rs:6436-6448 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart.
D4 · Code Duplication · Duplicated block (11 lines × 9) · ×1
  • Duplicated block (11 lines × 9) mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:399 — mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:399-409 | mistralrs-core/src/vision_models/gemma4/inputs_processor.rs:1042-1052 | mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:439-449 | mistralrs-core/src/vision_models/llama4/inputs_processor.rs:409-419 | mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:290-302 | mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:326-338 | mistralrs-core/src/vision_models/minicpmo/inputs_processor.rs:314-324 | mistralrs-core/src/vision_models/mistral3/inputs_processor.rs:271-281 | mistralrs-core/src/vision_models/phi3/phi3_inputs_processor.rs:299-311 — `mistralrs-core/src/vision_models/gemma3/inputs_processor.rs` and `mistralrs-core/src/vision_models/gemma4/inputs_processor.rs` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 6 separate duplicated blocks between them, totalling at least 86 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/vision_models/gemma3/inputs_processor.rs:399` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (10 lines × 24) · ×1
  • Duplicated block (10 lines × 24) mistralrs-core/src/embedding_models/qwen3_embedding.rs:251 — mistralrs-core/src/embedding_models/qwen3_embedding.rs:251-260 | mistralrs-core/src/models/deepseek2.rs:727-736 | mistralrs-core/src/models/deepseek3.rs:790-799 | mistralrs-core/src/models/glm4.rs:337-346 | mistralrs-core/src/models/glm4_moe.rs:627-636 | mistralrs-core/src/models/glm4_moe_lite.rs:736-745 | mistralrs-core/src/models/gpt_oss.rs:652-662 | mistralrs-core/src/models/hunyuan_v1_dense.rs:311-320 | mistralrs-core/src/models/llama.rs:285-294 | mistralrs-core/src/models/mistral.rs:332-341 | mistralrs-core/src/models/mixtral.rs:341-350 | mistralrs-core/src/models/qwen2.rs:364-373 | mistralrs-core/src/models/qwen3.rs:320-329 | mistralrs-core/src/models/smollm3.rs:301-310 | mistralrs-core/src/vision_models/gemma4/text.rs:987-997 | mistralrs-core/src/vision_models/gemma4/text.rs:1058-1067 | mistralrs-core/src/vision_models/llava/llava_llm/llama.rs:356-365 | mistralrs-core/src/vision_models/llava/llava_llm/mistral.rs:338-347 | mistralrs-core/src/vision_models/mllama/text.rs:282-291 | mistralrs-core/src/vision_models/mllama/text.rs:641-650 | mistralrs-core/src/xlora_models/llama.rs:359-368 | mistralrs-core/src/xlora_models/mistral.rs:339-348 | mistralrs-core/src/xlora_models/mixtral.rs:466-475 | mistralrs-core/src/xlora_models/phi3.rs:304-313 — before extracting anything, compare `mistralrs-core/src/embedding_models/qwen3_embedding.rs` and `mistralrs-core/src/models/deepseek2.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 35 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-core/src/embedding_models/qwen3_embedding.rs:251` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (3–7 lines × 11) · ×1
  • Duplicated block (3–7 lines × 11) mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:146 — mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:146-152 | mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:364-370 | mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:375-377 | mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:382-384 | mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:389-391 | mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:632-638 | mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:644-646 | mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:651-653 | mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:657-659 | mistralrs-paged-attn/src/cuda/backend/gather_kv.rs:198-200 | mistralrs-paged-attn/src/cuda/backend/gather_kv.rs:204-206 — before extracting anything, compare `mistralrs-paged-attn/src/cuda/backend/flashinfer.rs` and `mistralrs-paged-attn/src/cuda/backend/gather_kv.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 39 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:146` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:379` calls `slice_ptr`, `start_offset` and `mistralrs-paged-attn/src/cuda/backend/flashinfer.rs:372` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (5 lines × 9) · ×1
  • Duplicated block (5 lines × 9) mistralrs-core/src/metal/gdn.rs:195 — mistralrs-core/src/metal/gdn.rs:195-200 | mistralrs-core/src/metal/gdn.rs:310-315 | mistralrs-core/src/metal/gdn.rs:404-408 | mistralrs-core/src/metal/gdn.rs:556-560 | mistralrs-core/src/metal/gdn.rs:610-614 | mistralrs-core/src/metal/gdn.rs:673-677 | mistralrs-core/src/metal/gdn.rs:786-791 | mistralrs-core/src/metal/gdn.rs:972-977 | mistralrs-core/src/metal/ssm.rs:173-177 — before extracting anything, compare `mistralrs-core/src/metal/gdn.rs` and `mistralrs-core/src/metal/ssm.rs` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 68 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `mistralrs-core/src/metal/gdn.rs:192` calls `metal_buffer_and_offset` and `mistralrs-core/src/metal/gdn.rs:607` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (18–21 lines × 2) · ×1
  • Duplicated block (18–21 lines × 2) releases/v0.9.5/scripts/plot_results.py:118 — releases/v0.9.5/scripts/plot_results.py:118-135 | releases/v0.9.5/scripts/plot_results.py:218-238 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `releases/v0.9.5/scripts/plot_results.py:218` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Members sharing a duplicated core (24 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (24 members, 50+ identical tokens) examples/server/chat.py:8 — examples/server/chat.py:8-28 | examples/server/completion.py:8-28 | examples/server/embedding.py:8-28 | examples/server/gemma3.py:8-28 | examples/server/gemma3n.py:8-28 | examples/server/gpt_oss.py:18-38 | examples/server/idefics2.py:8-28 | examples/server/idefics3.py:8-28 | examples/server/llama4.py:8-28 | examples/server/llama_vision.py:8-28 | examples/server/llava.py:8-28 | examples/server/llava_next.py:8-28 | examples/server/minicpmo_2_6.py:8-28 | examples/server/mistral3.py:8-28 | examples/server/phi3v.py:8-28 | examples/server/phi3v_base64.py:9-29 | examples/server/phi3v_local_img.py:8-28 | examples/server/phi4mm.py:8-28 | examples/server/qwen3.py:8-28 | examples/server/responses.py:18-38 | examples/server/responses_audio.py:8-28 | examples/server/responses_vision.py:8-28 | examples/server/smollm3.py:8-28 | scripts/bench.py:26-46 — These 24 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 24 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 24 times.
D4 · Code Duplication · Duplicated block (39–41 lines × 2) · ×1
  • Duplicated block (39–41 lines × 2) scripts/production_soak.py:3280 — scripts/production_soak.py:3280-3318 | scripts/production_soak.py:4180-4220 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `scripts/production_soak.py:3280` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (22–25 lines × 2) · ×1
  • Duplicated block (22–25 lines × 2) scripts/production_soak.py:2788 — scripts/production_soak.py:2788-2812 | scripts/production_soak.py:3407-3428 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `scripts/production_soak.py:2788` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (21 lines × 24) · ×1
  • Duplicated block (21 lines × 24) examples/server/chat.py:8 — examples/server/chat.py:8-28 | examples/server/completion.py:8-28 | examples/server/embedding.py:8-28 | examples/server/gemma3.py:8-28 | examples/server/gemma3n.py:8-28 | examples/server/gpt_oss.py:18-38 | examples/server/idefics2.py:8-28 | examples/server/idefics3.py:8-28 | examples/server/llama4.py:8-28 | examples/server/llama_vision.py:8-28 | examples/server/llava.py:8-28 | examples/server/llava_next.py:8-28 | examples/server/minicpmo_2_6.py:8-28 | examples/server/mistral3.py:8-28 | examples/server/phi3v.py:8-28 | examples/server/phi3v_base64.py:9-29 | examples/server/phi3v_local_img.py:8-28 | examples/server/phi4mm.py:8-28 | examples/server/qwen3.py:8-28 | examples/server/responses.py:18-38 | examples/server/responses_audio.py:8-28 | examples/server/responses_vision.py:8-28 | examples/server/smollm3.py:8-28 | scripts/bench.py:26-46 — before extracting anything, compare `examples/server/chat.py` and `examples/server/completion.py` as WHOLE FILES: 83% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 1 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `examples/server/completion.py:39` calls `input` and `examples/server/embedding.py:38` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (6–8 lines × 3) · ×1
  • Duplicated block (6–8 lines × 3) scripts/production_soak.py:2686 — scripts/production_soak.py:2686-2691 | scripts/production_soak.py:9033-9040 | scripts/production_soak.py:11311-11316 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
R10 · Code Duplication · Duplicated block (11 lines × 2 locations) · ×1
  • Duplicated block (11 lines × 2 locations) mistralrs-cli/webui/src/lib/components/AssistantMessage.svelte:29 — mistralrs-cli/webui/src/lib/components/AssistantMessage.svelte:29 · mistralrs-cli/webui/src/lib/components/UserMessage.svelte:64 — the 2 copies are spread across 2 files, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
R10 · Code Duplication · Duplicated block (8 lines × 2 locations) · ×1
  • Duplicated block (8 lines × 2 locations) mistralrs-cli/webui/src/lib/components/FileCard.svelte:27 — mistralrs-cli/webui/src/lib/components/FileCard.svelte:27 · mistralrs-cli/webui/src/lib/services/streaming.ts:11 — the 2 copies are spread across 2 directories, so the shared home is a decision rather than an obvious spot: check first whether one of them already owns this behaviour, and otherwise put the extracted module somewhere all of the sites already reach rather than making one of them depend on another.
R10 · Code Duplication · Duplicated block (7 lines × 2 locations) · ×1
  • Duplicated block (7 lines × 2 locations) mistralrs-cli/webui/src/lib/services/api.ts:30 — mistralrs-cli/webui/src/lib/services/api.ts:30 · mistralrs-cli/webui/src/lib/services/api.ts:40 — all 2 copies are in the same file, and the CITED SPAN is not a self-contained block — it runs from inside one construct into the next (the tail of a branch plus the head of the following one, a run of switch arms, the end of a declaration plus the list that follows it) rather than covering a whole unit. So do not lift these lines literally: no call can be substituted for a half-open construct. Extract the enclosing repeated UNIT instead — the whole function, component or branch these lines sit in — and where the repetition IS the construct (a run of switch arms, a stack of near-identical declarations) replace it with one table or registry looked up by key rather than a helper each arm calls. The copies still drift apart the first time only one of them is edited, which is why this is reported.
R2 · Cyclomatic Complexity · Complex function streamChatCompletion (cyclomatic 43, cognitive 91) · ×1
  • Complex function streamChatCompletion (cyclomatic 43, cognitive 91) mistralrs-cli/webui/src/lib/services/streaming.ts:21 — streamChatCompletion has cyclomatic complexity 43 and cognitive complexity 91; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
R2 · Cyclomatic Complexity · Complex function fetch (cyclomatic 16, cognitive 19) · ×1
  • Complex function fetch (cyclomatic 16, cognitive 19) mistralrs-cli/webui/tests/chat-store.test.mjs:45 — fetch has cyclomatic complexity 16 and cognitive complexity 19; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
R2 · Cyclomatic Complexity · Complex function onToolCallProgress (cyclomatic 15, cognitive 16) · ×1
  • Complex function onToolCallProgress (cyclomatic 15, cognitive 16) mistralrs-cli/webui/src/lib/stores/chat.svelte.ts:445 — onToolCallProgress has cyclomatic complexity 15 and cognitive complexity 16; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
R2 · Cyclomatic Complexity · Complex function buildApiMessages (cyclomatic 14, cognitive 18) · ×1
  • Complex function buildApiMessages (cyclomatic 14, cognitive 18) mistralrs-cli/webui/src/lib/stores/chat.svelte.ts:344 — buildApiMessages has cyclomatic complexity 14 and cognitive complexity 18; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
R2 · Cyclomatic Complexity · Complex function finalizeStreaming (cyclomatic 13, cognitive 13) · ×1
  • Complex function finalizeStreaming (cyclomatic 13, cognitive 13) mistralrs-cli/webui/src/lib/stores/chat.svelte.ts:573 — finalizeStreaming has cyclomatic complexity 13 and cognitive complexity 13; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive is at or above cyclomatic here, so the branching is nested or entangled rather than laid out side by side — extracting each decision into its own named function is the change that pays. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
R2 · Cyclomatic Complexity · Complex function addFile (cyclomatic 12, cognitive 11) · ×1
  • Complex function addFile (cyclomatic 12, cognitive 11) mistralrs-cli/webui/src/lib/components/ChatInput.svelte:136 — addFile has cyclomatic complexity 12 and cognitive complexity 11; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
R2 · Cyclomatic Complexity · Complex function generateAssistant (cyclomatic 11, cognitive 10) · ×1
  • Complex function generateAssistant (cyclomatic 11, cognitive 10) mistralrs-cli/webui/src/lib/stores/chat.svelte.ts:378 — generateAssistant has cyclomatic complexity 11 and cognitive complexity 10; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
R2 · Cyclomatic Complexity · Complex function loadChat (cyclomatic 11, cognitive 9) · ×1
  • Complex function loadChat (cyclomatic 11, cognitive 9) mistralrs-cli/webui/src/lib/stores/chat.svelte.ts:718 — loadChat has cyclomatic complexity 11 and cognitive complexity 9; this row is raised above a cyclomatic bar of 10. The two numbers answer different questions and the gap between them is what decides whether to act: cyclomatic counts the independent arms through the body, cognitive counts what it costs to hold them in your head, so nesting and mixed boolean chains raise it while a flat run of independent arms does not. Cognitive sits below cyclomatic here, so much of the count is breadth — arms side by side rather than stacked — and splitting per arm would leave a function per arm; group the work between the checks into named steps instead. Measured by this repository's own parse of the file, so a body assembled at runtime, or generated, is counted as written rather than as it executes.
R3 · Large Files · mistralrs-cli/webui/src/lib/stores/chat.svelte.ts · ×1
  • mistralrs-cli/webui/src/lib/stores/chat.svelte.ts: 718 lines of code mistralrs-cli/webui/src/lib/stores/chat.svelte.ts:1 — mistralrs-cli/webui/src/lib/stores/chat.svelte.ts has 718 significant lines (blank lines excluded), over the 400-line bar, and contains logic — a file this long is usually several responsibilities in one module.
Minor — 124 finding(s)
X10 · Duplicated predicate · Duplicated predicate · ×40
  • Duplicated predicate mistralrs-core/src/flashinfer/mod.rs:536 — `!cfg!(feature = "cuda") || !crate::perf_flags::flashinfer_decode_enabled()` appears character-identically in 2 files — mistralrs-core/src/flashinfer/mod.rs, mistralrs-core/src/vision_models/gemma4/text.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate mistralrs-code-exec/src/lib.rs:346 — `!effective.rlimits_applied && sandbox.name() != "macos"` appears character-identically in 2 files — mistralrs-code-exec/src/lib.rs, mistralrs-code-exec/src/shell.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate mistralrs-quant/src/lib.rs:1823 — `!global_scale.is_finite() || global_scale <= 0.0` appears character-identically in 2 files — mistralrs-quant/src/lib.rs, mistralrs-quant/src/nvfp4/embedding.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate mistralrs-pyo3/src/lib.rs:291 — `!image_urls.is_empty() || !audio_urls.is_empty() || !video_urls.is_empty()` appears character-identically in 2 files — mistralrs-pyo3/src/lib.rs, mistralrs-server-core/src/chat_completion.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate mistralrs-core/src/sampler.rs:783 — `!inverse_temperature.is_finite() || inverse_temperature <= 0.0` appears character-identically in 2 files — mistralrs-core/src/sampler.rs, mistralrs-core/src/vision_models/qwen3_5/speculative.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate mistralrs-core/src/paged_attention/windowed_pool.rs:620 — `!key_cache.is_contiguous() || !value_cache.is_contiguous()` appears character-identically in 2 files — mistralrs-core/src/paged_attention/windowed_pool.rs, mistralrs-paged-attn/src/cuda/backend/cache.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate mistralrs-core/src/vision_models/qwen3_5/text.rs:1442 — `!meta.is_first_prompt_chunk && meta.num_cached_tokens.is_none()` appears character-identically in 2 files — mistralrs-core/src/vision_models/qwen3_5/text.rs, mistralrs-core/src/vision_models/qwen4_exp/text.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate mistralrs-core/src/engine/add_request.rs:996 — `!pipeline.get_metadata().no_kv_cache && pipeline.cache().is_hybrid()` appears character-identically in 2 files — mistralrs-core/src/engine/add_request.rs, mistralrs-core/src/engine/mod.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate mistralrs-core/src/pipeline/multimodal.rs:2853 — `!self.model.has_speculative_proposer() || self.model.supports_speculative_packed_prefill()` appears character-identically in 2 files — mistralrs-core/src/pipeline/multimodal.rs, mistralrs-core/src/pipeline/normal.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate mistralrs-core/src/vision_models/qwen3_5/config.rs:273 — `!self.partial_rotary_factor().is_finite() || self.partial_rotary_factor() <= 0.0 || self.partial_rotary_factor() > 1.0` appears character-identically in 2 files — mistralrs-core/src/vision_models/qwen3_5/config.rs, mistralrs-core/src/vision_models/qwen3_5_moe/config.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate mistralrs-core/src/vision_models/qwen3_5/config.rs:270 — `!self.rope_theta().is_finite() || self.rope_theta() <= 0.0` appears character-identically in 2 files — mistralrs-core/src/vision_models/qwen3_5/config.rs, mistralrs-core/src/vision_models/qwen3_5_moe/config.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate mistralrs-core/src/vision_models/idefics3/inputs_processor.rs:373 — `!seq.has_images() || seq.multimodal.has_changed_prompt` appears character-identically in 3 files — mistralrs-core/src/vision_models/idefics3/inputs_processor.rs, mistralrs-core/src/vision_models/lfm2_vl/inputs_processor.rs, mistralrs-core/src/vision_models/mistral3/inputs_processor.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate mistralrs-core/src/models/qwen3_next.rs:656 — `!x.device().same_device(cache.conv_state.device()) || !x.device().same_device(cache.recurrent_state.device())` appears character-identically in 2 files — mistralrs-core/src/models/qwen3_next.rs, mistralrs-core/src/vision_models/qwen3_5/packed_gdn.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate mistralrs-core/src/embedding_models/qwen3_embedding.rs:28 — `$cfg.sliding_window.is_some() && $cfg.use_sliding_window && $layer_idx >= $cfg.max_window_layers` appears character-identically in 3 files — mistralrs-core/src/embedding_models/qwen3_embedding.rs, mistralrs-core/src/models/qwen3.rs, mistralrs-core/src/models/qwen3_moe.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate mistralrs-quant/src/blockwise_fp8/mma.rs:172 — `activation.dtype() != DType::F8E4M3 || activation_scales.dtype() != DType::F32` appears character-identically in 2 files — mistralrs-quant/src/blockwise_fp8/mma.rs, mistralrs-quant/src/blockwise_fp8/ops.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate mistralrs-core/src/model_loader.rs:318 — `args.hf_config_overrides.is_some() && !supports_hf_config_overrides` appears character-identically in 2 files — mistralrs-core/src/model_loader.rs, mistralrs-core/src/toml_selector.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate mistralrs-core/src/model_loader.rs:328 — `args.max_model_len.is_some() && !supports_max_model_len` appears character-identically in 2 files — mistralrs-core/src/model_loader.rs, mistralrs-core/src/toml_selector.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate REDACTED:1155 — `args.packed_prefill && args.packed_layout.is_none()` appears character-identically in 2 files — REDACTED, mistralrs-core/src/vision_models/llama4/mod.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate mistralrs-core/src/vision_models/gemma3n/audio.rs:689 — `b == batch_size && n == num_query_blocks` appears character-identically in 2 files — mistralrs-core/src/vision_models/gemma3n/audio.rs, mistralrs-core/src/vision_models/gemma4/audio.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate mistralrs-code-exec/src/shell.rs:468 — `c.is_ascii_alphanumeric() || c == '-' || c == '_'` appears character-identically in 2 files — mistralrs-code-exec/src/shell.rs, mistralrs-core/src/engine/agentic_loop.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate mistralrs-core/src/models/qwen3_moe.rs:479 — `cfg.num_experts > 0 && (layer_idx + 1).is_multiple_of(cfg.decoder_sparse_step)` appears character-identically in 2 files — mistralrs-core/src/models/qwen3_moe.rs, mistralrs-core/src/vision_models/qwen3_vl_moe/text.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate mistralrs-core/src/pipeline/loaders/embedding_loaders.rs:664 — `cfg.use_sliding_window && cfg.sliding_window.is_some()` appears character-identically in 2 files — mistralrs-core/src/pipeline/loaders/embedding_loaders.rs, mistralrs-core/src/pipeline/loaders/normal_loaders.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate mistralrs-core/src/vision_models/gemma3n/text.rs:1265 — `context_lens.is_empty() || context_lens.len() != seqlen_offsets.len()` appears character-identically in 2 files — mistralrs-core/src/vision_models/gemma3n/text.rs, mistralrs-core/src/vision_models/gemma4/text.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate mistralrs-core/src/vision_models/gemma3/text.rs:612 — `ctx.prompt_chunk_attention_policy() == MultimodalAttentionPolicy::NonCausal && q_len > 1` appears character-identically in 2 files — mistralrs-core/src/vision_models/gemma3/text.rs, mistralrs-core/src/vision_models/gemma4/text.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate mistralrs-core/src/engine/agentic_loop.rs:726 — `decision.approve && decision.remember_for_session` appears character-identically in 2 files — mistralrs-core/src/engine/agentic_loop.rs, mistralrs-server-core/src/approvals.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • + 15 more in this group — see findings.md.
X4 · Structured logging · Interpolated log message defeats structured logging · ×40
  • Interpolated log message defeats structured logging mistralrs-server-core/src/chat_completion.rs:121 — `warn!` at line 121 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging mistralrs-server-core/src/chat_completion.rs:657 — `warn!` at line 657 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging mistralrs-server-core/src/metrics.rs:441 — `debug!` at line 441 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging mistralrs-server-core/src/metrics.rs:483 — `debug!` at line 483 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging mistralrs-server-core/src/metrics.rs:875 — `info!` at line 875 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging mistralrs-server-core/src/metrics.rs:879 — `info!` at line 879 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging mistralrs-server-core/src/metrics.rs:884 — `info!` at line 884 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging mistralrs-server-core/src/metrics.rs:942 — `info!` at line 942 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging mistralrs-server-core/src/metrics.rs:966 — `info!` at line 966 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging mistralrs-server-core/src/mistralrs_for_server_builder.rs:1057 — `info!` at line 1057 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging mistralrs-server-core/src/mistralrs_for_server_builder.rs:1062 — `info!` at line 1062 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging mistralrs-server-core/src/mistralrs_for_server_builder.rs:1139 — `info!` at line 1139 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging mistralrs-server-core/src/mistralrs_for_server_builder.rs:1293 — `info!` at line 1293 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging mistralrs-server-core/src/mistralrs_for_server_builder.rs:1298 — `info!` at line 1298 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging mistralrs-server-core/src/mistralrs_for_server_builder.rs:1314 — `info!` at line 1314 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging mistralrs-server-core/src/mistralrs_for_server_builder.rs:1318 — `info!` at line 1318 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging mistralrs-server-core/src/mistralrs_for_server_builder.rs:1320 — `info!` at line 1320 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging mistralrs-server-core/src/mistralrs_for_server_builder.rs:1404 — `debug!` at line 1404 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging mistralrs-server-core/src/mistralrs_for_server_builder.rs:1413 — `debug!` at line 1413 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging mistralrs-server-core/src/openai.rs:1110 — `warn!` at line 1110 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging mistralrs-server-core/src/streaming.rs:188 — `warn!` at line 188 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging mistralrs-sandbox/src/linux/cgroups.rs:28 — `debug!` at line 28 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging mistralrs-sandbox/src/linux/cgroups.rs:34 — `debug!` at line 34 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging mistralrs-sandbox/src/linux/cgroups.rs:37 — `debug!` at line 37 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging mistralrs-sandbox/src/linux/mod.rs:81 — `debug!` at line 81 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • + 15 more in this group — see findings.md.
D29 · Static Analysis (SAST) · REDACTED · ×11
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
X6 · Hand-rolled structured-format parsing · Hand-rolled JSON/XML parsing via regex · ×4
  • Hand-rolled JSON/XML parsing via regex mistralrs-core/src/vision_models/llava/llava_inputs_processor.rs:57 — A regex whose pattern encodes JSON/XML syntax is parsing a structured format by hand — malformed or differently-typed content (e.g. `"amount": "5"` as a string) silently mis-parses instead of failing validation. This Rust code already uses a real parser in the same package; use it here too.
  • Hand-rolled JSON/XML parsing via regex mistralrs-core/src/vision_models/llava/llava_next_inputs_processor.rs:59 — A regex whose pattern encodes JSON/XML syntax is parsing a structured format by hand — malformed or differently-typed content (e.g. `"amount": "5"` as a string) silently mis-parses instead of failing validation. This Rust code already uses a real parser in the same package; use it here too.
  • Hand-rolled JSON/XML parsing via regex mistralrs-core/src/tools/parsers/qwen.rs:54 — A regex whose pattern encodes JSON/XML syntax is parsing a structured format by hand — malformed or differently-typed content (e.g. `"amount": "5"` as a string) silently mis-parses instead of failing validation. This Rust code already uses a real parser in the same package; use it here too.
  • Hand-rolled JSON/XML parsing via regex mistralrs-core/src/tools/parsers/qwen.rs:121 — A regex whose pattern encodes JSON/XML syntax is parsing a structured format by hand — malformed or differently-typed content (e.g. `"amount": "5"` as a string) silently mis-parses instead of failing validation. This Rust code already uses a real parser in the same package; use it here too.
D34 · Knowledge Freshness · Orphaned file · ×3
  • Orphaned file mistralrs-core/src/vision_models/llava/utils.rs:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file scripts/convert_awq_marlin.py:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file mistralrs-paged-attn/src/cuda/backend/scale_update.rs:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
D31 · IaC & Container Security · Low IaC · ×2
  • REDACTED
  • REDACTED
X7 · Silent fallback defaults · Silent fallback default in catch · ×2
  • Silent fallback default in catch docs/scripts/render_pyi.py:165 — `_unparse` swallows every exception into `return ''` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
  • Silent fallback default in catch mistralrs-cli/webui/src/lib/services/streaming.ts:16 — `getApiBase` swallows every exception into `return "/"` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
C2 · Access Controls · No named authorization policies · ×1
  • No named authorization policies — Authorization IS enforced here (by route guards, auth middleware or checks that refuse a caller) — this is NOT a claim that endpoints are unprotected. What's missing is a NAMED rule set: who may do what is encoded inline where it is checked, so the rules can't be listed, reviewed or tested apart from the code that applies them. Recommendation, not a defect.
C2 · Access Controls · Thin authorization enforcement · ×1
  • Thin authorization enforcement — Only 1 place(s) refuse an unauthorized caller — too few to demonstrate default-deny across handlers.
D20 · ADR Quality · No ADRs found · ×1
  • No ADRs found mistralrs-cli/Cargo.toml:16 — No ADRs found. No recognised ADR directory (`docs/adr/`, `docs/decisions/`, `adr/`, `docs/rfcs/`, an `ADR0001/` folder, or their siblings) exists anywhere in this tree. What was searched, so you can tell an empty log from a search that missed one: every directory under the tree (build output, dependencies and VCS metadata excepted), for a document that is either any non-index page inside a recognised ADR directory, whatever its name and however deeply nested (`docs/adr/use-postgres.md`, `docs/adr/2024/0001-x.md`); or a file anywhere whose name is ADR-shaped (`0001-use-postgres.md`, `adr-012-caching.md`); or, when neither turned anything up, a document carrying the decision-record signature (an "Architecture Decision Record" heading, or Status / Context / Decision / Consequences as section headings). A decision log that clears none of these — unnumbered files outside any recognised directory, without those headings — is not seen by this check and this row is then wrong. If that is your case, say so rather than renaming anything; otherwise, consider recording architectural decisions in `docs/adr/`. ADRs are expected here because `mistralrs-cli/Cargo.toml` makes this repository a deployable product (line 16).
D21 · Naming Consistency · `OpenAIInputContent` spells `AI` where 23 names in the project spell it `Ai` · ×1
  • `OpenAIInputContent` spells `AI` where 23 names in the project spell it `Ai` mistralrs-server-core/src/responses_types/content.rs:93 — 23 of 24 names in project mistralrs_server_core spell the token `Ai` (23 of 24; unit: names in project mistralrs_server_core containing `Ai`). Peers: mistralrs_server_core.handler_core.OpenAiErrorBody (mistralrs-server-core/src/handler_core.rs:328); mistralrs_server_core.handler_core.OpenAiErrorResponse (mistralrs-server-core/src/handler_core.rs:337); mistralrs_server_core.openai.OpenAiFunctionToolType (mistralrs-server-core/src/openai.rs:630); mistralrs_server_core.openai.OpenAiWebSearchToolType (mistralrs-server-core/src/openai.rs:636); mistralrs_server_core.openai.OpenAiCodeInterpreterToolType (mistralrs-server-core/src/openai.rs:644). Rename to `OpenAiInputContent`. [rule N6]
D26 · Project Cohesion · Projects may be oversized for their cohesion · ×1
  • Projects may be oversized for their cohesion — 3 of 18 project(s) overshoot their size bounds, lowering Project Cohesion to 6.7/10. The most over is `mistralrs-core` (342833 LoC, 1466 module-visible types across 75 directories). Review these for cohesion — draw the boundary inside the module first (group each responsibility into its own package or directory and keep the cross-boundary members non-public), since splitting a published package moves types between packages and breaks consumers.
D28 · Secrets (history) · Rotate the exposed credentials · ×1
  • REDACTED
D34 · Knowledge Freshness · Orphaned files with no living knowledge · ×1
  • Orphaned files with no living knowledge — 3 of 742 analysed file(s) have no living knowledge left — their last meaningful change has decayed away, so if one breaks, no one currently understands it (counted over production source files of roughly 2,400 bytes or more, excluding vendored, generated, example/demo and scaffolding-template trees and test files identified by path convention, largest first; 742 of the 860 production source files in this repository met that bar). None is large enough to earn a read-through of its own, so this row stands in for the per-file rows rather than raising one each — most significant first: mistralrs-core/src/vision_models/llava/utils.rs, scripts/convert_awq_marlin.py, mistralrs-paged-attn/src/cuda/backend/scale_update.rs. Attach the read to the next change that touches one of them: have a second person review that change, and leave behind a short comment or test recording what the file is for, so the knowledge comes back at the cost of a change you were making anyway.
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
M2 · Architecture documentation · No ADRs · ×1
  • No ADRs — No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.
M4 · Documentation accuracy · README/code drift · ×1
  • README/code drift mistralrs-mcp/README.md:54 — mistralrs-mcp/README.md links to `../docs/MCP/README.md`, but `docs/MCP/README.md` does not exist. Checked without a model against the repository: its files and folders, the scripts and dependencies of every package.json, the projects, namespaces, package references and target frameworks of the .NET build, the SDK and Node pins, and the identifiers of every file that is not a document; the documents' own text never counts. A footprint generated at build time, read only by a platform, or living outside this repository is not seen, and this row is then wrong.
P3 · Security & performance tooling · No dependency-update automation · ×1
  • No dependency-update automation docs/package.json:19 — `docs/package.json` declares packages, and nothing in the repository keeps them current: no Dependabot or Renovate configuration that schedules updates, and no dependency-review gate on pull requests. A pinned dependency stays at the version it was added at until someone notices — including after an advisory is published against it. Add a `.github/dependabot.yml` with one `package-ecosystem` entry per ecosystem the tree uses (or an enabled `renovate.json`), and gate pull requests with `actions/dependency-review-action`.
R7 · Dead Code · Unused export 'uploadImage' · ×1
  • Unused export 'uploadImage' mistralrs-cli/webui/src/lib/services/api.ts:145 — Nothing imports this binding — it is safe to review for removal.
R7 · Dead Code · Unused export 'uploadText' · ×1
  • Unused export 'uploadText' mistralrs-cli/webui/src/lib/services/api.ts:149 — Nothing imports this binding — it is safe to review for removal.
R7 · Dead Code · Unused export 'uploadAudio' · ×1
  • Unused export 'uploadAudio' mistralrs-cli/webui/src/lib/services/api.ts:153 — Nothing imports this binding — it is safe to review for removal.
R7 · Dead Code · Unused export 'uploadVideo' · ×1
  • Unused export 'uploadVideo' mistralrs-cli/webui/src/lib/services/api.ts:157 — Nothing imports this binding — it is safe to review for removal.
R7 · Dead Code · Unused export 'generateSpeech' · ×1
  • Unused export 'generateSpeech' mistralrs-cli/webui/src/lib/services/api.ts:163 — Nothing imports this binding — it is safe to review for removal.
S1 · Web-Security Posture · No app-layer HTTPS enforcement detected · ×1
  • No app-layer HTTPS enforcement detected — This repository starts an HTTP server and nothing in its Rust source or committed `Rocket.toml` secures the transport: no TLS served (actix-web `bind_rustls`/`bind_openssl`, axum-server `bind_rustls` with a `RustlsConfig`, tonic `ServerTlsConfig`, a `TlsAcceptor`, Rocket's `[default.tls]`), no `Strict-Transport-Security` header, no `X-Forwarded-Proto` read from a TLS-terminating proxy — so its traffic may cross the network in clear text. (−2.0 on this card.) The server: `axum::serve(` (mistralrs-cli/src/commands/config.rs:198).
X2 · Cancellation propagation · Not all async functions that make a request accept an AbortSignal · ×1
  • Not all async functions that make a request accept an AbortSignal — Only 1/6 async functions that make a cancellable request (fetch, axios, ky, ofetch, got, undici, node:http) accept an AbortSignal or pass one on, so a request keeps running after whatever wanted it has given up — a page navigated away from, an unmounted component, a timed-out job. Take a `signal` (or an options object that carries one) and hand it to the request; where nothing could ever cancel the call, omitting it is a deliberate choice — judge against how the function is used.
X5 · Nullable reference types · Strict null checking is not enabled everywhere the repository type-checks · ×1
  • Strict null checking is not enabled everywhere the repository type-checks — 1/2 of this repository's type-checking configuration(s) turn on strict null checking (`"strict": true`, or `"strictNullChecks": true`). A configuration that states neither is counted as OFF, because off is tsc's own default; a solution-style one whose `"files"` is empty and whose `"references"` point at other projects is in neither number, because it checks no source itself. Where it is off, `string` admits `null` and `undefined`: passing a value that is null compiles silently and throws on the first property access.
X5 · Nullable reference types · Null assertions (`!`) override strict null checking · ×1
  • Null assertions (`!`) override strict null checking — ~1.6 `!` null assertions per 1k TypeScript source lines — 3 assertion(s) across the 1902 source line(s) of the 10 TypeScript file(s) read, which is the only code the operator asserts anything in (a `!` in a `.js` file is not this operator and was not counted, and one in a file whose null checking is off silences nothing). Densest: mistralrs-cli/webui/src/lib/stores/chat.svelte.ts (1), mistralrs-cli/webui/src/lib/utils/markdown.ts (1), mistralrs-cli/webui/src/main.ts (1). Each one tells the compiler to trust the author about null, suppressing the very diagnostic `strictNullChecks` exists to produce. Many are correct: each is a claim the checker could not verify, and it is wrong only where the value can in fact be missing, so review the densest places first.
X7 · Silent fallback defaults · Silent fallback default on Err · ×1
  • Silent fallback default on Err mistralrs-code-exec/src/lib.rs:149 — `resolve_python_prefixes` turns every `Err` into `Vec::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
Minor — 30 finding(s)
D12 · Dependency Hygiene · Outdated · ×30
  • Outdated: anyhow — `anyhow` is locked at 1.0.100 but 1.0.104 is the current stable release on crates.io, and it already satisfies the `"1.0.100"` requirement declared in mistralrs-audio/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p anyhow` and commit the updated REDACTED.
  • Outdated: bytemuck — `bytemuck` is locked at 1.24.0 but 1.25.2 is the current stable release on crates.io, and it already satisfies the `"1.24.0"` requirement declared in mistralrs-core/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p bytemuck` and commit the updated REDACTED.
  • Outdated: bytemuck_derive — `bytemuck_derive` is locked at 1.10.2 but 1.12.1 is the current stable release on crates.io, and it already satisfies the `"1.10.2"` requirement declared in mistralrs-core/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p bytemuck_derive` and commit the updated REDACTED.
  • Outdated: chrono — `chrono` is locked at 0.4.43 but 0.4.45 is the current stable release on crates.io, and it already satisfies the `"0.4.43"` requirement declared in mistralrs-cli/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p chrono` and commit the updated REDACTED.
  • Outdated: ctrlc — `ctrlc` is locked at 3.5.1 but 3.5.2 is the current stable release on crates.io, and it already satisfies the `"3.5.1"` requirement declared in mistralrs-cli/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p ctrlc` and commit the updated REDACTED.
  • Outdated: dispatch2 — `dispatch2` is locked at 0.3.0 but 0.3.1 is the current stable release on crates.io, and it already satisfies the `"0.3.0"` requirement declared in mistralrs-core/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p dispatch2` and commit the updated REDACTED.
  • Outdated: either — `either` is locked at 1.15.0 but 1.19.0 is the current stable release on crates.io, and it already satisfies the `"1.15.0"` requirement declared in mistralrs-cli/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p either` and commit the updated REDACTED.
  • Outdated: indexmap — `indexmap` is locked at 2.13.0 but 2.14.2 is the current stable release on crates.io, and it already satisfies the `"2.13.0"` requirement declared in mistralrs-cli/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p indexmap` and commit the updated REDACTED.
  • Outdated: indicatif — `indicatif` is locked at 0.18.3 but 0.18.6 is the current stable release on crates.io, and it already satisfies the `"0.18.3"` requirement declared in mistralrs-core/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p indicatif` and commit the updated REDACTED.
  • Outdated: interprocess — `interprocess` is locked at 2.2.3 but 2.4.8 is the current stable release on crates.io, and it already satisfies the `"2.2.3"` requirement declared in mistralrs-core/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p interprocess` and commit the updated REDACTED.
  • Outdated: itoa — `itoa` is locked at 1.0.18 but 1.0.19 is the current stable release on crates.io, and it already satisfies the `"1.0.18"` requirement declared in mistralrs-sandbox/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p itoa` and commit the updated REDACTED.
  • Outdated: landlock — `landlock` is locked at 0.4.4 but 0.4.7 is the current stable release on crates.io, and it already satisfies the `"0.4.4"` requirement declared in mistralrs-sandbox/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p landlock` and commit the updated REDACTED.
  • Outdated: lazy_static — `lazy_static` is locked at 1.5.0 but 1.5.1 is the current stable release on crates.io, and it already satisfies the `"1.5"` requirement declared in mistralrs-quant/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p lazy_static` and commit the updated REDACTED.
  • Outdated: libc — `libc` is locked at 0.2.186 but 0.2.191 is the current stable release on crates.io, and it already satisfies the `"0.2.180"` requirement declared in mistralrs-code-exec/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p libc` and commit the updated REDACTED.
  • Outdated: llguidance — `llguidance` is locked at 1.4.0 but 1.9.1 is the current stable release on crates.io, and it already satisfies the `"1.2.0"` requirement declared in mistralrs-core/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p llguidance` and commit the updated REDACTED.
  • Outdated: ordered-float — `ordered-float` is locked at 5.1.0 but 5.5.1 is the current stable release on crates.io, and it already satisfies the `"5.1.0"` requirement declared in mistralrs-core/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p ordered-float` and commit the updated REDACTED.
  • Outdated: proc-macro2 — `proc-macro2` is locked at 1.0.106 but 1.0.107 is the current stable release on crates.io, and it already satisfies the `"1.0"` requirement declared in mistralrs-macros/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p proc-macro2` and commit the updated REDACTED.
  • Outdated: rayon — `rayon` is locked at 1.11.0 but 1.12.0 is the current stable release on crates.io, and it already satisfies the `"1.11.0"` requirement declared in mistralrs-core/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p rayon` and commit the updated REDACTED.
  • Outdated: regex — `regex` is locked at 1.12.4 but 1.13.1 is the current stable release on crates.io, and it already satisfies the `"1.12.4"` requirement declared in mistralrs-cli/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p regex` and commit the updated REDACTED.
  • Outdated: rustc-hash — `rustc-hash` is locked at 2.1.1 but 2.1.3 is the current stable release on crates.io, and it already satisfies the `"2.1.1"` requirement declared in mistralrs-core/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p rustc-hash` and commit the updated REDACTED.
  • Outdated: schemars — `schemars` is locked at 1.2.0 but 1.2.3 is the current stable release on crates.io, and it already satisfies the `"1.2.0"` requirement declared in mistralrs-core/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p schemars` and commit the updated REDACTED.
  • Outdated: tempfile — `tempfile` is locked at 3.25.0 but 3.27.0 is the current stable release on crates.io, and it already satisfies the `"3"` requirement declared in mistralrs-code-exec/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p tempfile` and commit the updated REDACTED.
  • Outdated: thiserror — `thiserror` is locked at 2.0.18 but 2.0.21 is the current stable release on crates.io, and it already satisfies the `"2.0.18"` requirement declared in mistralrs-core/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p thiserror` and commit the updated REDACTED.
  • Outdated: toktrie — `toktrie` is locked at 1.4.0 but 1.9.1 is the current stable release on crates.io, and it already satisfies the `"1.4.0"` requirement declared in mistralrs-core/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p toktrie` and commit the updated REDACTED.
  • Outdated: toktrie_hf_tokenizers — `toktrie_hf_tokenizers` is locked at 1.4.0 but 1.9.1 is the current stable release on crates.io, and it already satisfies the `"1.2.0"` requirement declared in mistralrs-core/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p toktrie_hf_tokenizers` and commit the updated REDACTED.
  • + 5 more in this group — see findings.md.

Appendix B — Reproduction & audit trail

Every external tool invocation behind a deep-scan dimension — the tool, its captured version, the exact command, how many findings it yielded, and a link to the retained raw output. To reproduce any finding: check out the same commit and run the command shown (repo-relative — never an absolute scratch path). The complete raw scanner output is retained verbatim under artifacts/raw/ (indexed in artifacts/raw/index.json); per-invocation exit codes and wall-clock durations are in sidecar.json — kept out of this table so the rendered report stays byte-identical across runs of the same commit.

DimensionToolVersionCommandFindingsRaw output
D28 · Secrets (history)gitleaks—gitleaks detect --no-banner --config /opt/gitleaks-rules/canine-gitleaks.toml --report-format json --report-path /tmp/watchdog-gitleaks-f8f7402f96f24427957447eb848f3713/history.json --exit-code 0 --source .4artifacts/raw/gitleaks-history.json
D28 · Secrets (history)gitleaks—gitleaks detect --no-git --no-banner --config /opt/gitleaks-rules/canine-gitleaks.toml --report-format json --report-path /tmp/watchdog-gitleaks-f8f7402f96f24427957447eb848f3713/tree.json --exit-code 0 --source .4artifacts/raw/gitleaks-tree.json
D29 · Static Analysis (SAST)semgrep—semgrep --config /opt/semgrep-rules/security-audit.yml --config /opt/semgrep-rules/owasp-top-ten.yml --config /opt/semgrep-rules/canine-sast.yml --json --quiet --timeout 10 --timeout-threshold 3 --metrics off --exclude *.arrow --exclude *.avro --exclude *.csv --exclude *.dat --exclude *.db --exclude *.feather --exclude *.geojson --exclude *.h5 --exclude *.hdf5 --exclude *.jsonl --exclude *.log --exclude *.ndjson --exclude *.npy --exclude *.npz --exclude *.orc --exclude *.parquet --exclude *.pickle --exclude *.pkl --exclude *.psv --exclude *.sqlite --exclude *.sqlite3 --exclude *.tfrecord --exclude *.tsv --exclude *.txt --exclude docs/src/content/docs/examples/python --exclude docs/src/content/docs/examples/rust --exclude docs/src/content/docs/examples/server --exclude docs/src/content/docs/reference/cli --exclude mistralrs-paged-attn/third_party/flash-attention/hopper/instantiations --exclude website .130artifacts/raw/semgrep.json
D30 · Dependency Vulnerabilitiestrivy—trivy fs --scanners vuln --format json --quiet --severity CRITICAL,HIGH,MEDIUM,LOW --skip-dirs **/bin/** --skip-dirs **/obj/** .16artifacts/raw/trivy-fs.json
D31 · IaC & Container Securitytrivy—trivy config --format json --quiet .21artifacts/raw/trivy-config.json
D32 · Data Compliance (PII/GDPR)semgrep—semgrep: not applicable — No personal data was found crossing a boundary the PII/GDPR ruleset checks — nothing written to a log or console sink, placed in a URL or query string, or persisted to browser storage. That is a clean result for the LEAK surface only: this ruleset detects personal data escaping, it does not inventory the personal data a repository holds, so it is not evidence that this repository has no personal-data surface. The personal-data map (Appendix C) and the C1-C5 compliance cards are what speak to that.0—
D40 · Network Egress Confinementruntime-hardening—runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; network egress policy is a cluster-native control that may live at the platform/firewall layer, so there is nothing to assess here.0—
D41 · Kernel & Syscall Confinementruntime-hardening—runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; seccomp/AppArmor/SELinux confinement is a workload-level control, so there is nothing to assess here.0—
D42 · Runtime Threat Enforcementruntime-hardening—runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; runtime threat-detection and admission-control policy are cluster-level controls, so there is nothing to assess here.0—
D43 · Malicious Dependenciestrivy—trivy fs --scanners vuln --format json --quiet --severity CRITICAL,HIGH,MEDIUM,LOW --skip-dirs **/bin/** --skip-dirs **/obj/** .0artifacts/raw/trivy-fs.json

Run 01a1db16-7c80-75ed-a488-fd029e153c89 · every finding is also locatable in findings.md, and the complete scoring record (with exit codes + durations) in sidecar.json.

Downloadable artifacts

Machine-readable and reproducible from this commit + frozen rubric — drop them straight into a contract appendix, a CRA dossier, or a downstream SCA / VEX tool.

⬇ Findings, MITRE CWE-tagged .sarif⬇ Health changelog .md