refactor(serving): remove now-unused guard, debug, profiling, and host LM-head code from npu runners - #142
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughDeepSeek kernel contract validation, profiling exposure, dispatch diagnostics, tensor checks, and optional scope-statistics execution were removed. Related unit-test cases and debug-hook setup were deleted. ChangesDeepSeek runtime cleanup
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
fe0909a to
46c1ce1
Compare
46c1ce1 to
6feca44
Compare
9a52806 to
59b211a
Compare
Remove the fail-fast kernel-contract validator plus the AST-based helper it depended on (_int_constant_from_file, _AST_INT_OPERATORS) and the now- unused `ast`/`operator` imports. The guard compared checked-in pypto-lib kernel constants against the serving layout at model load; it was purely defensive, ran once off the hot path, and is no longer wanted. Drop its two dedicated unit tests as well. Also drop the now-unused `importlib.util` import, the unreferenced `profile_verbose` property (no callers; the base class does not define it), and the orphaned `l3_trace` constructor param / `self._l3_trace` attribute.
Drop the ad-hoc print-based debug scaffolding from DeepSeekV4ModelRunner: _debug_prefill_dispatch, _debug_decode_dispatch, _debug_tensor_stats, _debug_tensor_stats_enabled, and _tensor_is_finite, plus their call sites in the prefill/decode/lm-head paths and the now-unused `import os`. These were gated on undocumented PYPTO_DSV4_DEBUG / PYPTO_DSV4_DEBUG_ARGS / PYPTO_DSV4_LOGIT_DEBUG env vars and referenced nowhere outside this file. Also remove the optional scope-stats profiling path (_scope_stats_run_config and its run_config branch in _run_l3), whose default output dir was hardcoded to a personal /data/liuxu path. Update the MTP decode test that monkeypatched _debug_decode_dispatch.
Both runners captured the worker.run() return value and attached host/device wall times to profiling spans via per-runner helpers: _kernel_trace_name and _add_run_timing_args in deepseek (plus _run_timing_us in qwen). The captured timing is no longer consumed, so remove the helpers and simplify the dispatch methods (DeepSeekV4ModelRunner._run_l3, Qwen314BModelRunner._run_distributed_program) to a plain worker.run(...) that no longer records or returns timing. Profiling span names now use callable_spec.name directly instead of the prefill/decode lane mapper.
Remove production-dead methods from DeepSeekV4ModelRunner now that the LM head runs on device and these host paths have no callers: - _is_layer_weight_name, _logits_for_hidden, _final_hidden, _final_norm (host-side LM-head / final-norm cluster) - _invalidate_resident_cache_tensors, _reset_l3_worker (unused worker teardown helpers) - the now-orphaned DEEPSEEK_V4_RMS_NORM_EPS / DEEPSEEK_V4_HC_EPS constants Drop the two unit tests that exercised the removed host LM-head path (test_deepseek_lm_head_computes_selected_rows_on_host_without_padded_vocab, test_deepseek_final_hidden_normalizes_before_hc_head_projection_overflows).
59b211a to
16da634
Compare
Four focused dead-code cleanups, one per commit. Net deletion across all four; rebased onto current
main.refactor(deepseek): remove _validate_kernel_contract startup guardRemoves the fail-fast
_validate_kernel_contractguard inDeepSeekV4PyptoExecutorplus its AST helper (_int_constant_from_file,_AST_INT_OPERATORS) and the now-unusedimport ast/import operator. The guard compared checked-in pypto-lib kernel constants against the serving layout at model load; purely defensive, no runtime dependency. Its two dedicated unit tests are dropped.Also drops the now-unused
importlib.utilimport, the unreferencedprofile_verboseproperty (no callers; the base class does not define it), and the orphanedl3_traceconstructor param /self._l3_traceattribute.refactor(deepseek): remove npu_runner debug instrumentationRemoves the ad-hoc print-based debug scaffolding from
DeepSeekV4ModelRunner:_debug_prefill_dispatch,_debug_decode_dispatch,_debug_tensor_stats,_debug_tensor_stats_enabled,_tensor_is_finiteand all their call sites (prefill / decode / lm-head), plus the now-unusedimport os. Gated on undocumentedPYPTO_DSV4_*env vars, referenced nowhere outside this file._scope_stats_run_config+ itsrun_configbranch in_run_l3), whose default output dir was hardcoded to a personal/data/liuxu/...path._debug_decode_dispatch.refactor(serving): drop unused L3 timing plumbing from npu runnersBoth runners captured the
worker.run()return value and attached host/device wall times to profiling spans via per-runner helpers (_kernel_trace_name,_add_run_timing_argsin deepseek;_kernel_trace_name,_run_timing_us,_add_run_timing_argsin qwen). The captured timing was no longer consumed, so the helpers are removed and the dispatch methods (DeepSeekV4ModelRunner._run_l3,Qwen314BModelRunner._run_distributed_program) are simplified to a plainworker.run(...)that no longer records or returns timing. Profiling span names now usecallable_spec.namedirectly.refactor(deepseek): remove dead host LM-head and worker-reset codeRemoves production-dead methods from
DeepSeekV4ModelRunnernow that the LM head runs on device and these host paths have no callers:_is_layer_weight_name,_logits_for_hidden,_final_hidden,_final_norm(host-side LM-head / final-norm cluster)_invalidate_resident_cache_tensors,_reset_l3_worker(unused worker teardown helpers)DEEPSEEK_V4_RMS_NORM_EPS/DEEPSEEK_V4_HC_EPSconstantsDrops the two unit tests that exercised the removed host LM-head path.
Verification
py_compilecleanly.pytest tests/unit/model/→ 70 passed (on the rebased branch).