Skip to content

Commit ee2a1c7

Browse files
author
bruce.xu
committed
add end_process
Signed-off-by: bruce.xu <[email protected]>
1 parent 76e8ce2 commit ee2a1c7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

examples/deepseek/ptq.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,15 @@ def load_deepseek_model(model_config: str, model_path: str, batch_size: int):
229229
return model
230230

231231

232+
def end_process():
233+
world_size = int(os.getenv("WORLD_SIZE", "1"))
234+
rank = int(os.getenv("RANK", "0"))
235+
local_rank = int(os.getenv("LOCAL_RANK", "0"))
236+
if world_size > 1:
237+
if dist.is_initialized():
238+
dist.destroy_process_group()
239+
240+
232241
def ptq(
233242
model,
234243
tokenizer,
@@ -364,3 +373,4 @@ def state_dict_filter(state_dict):
364373
)
365374
model = ptq(model, tokenizer, args.quant_cfg, args.batch_size, args.calib_size)
366375
save_amax_and_quant_config(model, args.output_path, not args.disable_fp8_kvcache)
376+
end_process()

0 commit comments

Comments
 (0)