Skip to content

Fix config initialization, serialization, pipeline compatibility, and Apple MPS GPU compatibility - #29

Open
gokulrejith wants to merge 1 commit into
IBM:mainfrom
gokulrejith:fix/save-and-inference-issues
Open

Fix config initialization, serialization, pipeline compatibility, and Apple MPS GPU compatibility#29
gokulrejith wants to merge 1 commit into
IBM:mainfrom
gokulrejith:fix/save-and-inference-issues

Conversation

@gokulrejith

Copy link
Copy Markdown

This PR addresses several functional bugs that crash the model during standard inference and loading workflows:

  1. Hugging Face pipeline compatibility: Standard HF pipelines pass input_ids and attention_mask and do not provide labels during inference. Added fallback mapping for these arguments and graceful handling of labels=None by returning a SequenceClassifierOutput containing logits, which prevents the pipeline from crashing.
  2. Config Initialization & Serialization Fix: Saving and loading the model would crash because FastFitConfig strictly asserted an encoder config was provided. Made encoder optional to comply with Hugging Face's zero-argument config instantiation rules.
  3. MPS / Multi-Device Support in SupConLoss: Replaced the hardcoded cuda vs cpu fallback with dynamic device detection (features.device), preventing a crash on Apple Silicon (MPS) and other architectures.
  4. Precision Mismatch Fix: Cast labels to FloatTensor instead of DoubleTensor during the fallback loss calculation and explicitly sent them to self.device to prevent precision and device mismatch runtime errors on GPUs.

… MPS support

Signed-off-by: Gokul Rejithkumar <gokulrejith@gmail.com>
@gokulrejith
gokulrejith force-pushed the fix/save-and-inference-issues branch from 50a9e9b to 48cb2ea Compare July 24, 2026 11:42
@gokulrejith gokulrejith changed the title Fix config initialization, serialization, pipeline compatibility, and… Fix config initialization, serialization, pipeline compatibility, and Apple MPS GPU compatibility Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant